his_api_controller.go 1.2MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030
  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. //"github.com/tjfoc/gmsm/sm2"
  13. //"github.com/tjfoc/gmsm/sm3"
  14. "gdyb/controllers"
  15. "gdyb/enums"
  16. "gdyb/models"
  17. "gdyb/service"
  18. "gdyb/utils"
  19. "github.com/astaxie/beego"
  20. "github.com/axgle/mahonia"
  21. "github.com/gorilla/websocket"
  22. "github.com/jinzhu/gorm"
  23. "github.com/shopspring/decimal"
  24. "io"
  25. "io/ioutil"
  26. //"math"
  27. "math/rand"
  28. "net/http"
  29. "net/url"
  30. "os"
  31. "path/filepath"
  32. "regexp"
  33. "strconv"
  34. "strings"
  35. "syscall"
  36. "time"
  37. "unsafe"
  38. "github.com/go-ole/go-ole/oleutil"
  39. )
  40. type HisApiController struct {
  41. controllers.BaseAuthAPIController
  42. }
  43. func HisManagerApiRegistRouters() {
  44. //挂号
  45. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  46. //上传就诊信息-上传明细-结算
  47. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  48. //查询
  49. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  50. //对总账
  51. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  52. //对明细
  53. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  54. //退费,退明细
  55. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  56. //退号
  57. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  58. //退明细
  59. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  60. //上传就诊信息-上传明细-预结算
  61. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  62. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  63. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  64. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  65. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  66. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  67. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  68. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  69. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  70. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  71. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  72. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  73. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  74. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  75. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  76. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  77. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  78. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  79. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  80. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  81. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  82. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  83. beego.Router("/api/check", &HisApiController{}, "get:Check")
  84. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  85. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  86. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  87. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  88. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  89. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  90. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  91. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  92. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  93. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  94. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  95. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  96. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  97. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  98. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  99. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  100. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  101. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  102. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  103. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  104. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  105. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  106. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  109. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  110. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  111. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  112. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  113. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  114. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  115. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  116. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  117. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  118. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  119. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  120. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  121. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  122. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  123. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  124. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  125. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  126. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  127. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  128. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  129. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  130. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  131. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  132. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  133. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  134. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  135. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  136. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  137. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  138. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  139. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  140. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  141. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  142. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  143. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  144. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  145. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  146. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  147. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  148. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  149. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  150. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  151. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  152. }
  153. func (c *HisApiController) Get1318() {
  154. adminUser := c.GetAdminUserInfo()
  155. admin_user_id, _ := c.GetInt64("admin_user_id")
  156. code := c.GetString("code")
  157. code = ""
  158. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  159. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  160. api := ""
  161. if miConfig.MdtrtareaAdmvs == "320921" {
  162. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  163. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  164. } else {
  165. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  166. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  167. }
  168. resp, requestErr := http.Get(api)
  169. if requestErr != nil {
  170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  171. return
  172. }
  173. body, ioErr := ioutil.ReadAll(resp.Body)
  174. if ioErr != nil {
  175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  177. return
  178. }
  179. var respJSON map[string]interface{}
  180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  183. return
  184. }
  185. //var res Result2406
  186. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  187. result, _ := json.Marshal(respJSON)
  188. if err := json.Unmarshal([]byte(result), &res); err != nil {
  189. utils.ErrorLog("解析失败:%v", err)
  190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  191. return
  192. }
  193. if res.Infcode == "0" {
  194. c.ServeSuccessJSON(map[string]interface{}{
  195. "result": "",
  196. })
  197. } else {
  198. c.ServeSuccessJSON(map[string]interface{}{
  199. "failed_code": -10,
  200. "msg": res.ErrMsg,
  201. })
  202. */return
  203. //}
  204. }
  205. func (c *HisApiController) Get2503() {
  206. adminUser := c.GetAdminUserInfo()
  207. admin_user_id, _ := c.GetInt64("admin_user_id")
  208. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  209. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  210. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  211. }
  212. func (c *HisApiController) Get2406() {
  213. id, _ := c.GetInt64("id")
  214. record_time := c.GetString("record_time")
  215. his_patient_id, _ := c.GetInt64("his_patient_id")
  216. admin_user_id, _ := c.GetInt64("admin_user_id")
  217. diagnosis_id := c.GetString("diagnosis")
  218. timeLayout := "2006-01-02"
  219. loc, _ := time.LoadLocation("Local")
  220. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  221. if err != nil {
  222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  223. return
  224. }
  225. recordDateTime := theTime.Unix()
  226. adminUser := c.GetAdminUserInfo()
  227. diagnosis_ids := strings.Split(diagnosis_id, ",")
  228. var config []*models.HisXtDiagnoseConfig
  229. for _, item := range diagnosis_ids {
  230. id, _ := strconv.ParseInt(item, 10, 64)
  231. diagnosisConfig, _ := service.FindDiagnoseById(id)
  232. config = append(config, &diagnosisConfig)
  233. }
  234. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  235. fmt.Println(his_patient_id)
  236. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  237. //timestamp := time.Now().Unix()
  238. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  239. var patientPrescription models.HisPrescriptionInfo
  240. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  241. if patientPrescription.ID == 0 {
  242. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  243. }
  244. var res2 Result2406
  245. if miConfig.MdtrtareaAdmvs == "341203" {
  246. data := make(map[string]interface{})
  247. client := &http.Client{}
  248. data["psn_no"] = his.PsnNo
  249. data["mdtrt_id"] = his.Number
  250. data["operator"] = roles.UserName
  251. data["cert_no"] = his.IdCardNo
  252. data["org_name"] = miConfig.OrgName
  253. data["psn_name"] = his.Name
  254. data["ipt_otp_no"] = his.IptOtpNo
  255. data["ipt_psn_sp_flag_type"] = "0901"
  256. data["ipt_psn_sp_flag"] = "1"
  257. data["fixmedins_code"] = miConfig.Code
  258. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  259. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  260. data["url"] = miConfig.Url
  261. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  262. bytesData, _ := json.Marshal(data)
  263. var req *http.Request
  264. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  265. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  266. resp, _ := client.Do(req)
  267. defer resp.Body.Close()
  268. body, ioErr := ioutil.ReadAll(resp.Body)
  269. if ioErr != nil {
  270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  272. return
  273. }
  274. var respJSON map[string]interface{}
  275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  278. return
  279. }
  280. status := respJSON["data"].(map[string]interface{})["status"].(string)
  281. if status == "0" {
  282. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  283. c.ServeSuccessJSON(map[string]interface{}{
  284. "failed_code": -10,
  285. "msg": err_msg,
  286. })
  287. return
  288. }
  289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  290. userJSONBytes, _ := json.Marshal(respJSON)
  291. fmt.Println("log")
  292. fmt.Println(string(userJSONBytes))
  293. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  294. utils.ErrorLog("解析失败:%v", err)
  295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  296. return
  297. }
  298. }
  299. if res2.Infcode != 0 {
  300. adminUser := c.GetAdminUserInfo()
  301. errlog := &models.HisOrderError{
  302. UserOrgId: adminUser.CurrentOrgId,
  303. Ctime: time.Now().Unix(),
  304. Mtime: time.Now().Unix(),
  305. ErrMsg: res2.ErrMsg,
  306. Status: 1,
  307. PatientId: id,
  308. RecordTime: recordDateTime,
  309. Stage: 3,
  310. }
  311. service.CreateErrMsgLog(errlog)
  312. c.ServeSuccessJSON(map[string]interface{}{
  313. "failed_code": -10,
  314. "msg": res2.ErrMsg,
  315. })
  316. return
  317. } else {
  318. c.ServeSuccessJSON(map[string]interface{}{
  319. "msg": "上传成功",
  320. })
  321. return
  322. }
  323. }
  324. func (c *HisApiController) Get4105() {
  325. }
  326. func (c *HisApiController) Post5302() {
  327. patient_id, _ := c.GetInt64("id")
  328. admin_user_id, _ := c.GetInt64("admin_user_id")
  329. p, _ := service.GetHisPatientById(patient_id)
  330. adminUser := c.GetAdminUserInfo()
  331. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  332. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  333. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  334. }
  335. func (c *HisApiController) Get4104() {
  336. }
  337. type Output struct {
  338. CertNo string `json:"certno"`
  339. PsnName string `json:"psn_name"`
  340. CardNo string `json:"card_no"`
  341. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  342. CardSN string `json:"card_sn"`
  343. PsnCertType string `json:"psn_cert_type"`
  344. MdtrtCertNo string `json:"mdtrt_cert_no"`
  345. MdtrtCertType string `json:"mdtrt_cert_type"`
  346. QRCode string `json:"qrCode"`
  347. EcToken string `json:"ecToken"`
  348. }
  349. type AHResponse struct {
  350. Body AHBody `json:"body"`
  351. Code int `json:"code"`
  352. CSBCode int `json:"csbCode"`
  353. Message string `json:"message"`
  354. RequestID string `json:"requestId"`
  355. State struct{} `json:"state"`
  356. }
  357. type AHBody struct {
  358. ErrMsg string `json:"err_msg"`
  359. InfRefMsgID string `json:"inf_refmsgid"`
  360. InfCode int `json:"infcode"`
  361. Output struct {
  362. Result []struct {
  363. BasMednFlag string `json:"bas_medn_flag"`
  364. ChldMedcFlag string `json:"chld_medc_flag"`
  365. ChrgitmLv string `json:"chrgitm_lv"`
  366. Cnt float64 `json:"cnt"`
  367. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  368. DrtReimFlag string `json:"drt_reim_flag"`
  369. FeedetlSn string `json:"feedetl_sn"`
  370. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  371. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  372. InscpScpAmt float64 `json:"inscp_scp_amt"`
  373. ListSpItemFlag string `json:"list_sp_item_flag"`
  374. LmtUsedFlag string `json:"lmt_used_flag"`
  375. MedChrgitmType string `json:"med_chrgitm_type"`
  376. Memo string `json:"memo"`
  377. OverlmtAmt float64 `json:"overlmt_amt"`
  378. PreselfpayAmt float64 `json:"preselfpay_amt"`
  379. Pric float64 `json:"pric"`
  380. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  381. SelfpayProp float64 `json:"selfpay_prop"`
  382. } `json:"result"`
  383. } `json:"output"`
  384. }
  385. type Response struct {
  386. Output Output `json:"output"`
  387. Infcode int `json:"infcode"`
  388. InfRefMsgID string `json:"inf_refmsgid"`
  389. RefMsgTime string `json:"refmsg_time"`
  390. RespondTime string `json:"respond_time"`
  391. ErrMsg string `json:"err_msg"`
  392. WarnMsg string `json:"warn_msg"`
  393. SignType string `json:"signtype"`
  394. CAInfo string `json:"cainfo"`
  395. }
  396. func (c *HisApiController) Getquerydata() {
  397. query_type, _ := c.GetInt64("type")
  398. refd_setl_flag := c.GetString("refd_setl_flag")
  399. med_type := c.GetString("med_type")
  400. //admin_user_id,_ := c.GetInt64("admin_user_id")
  401. cert_no := c.GetString("cert_no")
  402. psn_no := c.GetString("psn_no")
  403. start_time := c.GetString("start_time")
  404. end_time := c.GetString("end_time")
  405. page, _ := c.GetInt64("page")
  406. limit, _ := c.GetInt64("limit")
  407. var bp models.BusinessParams5262
  408. bp.RefdSetlFlag = refd_setl_flag
  409. bp.MedType = med_type
  410. bp.Certno = cert_no
  411. bp.Psnno = psn_no
  412. bp.QBegntime = start_time
  413. bp.QEndtime = end_time
  414. if query_type == 1 { //本地
  415. Post5262(c, bp, page, limit)
  416. } else { //异地
  417. Post5267(c, bp, page, limit)
  418. }
  419. }
  420. func (c *HisApiController) Drugscheck() {
  421. admin_user_id, _ := c.GetInt64("admin_user_id")
  422. adminUser := c.GetAdminUserInfo()
  423. var queryResult []QueryResult
  424. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  425. for _, item := range drugs {
  426. result := QueryResult{
  427. ID: item.ID,
  428. Name: item.DrugName,
  429. Code: item.MedicalInsuranceNumber,
  430. List_type_code: "101",
  431. }
  432. queryResult = append(queryResult, result)
  433. }
  434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  435. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  436. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  437. for _, item := range queryResult {
  438. 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)
  439. }
  440. }
  441. func (c *HisApiController) Goodcheck() {
  442. admin_user_id, _ := c.GetInt64("admin_user_id")
  443. adminUser := c.GetAdminUserInfo()
  444. var queryResult []QueryResult
  445. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  446. for _, item := range goods {
  447. result := QueryResult{
  448. ID: item.ID,
  449. Name: item.GoodName,
  450. Code: item.SocialSecurityDirectoryCode,
  451. List_type_code: "301",
  452. }
  453. queryResult = append(queryResult, result)
  454. }
  455. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  456. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  457. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  458. for _, item := range queryResult {
  459. 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)
  460. //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)
  461. }
  462. }
  463. func (c *HisApiController) Projectcheck() {
  464. admin_user_id, _ := c.GetInt64("admin_user_id")
  465. adminUser := c.GetAdminUserInfo()
  466. var queryResult []QueryResult
  467. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  468. for _, item := range projects {
  469. result := QueryResult{
  470. ID: item.ID,
  471. Name: item.ProjectName,
  472. Code: item.MedicalCode,
  473. List_type_code: "201",
  474. }
  475. queryResult = append(queryResult, result)
  476. }
  477. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  478. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  479. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  480. for _, item := range queryResult {
  481. 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)
  482. }
  483. }
  484. //func (c *HisApiController)CancleDia(){
  485. //
  486. // id, _ := c.GetInt64("id")
  487. // record_time := c.GetString("record_time")
  488. // his_patient_id, _ := c.GetInt64("his_patient_id")
  489. //
  490. // admin_user_id, _ := c.GetInt64("admin_user_id")
  491. //
  492. // diagnosis_id := c.GetString("diagnosis")
  493. // sick_type, _ := c.GetInt64("sick_type")
  494. // reg_type, _ := c.GetInt64("p_type")
  495. // begin_time := c.GetString("begin_time")
  496. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  497. //
  498. //
  499. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  500. //
  501. // fmt.Println(acct_used_flag)
  502. //
  503. //
  504. // timeLayout := "2006-01-02"
  505. // loc, _ := time.LoadLocation("Local")
  506. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  507. // if err != nil {
  508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  509. // return
  510. // }
  511. // recordDateTime := theTime.Unix()
  512. // adminUser := c.GetAdminUserInfo()
  513. //
  514. //
  515. //
  516. //
  517. //
  518. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  519. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  520. // var patientPrescription models.HisPrescriptionInfo
  521. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  522. // if patientPrescription.ID == 0 {
  523. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  524. // }
  525. // //if patientPrescription.Do
  526. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  527. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  528. //
  529. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  530. //
  531. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  532. //
  533. // var config []*models.HisXtDiagnoseConfig
  534. // for _, item := range diagnosis_ids {
  535. // id, _ := strconv.ParseInt(item, 10, 64)
  536. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  537. // config = append(config, &diagnosisConfig)
  538. // }
  539. //
  540. // sickConfig, _ := service.FindSickById(sick_type)
  541. //
  542. //
  543. // data := make(map[string]interface{})
  544. // client := &http.Client{}
  545. // data["psn_no"] = his.PsnNo
  546. // data["mdtrt_id"] = his.Number
  547. // data["doctor"] = roles.UserName
  548. // data["department"] = department.Name
  549. // data["org_name"] = miConfig.OrgName
  550. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  551. // data["doctor_id"] = doctor_info.DoctorNumber
  552. // data["new_doctor_name"] = doctor_info.UserName
  553. // data["fixmedins_code"] = miConfig.Code
  554. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  555. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  556. // data["secret_key"] = miConfig.SecretKey
  557. // data["sick_code"] = sickConfig.CountryCode
  558. // data["sick_name"] = sickConfig.ClassName
  559. // data["url"] = miConfig.Url
  560. // data["ak"] = miConfig.AccessKey
  561. // data["begin_time"] = begin_time
  562. // data["cainfo"] = miConfig.Cainfo
  563. // data["is_vaild"] = "0"
  564. //
  565. // data["dept"] = strconv.FormatInt(department.ID, 10)
  566. // data["config"] = config
  567. // bytesData, _ := json.Marshal(data)
  568. //
  569. // var req *http.Request
  570. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  571. // resp, _ := client.Do(req)
  572. // defer resp.Body.Close()
  573. // body, ioErr := ioutil.ReadAll(resp.Body)
  574. // if ioErr != nil {
  575. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  576. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  577. // return
  578. // }
  579. // var respJSON map[string]interface{}
  580. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  581. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  583. // return
  584. // }
  585. //
  586. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  587. // userJSONBytes, _ := json.Marshal(respJSON)
  588. // fmt.Println("log")
  589. // fmt.Println(string(userJSONBytes))
  590. //
  591. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  592. // utils.ErrorLog("解析失败:%v", err)
  593. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  594. // return
  595. // }
  596. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  597. // res2.Output = ressix10265.Output
  598. // res2.ErrMsg = ressix10265.ErrMsg
  599. // res2.Cainfo = ressix10265.Cainfo
  600. // res2.WarnMsg = ressix10265.WarnMsg
  601. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  602. // res2.Infcode = infocode
  603. //
  604. //}
  605. func (c *HisApiController) Get4102() {
  606. order_id, _ := c.GetInt64("order_id")
  607. admin_user_id, _ := c.GetInt64("admin_user_id")
  608. stas_type := c.GetString("stas_type")
  609. order, _ := service.GetHisOrderByIDTwo(order_id)
  610. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  611. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  612. var pp models.PublicParams
  613. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  614. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  615. pp.FixmedinsName = miConfig.OrgName
  616. pp.FixmedinsCode = miConfig.Code
  617. pp.RequestUrl = miConfig.Url
  618. pp.Cainfo = miConfig.Cainfo
  619. pp.SecretKey = miConfig.SecretKey
  620. pp.AccessKey = miConfig.AccessKey
  621. pp.OpterName = curRoles.UserName
  622. if miConfig.MdtrtareaAdmvs == "350500" {
  623. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  624. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  625. saveLog(result, request, "4102", "清单确认")
  626. var dat map[string]interface{}
  627. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  628. fmt.Println(dat)
  629. } else {
  630. fmt.Println(err)
  631. }
  632. var empty ResultFourteen
  633. userJSONBytes, _ := json.Marshal(dat)
  634. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  635. utils.ErrorLog("解析失败:%v", err)
  636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  637. return
  638. }
  639. if empty.Infcode == 0 {
  640. c.ServeSuccessJSON(map[string]interface{}{
  641. "msg": "确认成功",
  642. })
  643. return
  644. }
  645. } else {
  646. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  647. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  648. result3, request3 := service.Jxyb4105(pp)
  649. saveLog(result, request, "4102", "清单确认")
  650. saveLog(result2, request2, "4103", "清单确认")
  651. saveLog(result3, request3, "4105", "清单统计")
  652. var dat map[string]interface{}
  653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  654. fmt.Println(dat)
  655. } else {
  656. fmt.Println(err)
  657. }
  658. var empty ResultFourteen
  659. userJSONBytes, _ := json.Marshal(dat)
  660. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  661. utils.ErrorLog("解析失败:%v", err)
  662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  663. return
  664. }
  665. if empty.Infcode == 0 {
  666. c.ServeSuccessJSON(map[string]interface{}{
  667. "msg": "确认成功",
  668. })
  669. return
  670. }
  671. }
  672. }
  673. // 对账权限查询
  674. func (c *HisApiController) Get3260() {
  675. admin_user_id, _ := c.GetInt64("admin_user_id")
  676. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  677. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  678. var api string
  679. var res models.JSResult3260
  680. if miConfig.MdtrtareaAdmvs == "320921" {
  681. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  682. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  683. } else {
  684. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  685. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  686. }
  687. resp, requestErr := http.Get(api)
  688. if requestErr != nil {
  689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  690. return
  691. }
  692. body, ioErr := ioutil.ReadAll(resp.Body)
  693. if ioErr != nil {
  694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  696. return
  697. }
  698. var respJSON map[string]interface{}
  699. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  702. return
  703. }
  704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  705. result, _ := json.Marshal(respJSON)
  706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  707. utils.ErrorLog("解析失败:%v", err)
  708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  709. return
  710. }
  711. if res.Infcode == "0" {
  712. c.ServeSuccessJSON(map[string]interface{}{
  713. "result": res.Output.Data,
  714. })
  715. } else {
  716. c.ServeSuccessJSON(map[string]interface{}{
  717. "failed_code": -10,
  718. "msg": res.ErrMsg,
  719. })
  720. return
  721. }
  722. }
  723. func (c *HisApiController) Get3261() {
  724. admin_user_id, _ := c.GetInt64("admin_user_id")
  725. //month := c.GetString("month")
  726. startTime := c.GetString("start_time")
  727. //endTime, _ := c.GetString("end_time")
  728. times := strings.Split(startTime, "-")
  729. stmt_mon := times[0] + times[1]
  730. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  731. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  732. var api string
  733. var res models.JSResult3261
  734. //var res10265 Result5301For10265
  735. if miConfig.MdtrtareaAdmvs == "320921" {
  736. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  737. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  738. } else {
  739. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  740. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  741. }
  742. resp, requestErr := http.Get(api)
  743. if requestErr != nil {
  744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  745. return
  746. }
  747. body, ioErr := ioutil.ReadAll(resp.Body)
  748. if ioErr != nil {
  749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  751. return
  752. }
  753. var respJSON map[string]interface{}
  754. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  757. return
  758. }
  759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  760. result, _ := json.Marshal(respJSON)
  761. if err := json.Unmarshal([]byte(result), &res); err != nil {
  762. utils.ErrorLog("解析失败:%v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. if res.Infcode == "0" {
  767. c.ServeSuccessJSON(map[string]interface{}{
  768. "result": res.Output,
  769. })
  770. } else {
  771. c.ServeSuccessJSON(map[string]interface{}{
  772. "failed_code": -10,
  773. "msg": res.ErrMsg,
  774. })
  775. return
  776. }
  777. }
  778. type TempFun struct {
  779. FundKey string
  780. FundCode string
  781. }
  782. func (c *HisApiController) Get3262() {
  783. admin_user_id, _ := c.GetInt64("admin_user_id")
  784. startTime := c.GetString("start_time")
  785. endTime := c.GetString("end_time")
  786. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  787. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  788. //timeLayout := "2006-01-02"
  789. //loc, _ := time.LoadLocation("Local")
  790. //var theStartTIme int64
  791. //if len(startTime) > 0 {
  792. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  793. // if err != nil {
  794. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  795. // return
  796. // }
  797. // theStartTIme = theTime.Unix()
  798. //}
  799. //var theEndtTIme int64
  800. //if len(endTime) > 0 {
  801. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  802. // if err != nil {
  803. // utils.ErrorLog(err.Error())
  804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  805. // return
  806. // }
  807. // theEndtTIme = theTime.Unix()
  808. //}
  809. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  810. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  811. for _, team := range datas {
  812. fmt.Println(team.PsnTime)
  813. for _, team_two := range datas_two {
  814. fmt.Println(team_two.PsnTime)
  815. if team.FundKey == team_two.FundKey {
  816. fmt.Println(team_two.PsnTime)
  817. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  818. fmt.Println(team.PsnTime)
  819. }
  820. }
  821. }
  822. fmt.Println("1111")
  823. fmt.Println(datas)
  824. fmt.Println("1111")
  825. var twos []models.FixMonRecDetailFileInTwo
  826. for _, team := range datas {
  827. var two models.FixMonRecDetailFileInTwo
  828. two.MedType = team.MedType
  829. two.Insutype = team.Insutype
  830. two.PsnType = team.PsnType
  831. two.MedType = team.MedType
  832. two.FixBlngAdmdvs = "999999"
  833. two.InsuAdmdvs = "555555"
  834. two.PsnTime = team.PsnTime
  835. two.PsnCnt = team.PsnCnt
  836. two.FundKey = team.FundKey
  837. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  838. fps, _ := strconv.ParseFloat(team.Fund, 64)
  839. ia, _ := strconv.ParseFloat(team.Amt, 64)
  840. two.MedfeeSumAmt = ms
  841. two.InscpAmt = ia
  842. two.FundPaySumAmt = fps
  843. twos = append(twos, two)
  844. }
  845. //startTime := c.GetString("start_time")
  846. //endTime, _ := c.GetString("end_time")
  847. times := strings.Split(startTime, "-")
  848. stmt_mon := times[0] + times[1]
  849. var funs []models.FundDetail
  850. for _, item := range datas {
  851. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  852. funs = append(funs, fun...)
  853. }
  854. var funInfos []models.Fund
  855. //for _, item := range funs {
  856. // var rf []models.FundInfo
  857. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  858. // for _, subitem := range rf {
  859. // var fund models.Fund
  860. // fund.FundCode = subitem.FundPayType
  861. // fund.FundName = subitem.FundPayTypeName
  862. // fund.FundAmt = subitem.FundPayAmt
  863. // fund.FundKey = item.FundKey
  864. // fund.InsuAdmdvs = "555555"
  865. // fund.FixBlngAdmdvs = "999999"
  866. // funInfos = append(funInfos, fund)
  867. // }
  868. //}
  869. var tempFuns []TempFun
  870. for _, funInfo := range funInfos {
  871. var tempFun TempFun
  872. tempFun.FundKey = funInfo.FundKey
  873. tempFun.FundCode = funInfo.FundCode
  874. tempFuns = append(tempFuns, tempFun)
  875. }
  876. tempFuns = RemoveRepeatedFunElement(tempFuns)
  877. fmt.Println(tempFuns)
  878. var funInfosTwo []models.Fund
  879. decimal.DivisionPrecision = 2
  880. for _, item := range tempFuns {
  881. var fund models.Fund
  882. for _, subItem := range funInfos {
  883. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  884. fund.FundKey = subItem.FundKey
  885. fund.InsuAdmdvs = subItem.InsuAdmdvs
  886. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  887. fund.FundName = subItem.FundName
  888. fund.FundCode = subItem.FundCode
  889. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  890. }
  891. }
  892. funInfosTwo = append(funInfosTwo, fund)
  893. }
  894. fmt.Println("funInfosTwo")
  895. fmt.Println(funInfosTwo)
  896. var upld_btch string
  897. var empty models.JSResultEmpty
  898. data := make(map[string]interface{})
  899. data["org_name"] = miConfig.OrgName
  900. data["doctor"] = curRoles.UserName
  901. data["doctor_name"] = curRoles.UserName
  902. data["fixmedins_code"] = miConfig.Code
  903. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  904. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  905. data["secret_key"] = miConfig.SecretKey
  906. data["url"] = miConfig.Url
  907. data["ak"] = miConfig.AccessKey
  908. data["cainfo"] = miConfig.Cainfo
  909. data["datas"] = twos
  910. data["fund"] = funInfosTwo
  911. fmt.Println(twos)
  912. month := time.Unix(1557042972, 0).Format("1")
  913. year := time.Now().Format("2006")
  914. month = time.Now().Format("01")
  915. day := time.Now().Format("02")
  916. hour := time.Now().Format("15")
  917. min := time.Now().Format("04")
  918. sec := time.Now().Format("05")
  919. fix_fill_date := year + month + day + hour + min + sec
  920. data["fix_fill_dept"] = miConfig.OrgName
  921. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  922. data["fix_fill_psn"] = curRoles.UserName
  923. data["fix_fill_date"] = fix_fill_date
  924. data["stmt_loc"] = "2"
  925. data["setl_mon"] = stmt_mon
  926. upld_btch = "0"
  927. data["upld_btch"] = upld_btch
  928. //fmt.Println(data)
  929. client := &http.Client{}
  930. bytesData, _ := json.Marshal(data)
  931. var req *http.Request
  932. if miConfig.MdtrtareaAdmvs == "320921" {
  933. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  934. } else {
  935. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  936. }
  937. resp, _ := client.Do(req)
  938. defer resp.Body.Close()
  939. body, ioErr := ioutil.ReadAll(resp.Body)
  940. if ioErr != nil {
  941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  943. }
  944. var respJSON map[string]interface{}
  945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  948. }
  949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  950. //fmt.Println(respJSON)
  951. result, _ := json.Marshal(respJSON)
  952. //fmt.Println(result)
  953. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  954. utils.ErrorLog("解析失败:%v", err)
  955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  956. }
  957. if empty.Infcode != "0" {
  958. c.ServeSuccessJSON(map[string]interface{}{
  959. "failed_code": -10,
  960. "msg": empty.ErrMsg,
  961. })
  962. return
  963. } else {
  964. c.ServeSuccessJSON(map[string]interface{}{
  965. "msg": "上传成功",
  966. })
  967. return
  968. }
  969. }
  970. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  971. newArr = make([]TempFun, 0)
  972. for i := 0; i < len(arr); i++ {
  973. repeat := false
  974. for j := i + 1; j < len(arr); j++ {
  975. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  976. repeat = true
  977. break
  978. }
  979. }
  980. if !repeat {
  981. newArr = append(newArr, arr[i])
  982. }
  983. }
  984. return
  985. }
  986. func (c *HisApiController) Get3263() {
  987. admin_user_id, _ := c.GetInt64("admin_user_id")
  988. startTime := c.GetString("start_time")
  989. //endTime, _ := c.GetString("end_time")
  990. times := strings.Split(startTime, "-")
  991. setl_mon := times[0] + times[1]
  992. upld_btch := "0"
  993. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  994. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  995. var result3263 models.JSResult3263
  996. data := make(map[string]interface{})
  997. data["org_name"] = miConfig.OrgName
  998. data["doctor"] = curRoles.UserName
  999. data["doctor_name"] = curRoles.UserName
  1000. data["fixmedins_code"] = miConfig.Code
  1001. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1002. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1003. data["secret_key"] = miConfig.SecretKey
  1004. data["url"] = miConfig.Url
  1005. data["ak"] = miConfig.AccessKey
  1006. data["cainfo"] = miConfig.Cainfo
  1007. data["setl_mon"] = setl_mon
  1008. data["stmt_loc"] = "2"
  1009. data["upld_btch"] = upld_btch
  1010. client := &http.Client{}
  1011. bytesData, _ := json.Marshal(data)
  1012. var req *http.Request
  1013. if miConfig.MdtrtareaAdmvs == "320921" {
  1014. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1015. } else {
  1016. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1017. }
  1018. resp, _ := client.Do(req)
  1019. defer resp.Body.Close()
  1020. body, ioErr := ioutil.ReadAll(resp.Body)
  1021. if ioErr != nil {
  1022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. }
  1025. var respJSON map[string]interface{}
  1026. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1029. }
  1030. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1031. fmt.Println(respJSON)
  1032. result, _ := json.Marshal(respJSON)
  1033. fmt.Println(result)
  1034. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1035. utils.ErrorLog("解析失败:%v", err)
  1036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1037. }
  1038. if result3263.Infcode != "0" {
  1039. c.ServeSuccessJSON(map[string]interface{}{
  1040. "failed_code": -10,
  1041. "msg": result3263.ErrMsg,
  1042. })
  1043. return
  1044. } else {
  1045. c.ServeSuccessJSON(map[string]interface{}{
  1046. "list": result3263.Output,
  1047. })
  1048. return
  1049. }
  1050. }
  1051. func (c *HisApiController) Get3264() {
  1052. admin_user_id, _ := c.GetInt64("admin_user_id")
  1053. startTime := c.GetString("start_time")
  1054. //endTime, _ := c.GetString("end_time")
  1055. times := strings.Split(startTime, "-")
  1056. setl_mon := times[0] + times[1]
  1057. upld_btch := "0"
  1058. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1059. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1060. //solidify_id := []
  1061. var result3263 models.JSResult3263
  1062. data := make(map[string]interface{})
  1063. data["org_name"] = miConfig.OrgName
  1064. data["doctor"] = curRoles.UserName
  1065. data["doctor_name"] = curRoles.UserName
  1066. data["fixmedins_code"] = miConfig.Code
  1067. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1068. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1069. data["secret_key"] = miConfig.SecretKey
  1070. data["url"] = miConfig.Url
  1071. data["ak"] = miConfig.AccessKey
  1072. data["cainfo"] = miConfig.Cainfo
  1073. data["setl_mon"] = setl_mon
  1074. data["stmt_loc"] = "2"
  1075. data["upld_btch"] = upld_btch
  1076. client := &http.Client{}
  1077. bytesData, _ := json.Marshal(data)
  1078. var req3263 *http.Request
  1079. if miConfig.MdtrtareaAdmvs == "320921" {
  1080. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1081. } else {
  1082. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1083. }
  1084. resp, _ := client.Do(req3263)
  1085. defer resp.Body.Close()
  1086. body, ioErr := ioutil.ReadAll(resp.Body)
  1087. if ioErr != nil {
  1088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1090. }
  1091. var respJSON3263 map[string]interface{}
  1092. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1095. }
  1096. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1097. fmt.Println(respJSON3263)
  1098. result, _ := json.Marshal(respJSON3263)
  1099. fmt.Println(result)
  1100. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1101. utils.ErrorLog("解析失败:%v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. }
  1104. var ids []string
  1105. for _, item := range result3263.Output {
  1106. ids = append(ids, item.SolidifyID)
  1107. }
  1108. var empty models.JSResultEmpty
  1109. data2 := make(map[string]interface{})
  1110. data2["org_name"] = miConfig.OrgName
  1111. data2["doctor"] = curRoles.UserName
  1112. data2["doctor_name"] = curRoles.UserName
  1113. data2["fixmedins_code"] = miConfig.Code
  1114. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1115. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1116. data2["secret_key"] = miConfig.SecretKey
  1117. data2["url"] = miConfig.Url
  1118. data2["ak"] = miConfig.AccessKey
  1119. data2["cainfo"] = miConfig.Cainfo
  1120. data2["setl_mon"] = setl_mon
  1121. data2["stmt_loc"] = "2"
  1122. data2["upld_btch"] = upld_btch
  1123. data2["solidify_id"] = ids
  1124. client2 := &http.Client{}
  1125. bytesData2, _ := json.Marshal(data2)
  1126. var req *http.Request
  1127. if miConfig.MdtrtareaAdmvs == "320921" {
  1128. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1129. } else {
  1130. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1131. }
  1132. resp2, _ := client2.Do(req)
  1133. defer resp.Body.Close()
  1134. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1135. if ioErr2 != nil {
  1136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1138. }
  1139. var respJSON map[string]interface{}
  1140. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1143. }
  1144. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1145. fmt.Println(respJSON)
  1146. result2, _ := json.Marshal(respJSON)
  1147. fmt.Println(result2)
  1148. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1149. utils.ErrorLog("解析失败:%v", err)
  1150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1151. }
  1152. if empty.Infcode != "0" {
  1153. c.ServeSuccessJSON(map[string]interface{}{
  1154. "failed_code": -10,
  1155. "msg": empty.ErrMsg,
  1156. })
  1157. return
  1158. } else {
  1159. c.ServeSuccessJSON(map[string]interface{}{
  1160. "msg": "",
  1161. })
  1162. return
  1163. }
  1164. }
  1165. func (c *HisApiController) Get3265() {
  1166. admin_user_id, _ := c.GetInt64("admin_user_id")
  1167. startTime := c.GetString("start_time")
  1168. //endTime, _ := c.GetString("end_time")
  1169. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1170. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1171. times := strings.Split(startTime, "-")
  1172. setl_mon := times[0] + times[1]
  1173. var upld_btch string
  1174. upld_btch = "0"
  1175. //var empty models.JSResultEmpty
  1176. var result3265 models.JSResult3264
  1177. var result3263 models.JSResult3263
  1178. data2 := make(map[string]interface{})
  1179. data2["org_name"] = miConfig.OrgName
  1180. data2["doctor"] = curRoles.UserName
  1181. data2["doctor_name"] = curRoles.UserName
  1182. data2["fixmedins_code"] = miConfig.Code
  1183. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1184. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1185. data2["secret_key"] = miConfig.SecretKey
  1186. data2["url"] = miConfig.Url
  1187. data2["ak"] = miConfig.AccessKey
  1188. data2["cainfo"] = miConfig.Cainfo
  1189. data2["setl_mon"] = setl_mon
  1190. data2["stmt_loc"] = "2"
  1191. data2["upld_btch"] = upld_btch
  1192. client2 := &http.Client{}
  1193. bytesData2, _ := json.Marshal(data2)
  1194. var req3263 *http.Request
  1195. if miConfig.MdtrtareaAdmvs == "320921" {
  1196. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1197. } else {
  1198. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1199. }
  1200. resp2, _ := client2.Do(req3263)
  1201. defer resp2.Body.Close()
  1202. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1203. if ioErr2 != nil {
  1204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1206. }
  1207. var respJSON3263 map[string]interface{}
  1208. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1211. }
  1212. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1213. fmt.Println(respJSON3263)
  1214. result2, _ := json.Marshal(respJSON3263)
  1215. fmt.Println(result2)
  1216. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1217. utils.ErrorLog("解析失败:%v", err)
  1218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1219. }
  1220. var ids []string
  1221. for _, item := range result3263.Output {
  1222. ids = append(ids, item.SolidifyID)
  1223. }
  1224. data := make(map[string]interface{})
  1225. data["org_name"] = miConfig.OrgName
  1226. data["doctor"] = curRoles.UserName
  1227. data["doctor_name"] = curRoles.UserName
  1228. data["fixmedins_code"] = miConfig.Code
  1229. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1230. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1231. data["secret_key"] = miConfig.SecretKey
  1232. data["url"] = miConfig.Url
  1233. data["ak"] = miConfig.AccessKey
  1234. data["cainfo"] = miConfig.Cainfo
  1235. data["setl_mon"] = setl_mon
  1236. data["solidify_id"] = ids
  1237. month := time.Unix(1557042972, 0).Format("1")
  1238. year := time.Now().Format("2006")
  1239. month = time.Now().Format("01")
  1240. day := time.Now().Format("02")
  1241. hour := time.Now().Format("15")
  1242. min := time.Now().Format("04")
  1243. sec := time.Now().Format("05")
  1244. fix_fill_date := year + month + day + hour + min + sec
  1245. data["fix_fill_dept"] = miConfig.OrgName
  1246. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1247. data["fix_fill_psn"] = curRoles.UserName
  1248. data["fix_fill_date"] = fix_fill_date
  1249. data["stmt_loc"] = "2"
  1250. data["upld_btch"] = upld_btch
  1251. client := &http.Client{}
  1252. bytesData, _ := json.Marshal(data)
  1253. var req *http.Request
  1254. if miConfig.MdtrtareaAdmvs == "320921" {
  1255. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1256. } else {
  1257. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1258. }
  1259. resp, _ := client.Do(req)
  1260. defer resp.Body.Close()
  1261. body, ioErr := ioutil.ReadAll(resp.Body)
  1262. if ioErr != nil {
  1263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1265. }
  1266. var respJSON map[string]interface{}
  1267. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1270. }
  1271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1272. fmt.Println(respJSON)
  1273. result, _ := json.Marshal(respJSON)
  1274. fmt.Println(result)
  1275. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1276. utils.ErrorLog("解析失败:%v", err)
  1277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1278. }
  1279. if result3265.Infcode != "0" {
  1280. c.ServeSuccessJSON(map[string]interface{}{
  1281. "failed_code": -10,
  1282. "msg": result3265.ErrMsg,
  1283. })
  1284. return
  1285. } else {
  1286. c.ServeSuccessJSON(map[string]interface{}{
  1287. "info": result3265.Output,
  1288. })
  1289. return
  1290. }
  1291. }
  1292. func (c *HisApiController) Get3266() {
  1293. admin_user_id, _ := c.GetInt64("admin_user_id")
  1294. startTime := c.GetString("start_time")
  1295. //endTime, _ := c.GetString("end_time")
  1296. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1297. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1298. times := strings.Split(startTime, "-")
  1299. stmt_mon := times[0] + times[1]
  1300. var upld_btch string
  1301. //var empty models.JSResultEmpty
  1302. var result3265 models.JSResult3264
  1303. data := make(map[string]interface{})
  1304. data["org_name"] = miConfig.OrgName
  1305. data["doctor"] = curRoles.UserName
  1306. data["doctor_name"] = curRoles.UserName
  1307. data["fixmedins_code"] = miConfig.Code
  1308. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1309. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1310. data["secret_key"] = miConfig.SecretKey
  1311. data["url"] = miConfig.Url
  1312. data["ak"] = miConfig.AccessKey
  1313. data["cainfo"] = miConfig.Cainfo
  1314. data["setl_mon"] = stmt_mon
  1315. month := time.Unix(1557042972, 0).Format("1")
  1316. year := time.Now().Format("2006")
  1317. month = time.Now().Format("01")
  1318. day := time.Now().Format("02")
  1319. hour := time.Now().Format("15")
  1320. min := time.Now().Format("04")
  1321. sec := time.Now().Format("05")
  1322. fix_fill_date := year + month + day + hour + min + sec
  1323. data["fix_fill_dept"] = miConfig.OrgName
  1324. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1325. data["fix_fill_psn"] = curRoles.UserName
  1326. data["fix_fill_date"] = fix_fill_date
  1327. data["stmt_loc"] = "2"
  1328. upld_btch = "0"
  1329. data["upld_btch"] = upld_btch
  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/3266", bytes.NewReader(bytesData))
  1335. } else {
  1336. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", 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), &result3265); err != nil {
  1355. utils.ErrorLog("解析失败:%v", err)
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1357. }
  1358. if result3265.Infcode != "0" {
  1359. c.ServeSuccessJSON(map[string]interface{}{
  1360. "failed_code": -10,
  1361. "msg": result3265.ErrMsg,
  1362. })
  1363. return
  1364. } else {
  1365. c.ServeSuccessJSON(map[string]interface{}{
  1366. "info": result3265.Output,
  1367. })
  1368. return
  1369. }
  1370. }
  1371. func (c *HisApiController) Get3267() {
  1372. admin_user_id, _ := c.GetInt64("admin_user_id")
  1373. startTime := c.GetString("start_time")
  1374. //endTime, _ := c.GetString("end_time")
  1375. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1376. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1377. times := strings.Split(startTime, "-")
  1378. setl_mon := times[0] + times[1]
  1379. var upld_btch string
  1380. //var empty models.JSResultEmpty
  1381. var result3265 models.JSResult3264
  1382. upld_btch = "0"
  1383. data := make(map[string]interface{})
  1384. data["org_name"] = miConfig.OrgName
  1385. data["doctor"] = curRoles.UserName
  1386. data["doctor_name"] = curRoles.UserName
  1387. data["fixmedins_code"] = miConfig.Code
  1388. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1389. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1390. data["secret_key"] = miConfig.SecretKey
  1391. data["url"] = miConfig.Url
  1392. data["ak"] = miConfig.AccessKey
  1393. data["cainfo"] = miConfig.Cainfo
  1394. data["setl_mon"] = setl_mon
  1395. data["stmt_loc"] = "2"
  1396. data["upld_btch"] = upld_btch
  1397. client := &http.Client{}
  1398. bytesData, _ := json.Marshal(data)
  1399. var req *http.Request
  1400. if miConfig.MdtrtareaAdmvs == "320921" {
  1401. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1402. } else {
  1403. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1404. }
  1405. resp, _ := client.Do(req)
  1406. defer resp.Body.Close()
  1407. body, ioErr := ioutil.ReadAll(resp.Body)
  1408. if ioErr != nil {
  1409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1411. }
  1412. var respJSON map[string]interface{}
  1413. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1416. }
  1417. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1418. fmt.Println(respJSON)
  1419. result, _ := json.Marshal(respJSON)
  1420. fmt.Println(result)
  1421. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1422. utils.ErrorLog("解析失败:%v", err)
  1423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1424. }
  1425. if result3265.Infcode != "0" {
  1426. c.ServeSuccessJSON(map[string]interface{}{
  1427. "failed_code": -10,
  1428. "msg": result3265.ErrMsg,
  1429. })
  1430. return
  1431. } else {
  1432. c.ServeSuccessJSON(map[string]interface{}{
  1433. "info": result3265.Output.Data,
  1434. })
  1435. return
  1436. }
  1437. }
  1438. func (c *HisApiController) Get3268() {
  1439. admin_user_id, _ := c.GetInt64("admin_user_id")
  1440. startTime := c.GetString("start_time")
  1441. endTime := c.GetString("end_time")
  1442. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1443. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1444. times := strings.Split(startTime, "-")
  1445. setl_mon := times[0] + times[1]
  1446. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1447. var twos []models.FixMonRecDetailFileInTwo
  1448. var funs []models.FundDetail
  1449. for _, item := range datas {
  1450. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1451. funs = append(funs, fun...)
  1452. }
  1453. var funInfos []models.Fund
  1454. //for _, item := range funs {
  1455. // var rf []models.FundInfo
  1456. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1457. // for _, subitem := range rf {
  1458. // var fund models.Fund
  1459. // fund.FundCode = subitem.FundPayType
  1460. // fund.FundName = subitem.FundPayTypeName
  1461. // fund.FundAmt = subitem.FundPayAmt
  1462. // fund.FundKey = item.FundKey
  1463. // fund.InsuAdmdvs = "555555"
  1464. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1465. // funInfos = append(funInfos, fund)
  1466. // }
  1467. //}
  1468. for _, team := range datas {
  1469. var two models.FixMonRecDetailFileInTwo
  1470. two.SetlDate = time.Now().Format("2006-01-02")
  1471. two.MedType = team.MedType
  1472. two.Insutype = team.Insutype
  1473. two.PsnType = team.PsnType
  1474. two.MedType = team.MedType
  1475. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1476. two.InsuAdmdvs = team.InsuAdmdvs
  1477. two.PsnTime = team.PsnTime
  1478. two.PsnCnt = team.PsnCnt
  1479. two.FundKey = team.FundKey
  1480. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1481. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1482. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1483. two.MedfeeSumAmt = ms
  1484. two.InscpAmt = ia
  1485. two.FundPaySumAmt = fps
  1486. twos = append(twos, two)
  1487. }
  1488. var upld_btch string
  1489. upld_btch = "0"
  1490. var empty models.JSResultEmpty
  1491. data := make(map[string]interface{})
  1492. data["org_name"] = miConfig.OrgName
  1493. data["doctor"] = curRoles.UserName
  1494. data["doctor_name"] = curRoles.UserName
  1495. data["fixmedins_code"] = miConfig.Code
  1496. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1497. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1498. data["secret_key"] = miConfig.SecretKey
  1499. data["url"] = miConfig.Url
  1500. data["ak"] = miConfig.AccessKey
  1501. data["cainfo"] = miConfig.Cainfo
  1502. data["datas"] = twos
  1503. data["fund"] = funInfos
  1504. data["setl_mon"] = setl_mon
  1505. month := time.Unix(1557042972, 0).Format("1")
  1506. year := time.Now().Format("2006")
  1507. month = time.Now().Format("01")
  1508. day := time.Now().Format("02")
  1509. hour := time.Now().Format("15")
  1510. min := time.Now().Format("04")
  1511. sec := time.Now().Format("05")
  1512. fix_fill_date := year + month + day + hour + min + sec
  1513. data["fix_fill_dept"] = miConfig.OrgName
  1514. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1515. data["fix_fill_psn"] = curRoles.UserName
  1516. data["fix_fill_date"] = fix_fill_date
  1517. data["stmt_loc"] = "2"
  1518. data["upld_btch"] = upld_btch
  1519. client := &http.Client{}
  1520. bytesData, _ := json.Marshal(data)
  1521. var req *http.Request
  1522. if miConfig.MdtrtareaAdmvs == "320921" {
  1523. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1524. } else {
  1525. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1526. }
  1527. resp, _ := client.Do(req)
  1528. defer resp.Body.Close()
  1529. body, ioErr := ioutil.ReadAll(resp.Body)
  1530. if ioErr != nil {
  1531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. }
  1534. var respJSON map[string]interface{}
  1535. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1538. }
  1539. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1540. fmt.Println(respJSON)
  1541. result, _ := json.Marshal(respJSON)
  1542. fmt.Println(result)
  1543. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1544. utils.ErrorLog("解析失败:%v", err)
  1545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1546. }
  1547. if empty.Infcode != "0" {
  1548. c.ServeSuccessJSON(map[string]interface{}{
  1549. "failed_code": -10,
  1550. "msg": empty.ErrMsg,
  1551. })
  1552. return
  1553. } else {
  1554. c.ServeSuccessJSON(map[string]interface{}{
  1555. "msg": "上传成功",
  1556. })
  1557. return
  1558. }
  1559. }
  1560. func (c *HisApiController) Get3269() {
  1561. admin_user_id, _ := c.GetInt64("admin_user_id")
  1562. startTime := c.GetString("start_time")
  1563. //endTime, _ := c.GetString("end_time")
  1564. times := strings.Split(startTime, "-")
  1565. setl_mon := times[0] + times[1]
  1566. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1567. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1568. var result3263 models.JSResult3263
  1569. data := make(map[string]interface{})
  1570. data["org_name"] = miConfig.OrgName
  1571. data["doctor"] = curRoles.UserName
  1572. data["doctor_name"] = curRoles.UserName
  1573. data["fixmedins_code"] = miConfig.Code
  1574. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1575. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1576. data["secret_key"] = miConfig.SecretKey
  1577. data["url"] = miConfig.Url
  1578. data["ak"] = miConfig.AccessKey
  1579. data["cainfo"] = miConfig.Cainfo
  1580. data["setl_mon"] = setl_mon
  1581. data["stmt_loc"] = "2"
  1582. client := &http.Client{}
  1583. bytesData, _ := json.Marshal(data)
  1584. var req *http.Request
  1585. if miConfig.MdtrtareaAdmvs == "320921" {
  1586. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1587. } else {
  1588. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1589. }
  1590. resp, _ := client.Do(req)
  1591. defer resp.Body.Close()
  1592. body, ioErr := ioutil.ReadAll(resp.Body)
  1593. if ioErr != nil {
  1594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1596. }
  1597. var respJSON map[string]interface{}
  1598. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1601. }
  1602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1603. fmt.Println(respJSON)
  1604. result, _ := json.Marshal(respJSON)
  1605. fmt.Println(result)
  1606. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1607. utils.ErrorLog("解析失败:%v", err)
  1608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1609. }
  1610. if result3263.Infcode != "0" {
  1611. c.ServeSuccessJSON(map[string]interface{}{
  1612. "failed_code": -10,
  1613. "msg": result3263.ErrMsg,
  1614. })
  1615. return
  1616. } else {
  1617. c.ServeSuccessJSON(map[string]interface{}{
  1618. "msg": "上传成功",
  1619. })
  1620. return
  1621. }
  1622. }
  1623. func (c *HisApiController) Get3270() {
  1624. admin_user_id, _ := c.GetInt64("admin_user_id")
  1625. startTime := c.GetString("start_time")
  1626. //endTime, _ := c.GetString("end_time")
  1627. times := strings.Split(startTime, "-")
  1628. setl_mon := times[0] + times[1]
  1629. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1630. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1631. var result3263 models.JSResult3263
  1632. data2 := make(map[string]interface{})
  1633. data2["org_name"] = miConfig.OrgName
  1634. data2["doctor"] = curRoles.UserName
  1635. data2["doctor_name"] = curRoles.UserName
  1636. data2["fixmedins_code"] = miConfig.Code
  1637. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1638. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1639. data2["secret_key"] = miConfig.SecretKey
  1640. data2["url"] = miConfig.Url
  1641. data2["ak"] = miConfig.AccessKey
  1642. data2["cainfo"] = miConfig.Cainfo
  1643. data2["setl_mon"] = setl_mon
  1644. data2["stmt_loc"] = "2"
  1645. client2 := &http.Client{}
  1646. bytesData2, _ := json.Marshal(data2)
  1647. var req3263 *http.Request
  1648. if miConfig.MdtrtareaAdmvs == "320921" {
  1649. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1650. } else {
  1651. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1652. }
  1653. resp2, _ := client2.Do(req3263)
  1654. defer resp2.Body.Close()
  1655. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1656. if ioErr2 != nil {
  1657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1659. }
  1660. var respJSON3263 map[string]interface{}
  1661. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. }
  1665. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1666. fmt.Println(respJSON3263)
  1667. result2, _ := json.Marshal(respJSON3263)
  1668. fmt.Println(result2)
  1669. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1670. utils.ErrorLog("解析失败:%v", err)
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1672. }
  1673. var ids []string
  1674. for _, item := range result3263.Output {
  1675. ids = append(ids, item.SolidifyID)
  1676. }
  1677. var result3264 models.JSResult3264
  1678. data := make(map[string]interface{})
  1679. data["org_name"] = miConfig.OrgName
  1680. data["doctor"] = curRoles.UserName
  1681. data["doctor_name"] = curRoles.UserName
  1682. data["fixmedins_code"] = miConfig.Code
  1683. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1684. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1685. data["secret_key"] = miConfig.SecretKey
  1686. data["url"] = miConfig.Url
  1687. data["ak"] = miConfig.AccessKey
  1688. data["cainfo"] = miConfig.Cainfo
  1689. data["setl_mon"] = setl_mon
  1690. data["stmt_loc"] = "2"
  1691. data["solidify_id"] = ids
  1692. client := &http.Client{}
  1693. bytesData, _ := json.Marshal(data)
  1694. var req *http.Request
  1695. if miConfig.MdtrtareaAdmvs == "320921" {
  1696. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1697. } else {
  1698. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1699. }
  1700. resp, _ := client.Do(req)
  1701. defer resp.Body.Close()
  1702. body, ioErr := ioutil.ReadAll(resp.Body)
  1703. if ioErr != nil {
  1704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1706. }
  1707. var respJSON map[string]interface{}
  1708. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1711. }
  1712. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1713. fmt.Println(respJSON)
  1714. result, _ := json.Marshal(respJSON)
  1715. fmt.Println(result)
  1716. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  1717. utils.ErrorLog("解析失败:%v", err)
  1718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1719. }
  1720. if result3264.Infcode != "0" {
  1721. c.ServeSuccessJSON(map[string]interface{}{
  1722. "failed_code": -10,
  1723. "msg": result3264.ErrMsg,
  1724. })
  1725. return
  1726. } else {
  1727. c.ServeSuccessJSON(map[string]interface{}{
  1728. "info": result3264.Output,
  1729. })
  1730. return
  1731. }
  1732. }
  1733. func (c *HisApiController) Get3271() {
  1734. admin_user_id, _ := c.GetInt64("admin_user_id")
  1735. startTime := c.GetString("start_time")
  1736. //endTime, _ := c.GetString("end_time")
  1737. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1738. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1739. times := strings.Split(startTime, "-")
  1740. setl_mon := times[0] + times[1]
  1741. //var empty models.JSResultEmpty
  1742. var result3265 models.JSResult3264
  1743. var result3263 models.JSResult3263
  1744. data2 := make(map[string]interface{})
  1745. data2["org_name"] = miConfig.OrgName
  1746. data2["doctor"] = curRoles.UserName
  1747. data2["doctor_name"] = curRoles.UserName
  1748. data2["fixmedins_code"] = miConfig.Code
  1749. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1750. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1751. data2["secret_key"] = miConfig.SecretKey
  1752. data2["url"] = miConfig.Url
  1753. data2["ak"] = miConfig.AccessKey
  1754. data2["cainfo"] = miConfig.Cainfo
  1755. data2["setl_mon"] = setl_mon
  1756. data2["stmt_loc"] = "2"
  1757. client2 := &http.Client{}
  1758. bytesData2, _ := json.Marshal(data2)
  1759. var req3263 *http.Request
  1760. if miConfig.MdtrtareaAdmvs == "320921" {
  1761. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1762. } else {
  1763. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1764. }
  1765. resp2, _ := client2.Do(req3263)
  1766. defer resp2.Body.Close()
  1767. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1768. if ioErr2 != nil {
  1769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1771. }
  1772. var respJSON3263 map[string]interface{}
  1773. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1776. }
  1777. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1778. fmt.Println(respJSON3263)
  1779. result2, _ := json.Marshal(respJSON3263)
  1780. fmt.Println(result2)
  1781. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1782. utils.ErrorLog("解析失败:%v", err)
  1783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1784. }
  1785. var ids []string
  1786. for _, item := range result3263.Output {
  1787. ids = append(ids, item.SolidifyID)
  1788. }
  1789. data := make(map[string]interface{})
  1790. data["org_name"] = miConfig.OrgName
  1791. data["doctor"] = curRoles.UserName
  1792. data["doctor_name"] = curRoles.UserName
  1793. data["fixmedins_code"] = miConfig.Code
  1794. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1795. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1796. data["secret_key"] = miConfig.SecretKey
  1797. data["url"] = miConfig.Url
  1798. data["ak"] = miConfig.AccessKey
  1799. data["cainfo"] = miConfig.Cainfo
  1800. data["setl_mon"] = setl_mon
  1801. data["solidify_id"] = ids
  1802. month := time.Unix(1557042972, 0).Format("1")
  1803. year := time.Now().Format("2006")
  1804. month = time.Now().Format("01")
  1805. day := time.Now().Format("02")
  1806. hour := time.Now().Format("15")
  1807. min := time.Now().Format("04")
  1808. sec := time.Now().Format("05")
  1809. fix_fill_date := year + month + day + hour + min + sec
  1810. data["fix_fill_dept"] = miConfig.OrgName
  1811. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1812. data["fix_fill_psn"] = curRoles.UserName
  1813. data["fix_fill_date"] = fix_fill_date
  1814. data["stmt_loc"] = "2"
  1815. client := &http.Client{}
  1816. bytesData, _ := json.Marshal(data)
  1817. var req *http.Request
  1818. if miConfig.MdtrtareaAdmvs == "320921" {
  1819. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1820. } else {
  1821. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1822. }
  1823. resp, _ := client.Do(req)
  1824. defer resp.Body.Close()
  1825. body, ioErr := ioutil.ReadAll(resp.Body)
  1826. if ioErr != nil {
  1827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. }
  1830. var respJSON map[string]interface{}
  1831. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1834. }
  1835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1836. fmt.Println(respJSON)
  1837. result, _ := json.Marshal(respJSON)
  1838. fmt.Println(result)
  1839. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1840. utils.ErrorLog("解析失败:%v", err)
  1841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1842. }
  1843. if result3265.Infcode != "0" {
  1844. c.ServeSuccessJSON(map[string]interface{}{
  1845. "failed_code": -10,
  1846. "msg": result3265.ErrMsg,
  1847. })
  1848. return
  1849. } else {
  1850. c.ServeSuccessJSON(map[string]interface{}{
  1851. "info": result3265.Output.Data,
  1852. })
  1853. return
  1854. }
  1855. }
  1856. func (c *HisApiController) Get3272() {
  1857. admin_user_id, _ := c.GetInt64("admin_user_id")
  1858. startTime := c.GetString("start_time")
  1859. //endTime, _ := c.GetString("end_time")
  1860. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1861. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1862. times := strings.Split(startTime, "-")
  1863. setl_mon := times[0] + times[1]
  1864. var upld_btch string
  1865. //var empty models.JSResultEmpty
  1866. var result3265 models.JSResult3264
  1867. data := make(map[string]interface{})
  1868. data["org_name"] = miConfig.OrgName
  1869. data["doctor"] = curRoles.UserName
  1870. data["doctor_name"] = curRoles.UserName
  1871. data["fixmedins_code"] = miConfig.Code
  1872. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1873. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1874. data["secret_key"] = miConfig.SecretKey
  1875. data["url"] = miConfig.Url
  1876. data["ak"] = miConfig.AccessKey
  1877. data["cainfo"] = miConfig.Cainfo
  1878. data["setl_mon"] = setl_mon
  1879. month := time.Unix(1557042972, 0).Format("1")
  1880. year := time.Now().Format("2006")
  1881. month = time.Now().Format("01")
  1882. day := time.Now().Format("02")
  1883. hour := time.Now().Format("15")
  1884. min := time.Now().Format("04")
  1885. sec := time.Now().Format("05")
  1886. fix_fill_date := year + month + day + hour + min + sec
  1887. data["fix_fill_dept"] = miConfig.OrgName
  1888. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1889. data["fix_fill_psn"] = curRoles.UserName
  1890. data["fix_fill_date"] = fix_fill_date
  1891. data["stmt_loc"] = "2"
  1892. data["upld_btch"] = upld_btch
  1893. client := &http.Client{}
  1894. bytesData, _ := json.Marshal(data)
  1895. var req *http.Request
  1896. if miConfig.MdtrtareaAdmvs == "320921" {
  1897. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1898. } else {
  1899. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1900. }
  1901. resp, _ := client.Do(req)
  1902. defer resp.Body.Close()
  1903. body, ioErr := ioutil.ReadAll(resp.Body)
  1904. if ioErr != nil {
  1905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1907. }
  1908. var respJSON map[string]interface{}
  1909. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1912. }
  1913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1914. fmt.Println(respJSON)
  1915. result, _ := json.Marshal(respJSON)
  1916. fmt.Println(result)
  1917. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1918. utils.ErrorLog("解析失败:%v", err)
  1919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. }
  1921. if result3265.Infcode != "0" {
  1922. c.ServeSuccessJSON(map[string]interface{}{
  1923. "failed_code": -10,
  1924. "msg": result3265.ErrMsg,
  1925. })
  1926. return
  1927. } else {
  1928. c.ServeSuccessJSON(map[string]interface{}{
  1929. "info": result3265.Output,
  1930. })
  1931. return
  1932. }
  1933. }
  1934. func (c *HisApiController) Get3273() {
  1935. admin_user_id, _ := c.GetInt64("admin_user_id")
  1936. startTime := c.GetString("start_time")
  1937. //endTime, _ := c.GetString("end_time")
  1938. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1939. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1940. times := strings.Split(startTime, "-")
  1941. setl_mon := times[0] + times[1]
  1942. var result3265 models.JSResult3264
  1943. data := make(map[string]interface{})
  1944. data["org_name"] = miConfig.OrgName
  1945. data["doctor"] = curRoles.UserName
  1946. data["doctor_name"] = curRoles.UserName
  1947. data["fixmedins_code"] = miConfig.Code
  1948. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1949. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1950. data["secret_key"] = miConfig.SecretKey
  1951. data["url"] = miConfig.Url
  1952. data["ak"] = miConfig.AccessKey
  1953. data["cainfo"] = miConfig.Cainfo
  1954. data["setl_mon"] = setl_mon
  1955. data["stmt_loc"] = "2"
  1956. client := &http.Client{}
  1957. bytesData, _ := json.Marshal(data)
  1958. var req *http.Request
  1959. if miConfig.MdtrtareaAdmvs == "320921" {
  1960. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1961. } else {
  1962. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1963. }
  1964. resp, _ := client.Do(req)
  1965. defer resp.Body.Close()
  1966. body, ioErr := ioutil.ReadAll(resp.Body)
  1967. if ioErr != nil {
  1968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1970. }
  1971. var respJSON map[string]interface{}
  1972. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1975. }
  1976. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1977. fmt.Println(respJSON)
  1978. result, _ := json.Marshal(respJSON)
  1979. fmt.Println(result)
  1980. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1981. utils.ErrorLog("解析失败:%v", err)
  1982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1983. }
  1984. if result3265.Infcode != "0" {
  1985. c.ServeSuccessJSON(map[string]interface{}{
  1986. "failed_code": -10,
  1987. "msg": result3265.ErrMsg,
  1988. })
  1989. return
  1990. } else {
  1991. c.ServeSuccessJSON(map[string]interface{}{
  1992. "info": result3265.Output.Data,
  1993. })
  1994. return
  1995. }
  1996. }
  1997. func (c *HisApiController) Get3274() {
  1998. //if miConfig.MdtrtareaAdmvs == "320921" {
  1999. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2000. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2001. // "&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
  2002. //
  2003. //} else {
  2004. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2005. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2006. // "&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
  2007. //
  2008. //}
  2009. }
  2010. func (c *HisApiController) Get3275() {
  2011. //if miConfig.MdtrtareaAdmvs == "320921" {
  2012. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2013. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2014. // "&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
  2015. //
  2016. //} else {
  2017. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2018. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2019. // "&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
  2020. //
  2021. //}
  2022. }
  2023. func (c *HisApiController) Get3276() {
  2024. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2025. //month := c.GetString("month")
  2026. //
  2027. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2028. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2029. //var api string
  2030. //var res Result5301
  2031. //
  2032. //if miConfig.MdtrtareaAdmvs == "320921" {
  2033. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2034. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2035. //} else {
  2036. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2037. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2038. //}
  2039. //
  2040. //resp, requestErr := http.Get(api)
  2041. //if requestErr != nil {
  2042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2043. // return
  2044. //}
  2045. //
  2046. //body, ioErr := ioutil.ReadAll(resp.Body)
  2047. //if ioErr != nil {
  2048. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2050. // return
  2051. //}
  2052. //var respJSON map[string]interface{}
  2053. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2054. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2056. // return
  2057. //}
  2058. //
  2059. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2060. //result, _ := json.Marshal(respJSON)
  2061. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2062. // utils.ErrorLog("解析失败:%v", err)
  2063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2064. // return
  2065. //}
  2066. }
  2067. func (c *HisApiController) Get3277() {
  2068. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2069. //month := c.GetString("month")
  2070. //
  2071. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2072. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2073. //var api string
  2074. //var res Result5301
  2075. //
  2076. //if miConfig.MdtrtareaAdmvs == "320921" {
  2077. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2078. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2079. //} else {
  2080. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2081. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2082. //}
  2083. //
  2084. //resp, requestErr := http.Get(api)
  2085. //if requestErr != nil {
  2086. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2087. // return
  2088. //}
  2089. //
  2090. //body, ioErr := ioutil.ReadAll(resp.Body)
  2091. //if ioErr != nil {
  2092. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2094. // return
  2095. //}
  2096. //var respJSON map[string]interface{}
  2097. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2098. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2100. // return
  2101. //}
  2102. //
  2103. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2104. //result, _ := json.Marshal(respJSON)
  2105. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2106. // utils.ErrorLog("解析失败:%v", err)
  2107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2108. // return
  2109. //}
  2110. }
  2111. func (c *HisApiController) GetCFYLJG001() {
  2112. admin_user_id, _ := c.GetInt64("admin_user_id")
  2113. patient_id, _ := c.GetInt64("patient_id")
  2114. his_patient_id, _ := c.GetInt64("his_patient_id")
  2115. record_time := c.GetString("record_time")
  2116. admin_user_id = 3626
  2117. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2118. psn, _ := service.GetPsnByPatientId(patient_id)
  2119. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2120. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2121. var cFYLJG001 models.CFYLJG001
  2122. timeLayout := "2006-01-02"
  2123. loc, _ := time.LoadLocation("Local")
  2124. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2125. if err != nil {
  2126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2127. return
  2128. }
  2129. recordDateTime := theTime.Unix()
  2130. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2131. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2132. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2133. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2134. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2135. for _, item := range prescriptions {
  2136. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2137. if his.IdCardType == 1 {
  2138. bas := strings.Split(psn.CardInfo, "|")
  2139. basNumber := bas[1]
  2140. fmt.Println(basNumber)
  2141. card_sn := bas[3]
  2142. card_no := bas[2]
  2143. cFYLJG001.MdtrtCertType = "03"
  2144. cFYLJG001.CardSn = card_sn
  2145. cFYLJG001.MdtrtCertNo = card_no
  2146. cFYLJG001.EcToken = ""
  2147. cFYLJG001.AuthNo = ""
  2148. } else if his.IdCardType == 2 {
  2149. cFYLJG001.MdtrtCertType = "02"
  2150. cFYLJG001.CardSn = ""
  2151. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2152. cFYLJG001.EcToken = ""
  2153. cFYLJG001.AuthNo = ""
  2154. } else if his.IdCardType == 4 {
  2155. cFYLJG001.MdtrtCertType = "01"
  2156. cFYLJG001.CardSn = ""
  2157. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2158. cFYLJG001.EcToken = psn.VerifyNumber
  2159. cFYLJG001.AuthNo = ""
  2160. }
  2161. cFYLJG001.BizTypeCode = "01"
  2162. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2163. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2164. cFYLJG001.RxTypeCode = "1"
  2165. tempTime := time.Unix(item.PreTime, 0)
  2166. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2167. cFYLJG001.PrscTime = timeFormatOne
  2168. var count float64
  2169. if item.Type == 1 {
  2170. for _, sumItem := range item.HisDoctorAdviceInfo {
  2171. count = count + sumItem.PrescribingNumber
  2172. }
  2173. }
  2174. cFYLJG001.RxDrugCnt = count
  2175. cFYLJG001.ValiDays = "5"
  2176. ts := time.Unix(item.PreTime, 0)
  2177. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2178. tempTime3 := time.Unix(record_time2, 0)
  2179. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2180. cFYLJG001.ValiEndTime = timeFormat3
  2181. cFYLJG001.RxCotnFlag = "0"
  2182. for _, subItem := range item.HisDoctorAdviceInfo {
  2183. var drug models.RxDrug
  2184. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2185. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2186. drug.RxItemTypeCode = "11"
  2187. drug.DrugDosform = "乳膏剂" //TODO
  2188. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2189. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2190. }
  2191. drug.MedcWayDscr = subItem.DeliveryWay
  2192. tempTime2 := time.Unix(subItem.StartTime, 0)
  2193. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2194. drug.MedcBegntime = timeFormatTwo
  2195. if subItem.Day > 0 {
  2196. ts := time.Unix(subItem.StartTime, 0)
  2197. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2198. tempTime4 := time.Unix(record_time, 0)
  2199. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2200. drug.MedcEndtime = timeFormat5
  2201. } else {
  2202. tempTime2 := time.Unix(subItem.StartTime, 0)
  2203. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2204. drug.MedcEndtime = timeFormatTwo
  2205. }
  2206. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2207. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2208. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2209. drug.DrugCnt = subItem.PrescribingNumber
  2210. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2211. drug.DrugGenname = subItem.AdviceName
  2212. drug.MedcWayCodg = subItem.DeliveryWay
  2213. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2214. drug.SinDoscnt = subItem.SingleDose
  2215. drug.SinDosunt = subItem.SingleDoseUnit
  2216. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2217. drug.UsedFrquName = subItem.ExecutionFrequency
  2218. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2219. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2220. drug.HospApprFlag = "1"
  2221. cFYLJG001.List = append(cFYLJG001.List, drug)
  2222. }
  2223. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2224. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2225. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2226. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2227. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2228. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2229. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2230. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2231. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2232. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2233. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2234. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2235. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2236. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2237. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2238. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2239. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2240. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2241. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2242. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2243. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2244. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2245. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2246. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2247. tempTime2 := time.Now().Unix()
  2248. tempTime6 := time.Unix(tempTime2, 0)
  2249. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2250. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2251. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2252. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2253. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2254. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2255. //memo := make(map[string]interface{})
  2256. //inputData := make(map[string]interface{}, 0)
  2257. //type MyData struct {
  2258. // Insutype string `json:"insutype"`
  2259. //}
  2260. //
  2261. // data := MyData{
  2262. // Insutype: his.Insutype,
  2263. //}
  2264. //
  2265. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2266. var config []*models.HisXtDiagnoseConfig
  2267. for _, item := range diagnosis_ids {
  2268. id, _ := strconv.ParseInt(item, 10, 64)
  2269. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2270. config = append(config, &diagnosisConfig)
  2271. }
  2272. for index, subitem := range config {
  2273. if index == 0 {
  2274. var dia models.DiseInfo
  2275. dia.DiagType = "1"
  2276. dia.MaindiagFlag = "1"
  2277. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2278. dia.DiagCode = subitem.CountryCode
  2279. dia.DiagName = subitem.ClassName
  2280. dia.DiagDept = "肾内科"
  2281. dia.DiagDrNo = doctor.DoctorNumber
  2282. dia.DiagDrName = doctor.UserName
  2283. tempTime3 := time.Unix(item.PreTime, 0)
  2284. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2285. dia.DiagTime = timeFormatTwo
  2286. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2287. } else {
  2288. var dia models.DiseInfo
  2289. dia.DiagType = "1"
  2290. dia.MaindiagFlag = "0"
  2291. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2292. dia.DiagCode = subitem.CountryCode
  2293. dia.DiagName = subitem.ClassName
  2294. dia.DiagDept = "肾内科"
  2295. dia.DiagDrNo = doctor.DoctorNumber
  2296. dia.DiagDrName = doctor.UserName
  2297. tempTime3 := time.Unix(item.PreTime, 0)
  2298. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2299. dia.DiagTime = timeFormatTwo
  2300. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2301. }
  2302. }
  2303. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2304. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2305. var res ResultCFYLJG001
  2306. var respJSON2 map[string]interface{}
  2307. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2310. return
  2311. }
  2312. userJSONBytes2, _ := json.Marshal(respJSON2)
  2313. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2314. utils.ErrorLog("解析失败:%v", err)
  2315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2316. return
  2317. }
  2318. if res.Infcode == -1 {
  2319. c.ServeSuccessJSON(map[string]interface{}{
  2320. "failed_code": -10,
  2321. "msg": res.ErrMsg,
  2322. })
  2323. return
  2324. } else {
  2325. var flow models.HisPrescriptionFlow
  2326. flow.Ctime = time.Now().Unix()
  2327. flow.SignDigest = ""
  2328. flow.RxTraceCode = res.Output.RxTraceCode
  2329. flow.HiRxno = res.Output.HiRxno
  2330. flow.MID = his.Number
  2331. flow.Status = 1
  2332. flow.DCode = doctor_info.DoctorNumber
  2333. flow.OriginalRxFile = ""
  2334. flow.OriginalValue = ""
  2335. flow.SignCertDn = ""
  2336. flow.SignCertSn = ""
  2337. flow.Mtime = time.Now().Unix()
  2338. flow.ID = 0
  2339. service.Createflow(flow)
  2340. c.ServeSuccessJSON(map[string]interface{}{
  2341. "msg": "上传成功",
  2342. })
  2343. }
  2344. }
  2345. }
  2346. func (c *HisApiController) GetCFYLJG002() {
  2347. admin_user_id, _ := c.GetInt64("admin_user_id")
  2348. id, _ := c.GetInt64("id")
  2349. admin_user_id = 3626
  2350. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2351. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2352. flow, _ := service.Getflow(id)
  2353. his, _ := service.GetHisPatientByNumber(flow.MID)
  2354. record_time := c.GetString("record_time")
  2355. patient_id, _ := c.GetInt64("patient_id")
  2356. //patient_id = 23834
  2357. //record_time = "2023-09-18"
  2358. timeLayout := "2006-01-02"
  2359. loc, _ := time.LoadLocation("Local")
  2360. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2361. if err != nil {
  2362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2363. return
  2364. }
  2365. recordDateTime := theTime.Unix()
  2366. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2367. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2368. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2369. dept, _ := service.GetDepartMentDetail(info.Departments)
  2370. inputData := make(map[string]interface{})
  2371. inputData["rxTraceCode"] = flow.RxTraceCode
  2372. inputData["hiRxno"] = flow.HiRxno
  2373. inputData["mdtrtId"] = flow.MID
  2374. inputData["patnName"] = his.PsnName
  2375. inputData["psnCertType"] = his.PsnCertType
  2376. inputData["certno"] = his.Certno
  2377. inputData["fixmedinsName"] = miConfig.OrgName
  2378. inputData["fixmedinsCode"] = miConfig.Code
  2379. inputData["drCode"] = doctor_info.DoctorNumber
  2380. inputData["prscDrName"] = doctor_info.UserName
  2381. inputData["pharDeptName"] = dept.Name
  2382. inputData["pharDeptCode"] = dept.Number
  2383. inputData["pharProfttlCodg"] = dept.Name
  2384. inputData["pharProfttlName"] = ""
  2385. inputData["pharCode"] = "HY440309002107"
  2386. inputData["pharCertType"] = "01"
  2387. inputData["pharCertno"] = "430482199408260023"
  2388. inputData["pharName"] = "彭斯遥"
  2389. inputData["pharPracCertNo"] = ""
  2390. tempTime2 := time.Unix(info.Ctime, 0)
  2391. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2392. inputData["pharChkTime"] = timeFormatTwo
  2393. bytesData, _ := json.Marshal(inputData)
  2394. fmt.Println(string(bytesData))
  2395. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2396. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2397. if err != nil {
  2398. fmt.Println("Error reading PDF file:", err)
  2399. return
  2400. }
  2401. // 将 PDF 文件内容进行 Base64 编码
  2402. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2403. fmt.Println(err)
  2404. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2405. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2406. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2407. var res2 Result002
  2408. var respJSON2 map[string]interface{}
  2409. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2412. return
  2413. }
  2414. userJSONBytes2, _ := json.Marshal(respJSON2)
  2415. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2416. utils.ErrorLog("解析失败:%v", err)
  2417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2418. return
  2419. }
  2420. if res2.Infcode == 0 {
  2421. flow.Ctime = time.Now().Unix()
  2422. flow.SignDigest = res2.Output.SignDigest
  2423. flow.RxFile = res2.Output.RxFile
  2424. flow.MID = his.Number
  2425. flow.Status = 1
  2426. flow.DCode = doctor_info.DoctorNumber
  2427. flow.OriginalRxFile = rx_encoded
  2428. flow.OriginalValue = encoded
  2429. flow.SignCertDn = res2.Output.SignCertDn
  2430. flow.SignCertSn = res2.Output.SignCertSn
  2431. flow.Mtime = time.Now().Unix()
  2432. service.Saveflow(flow)
  2433. c.ServeSuccessJSON(map[string]interface{}{
  2434. "msg": "预签名成功",
  2435. })
  2436. } else {
  2437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2438. return
  2439. }
  2440. }
  2441. func (c *HisApiController) GetCFYLJG003() {
  2442. admin_user_id, _ := c.GetInt64("admin_user_id")
  2443. id, _ := c.GetInt64("id")
  2444. admin_user_id = 3626
  2445. //id = 3
  2446. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2447. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2448. flow, _ := service.Getflow(id)
  2449. his, _ := service.GetHisPatientByNumber(flow.MID)
  2450. record_time := c.GetString("record_time")
  2451. patient_id, _ := c.GetInt64("patient_id")
  2452. //patient_id = 23834
  2453. //record_time = "2023-09-18"
  2454. timeLayout := "2006-01-02"
  2455. loc, _ := time.LoadLocation("Local")
  2456. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2457. if err != nil {
  2458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2459. return
  2460. }
  2461. recordDateTime := theTime.Unix()
  2462. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2463. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2464. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2465. dept, _ := service.GetDepartMentDetail(info.Departments)
  2466. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  2467. var cFYLJG003 models.CFYLJG003
  2468. cFYLJG003.RxTraceCode = flow.RxTraceCode
  2469. cFYLJG003.HiRxno = flow.HiRxno
  2470. cFYLJG003.MdtrtID = flow.MID
  2471. cFYLJG003.PatnName = his.Name
  2472. cFYLJG003.Certno = his.Certno
  2473. cFYLJG003.FixmedinsName = miConfig.OrgName
  2474. cFYLJG003.FixmedinsCode = miConfig.Code
  2475. cFYLJG003.DrCode = doctor_info.DoctorNumber
  2476. cFYLJG003.PrscDrName = doctor_info.UserName
  2477. cFYLJG003.PharDeptName = dept.Name
  2478. cFYLJG003.PharDeptCode = dept.Number
  2479. cFYLJG003.PharCode = "HY440309002107"
  2480. cFYLJG003.PharCertType = "01"
  2481. cFYLJG003.PharCertno = "430482199408260023"
  2482. cFYLJG003.PharName = "彭斯遥"
  2483. cFYLJG003.PsnCertType = "01"
  2484. cFYLJG003.RxFile = flow.RxFile
  2485. cFYLJG003.SignDigest = flow.SignDigest
  2486. cFYLJG003.FixmedinsCode = miConfig.Code
  2487. cFYLJG003.PsnCertType = "01"
  2488. cFYLJG003.PharProfttlCodg = dept.Name
  2489. //inputData["pharProfttlCodg"] =dept.Name
  2490. tempTime2 := time.Unix(info.Ctime, 0)
  2491. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2492. cFYLJG003.PharChkTime = timeFormatTwo
  2493. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2494. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  2495. var res ResultCFYLJG003
  2496. var respJSON2 map[string]interface{}
  2497. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2500. return
  2501. }
  2502. userJSONBytes2, _ := json.Marshal(respJSON2)
  2503. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2504. utils.ErrorLog("解析失败:%v", err)
  2505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2506. return
  2507. }
  2508. if res.Infcode == -1 {
  2509. c.ServeSuccessJSON(map[string]interface{}{
  2510. "failed_code": -10,
  2511. "msg": res.ErrMsg,
  2512. })
  2513. return
  2514. } else {
  2515. c.ServeSuccessJSON(map[string]interface{}{
  2516. "info": res.Output,
  2517. })
  2518. }
  2519. }
  2520. func (c *HisApiController) GetCFYLJG004() {
  2521. admin_user_id, _ := c.GetInt64("admin_user_id")
  2522. id, _ := c.GetInt64("id")
  2523. admin_user_id = 3626
  2524. //id = 3
  2525. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2526. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2527. flow, _ := service.Getflow(id)
  2528. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2529. record_time := c.GetString("record_time")
  2530. patient_id, _ := c.GetInt64("patient_id")
  2531. //patient_id = 23834
  2532. //record_time = "2023-09-18"
  2533. timeLayout := "2006-01-02"
  2534. loc, _ := time.LoadLocation("Local")
  2535. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2536. if err != nil {
  2537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2538. return
  2539. }
  2540. recordDateTime := theTime.Unix()
  2541. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2542. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2543. var cFYLJG004 models.CFYLJG004
  2544. cFYLJG004.HiRxno = flow.HiRxno
  2545. cFYLJG004.FixmedinsCode = miConfig.Code
  2546. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  2547. cFYLJG004.UndoDrCertType = "01"
  2548. cFYLJG004.UndoRea = "撤销处方"
  2549. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  2550. cFYLJG004.UndoDrName = doctor_info.UserName
  2551. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  2552. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2553. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  2554. var res ResultCFYLJG004
  2555. var respJSON2 map[string]interface{}
  2556. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2559. return
  2560. }
  2561. userJSONBytes2, _ := json.Marshal(respJSON2)
  2562. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2563. utils.ErrorLog("解析失败:%v", err)
  2564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2565. return
  2566. }
  2567. if res.Infcode == -1 {
  2568. c.ServeSuccessJSON(map[string]interface{}{
  2569. "failed_code": -10,
  2570. "msg": res.ErrMsg,
  2571. })
  2572. return
  2573. } else {
  2574. flow.Status = 0
  2575. service.Saveflow(flow)
  2576. c.ServeSuccessJSON(map[string]interface{}{
  2577. "msg": "撤销成功",
  2578. })
  2579. return
  2580. }
  2581. }
  2582. func (c *HisApiController) GetCFYLJG005() {
  2583. admin_user_id, _ := c.GetInt64("admin_user_id")
  2584. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2585. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2586. var cFYLJG005 models.CFYLJG005
  2587. id, _ := c.GetInt64("id")
  2588. patient_id, _ := c.GetInt64("patient_id")
  2589. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2590. flow, _ := service.Getflow(id)
  2591. cFYLJG005.HiRxno = flow.HiRxno
  2592. cFYLJG005.MdtrtID = flow.MID
  2593. cFYLJG005.EcToken = ""
  2594. cFYLJG005.PsnName = patient.Name
  2595. cFYLJG005.PsnCertType = "01"
  2596. cFYLJG005.Certno = patient.IdCardNo
  2597. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  2598. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  2599. var res ResultCFYLJG005
  2600. var respJSON2 map[string]interface{}
  2601. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2604. return
  2605. }
  2606. userJSONBytes2, _ := json.Marshal(respJSON2)
  2607. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2608. utils.ErrorLog("解析失败:%v", err)
  2609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2610. return
  2611. }
  2612. if res.Infcode == -1 {
  2613. c.ServeSuccessJSON(map[string]interface{}{
  2614. "failed_code": -10,
  2615. "msg": res.ErrMsg,
  2616. })
  2617. return
  2618. } else {
  2619. c.ServeSuccessJSON(map[string]interface{}{
  2620. "info": res.Output,
  2621. })
  2622. return
  2623. }
  2624. }
  2625. func (c *HisApiController) GetCFYLJG006() {
  2626. admin_user_id, _ := c.GetInt64("admin_user_id")
  2627. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2628. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2629. var cFYLJG006 models.CFYLJG006
  2630. id, _ := c.GetInt64("id")
  2631. patient_id, _ := c.GetInt64("patient_id")
  2632. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2633. flow, _ := service.Getflow(id)
  2634. cFYLJG006.HiRxno = flow.HiRxno
  2635. cFYLJG006.MdtrtID = flow.MID
  2636. cFYLJG006.PsnName = patient.Name
  2637. cFYLJG006.PsnCertType = "01"
  2638. cFYLJG006.Certno = patient.IdCardNo
  2639. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  2640. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  2641. }
  2642. func (c *HisApiController) GetCFYLJG007() {
  2643. admin_user_id, _ := c.GetInt64("admin_user_id")
  2644. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2645. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2646. var cFYLJG007 models.CFYLJG007
  2647. id, _ := c.GetInt64("id")
  2648. patient_id, _ := c.GetInt64("patient_id")
  2649. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2650. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2651. flow, _ := service.Getflow(id)
  2652. his, _ := service.GetHisPatientByNumber(flow.MID)
  2653. cFYLJG007.HiRxno = flow.HiRxno
  2654. cFYLJG007.MdtrtID = flow.MID
  2655. cFYLJG007.PsnNo = his.PsnNo
  2656. cFYLJG007.PsnCertType = "01"
  2657. cFYLJG007.Certno = patient.IdCardNo
  2658. cFYLJG007.PsnName = patient.Name
  2659. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  2660. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  2661. var res ResultCFYLJG006
  2662. var respJSON2 map[string]interface{}
  2663. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2666. return
  2667. }
  2668. userJSONBytes2, _ := json.Marshal(respJSON2)
  2669. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2670. utils.ErrorLog("解析失败:%v", err)
  2671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2672. return
  2673. }
  2674. if res.Infcode == -1 {
  2675. c.ServeSuccessJSON(map[string]interface{}{
  2676. "failed_code": -10,
  2677. "msg": res.ErrMsg,
  2678. })
  2679. return
  2680. } else {
  2681. c.ServeSuccessJSON(map[string]interface{}{
  2682. "info": res.Output,
  2683. })
  2684. return
  2685. }
  2686. }
  2687. func (c *HisApiController) GetCFYLJG008() {
  2688. admin_user_id, _ := c.GetInt64("admin_user_id")
  2689. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2690. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2691. var cFYLJG008 models.CFYLJG008
  2692. //id, _ := c.GetInt64("id")
  2693. patient_id, _ := c.GetInt64("patient_id")
  2694. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2695. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2696. //id = 3
  2697. //flow, _ := service.Getflow(id)
  2698. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2699. //
  2700. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2701. //patient_id, _ := c.GetInt64("patient_id")
  2702. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2703. record_time := c.GetString("record_time")
  2704. admin_user_id = 3626
  2705. patient_id = 19424
  2706. //his_patient_id = 263947
  2707. record_time = "2023-08-29"
  2708. timeLayout := "2006-01-02"
  2709. loc, _ := time.LoadLocation("Local")
  2710. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2711. if err != nil {
  2712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2713. return
  2714. }
  2715. recordDateTime := theTime.Unix()
  2716. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2717. cFYLJG008.FixmedinsName = ""
  2718. cFYLJG008.Lat = ""
  2719. cFYLJG008.Lng = ""
  2720. cFYLJG008.OrderType = "1"
  2721. cFYLJG008.PoolareaNo = ""
  2722. cFYLJG008.Lng = ""
  2723. cFYLJG008.PageNum = 1
  2724. cFYLJG008.PageSize = 10
  2725. var MPI models.MedinsProdInvChgDDTO
  2726. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  2727. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  2728. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  2729. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  2730. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  2731. var res ResultCFYLJG008
  2732. var respJSON2 map[string]interface{}
  2733. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2736. return
  2737. }
  2738. userJSONBytes2, _ := json.Marshal(respJSON2)
  2739. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2740. utils.ErrorLog("解析失败:%v", err)
  2741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2742. return
  2743. }
  2744. if res.Infcode == -1 {
  2745. c.ServeSuccessJSON(map[string]interface{}{
  2746. "failed_code": -10,
  2747. "msg": res.ErrMsg,
  2748. })
  2749. return
  2750. } else {
  2751. c.ServeSuccessJSON(map[string]interface{}{
  2752. "info": res.Output,
  2753. })
  2754. return
  2755. }
  2756. }
  2757. func (c *HisApiController) GetBL4201A() {
  2758. order_id, _ := c.GetInt64("order_id")
  2759. admin_user_id, _ := c.GetInt64("admin_user_id")
  2760. order, _ := service.GetHisOrderByIDTwo(order_id)
  2761. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2762. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  2763. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  2764. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2765. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2766. department, _ := service.GetDepartMentDetail(his.Departments)
  2767. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2768. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2769. if order.ID == 0 {
  2770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2771. return
  2772. }
  2773. var struct4201A models.Struct4201A
  2774. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2775. for _, items := range order_info {
  2776. memo := make(map[string]interface{})
  2777. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2778. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2779. fsiOPFLD.MedType = "14"
  2780. fsiOPFLD.BkkpSn = items.FeedetlSn
  2781. fsiOPFLD.FixmedinsCode = miConfig.Code
  2782. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2783. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2784. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2785. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2786. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2787. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2788. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2789. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2790. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2791. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2792. fsiOPFLD.BilgDeptName = department.Name
  2793. fsiOPFLD.BilgDeptCodg = department.Number
  2794. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2795. fsiOPFLD.BilgDrName = doctor.UserName
  2796. fsiOPFLD.MedChrgitmType = "09"
  2797. memo["hosp_appr_flag"] = "1"
  2798. memo["invoice_no"] = order.MdtrtId
  2799. memo["memo"] = "自费"
  2800. bytesData, _ := json.Marshal(memo)
  2801. fsiOPFLD.Memo = string(bytesData)
  2802. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2803. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2804. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2805. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2806. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2807. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2808. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2809. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2810. fsiOPFLD.BilgDeptName = department.Name
  2811. fsiOPFLD.BilgDeptCodg = department.Number
  2812. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2813. fsiOPFLD.BilgDrName = doctor.UserName
  2814. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2815. case 0:
  2816. break
  2817. case 1:
  2818. fsiOPFLD.MedChrgitmType = "14"
  2819. break
  2820. case 2:
  2821. fsiOPFLD.MedChrgitmType = "05"
  2822. break
  2823. case 3:
  2824. fsiOPFLD.MedChrgitmType = "03"
  2825. break
  2826. case 4:
  2827. fsiOPFLD.MedChrgitmType = "03"
  2828. break
  2829. case 5:
  2830. fsiOPFLD.MedChrgitmType = "08"
  2831. break
  2832. case 6:
  2833. fsiOPFLD.MedChrgitmType = "14"
  2834. break
  2835. case 7:
  2836. fsiOPFLD.MedChrgitmType = "14"
  2837. break
  2838. case 8:
  2839. fsiOPFLD.MedChrgitmType = "03"
  2840. break
  2841. case 9:
  2842. fsiOPFLD.MedChrgitmType = "14"
  2843. break
  2844. case 10:
  2845. fsiOPFLD.MedChrgitmType = "14"
  2846. break
  2847. case 11:
  2848. fsiOPFLD.MedChrgitmType = "06"
  2849. break
  2850. case 12:
  2851. fsiOPFLD.MedChrgitmType = "12"
  2852. break
  2853. case 13:
  2854. fsiOPFLD.MedChrgitmType = "01"
  2855. break
  2856. case 14:
  2857. fsiOPFLD.MedChrgitmType = "04"
  2858. break
  2859. case 15:
  2860. fsiOPFLD.MedChrgitmType = "14"
  2861. break
  2862. }
  2863. memo["hosp_appr_flag"] = "1"
  2864. memo["invoice_no"] = order.MdtrtId
  2865. memo["memo"] = "自费"
  2866. bytesData, _ := json.Marshal(memo)
  2867. fsiOPFLD.Memo = string(bytesData)
  2868. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2869. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2870. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2871. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2872. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2873. fsiOPFLD.BilgDeptName = department.Name
  2874. fsiOPFLD.BilgDeptCodg = department.Number
  2875. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2876. fsiOPFLD.BilgDrName = doctor.UserName
  2877. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2878. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2879. fsiOPFLD.MedChrgitmType = "08"
  2880. memo["hosp_appr_flag"] = "1"
  2881. memo["invoice_no"] = order.MdtrtId
  2882. memo["memo"] = "自费"
  2883. bytesData, _ := json.Marshal(memo)
  2884. fsiOPFLD.Memo = string(bytesData)
  2885. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2886. }
  2887. }
  2888. }
  2889. for _, items := range order_info_two {
  2890. memo := make(map[string]interface{})
  2891. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2892. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2893. fsiOPFLD.MedType = "14"
  2894. fsiOPFLD.BkkpSn = items.FeedetlSn
  2895. fsiOPFLD.FixmedinsCode = miConfig.Code
  2896. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2897. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2898. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2899. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2900. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2901. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2902. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2903. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2904. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2905. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2906. fsiOPFLD.BilgDeptName = department.Name
  2907. fsiOPFLD.BilgDeptCodg = department.Number
  2908. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2909. fsiOPFLD.BilgDrName = doctor.UserName
  2910. fsiOPFLD.MedChrgitmType = "09"
  2911. memo["hosp_appr_flag"] = "1"
  2912. memo["invoice_no"] = order.MdtrtId
  2913. memo["memo"] = "自费"
  2914. bytesData, _ := json.Marshal(memo)
  2915. fsiOPFLD.Memo = string(bytesData)
  2916. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2917. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2918. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2919. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2920. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2921. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2922. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2923. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2924. fsiOPFLD.BilgDeptName = department.Name
  2925. fsiOPFLD.BilgDeptCodg = department.Number
  2926. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2927. fsiOPFLD.BilgDrName = doctor.UserName
  2928. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2929. case 0:
  2930. break
  2931. case 1:
  2932. fsiOPFLD.MedChrgitmType = "14"
  2933. break
  2934. case 2:
  2935. fsiOPFLD.MedChrgitmType = "05"
  2936. break
  2937. case 3:
  2938. fsiOPFLD.MedChrgitmType = "03"
  2939. break
  2940. case 4:
  2941. fsiOPFLD.MedChrgitmType = "03"
  2942. break
  2943. case 5:
  2944. fsiOPFLD.MedChrgitmType = "08"
  2945. break
  2946. case 6:
  2947. fsiOPFLD.MedChrgitmType = "14"
  2948. break
  2949. case 7:
  2950. fsiOPFLD.MedChrgitmType = "14"
  2951. break
  2952. case 8:
  2953. fsiOPFLD.MedChrgitmType = "03"
  2954. break
  2955. case 9:
  2956. fsiOPFLD.MedChrgitmType = "14"
  2957. break
  2958. case 10:
  2959. fsiOPFLD.MedChrgitmType = "14"
  2960. break
  2961. case 11:
  2962. fsiOPFLD.MedChrgitmType = "06"
  2963. break
  2964. case 12:
  2965. fsiOPFLD.MedChrgitmType = "12"
  2966. break
  2967. case 13:
  2968. fsiOPFLD.MedChrgitmType = "01"
  2969. break
  2970. case 14:
  2971. fsiOPFLD.MedChrgitmType = "04"
  2972. break
  2973. case 15:
  2974. fsiOPFLD.MedChrgitmType = "14"
  2975. break
  2976. }
  2977. memo["hosp_appr_flag"] = "1"
  2978. memo["invoice_no"] = order.MdtrtId
  2979. memo["memo"] = "自费"
  2980. bytesData, _ := json.Marshal(memo)
  2981. fsiOPFLD.Memo = string(bytesData)
  2982. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2983. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2984. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2985. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2986. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2987. fsiOPFLD.BilgDeptName = department.Name
  2988. fsiOPFLD.BilgDeptCodg = department.Number
  2989. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2990. fsiOPFLD.BilgDrName = doctor.UserName
  2991. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2992. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2993. fsiOPFLD.MedChrgitmType = "08"
  2994. memo["hosp_appr_flag"] = "1"
  2995. memo["invoice_no"] = order.MdtrtId
  2996. memo["memo"] = "自费"
  2997. bytesData, _ := json.Marshal(memo)
  2998. fsiOPFLD.Memo = string(bytesData)
  2999. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3000. }
  3001. }
  3002. }
  3003. fmt.Println(fsiOPFLDs)
  3004. struct4201A.Fopfd = fsiOPFLDs
  3005. fmt.Println(struct4201A.Fopfd)
  3006. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3007. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3008. var res2 ResultSix
  3009. var respJSON2 map[string]interface{}
  3010. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3013. return
  3014. }
  3015. userJSONBytes2, _ := json.Marshal(respJSON2)
  3016. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3017. utils.ErrorLog("解析失败:%v", err)
  3018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3019. return
  3020. }
  3021. if res2.Infcode != 0 {
  3022. c.ServeSuccessJSON(map[string]interface{}{
  3023. "failed_code": -10,
  3024. "msg": res2.ErrMsg,
  3025. })
  3026. return
  3027. } else {
  3028. order.IsUploadOrderInfo = 1
  3029. service.UpdateOrder(order)
  3030. c.ServeSuccessJSON(map[string]interface{}{
  3031. "msg": "上传成功",
  3032. })
  3033. }
  3034. }
  3035. func (c *HisApiController) Get2505() {
  3036. admin_user_id, _ := c.GetInt64("admin_user_id")
  3037. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3038. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3039. 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)
  3040. }
  3041. func (c *HisApiController) Get4201A() {
  3042. order_id, _ := c.GetInt64("order_id")
  3043. admin_user_id, _ := c.GetInt64("admin_user_id")
  3044. order, _ := service.GetHisOrderByIDTwo(order_id)
  3045. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3046. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3047. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3048. //order_info = append(order_info, order_info_two...)
  3049. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3050. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3051. department, _ := service.GetDepartMentDetail(his.Departments)
  3052. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3053. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3054. if order.ID == 0 {
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3056. return
  3057. }
  3058. var struct4201A models.Struct4201A
  3059. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3060. for _, items := range order_info {
  3061. memo := make(map[string]interface{})
  3062. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3063. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3064. fsiOPFLD.MedType = "14"
  3065. fsiOPFLD.BkkpSn = items.FeedetlSn
  3066. fsiOPFLD.FixmedinsCode = miConfig.Code
  3067. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3068. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3069. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3070. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3071. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3072. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3073. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3074. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3075. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3076. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3077. fsiOPFLD.BilgDeptName = department.Name
  3078. fsiOPFLD.BilgDeptCodg = department.Number
  3079. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3080. fsiOPFLD.BilgDrName = doctor.UserName
  3081. fsiOPFLD.MedChrgitmType = "09"
  3082. memo["hosp_appr_flag"] = "1"
  3083. memo["invoice_no"] = order.MdtrtId
  3084. memo["memo"] = "自费"
  3085. bytesData, _ := json.Marshal(memo)
  3086. fsiOPFLD.Memo = string(bytesData)
  3087. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3088. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3089. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3090. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3091. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3092. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3093. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3094. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3095. fsiOPFLD.BilgDeptName = department.Name
  3096. fsiOPFLD.BilgDeptCodg = department.Number
  3097. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3098. fsiOPFLD.BilgDrName = doctor.UserName
  3099. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3100. case 0:
  3101. break
  3102. case 1:
  3103. fsiOPFLD.MedChrgitmType = "14"
  3104. break
  3105. case 2:
  3106. fsiOPFLD.MedChrgitmType = "05"
  3107. break
  3108. case 3:
  3109. fsiOPFLD.MedChrgitmType = "03"
  3110. break
  3111. case 4:
  3112. fsiOPFLD.MedChrgitmType = "03"
  3113. break
  3114. case 5:
  3115. fsiOPFLD.MedChrgitmType = "08"
  3116. break
  3117. case 6:
  3118. fsiOPFLD.MedChrgitmType = "14"
  3119. break
  3120. case 7:
  3121. fsiOPFLD.MedChrgitmType = "14"
  3122. break
  3123. case 8:
  3124. fsiOPFLD.MedChrgitmType = "03"
  3125. break
  3126. case 9:
  3127. fsiOPFLD.MedChrgitmType = "14"
  3128. break
  3129. case 10:
  3130. fsiOPFLD.MedChrgitmType = "14"
  3131. break
  3132. case 11:
  3133. fsiOPFLD.MedChrgitmType = "06"
  3134. break
  3135. case 12:
  3136. fsiOPFLD.MedChrgitmType = "12"
  3137. break
  3138. case 13:
  3139. fsiOPFLD.MedChrgitmType = "01"
  3140. break
  3141. case 14:
  3142. fsiOPFLD.MedChrgitmType = "04"
  3143. break
  3144. case 15:
  3145. fsiOPFLD.MedChrgitmType = "14"
  3146. break
  3147. }
  3148. memo["hosp_appr_flag"] = "1"
  3149. memo["invoice_no"] = order.MdtrtId
  3150. memo["memo"] = "自费"
  3151. bytesData, _ := json.Marshal(memo)
  3152. fsiOPFLD.Memo = string(bytesData)
  3153. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3154. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3155. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3156. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3157. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3158. fsiOPFLD.BilgDeptName = department.Name
  3159. fsiOPFLD.BilgDeptCodg = department.Number
  3160. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3161. fsiOPFLD.BilgDrName = doctor.UserName
  3162. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3163. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3164. fsiOPFLD.MedChrgitmType = "08"
  3165. memo["hosp_appr_flag"] = "1"
  3166. memo["invoice_no"] = order.MdtrtId
  3167. memo["memo"] = "自费"
  3168. bytesData, _ := json.Marshal(memo)
  3169. fsiOPFLD.Memo = string(bytesData)
  3170. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3171. }
  3172. }
  3173. }
  3174. for _, items := range order_info_two {
  3175. memo := make(map[string]interface{})
  3176. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3177. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3178. fsiOPFLD.MedType = "14"
  3179. fsiOPFLD.BkkpSn = items.FeedetlSn
  3180. fsiOPFLD.FixmedinsCode = miConfig.Code
  3181. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3182. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3183. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3184. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3185. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3186. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3187. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3188. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3189. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3190. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3191. fsiOPFLD.BilgDeptName = department.Name
  3192. fsiOPFLD.BilgDeptCodg = department.Number
  3193. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3194. fsiOPFLD.BilgDrName = doctor.UserName
  3195. fsiOPFLD.MedChrgitmType = "09"
  3196. memo["hosp_appr_flag"] = "1"
  3197. memo["invoice_no"] = order.MdtrtId
  3198. memo["memo"] = "自费"
  3199. bytesData, _ := json.Marshal(memo)
  3200. fsiOPFLD.Memo = string(bytesData)
  3201. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3202. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3203. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3204. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3205. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3206. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3207. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3208. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3209. fsiOPFLD.BilgDeptName = department.Name
  3210. fsiOPFLD.BilgDeptCodg = department.Number
  3211. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3212. fsiOPFLD.BilgDrName = doctor.UserName
  3213. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3214. case 0:
  3215. break
  3216. case 1:
  3217. fsiOPFLD.MedChrgitmType = "14"
  3218. break
  3219. case 2:
  3220. fsiOPFLD.MedChrgitmType = "05"
  3221. break
  3222. case 3:
  3223. fsiOPFLD.MedChrgitmType = "03"
  3224. break
  3225. case 4:
  3226. fsiOPFLD.MedChrgitmType = "03"
  3227. break
  3228. case 5:
  3229. fsiOPFLD.MedChrgitmType = "08"
  3230. break
  3231. case 6:
  3232. fsiOPFLD.MedChrgitmType = "14"
  3233. break
  3234. case 7:
  3235. fsiOPFLD.MedChrgitmType = "14"
  3236. break
  3237. case 8:
  3238. fsiOPFLD.MedChrgitmType = "03"
  3239. break
  3240. case 9:
  3241. fsiOPFLD.MedChrgitmType = "14"
  3242. break
  3243. case 10:
  3244. fsiOPFLD.MedChrgitmType = "14"
  3245. break
  3246. case 11:
  3247. fsiOPFLD.MedChrgitmType = "06"
  3248. break
  3249. case 12:
  3250. fsiOPFLD.MedChrgitmType = "12"
  3251. break
  3252. case 13:
  3253. fsiOPFLD.MedChrgitmType = "01"
  3254. break
  3255. case 14:
  3256. fsiOPFLD.MedChrgitmType = "04"
  3257. break
  3258. case 15:
  3259. fsiOPFLD.MedChrgitmType = "14"
  3260. break
  3261. }
  3262. memo["hosp_appr_flag"] = "1"
  3263. memo["invoice_no"] = order.MdtrtId
  3264. memo["memo"] = "自费"
  3265. bytesData, _ := json.Marshal(memo)
  3266. fsiOPFLD.Memo = string(bytesData)
  3267. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3268. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3269. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3270. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3271. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3272. fsiOPFLD.BilgDeptName = department.Name
  3273. fsiOPFLD.BilgDeptCodg = department.Number
  3274. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3275. fsiOPFLD.BilgDrName = doctor.UserName
  3276. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3277. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3278. fsiOPFLD.MedChrgitmType = "08"
  3279. memo["hosp_appr_flag"] = "1"
  3280. memo["invoice_no"] = order.MdtrtId
  3281. memo["memo"] = "自费"
  3282. bytesData, _ := json.Marshal(memo)
  3283. fsiOPFLD.Memo = string(bytesData)
  3284. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3285. }
  3286. }
  3287. }
  3288. fmt.Println(fsiOPFLDs)
  3289. struct4201A.Fopfd = fsiOPFLDs
  3290. fmt.Println(struct4201A.Fopfd)
  3291. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3292. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3293. var res2 ResultSix
  3294. var respJSON2 map[string]interface{}
  3295. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3298. return
  3299. }
  3300. userJSONBytes2, _ := json.Marshal(respJSON2)
  3301. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3302. utils.ErrorLog("解析失败:%v", err)
  3303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3304. return
  3305. }
  3306. if res2.Infcode != 0 {
  3307. c.ServeSuccessJSON(map[string]interface{}{
  3308. "failed_code": -10,
  3309. "msg": res2.ErrMsg,
  3310. })
  3311. return
  3312. } else {
  3313. order.IsUploadOrderInfo = 1
  3314. service.UpdateOrder(order)
  3315. c.ServeSuccessJSON(map[string]interface{}{
  3316. "msg": "上传成功",
  3317. })
  3318. }
  3319. }
  3320. func (c *HisApiController) Get4202() {
  3321. order_id, _ := c.GetInt64("order_id")
  3322. admin_user_id, _ := c.GetInt64("admin_user_id")
  3323. order, _ := service.GetHisOrderByIDTwo(order_id)
  3324. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3325. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3326. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3327. if order.ID == 0 {
  3328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3329. return
  3330. }
  3331. var struct4202 models.Struct4202
  3332. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3333. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3334. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3335. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3336. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3337. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3338. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3339. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3340. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3341. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3342. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3343. var config []*models.HisXtDiagnoseConfig
  3344. for _, item := range diagnosis_ids {
  3345. id, _ := strconv.ParseInt(item, 10, 64)
  3346. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3347. config = append(config, &diagnosisConfig)
  3348. }
  3349. var tempDiaginfos []models.OwnPayPatnDiagListD
  3350. for index, item := range config {
  3351. if index == 0 {
  3352. var tempDiaginfo models.OwnPayPatnDiagListD
  3353. tempDiaginfo.InoutDiagType = "1"
  3354. tempDiaginfo.DiagCode = item.CountryCode
  3355. tempDiaginfo.DiagName = item.CountryContentName
  3356. tempDiaginfo.DiagType = "1"
  3357. tempDiaginfo.DiagSrtNo = "1"
  3358. tempDiaginfo.MaindiagFlag = "1"
  3359. tempDiaginfo.ValiFlag = "1"
  3360. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3361. } else {
  3362. var tempDiaginfo models.OwnPayPatnDiagListD
  3363. tempDiaginfo.DiagCode = item.CountryCode
  3364. tempDiaginfo.DiagName = item.CountryContentName
  3365. tempDiaginfo.DiagType = "2"
  3366. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3367. tempDiaginfo.MaindiagFlag = "0"
  3368. tempDiaginfo.ValiFlag = "1"
  3369. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3370. }
  3371. }
  3372. struct4202.ODiagListD = tempDiaginfos
  3373. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3374. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3375. var res2 ResultSix
  3376. var respJSON2 map[string]interface{}
  3377. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3380. return
  3381. }
  3382. userJSONBytes2, _ := json.Marshal(respJSON2)
  3383. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3384. utils.ErrorLog("解析失败:%v", err)
  3385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3386. return
  3387. }
  3388. if res2.Infcode != 0 {
  3389. c.ServeSuccessJSON(map[string]interface{}{
  3390. "failed_code": -10,
  3391. "msg": res2.ErrMsg,
  3392. })
  3393. return
  3394. } else {
  3395. order.IsUploadDiagnose = 1
  3396. service.UpdateOrder(order)
  3397. c.ServeSuccessJSON(map[string]interface{}{
  3398. "msg": "上传成功",
  3399. })
  3400. }
  3401. }
  3402. func (c *HisApiController) Get4203() {
  3403. admin_user_id, _ := c.GetInt64("admin_user_id")
  3404. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3405. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3406. order_id, _ := c.GetInt64("order_id")
  3407. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3408. number := ""
  3409. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3410. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3411. if his.ID == 0 {
  3412. number = hospital.Number
  3413. } else {
  3414. number = his.Number
  3415. }
  3416. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  3417. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  3418. var res2 ResultSix
  3419. var respJSON2 map[string]interface{}
  3420. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3423. return
  3424. }
  3425. userJSONBytes2, _ := json.Marshal(respJSON2)
  3426. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3427. utils.ErrorLog("解析失败:%v", err)
  3428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3429. return
  3430. }
  3431. if res2.Infcode != 0 {
  3432. c.ServeSuccessJSON(map[string]interface{}{
  3433. "failed_code": -10,
  3434. "msg": res2.ErrMsg,
  3435. })
  3436. return
  3437. } else {
  3438. order.IsUploadSuccess = 1
  3439. service.UpdateOrderTwo(order)
  3440. c.ServeSuccessJSON(map[string]interface{}{
  3441. "msg": "上传成功",
  3442. })
  3443. }
  3444. }
  3445. func (c *HisApiController) Get4205() {
  3446. order_id, _ := c.GetInt64("order_id")
  3447. admin_user_id, _ := c.GetInt64("admin_user_id")
  3448. fapiao_code := c.GetString("fapiao_code")
  3449. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3450. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3451. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3452. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3453. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  3454. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3455. //order_info = append(order_info, order_info_two...)
  3456. department, _ := service.GetDepartMentDetail(his.Departments)
  3457. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3458. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3459. if order.ID == 0 {
  3460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3461. return
  3462. }
  3463. var struct4201A models.Struct4201A
  3464. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3465. for _, items := range order_info {
  3466. memo := make(map[string]interface{})
  3467. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3468. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3469. fsiOPFLD.MedType = pre.MedType
  3470. fsiOPFLD.FixmedinsCode = miConfig.Code
  3471. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3472. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3473. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3474. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3475. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3476. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3477. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3478. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  3479. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3480. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3481. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3482. fsiOPFLD.BilgDeptName = department.Name
  3483. fsiOPFLD.BilgDeptCodg = department.Number
  3484. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3485. fsiOPFLD.BilgDrName = doctor.UserName
  3486. fsiOPFLD.MedChrgitmType = "09"
  3487. memo["hosp_appr_flag"] = "1"
  3488. memo["invoice_no"] = fapiao_code
  3489. memo["memo"] = "自费"
  3490. bytesData, _ := json.Marshal(memo)
  3491. fsiOPFLD.Memo = string(bytesData)
  3492. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3493. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3494. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3495. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3496. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3497. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3498. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3499. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3500. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3501. fsiOPFLD.BilgDeptName = department.Name
  3502. fsiOPFLD.BilgDeptCodg = department.Number
  3503. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3504. fsiOPFLD.BilgDrName = doctor.UserName
  3505. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3506. case 0:
  3507. break
  3508. case 1:
  3509. fsiOPFLD.MedChrgitmType = "14"
  3510. break
  3511. case 2:
  3512. fsiOPFLD.MedChrgitmType = "05"
  3513. break
  3514. case 3:
  3515. fsiOPFLD.MedChrgitmType = "03"
  3516. break
  3517. case 4:
  3518. fsiOPFLD.MedChrgitmType = "03"
  3519. break
  3520. case 5:
  3521. fsiOPFLD.MedChrgitmType = "08"
  3522. break
  3523. case 6:
  3524. fsiOPFLD.MedChrgitmType = "14"
  3525. break
  3526. case 7:
  3527. fsiOPFLD.MedChrgitmType = "14"
  3528. break
  3529. case 8:
  3530. fsiOPFLD.MedChrgitmType = "03"
  3531. break
  3532. case 9:
  3533. fsiOPFLD.MedChrgitmType = "14"
  3534. break
  3535. case 10:
  3536. fsiOPFLD.MedChrgitmType = "14"
  3537. break
  3538. case 11:
  3539. fsiOPFLD.MedChrgitmType = "06"
  3540. break
  3541. case 12:
  3542. fsiOPFLD.MedChrgitmType = "12"
  3543. break
  3544. case 13:
  3545. fsiOPFLD.MedChrgitmType = "01"
  3546. break
  3547. case 14:
  3548. fsiOPFLD.MedChrgitmType = "04"
  3549. break
  3550. case 15:
  3551. fsiOPFLD.MedChrgitmType = "14"
  3552. break
  3553. }
  3554. memo["hosp_appr_flag"] = "1"
  3555. memo["invoice_no"] = fapiao_code
  3556. memo["memo"] = "自费"
  3557. bytesData, _ := json.Marshal(memo)
  3558. fsiOPFLD.Memo = string(bytesData)
  3559. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3560. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3561. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3562. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3563. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3564. fsiOPFLD.BilgDeptName = department.Name
  3565. fsiOPFLD.BilgDeptCodg = department.Number
  3566. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3567. fsiOPFLD.BilgDrName = doctor.UserName
  3568. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3569. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3570. fsiOPFLD.MedChrgitmType = "08"
  3571. memo["hosp_appr_flag"] = "1"
  3572. memo["invoice_no"] = fapiao_code
  3573. memo["memo"] = "自费"
  3574. bytesData, _ := json.Marshal(memo)
  3575. fsiOPFLD.Memo = string(bytesData)
  3576. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3577. }
  3578. }
  3579. }
  3580. for _, items := range order_info_two {
  3581. memo := make(map[string]interface{})
  3582. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3583. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3584. fsiOPFLD.MedType = pre.MedType
  3585. fsiOPFLD.BkkpSn = items.FeedetlSn
  3586. fsiOPFLD.FixmedinsCode = miConfig.Code
  3587. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3588. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3589. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3590. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3591. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3592. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3593. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3594. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3595. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3596. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3597. fsiOPFLD.BilgDeptName = department.Name
  3598. fsiOPFLD.BilgDeptCodg = department.Number
  3599. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3600. fsiOPFLD.BilgDrName = doctor.UserName
  3601. fsiOPFLD.MedChrgitmType = "09"
  3602. memo["hosp_appr_flag"] = "1"
  3603. memo["invoice_no"] = fapiao_code
  3604. memo["memo"] = "自费"
  3605. bytesData, _ := json.Marshal(memo)
  3606. fsiOPFLD.Memo = string(bytesData)
  3607. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3608. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3609. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3610. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3611. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3612. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3613. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3614. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3615. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3616. fsiOPFLD.BilgDeptName = department.Name
  3617. fsiOPFLD.BilgDeptCodg = department.Number
  3618. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3619. fsiOPFLD.BilgDrName = doctor.UserName
  3620. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3621. case 0:
  3622. break
  3623. case 1:
  3624. fsiOPFLD.MedChrgitmType = "14"
  3625. break
  3626. case 2:
  3627. fsiOPFLD.MedChrgitmType = "05"
  3628. break
  3629. case 3:
  3630. fsiOPFLD.MedChrgitmType = "03"
  3631. break
  3632. case 4:
  3633. fsiOPFLD.MedChrgitmType = "03"
  3634. break
  3635. case 5:
  3636. fsiOPFLD.MedChrgitmType = "08"
  3637. break
  3638. case 6:
  3639. fsiOPFLD.MedChrgitmType = "14"
  3640. break
  3641. case 7:
  3642. fsiOPFLD.MedChrgitmType = "14"
  3643. break
  3644. case 8:
  3645. fsiOPFLD.MedChrgitmType = "03"
  3646. break
  3647. case 9:
  3648. fsiOPFLD.MedChrgitmType = "14"
  3649. break
  3650. case 10:
  3651. fsiOPFLD.MedChrgitmType = "14"
  3652. break
  3653. case 11:
  3654. fsiOPFLD.MedChrgitmType = "06"
  3655. break
  3656. case 12:
  3657. fsiOPFLD.MedChrgitmType = "12"
  3658. break
  3659. case 13:
  3660. fsiOPFLD.MedChrgitmType = "01"
  3661. break
  3662. case 14:
  3663. fsiOPFLD.MedChrgitmType = "04"
  3664. break
  3665. case 15:
  3666. fsiOPFLD.MedChrgitmType = "14"
  3667. break
  3668. }
  3669. memo["hosp_appr_flag"] = "1"
  3670. memo["invoice_no"] = fapiao_code
  3671. memo["memo"] = "自费"
  3672. bytesData, _ := json.Marshal(memo)
  3673. fsiOPFLD.Memo = string(bytesData)
  3674. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3675. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3676. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3677. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3678. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3679. fsiOPFLD.BilgDeptName = department.Name
  3680. fsiOPFLD.BilgDeptCodg = department.Number
  3681. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3682. fsiOPFLD.BilgDrName = doctor.UserName
  3683. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3684. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3685. fsiOPFLD.MedChrgitmType = "08"
  3686. memo["hosp_appr_flag"] = "1"
  3687. memo["invoice_no"] = fapiao_code
  3688. memo["memo"] = "自费"
  3689. bytesData, _ := json.Marshal(memo)
  3690. fsiOPFLD.Memo = string(bytesData)
  3691. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3692. }
  3693. }
  3694. }
  3695. fmt.Println(fsiOPFLDs)
  3696. struct4201A.Fopfd = fsiOPFLDs
  3697. fmt.Println(struct4201A.Fopfd)
  3698. var struct4202 models.Struct4202
  3699. timeLayout := "2006-01-02 15:04:05"
  3700. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  3701. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3702. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3703. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3704. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3705. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3706. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3707. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  3708. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  3709. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3710. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3711. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3712. var config []*models.HisXtDiagnoseConfig
  3713. for _, item := range diagnosis_ids {
  3714. id, _ := strconv.ParseInt(item, 10, 64)
  3715. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3716. config = append(config, &diagnosisConfig)
  3717. }
  3718. var tempDiaginfos []models.OwnPayPatnDiagListD
  3719. for index, item := range config {
  3720. if index == 0 {
  3721. var tempDiaginfo models.OwnPayPatnDiagListD
  3722. tempDiaginfo.InoutDiagType = "1"
  3723. tempDiaginfo.DiagCode = item.CountryCode
  3724. tempDiaginfo.DiagName = item.CountryContentName
  3725. tempDiaginfo.DiagType = "1"
  3726. tempDiaginfo.DiagSrtNo = "1"
  3727. tempDiaginfo.MaindiagFlag = "1"
  3728. tempDiaginfo.ValiFlag = "1"
  3729. tempDiaginfo.DiagDrName = doctor.UserName
  3730. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  3731. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  3732. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3733. } else {
  3734. var tempDiaginfo models.OwnPayPatnDiagListD
  3735. tempDiaginfo.DiagCode = item.CountryCode
  3736. tempDiaginfo.DiagName = item.CountryContentName
  3737. tempDiaginfo.DiagType = "2"
  3738. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3739. tempDiaginfo.MaindiagFlag = "0"
  3740. tempDiaginfo.ValiFlag = "1"
  3741. tempDiaginfo.DiagDrName = doctor.UserName
  3742. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  3743. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  3744. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3745. }
  3746. }
  3747. struct4202.ODiagListD = tempDiaginfos
  3748. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  3749. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  3750. var res2 ResultSix
  3751. var respJSON2 map[string]interface{}
  3752. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3755. return
  3756. }
  3757. userJSONBytes2, _ := json.Marshal(respJSON2)
  3758. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3759. utils.ErrorLog("解析失败:%v", err)
  3760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3761. return
  3762. }
  3763. if res2.Infcode != 0 {
  3764. c.ServeSuccessJSON(map[string]interface{}{
  3765. "failed_code": -10,
  3766. "msg": res2.ErrMsg,
  3767. })
  3768. return
  3769. } else {
  3770. order.IsUploadDiagnose = 1
  3771. order.IsUploadOrderInfo = 1
  3772. service.UpdateOrderTwo(order)
  3773. c.ServeSuccessJSON(map[string]interface{}{
  3774. "msg": "上传成功",
  3775. })
  3776. }
  3777. }
  3778. func (c *HisApiController) Get4207() {
  3779. admin_user_id, _ := c.GetInt64("admin_user_id")
  3780. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3781. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3782. order_id, _ := c.GetInt64("order_id")
  3783. order, _ := service.GetHisOrderByIDTwo(order_id)
  3784. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3785. var struct4207 models.Struct4207
  3786. struct4207.PageNum = "1"
  3787. struct4207.PageSize = "1000"
  3788. struct4207.FixmedinsCode = miConfig.Code
  3789. struct4207.FixmedinsMdtrtID = order.Number
  3790. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  3791. saveLog(result, requestLog, "4207", "查询")
  3792. var res2 ResultSix
  3793. var respJSON2 map[string]interface{}
  3794. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3797. return
  3798. }
  3799. userJSONBytes2, _ := json.Marshal(respJSON2)
  3800. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3801. utils.ErrorLog("解析失败:%v", err)
  3802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3803. return
  3804. }
  3805. if res2.Infcode != 0 {
  3806. c.ServeSuccessJSON(map[string]interface{}{
  3807. "failed_code": -10,
  3808. "msg": res2.ErrMsg,
  3809. })
  3810. return
  3811. } else {
  3812. c.ServeSuccessJSON(map[string]interface{}{
  3813. "msg": "查询成功",
  3814. })
  3815. }
  3816. }
  3817. func (c *HisApiController) Get4208() {
  3818. admin_user_id, _ := c.GetInt64("admin_user_id")
  3819. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3820. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3821. order_id, _ := c.GetInt64("order_id")
  3822. order, _ := service.GetHisOrderByIDTwo(order_id)
  3823. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3824. var struct4208 models.Struct4208
  3825. struct4208.PageNum = "1"
  3826. struct4208.PageSize = "1000"
  3827. struct4208.PsnCertType = "01"
  3828. struct4208.Certno = his.Certno
  3829. struct4208.MedType = order.MedType
  3830. struct4208.PsnName = his.Name
  3831. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  3832. saveLog(result, requestLog, "4208", "查询")
  3833. var res2 ResultSix
  3834. var respJSON2 map[string]interface{}
  3835. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3838. return
  3839. }
  3840. userJSONBytes2, _ := json.Marshal(respJSON2)
  3841. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3842. utils.ErrorLog("解析失败:%v", err)
  3843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3844. return
  3845. }
  3846. if res2.Infcode != 0 {
  3847. c.ServeSuccessJSON(map[string]interface{}{
  3848. "failed_code": -10,
  3849. "msg": res2.ErrMsg,
  3850. })
  3851. return
  3852. } else {
  3853. c.ServeSuccessJSON(map[string]interface{}{
  3854. "msg": "查询成功",
  3855. })
  3856. }
  3857. }
  3858. func (c *HisApiController) Get4209() {
  3859. admin_user_id, _ := c.GetInt64("admin_user_id")
  3860. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3861. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3862. order_id, _ := c.GetInt64("order_id")
  3863. order, _ := service.GetHisOrderByIDTwo(order_id)
  3864. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3865. var struct4209 models.Struct4209
  3866. struct4209.FixmedinsMdtrtID = order.Number
  3867. struct4209.FixmedinsCode = miConfig.Code
  3868. struct4209.PageSize = "1000"
  3869. struct4209.PageNum = "1"
  3870. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  3871. saveLog(result, requestLog, "4209", "查询")
  3872. var res2 ResultSix
  3873. var respJSON2 map[string]interface{}
  3874. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3877. return
  3878. }
  3879. userJSONBytes2, _ := json.Marshal(respJSON2)
  3880. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3881. utils.ErrorLog("解析失败:%v", err)
  3882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3883. return
  3884. }
  3885. if res2.Infcode != 0 {
  3886. c.ServeSuccessJSON(map[string]interface{}{
  3887. "failed_code": -10,
  3888. "msg": res2.ErrMsg,
  3889. })
  3890. return
  3891. } else {
  3892. c.ServeSuccessJSON(map[string]interface{}{
  3893. "msg": "查询成功",
  3894. })
  3895. }
  3896. }
  3897. type Result3101 struct {
  3898. Infcode string `json:"infcode"`
  3899. InfRefmsgid string `json:"inf_refmsgid"`
  3900. RefmsgTime string `json:"refmsg_time"`
  3901. RespondTime string `json:"respond_time"`
  3902. Enctype string `json:"enctype"`
  3903. Signtype string `json:"signtype"`
  3904. ErrMsg string `json:"err_msg"`
  3905. Output struct {
  3906. Result []struct {
  3907. JudgeResultDetailDtos []struct {
  3908. VolaItemType string `json:"vola_item_type"`
  3909. MdtrtID string `json:"mdtrt_id"`
  3910. JrdID string `json:"jrd_id"`
  3911. PatnID string `json:"patn_id"`
  3912. RxID string `json:"rx_id"`
  3913. VolaAmt interface{} `json:"vola_amt"`
  3914. } `json:"judge_result_detail_dtos"`
  3915. RuleID string `json:"rule_id"`
  3916. VolaEvid string `json:"vola_evid"`
  3917. MdtrtID string `json:"mdtrt_id"`
  3918. RuleName string `json:"rule_name"`
  3919. VolaAmtStas string `json:"vola_amt_stas"`
  3920. JrID string `json:"jr_id"`
  3921. PatnID string `json:"patn_id"`
  3922. SevDeg string `json:"sev_deg"`
  3923. VolaAmt float64 `json:"vola_amt"`
  3924. VolaBhvrType string `json:"vola_bhvr_type"`
  3925. VolaCont string `json:"vola_cont"`
  3926. } `json:"result"`
  3927. } `json:"output"`
  3928. }
  3929. type Resultgd3101 struct {
  3930. Infcode int64 `json:"infcode"`
  3931. InfRefmsgid string `json:"inf_refmsgid"`
  3932. RefmsgTime string `json:"refmsg_time"`
  3933. RespondTime string `json:"respond_time"`
  3934. Enctype string `json:"enctype"`
  3935. Signtype string `json:"signtype"`
  3936. ErrMsg string `json:"err_msg"`
  3937. Output struct {
  3938. Result []struct {
  3939. JudgeResultDetailDtos []struct {
  3940. VolaItemType string `json:"vola_item_type"`
  3941. MdtrtID string `json:"mdtrt_id"`
  3942. JrdID string `json:"jrd_id"`
  3943. PatnID string `json:"patn_id"`
  3944. RxID string `json:"rx_id"`
  3945. VolaAmt interface{} `json:"vola_amt"`
  3946. } `json:"judge_result_detail_dtos"`
  3947. RuleID string `json:"rule_id"`
  3948. VolaEvid string `json:"vola_evid"`
  3949. MdtrtID string `json:"mdtrt_id"`
  3950. RuleName string `json:"rule_name"`
  3951. VolaAmtStas string `json:"vola_amt_stas"`
  3952. JrID string `json:"jr_id"`
  3953. PatnID string `json:"patn_id"`
  3954. SevDeg string `json:"sev_deg"`
  3955. VolaAmt float64 `json:"vola_amt"`
  3956. VolaBhvrType string `json:"vola_bhvr_type"`
  3957. VolaCont string `json:"vola_cont"`
  3958. } `json:"result"`
  3959. } `json:"output"`
  3960. }
  3961. func (c *HisApiController) ReadEleToken() {
  3962. admin_user_id, _ := c.GetInt64("admin_user_id")
  3963. his_patient_id, _ := c.GetInt64("his_patient_id")
  3964. adminUser := c.GetAdminUserInfo()
  3965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3966. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3967. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3968. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3969. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  3970. if len(tokens) > 0 {
  3971. c.ServeSuccessJSON(map[string]interface{}{
  3972. "msg": "读取成功",
  3973. })
  3974. } else {
  3975. c.ServeSuccessJSON(map[string]interface{}{
  3976. "failed_code": -10,
  3977. "msg": "读取失败",
  3978. })
  3979. }
  3980. } else if miConfig.MdtrtareaAdmvs == "341203" {
  3981. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  3982. if len(tokens) > 0 {
  3983. c.ServeSuccessJSON(map[string]interface{}{
  3984. "msg": "读取成功",
  3985. })
  3986. } else {
  3987. c.ServeSuccessJSON(map[string]interface{}{
  3988. "failed_code": -10,
  3989. "msg": "读取失败",
  3990. })
  3991. }
  3992. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3993. var api string
  3994. 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 +
  3995. "&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"
  3996. resp, requestErr := http.Get(api)
  3997. if requestErr != nil {
  3998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3999. }
  4000. body, ioErr := ioutil.ReadAll(resp.Body)
  4001. if ioErr != nil {
  4002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4004. }
  4005. var respJSON map[string]interface{}
  4006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4009. return
  4010. }
  4011. var status string
  4012. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4013. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4014. var token string
  4015. var res ResultTwo //1101结果
  4016. var res10265 ResultTwo10265 //1101结果
  4017. if status == "0" { //读卡成功
  4018. var card_info string //卡信息
  4019. var busi_card_info string
  4020. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4021. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4022. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4023. fmt.Println(card_info)
  4024. fmt.Println(busi_card_info)
  4025. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4026. result, _ := json.Marshal(respJSON)
  4027. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4028. utils.ErrorLog("解析失败:%v", err)
  4029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4030. return
  4031. }
  4032. res.ErrMsg = res10265.ErrMsg
  4033. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4034. res.Infcode = infocode
  4035. res.Output = res10265.Output
  4036. res.InfRefmsgid = res10265.InfRefmsgid
  4037. if res.Infcode == 0 {
  4038. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4039. if err == gorm.ErrRecordNotFound {
  4040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4041. return
  4042. } else if err != nil {
  4043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4044. return
  4045. } else {
  4046. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4047. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4048. infoStr := string(Iinfos)
  4049. idetinfoStr := string(Idetinfos)
  4050. psn := &models.HisPsn{
  4051. PsnNo: res.Output.Baseinfo.PsnNo,
  4052. PatientId: patient.ID,
  4053. Certno: res.Output.Baseinfo.Certno,
  4054. Gend: res.Output.Baseinfo.Gend,
  4055. Naty: res.Output.Baseinfo.Naty,
  4056. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4057. PsnName: res.Output.Baseinfo.PsnName,
  4058. Idetinfo: idetinfoStr,
  4059. Insuinfo: infoStr,
  4060. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4061. CardInfo: card_info,
  4062. VerifyNumber: token,
  4063. IdCardType: 4,
  4064. }
  4065. var rf []*ResultFive
  4066. json.Unmarshal([]byte(infoStr), &rf)
  4067. var insutypes []*ResultFive
  4068. var insutype string
  4069. var is390 int = 0
  4070. var is310 int = 0
  4071. for _, item := range rf {
  4072. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4073. insutypes = append(insutypes, item)
  4074. }
  4075. }
  4076. if len(insutypes) == 1 {
  4077. insutype = insutypes[0].Insutype
  4078. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4079. } else {
  4080. for _, i := range insutypes {
  4081. if i.Insutype == "390" {
  4082. is390 = 1
  4083. }
  4084. if i.Insutype == "310" {
  4085. is310 = 1
  4086. }
  4087. }
  4088. }
  4089. if is390 == 1 {
  4090. insutype = "390"
  4091. }
  4092. if is310 == 1 {
  4093. insutype = "310"
  4094. }
  4095. if len(insutypes) == 0 {
  4096. insutype = "310"
  4097. }
  4098. service.CreateHisPsn(psn)
  4099. c.ServeSuccessJSON(map[string]interface{}{
  4100. "patient": patient,
  4101. "number": token,
  4102. "insutype": insutype,
  4103. })
  4104. }
  4105. } else {
  4106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4107. return
  4108. }
  4109. } else { //读卡失败
  4110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4111. return
  4112. }
  4113. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4114. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4115. if len(errMsg) == 0 {
  4116. type ELeData struct {
  4117. Data struct {
  4118. IdNo string `json:"idNo"`
  4119. IdType string `json:"idType"`
  4120. UserName string `json:"userName"`
  4121. EcToken string `json:"ecToken"`
  4122. InsuOrg string `json:"insuOrg"`
  4123. Gender string `json:"gender"`
  4124. Birthday string `json:"birthday"`
  4125. Nationality string `json:"nationality"`
  4126. Email string `json:"email"`
  4127. Extra string `json:"extra"`
  4128. } `json:"data"`
  4129. Code int `json:"code"`
  4130. Message string `json:"message"`
  4131. }
  4132. var ele ELeData
  4133. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4134. if err != nil {
  4135. utils.ErrorLog("解析失败:%v", err)
  4136. }
  4137. token := ele.Data.EcToken
  4138. if len(token) > 0 {
  4139. psn := &models.HisPsn{
  4140. PsnNo: his.PsnNo,
  4141. Age: 0,
  4142. PatientId: his.PatientId,
  4143. Certno: his.Certno,
  4144. Brdy: his.Brdy,
  4145. Gend: his.Gend,
  4146. Naty: his.Naty,
  4147. PsnCertType: his.PsnCertType,
  4148. PsnName: his.PsnName,
  4149. Idetinfo: his.Idetinfo,
  4150. Insuinfo: his.Iinfo,
  4151. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4152. CardInfo: outPutInfo,
  4153. VerifyNumber: token,
  4154. }
  4155. service.CreateHisPsn(psn)
  4156. }
  4157. if len(token) > 0 {
  4158. c.ServeSuccessJSON(map[string]interface{}{
  4159. "msg": "读取成功",
  4160. })
  4161. } else {
  4162. c.ServeSuccessJSON(map[string]interface{}{
  4163. "failed_code": -10,
  4164. "msg": "读取失败",
  4165. })
  4166. }
  4167. }
  4168. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4169. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4170. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4171. type ELeData struct {
  4172. Data struct {
  4173. IdNo string `json:"idNo"`
  4174. IdType string `json:"idType"`
  4175. UserName string `json:"userName"`
  4176. EcToken string `json:"ecToken"`
  4177. InsuOrg string `json:"insuOrg"`
  4178. Gender string `json:"gender"`
  4179. Birthday string `json:"birthday"`
  4180. Nationality string `json:"nationality"`
  4181. Email string `json:"email"`
  4182. Extra string `json:"extra"`
  4183. } `json:"data"`
  4184. Code int `json:"code"`
  4185. Message string `json:"message"`
  4186. }
  4187. var ele ELeData
  4188. err := json.Unmarshal([]byte(result), &ele)
  4189. if err != nil {
  4190. utils.ErrorLog("解析失败:%v", err)
  4191. }
  4192. token := ele.Data.EcToken
  4193. token = Remove0000(token)
  4194. fmt.Println(ele.Data.UserName)
  4195. 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)
  4196. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4197. var res ResultTwo
  4198. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4199. utils.ErrorLog("解析失败:%v", err)
  4200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4201. return
  4202. }
  4203. if res.Infcode == 0 {
  4204. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4205. if err == gorm.ErrRecordNotFound {
  4206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4207. return
  4208. } else if err != nil {
  4209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4210. return
  4211. } else {
  4212. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4213. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4214. infoStr := string(Iinfos)
  4215. idetinfoStr := string(Idetinfos)
  4216. psn := &models.HisPsn{
  4217. PsnNo: res.Output.Baseinfo.PsnNo,
  4218. PatientId: patient.ID,
  4219. Certno: res.Output.Baseinfo.Certno,
  4220. Gend: res.Output.Baseinfo.Gend,
  4221. Naty: res.Output.Baseinfo.Naty,
  4222. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4223. PsnName: res.Output.Baseinfo.PsnName,
  4224. Idetinfo: idetinfoStr,
  4225. Insuinfo: infoStr,
  4226. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4227. CardInfo: "",
  4228. VerifyNumber: token,
  4229. }
  4230. service.CreateHisPsn(psn)
  4231. c.ServeSuccessJSON(map[string]interface{}{
  4232. "patient": patient,
  4233. "number": token,
  4234. })
  4235. }
  4236. } else {
  4237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4238. return
  4239. }
  4240. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4241. idNo := c.GetString("idNo")
  4242. userName := c.GetString("userName")
  4243. ecToken := c.GetString("ecToken")
  4244. insuOrg := c.GetString("insuOrg")
  4245. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4246. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4247. var res ResultTwo
  4248. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4249. utils.ErrorLog("解析失败:%v", err)
  4250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4251. return
  4252. }
  4253. if res.Infcode == 0 {
  4254. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4255. if err == gorm.ErrRecordNotFound {
  4256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4257. return
  4258. } else if err != nil {
  4259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4260. return
  4261. } else {
  4262. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4263. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4264. infoStr := string(Iinfos)
  4265. idetinfoStr := string(Idetinfos)
  4266. psn := &models.HisPsn{
  4267. PsnNo: res.Output.Baseinfo.PsnNo,
  4268. PatientId: patient.ID,
  4269. Certno: res.Output.Baseinfo.Certno,
  4270. Gend: res.Output.Baseinfo.Gend,
  4271. Naty: res.Output.Baseinfo.Naty,
  4272. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4273. PsnName: res.Output.Baseinfo.PsnName,
  4274. Idetinfo: idetinfoStr,
  4275. Insuinfo: infoStr,
  4276. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4277. CardInfo: "",
  4278. VerifyNumber: ecToken,
  4279. InsuplcAdmdvs: insuOrg,
  4280. }
  4281. service.CreateHisPsn(psn)
  4282. c.ServeSuccessJSON(map[string]interface{}{
  4283. "patient": patient,
  4284. "number": ecToken,
  4285. })
  4286. }
  4287. } else {
  4288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4289. return
  4290. }
  4291. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4292. res := c.GetoleInfo()
  4293. if res.Infcode == 0 {
  4294. var result string
  4295. if res.Output.MdtrtCertType == "01" {
  4296. 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)
  4297. } else if res.Output.MdtrtCertType == "02" {
  4298. 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)
  4299. } else if res.Output.MdtrtCertType == "03" {
  4300. 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)
  4301. }
  4302. var dat map[string]interface{}
  4303. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4304. fmt.Println(dat)
  4305. } else {
  4306. fmt.Println(err)
  4307. }
  4308. userJSONBytes, _ := json.Marshal(dat)
  4309. var res2 ResultTwo
  4310. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4311. utils.ErrorLog("解析失败:%v", err)
  4312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4313. return
  4314. }
  4315. if res2.Infcode == 0 {
  4316. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4317. if err == gorm.ErrRecordNotFound {
  4318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4319. return
  4320. } else if err != nil {
  4321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4322. return
  4323. } else {
  4324. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4325. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4326. infoStr := string(Iinfos)
  4327. idetinfoStr := string(Idetinfos)
  4328. var rf []*ResultFive
  4329. json.Unmarshal([]byte(infoStr), &rf)
  4330. var insutypes []*ResultFive
  4331. var insutype string
  4332. var is390 int = 0
  4333. var is310 int = 0
  4334. //var insuplc_admdvs string
  4335. for _, item := range rf {
  4336. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4337. insutypes = append(insutypes, item)
  4338. }
  4339. }
  4340. if len(insutypes) == 1 {
  4341. insutype = insutypes[0].Insutype
  4342. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4343. } else {
  4344. for _, i := range insutypes {
  4345. if i.Insutype == "390" {
  4346. is390 = 1
  4347. }
  4348. if i.Insutype == "310" {
  4349. is310 = 1
  4350. }
  4351. }
  4352. }
  4353. if is390 == 1 {
  4354. insutype = "390"
  4355. }
  4356. if is310 == 1 {
  4357. insutype = "310"
  4358. }
  4359. if len(insutypes) == 0 {
  4360. insutype = "310"
  4361. }
  4362. psn := &models.HisPsn{
  4363. PsnNo: res2.Output.Baseinfo.PsnNo,
  4364. PatientId: patient.ID,
  4365. Certno: res2.Output.Baseinfo.Certno,
  4366. Gend: res2.Output.Baseinfo.Gend,
  4367. Naty: res2.Output.Baseinfo.Naty,
  4368. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4369. PsnName: res2.Output.Baseinfo.PsnName,
  4370. Idetinfo: idetinfoStr,
  4371. Insuinfo: infoStr,
  4372. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4373. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4374. VerifyNumber: res.Output.EcToken,
  4375. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4376. }
  4377. service.CreateHisPsn(psn)
  4378. c.ServeSuccessJSON(map[string]interface{}{
  4379. "patient": patient,
  4380. "number": res.Output.CardNo,
  4381. "insutype": insutype,
  4382. })
  4383. }
  4384. } else {
  4385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4386. return
  4387. }
  4388. } else {
  4389. c.ServeSuccessJSON(map[string]interface{}{
  4390. "failed_code": -10,
  4391. "msg": res.ErrMsg,
  4392. })
  4393. }
  4394. } else {
  4395. //if initFlag == 0 {
  4396. // c.TestGetBasBaseInit()
  4397. //}
  4398. //token := c.GetEleBaseInfo()
  4399. //token = Remove0000(token)
  4400. type ELeData struct {
  4401. Code string `json:"code"`
  4402. Data struct {
  4403. Aac002 string `json:"aac002"`
  4404. Aaz500 string `json:"aaz500"`
  4405. ActCardNo string `json:"actCardNo"`
  4406. Bab520 string `json:"bab520"`
  4407. Bkz543 string `json:"bkz543"`
  4408. BusinessType string `json:"businessType"`
  4409. CertfCodg string `json:"certfCodg"`
  4410. EcIndexNo string `json:"ecIndexNo"`
  4411. EcToken string `json:"ecToken"`
  4412. ID0000 string `json:"id0000"`
  4413. IDNo string `json:"idNo"`
  4414. IDType string `json:"idType"`
  4415. Idcode string `json:"idcode"`
  4416. IdentityToken string `json:"identity_token"`
  4417. InsuOrg string `json:"insuOrg"`
  4418. OfficeID string `json:"officeId"`
  4419. OfficeName string `json:"officeName"`
  4420. OperatorID string `json:"operatorId"`
  4421. OperatorName string `json:"operatorName"`
  4422. OrgID string `json:"orgId"`
  4423. UserName string `json:"userName"`
  4424. } `json:"data"`
  4425. Infno interface{} `json:"infno"`
  4426. Message string `json:"message"`
  4427. OrgID string `json:"orgId"`
  4428. TransType string `json:"transType"`
  4429. }
  4430. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4431. fmt.Println(result)
  4432. outPutInfo := Remove0000(result)
  4433. fmt.Println(outPutInfo)
  4434. var ele ELeData
  4435. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4436. if err != nil {
  4437. utils.ErrorLog("解析失败:%v", err)
  4438. }
  4439. token := ele.Data.EcToken
  4440. var result2 string
  4441. var requestLog2 string
  4442. if len(token) > 0 {
  4443. if strings.Contains(ele.Data.IDNo, "HKG") {
  4444. 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)
  4445. } else {
  4446. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4447. }
  4448. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4449. var res ResultTwo
  4450. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4451. utils.ErrorLog("解析失败:%v", err)
  4452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4453. return
  4454. }
  4455. if res.Infcode == 0 {
  4456. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4457. if err == gorm.ErrRecordNotFound {
  4458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4459. return
  4460. } else if err != nil {
  4461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4462. return
  4463. } else {
  4464. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4465. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4466. infoStr := string(Iinfos)
  4467. idetinfoStr := string(Idetinfos)
  4468. psn := &models.HisPsn{
  4469. PsnNo: res.Output.Baseinfo.PsnNo,
  4470. PatientId: patient.ID,
  4471. Certno: res.Output.Baseinfo.Certno,
  4472. Gend: res.Output.Baseinfo.Gend,
  4473. Naty: res.Output.Baseinfo.Naty,
  4474. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4475. PsnName: res.Output.Baseinfo.PsnName,
  4476. Idetinfo: idetinfoStr,
  4477. Insuinfo: infoStr,
  4478. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4479. CardInfo: "",
  4480. VerifyNumber: token,
  4481. }
  4482. service.CreateHisPsn(psn)
  4483. c.ServeSuccessJSON(map[string]interface{}{
  4484. "msg": "读取成功",
  4485. })
  4486. }
  4487. } else {
  4488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4489. return
  4490. }
  4491. } else {
  4492. c.ServeSuccessJSON(map[string]interface{}{
  4493. "failed_code": -10,
  4494. "msg": "读取失败",
  4495. })
  4496. }
  4497. }
  4498. }
  4499. func (c *HisApiController) ReadEleFace() {
  4500. admin_user_id, _ := c.GetInt64("admin_user_id")
  4501. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4502. adminUser := c.GetAdminUserInfo()
  4503. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4504. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4505. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4506. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4507. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4508. if len(tokens) > 0 {
  4509. c.ServeSuccessJSON(map[string]interface{}{
  4510. "msg": "读取成功",
  4511. })
  4512. } else {
  4513. c.ServeSuccessJSON(map[string]interface{}{
  4514. "failed_code": -10,
  4515. "msg": "读取失败",
  4516. })
  4517. }
  4518. }
  4519. }
  4520. func (c *HisApiController) Get9001() {
  4521. adminUser := c.GetAdminUserInfo()
  4522. admin_user_id, _ := c.GetInt64("admin_user_id")
  4523. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4524. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4525. if miConfig.MdtrtareaAdmvs == "350500" {
  4526. service.GetFjAuthorizationInfo(miConfig.Code)
  4527. } else if miConfig.MdtrtareaAdmvs == "131023" {
  4528. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  4529. var dat map[string]interface{}
  4530. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4531. fmt.Println(dat)
  4532. } else {
  4533. fmt.Println(err)
  4534. }
  4535. userJSONBytes, _ := json.Marshal(dat)
  4536. var res models.Result9001
  4537. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4538. utils.ErrorLog("解析失败:%v", err)
  4539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4540. return
  4541. }
  4542. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4543. fmt.Println(miConfig.SecretKey)
  4544. var res models.Result9001Two
  4545. 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 +
  4546. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  4547. resp, requestErr := http.Get(api)
  4548. if requestErr != nil {
  4549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4550. return
  4551. }
  4552. body, ioErr := ioutil.ReadAll(resp.Body)
  4553. if ioErr != nil {
  4554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4556. return
  4557. }
  4558. var respJSON map[string]interface{}
  4559. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4562. return
  4563. }
  4564. status := respJSON["data"].(map[string]interface{})["status"].(string)
  4565. if status == "0" {
  4566. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  4567. c.ServeSuccessJSON(map[string]interface{}{
  4568. "failed_code": -10,
  4569. "msg": err_msg,
  4570. })
  4571. return
  4572. }
  4573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4574. result, _ := json.Marshal(respJSON)
  4575. fmt.Println("log")
  4576. fmt.Println(string(result))
  4577. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4578. utils.ErrorLog("解析失败:%v", err)
  4579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4580. return
  4581. }
  4582. if res.Infcode == 0 {
  4583. sign := models.HisSignIn{
  4584. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4585. SignNo: res.Output.Signinoutb.SignNo,
  4586. SignTime: "",
  4587. Ctime: time.Now().Unix(),
  4588. Mtime: time.Now().Unix(),
  4589. Status: 1,
  4590. InputLog: "",
  4591. OutputLog: "",
  4592. FixmedinsCode: miConfig.Code,
  4593. }
  4594. err := service.CreateSignIn(&sign)
  4595. if err == nil {
  4596. c.ServeSuccessJSON(map[string]interface{}{
  4597. "msg": "签到成功",
  4598. })
  4599. }
  4600. } else {
  4601. c.ServeSuccessJSON(map[string]interface{}{
  4602. "failed_code": -10,
  4603. "msg": res.ErrMsg,
  4604. })
  4605. return
  4606. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4607. //return
  4608. }
  4609. } else {
  4610. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  4611. var dat map[string]interface{}
  4612. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4613. fmt.Println(dat)
  4614. } else {
  4615. fmt.Println(err)
  4616. }
  4617. userJSONBytes, _ := json.Marshal(dat)
  4618. var res models.Result9001
  4619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4620. utils.ErrorLog("解析失败:%v", err)
  4621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4622. return
  4623. }
  4624. if res.Infcode == 0 {
  4625. sign := models.HisSignIn{
  4626. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4627. SignNo: res.Output.Signinoutb.SignNo,
  4628. SignTime: res.Output.Signinoutb.SignTime,
  4629. Ctime: time.Now().Unix(),
  4630. Mtime: time.Now().Unix(),
  4631. Status: 1,
  4632. InputLog: "",
  4633. OutputLog: "",
  4634. FixmedinsCode: miConfig.Code,
  4635. }
  4636. err := service.CreateSignIn(&sign)
  4637. if err == nil {
  4638. c.ServeSuccessJSON(map[string]interface{}{
  4639. "msg": "签到成功",
  4640. })
  4641. }
  4642. }
  4643. }
  4644. }
  4645. 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) {
  4646. var res Result3101
  4647. adminUser := c.GetAdminUserInfo()
  4648. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4649. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4650. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4651. //record_time := c.GetString("record_time")
  4652. //trig_scen := c.GetString("trig_scen")
  4653. timeLayout := "2006-01-02"
  4654. loc, _ := time.LoadLocation("Local")
  4655. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4656. if err != nil {
  4657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4658. return res
  4659. }
  4660. recordDateTime := theTime.Unix()
  4661. var patientPrescription models.HisPrescriptionInfo
  4662. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4663. //if patientPrescription.ID == 0 {
  4664. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4665. //}
  4666. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4667. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4668. //
  4669. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  4670. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4671. var pp models.PublicParams
  4672. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4673. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4674. pp.FixmedinsName = miConfig.OrgName
  4675. pp.FixmedinsCode = miConfig.Code
  4676. pp.RequestUrl = miConfig.Url
  4677. pp.Cainfo = miConfig.Cainfo
  4678. pp.SecretKey = miConfig.SecretKey
  4679. pp.AccessKey = miConfig.AccessKey
  4680. pp.OpterName = roles.UserName
  4681. var config []*models.HisXtDiagnoseConfig
  4682. for _, item := range diagnosis_ids {
  4683. id, _ := strconv.ParseInt(item, 10, 64)
  4684. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4685. config = append(config, &diagnosisConfig)
  4686. }
  4687. var pd models.PatientDtos
  4688. pd.PatnID = his.PsnNo
  4689. pd.PatnName = his.Name
  4690. pd.Gend = his.Gend
  4691. pd.Brdy = his.Brdy
  4692. pd.Poolarea = miConfig.MdtrtareaAdmvs
  4693. pd.CurrMdtrtID = his.Number
  4694. var fed models.FsiEncounterDtos
  4695. fed.MdtrtID = his.Number
  4696. fed.MedinsID = miConfig.Code
  4697. fed.MedinsName = miConfig.OrgName
  4698. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4699. fed.MedMdtrtType = "1"
  4700. fed.MedinsType = "1"
  4701. fed.MedinsLv = "11"
  4702. tm := time.Unix(his.RecordDate, 0)
  4703. s_tm := tm.Format("2006-01-02 15:04:05")
  4704. fed.AdmDate = s_tm
  4705. fed.DscgDate = s_tm
  4706. fed.DscgMainDiseCodg = config[0].CountryCode
  4707. fed.DscgMainDiseName = config[0].CountryContentName
  4708. //诊断信息
  4709. var fdds []*models.FsiDiagnoseDtos
  4710. for index, item := range config {
  4711. if index == 0 {
  4712. var fdd models.FsiDiagnoseDtos
  4713. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4714. fdd.InoutDiseType = "1"
  4715. fdd.MaindiseFlag = "1"
  4716. fdd.DiseDate = s_tm
  4717. fdd.DiasSrtNo = "1"
  4718. fdd.DiseName = item.CountryContentName
  4719. fdd.DiseCodg = item.CountryCode
  4720. fdds = append(fdds, &fdd)
  4721. } else {
  4722. var fdd models.FsiDiagnoseDtos
  4723. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4724. fdd.InoutDiseType = "1"
  4725. fdd.MaindiseFlag = "1"
  4726. fdd.DiseDate = s_tm
  4727. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  4728. fdd.DiseName = item.CountryContentName
  4729. fdd.DiseCodg = item.CountryCode
  4730. fdds = append(fdds, &fdd)
  4731. }
  4732. }
  4733. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  4734. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  4735. fed.AdmDeptName = department.Name
  4736. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  4737. fed.DscgDeptName = department.Name
  4738. fed.MedMdtrtType = "1"
  4739. fed.MedType = "11"
  4740. //if his.Insutype == "390" {
  4741. // fed.MedType = "1402"
  4742. //} else {
  4743. // fed.MedType = "9933"
  4744. //}
  4745. var orders []*models.FsiOrderDtos
  4746. if trig_scen == "2" {
  4747. //处方医嘱信息
  4748. for _, item := range prescriptions {
  4749. for _, subItem := range item.HisDoctorAdviceInfo {
  4750. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4751. var order models.FsiOrderDtos
  4752. order.RxID = strconv.FormatInt(item.ID, 10)
  4753. order.Rxno = strconv.FormatInt(item.ID, 10)
  4754. order.LongDrordFlag = "0"
  4755. order.HilistType = "1"
  4756. order.ChrgType = "1"
  4757. order.DrordBhvr = "-"
  4758. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4759. order.HosplistName = subItem.BaseDrugLib.DrugName
  4760. order.HilistLv = "1"
  4761. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4762. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4763. order.HosplistName = subItem.BaseDrugLib.DrugName
  4764. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  4765. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4766. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  4767. order.OwnpayAmt = ""
  4768. order.SelfpayAmt = ""
  4769. order.Spec = ""
  4770. order.SpecUnt = ""
  4771. order.DrordBegnDate = s_tm
  4772. order.DrordStopDate = ""
  4773. order.DrordDrCodg = doctor_info.DoctorNumber
  4774. order.DrordDeptName = department.Name
  4775. order.DrordDeptCodg = department.Number
  4776. order.DrordDrName = doctor_info.UserName
  4777. order.DrordDrProfttl = "234"
  4778. order.CurrDrordFlag = "1"
  4779. orders = append(orders, &order)
  4780. }
  4781. }
  4782. for _, subItem := range item.HisPrescriptionProject {
  4783. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  4784. var order models.FsiOrderDtos
  4785. order.RxID = strconv.FormatInt(item.ID, 10)
  4786. order.Rxno = strconv.FormatInt(item.ID, 10)
  4787. order.LongDrordFlag = "0"
  4788. order.HilistType = "1"
  4789. order.ChrgType = "1"
  4790. order.DrordBhvr = "-"
  4791. order.HilistCode = subItem.HisProject.MedicalCode
  4792. order.HosplistName = subItem.HisProject.ProjectName
  4793. order.HilistLv = "1"
  4794. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4795. order.HosplistCode = subItem.HisProject.MedicalCode
  4796. order.HosplistName = subItem.HisProject.ProjectName
  4797. order.Cnt = subItem.Count
  4798. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4799. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4800. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4801. order.OwnpayAmt = ""
  4802. order.SelfpayAmt = ""
  4803. order.Spec = ""
  4804. order.SpecUnt = ""
  4805. order.DrordBegnDate = s_tm
  4806. order.DrordStopDate = ""
  4807. order.DrordDrCodg = doctor_info.DoctorNumber
  4808. order.DrordDeptName = department.Name
  4809. order.DrordDeptCodg = department.Number
  4810. order.DrordDrName = doctor_info.UserName
  4811. order.DrordDrProfttl = "234"
  4812. order.CurrDrordFlag = "1"
  4813. orders = append(orders, &order)
  4814. }
  4815. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  4816. var order models.FsiOrderDtos
  4817. order.RxID = strconv.FormatInt(item.ID, 10)
  4818. order.Rxno = strconv.FormatInt(item.ID, 10)
  4819. order.LongDrordFlag = "0"
  4820. order.HilistType = "1"
  4821. order.ChrgType = "1"
  4822. order.DrordBhvr = "-"
  4823. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4824. order.HosplistName = subItem.GoodInfo.GoodName
  4825. order.HilistLv = "1"
  4826. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4827. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4828. order.HosplistName = subItem.GoodInfo.GoodName
  4829. order.Cnt = subItem.Count
  4830. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4831. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4832. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4833. order.OwnpayAmt = ""
  4834. order.SelfpayAmt = ""
  4835. order.Spec = ""
  4836. order.SpecUnt = ""
  4837. order.DrordBegnDate = s_tm
  4838. order.DrordStopDate = ""
  4839. order.DrordDrCodg = doctor_info.DoctorNumber
  4840. order.DrordDeptName = department.Name
  4841. order.DrordDeptCodg = department.Number
  4842. order.DrordDrName = doctor_info.UserName
  4843. order.DrordDrProfttl = "234"
  4844. order.CurrDrordFlag = "1"
  4845. orders = append(orders, &order)
  4846. }
  4847. }
  4848. }
  4849. //处方医嘱信息
  4850. }
  4851. fed.MatnStas = "0"
  4852. fed.MedfeeSumamt = "0"
  4853. fed.OwnpayAmt = "0"
  4854. fed.SelfpayAmt = "0"
  4855. fed.AcctPayamt = "0"
  4856. fed.MaAmt = "0"
  4857. fed.HifpPayamt = "0"
  4858. fed.SetlTotlnum = "1"
  4859. fed.Insutype = his.Insutype
  4860. fed.ReimFlag = "0"
  4861. fed.OutSetlFlag = "0"
  4862. var fopd []*models.FsiOperationDtosData
  4863. data := make(map[string]interface{})
  4864. data["fed"] = fed
  4865. data["fdd"] = fdds
  4866. data["fod"] = orders
  4867. data["pd"] = pd
  4868. data["pp"] = pp
  4869. data["fopd"] = fopd
  4870. data["trig_scen"] = trig_scen
  4871. fmt.Println(data)
  4872. fmt.Println(fed)
  4873. fmt.Println(fdds)
  4874. fmt.Println(orders)
  4875. fmt.Println(pd)
  4876. fmt.Println(pp)
  4877. fmt.Println(fopd)
  4878. client := &http.Client{}
  4879. bytesData, _ := json.Marshal(data)
  4880. var req *http.Request
  4881. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4882. if miConfig.MdtrtareaAdmvs == "320921" {
  4883. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4884. } else {
  4885. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4886. }
  4887. resp, _ := client.Do(req)
  4888. defer resp.Body.Close()
  4889. body, ioErr := ioutil.ReadAll(resp.Body)
  4890. if ioErr != nil {
  4891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4893. return res
  4894. }
  4895. var respJSON map[string]interface{}
  4896. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4899. return res
  4900. }
  4901. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4902. fmt.Println(respJSON)
  4903. result, _ := json.Marshal(respJSON)
  4904. fmt.Println(result)
  4905. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4906. utils.ErrorLog("解析失败:%v", err)
  4907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4908. return res
  4909. }
  4910. return res
  4911. } else {
  4912. //if miConfig.MdtrtareaAdmvs == "441202" {
  4913. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  4914. saveLog(output, input, "3101", "事前")
  4915. if err := json.Unmarshal([]byte(output), &res); err != nil {
  4916. utils.ErrorLog("解析失败:%v", err)
  4917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4918. return
  4919. }
  4920. return res
  4921. //}
  4922. }
  4923. }
  4924. 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) {
  4925. adminUser := c.GetAdminUserInfo()
  4926. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4927. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4928. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4929. //record_time := c.GetString("record_time")
  4930. //trig_scen := c.GetString("trig_scen")
  4931. timeLayout := "2006-01-02"
  4932. loc, _ := time.LoadLocation("Local")
  4933. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4934. if err != nil {
  4935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4936. return res
  4937. }
  4938. recordDateTime := theTime.Unix()
  4939. var patientPrescription models.HisPrescriptionInfo
  4940. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4941. if patientPrescription.ID == 0 {
  4942. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4943. }
  4944. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4945. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4946. //
  4947. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  4948. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4949. var pp models.PublicParams
  4950. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4951. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4952. pp.FixmedinsName = miConfig.OrgName
  4953. pp.FixmedinsCode = miConfig.Code
  4954. pp.RequestUrl = miConfig.Url
  4955. pp.Cainfo = miConfig.Cainfo
  4956. pp.SecretKey = miConfig.SecretKey
  4957. pp.AccessKey = miConfig.AccessKey
  4958. pp.OpterName = roles.UserName
  4959. var config []*models.HisXtDiagnoseConfig
  4960. for _, item := range diagnosis_ids {
  4961. id, _ := strconv.ParseInt(item, 10, 64)
  4962. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4963. config = append(config, &diagnosisConfig)
  4964. }
  4965. var pd models.PatientDtos
  4966. pd.PatnID = his.PsnNo
  4967. pd.PatnName = his.Name
  4968. pd.Gend = his.Gend
  4969. pd.Brdy = his.Brdy
  4970. pd.Poolarea = his.InsuplcAdmdvs
  4971. pd.CurrMdtrtID = his.Number
  4972. var fed models.FsiEncounterDtos
  4973. fed.MdtrtID = his.Number
  4974. fed.MedinsID = miConfig.Code
  4975. fed.MedinsName = miConfig.OrgName
  4976. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4977. fed.MedMdtrtType = "1"
  4978. fed.MedinsType = "1"
  4979. fed.MedinsLv = "11"
  4980. tm := time.Unix(his.RecordDate, 0)
  4981. s_tm := tm.Format("2006-01-02 15:04:05")
  4982. fed.AdmDate = s_tm
  4983. fed.DscgDate = s_tm
  4984. fed.DscgMainDiseCodg = config[0].CountryCode
  4985. fed.DscgMainDiseName = config[0].CountryContentName
  4986. //诊断信息
  4987. var fdds []*models.FsiDiagnoseDtos
  4988. for index, item := range config {
  4989. if index == 0 {
  4990. var fdd models.FsiDiagnoseDtos
  4991. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4992. fdd.InoutDiseType = "1"
  4993. fdd.MaindiseFlag = "1"
  4994. fdd.DiseDate = s_tm
  4995. fdd.DiasSrtNo = "1"
  4996. fdd.DiseName = item.CountryContentName
  4997. fdd.DiseCodg = item.CountryCode
  4998. fdds = append(fdds, &fdd)
  4999. } else {
  5000. var fdd models.FsiDiagnoseDtos
  5001. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5002. fdd.InoutDiseType = "1"
  5003. fdd.MaindiseFlag = "1"
  5004. fdd.DiseDate = s_tm
  5005. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5006. fdd.DiseName = item.CountryContentName
  5007. fdd.DiseCodg = item.CountryCode
  5008. fdds = append(fdds, &fdd)
  5009. }
  5010. }
  5011. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5012. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5013. fed.AdmDeptName = department.Name
  5014. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5015. fed.DscgDeptName = department.Name
  5016. fed.MedMdtrtType = "1"
  5017. fed.MedType = "11"
  5018. //if his.Insutype == "390" {
  5019. // fed.MedType = "1402"
  5020. //} else {
  5021. // fed.MedType = "9933"
  5022. //}
  5023. var orders []*models.FsiOrderDtos
  5024. if trig_scen == "2" {
  5025. //处方医嘱信息
  5026. for _, item := range prescriptions {
  5027. for _, subItem := range item.HisDoctorAdviceInfo {
  5028. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5029. var order models.FsiOrderDtos
  5030. order.RxID = strconv.FormatInt(item.ID, 10)
  5031. order.Rxno = strconv.FormatInt(item.ID, 10)
  5032. order.LongDrordFlag = "0"
  5033. order.HilistType = "1"
  5034. order.ChrgType = "1"
  5035. order.DrordBhvr = "-"
  5036. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5037. order.HosplistName = subItem.BaseDrugLib.DrugName
  5038. order.HilistLv = "1"
  5039. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5040. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5041. order.HosplistName = subItem.BaseDrugLib.DrugName
  5042. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5043. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5044. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5045. order.OwnpayAmt = ""
  5046. order.SelfpayAmt = ""
  5047. order.Spec = ""
  5048. order.SpecUnt = ""
  5049. order.DrordBegnDate = s_tm
  5050. order.DrordStopDate = ""
  5051. order.DrordDrCodg = doctor_info.DoctorNumber
  5052. order.DrordDeptName = department.Name
  5053. order.DrordDeptCodg = department.Number
  5054. order.DrordDrName = doctor_info.UserName
  5055. order.DrordDrProfttl = "234"
  5056. order.CurrDrordFlag = "1"
  5057. orders = append(orders, &order)
  5058. }
  5059. }
  5060. for _, subItem := range item.HisPrescriptionProject {
  5061. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5062. var order models.FsiOrderDtos
  5063. order.RxID = strconv.FormatInt(item.ID, 10)
  5064. order.Rxno = strconv.FormatInt(item.ID, 10)
  5065. order.LongDrordFlag = "0"
  5066. order.HilistType = "1"
  5067. order.ChrgType = "1"
  5068. order.DrordBhvr = "-"
  5069. order.HilistCode = subItem.HisProject.MedicalCode
  5070. order.HosplistName = subItem.HisProject.ProjectName
  5071. order.HilistLv = "1"
  5072. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5073. order.HosplistCode = subItem.HisProject.MedicalCode
  5074. order.HosplistName = subItem.HisProject.ProjectName
  5075. order.Cnt = subItem.Count
  5076. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5077. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5078. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5079. order.OwnpayAmt = ""
  5080. order.SelfpayAmt = ""
  5081. order.Spec = ""
  5082. order.SpecUnt = ""
  5083. order.DrordBegnDate = s_tm
  5084. order.DrordStopDate = ""
  5085. order.DrordDrCodg = doctor_info.DoctorNumber
  5086. order.DrordDeptName = department.Name
  5087. order.DrordDeptCodg = department.Number
  5088. order.DrordDrName = doctor_info.UserName
  5089. order.DrordDrProfttl = "234"
  5090. order.CurrDrordFlag = "1"
  5091. orders = append(orders, &order)
  5092. }
  5093. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5094. var order models.FsiOrderDtos
  5095. order.RxID = strconv.FormatInt(item.ID, 10)
  5096. order.Rxno = strconv.FormatInt(item.ID, 10)
  5097. order.LongDrordFlag = "0"
  5098. order.HilistType = "1"
  5099. order.ChrgType = "1"
  5100. order.DrordBhvr = "-"
  5101. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5102. order.HosplistName = subItem.GoodInfo.GoodName
  5103. order.HilistLv = "1"
  5104. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5105. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5106. order.HosplistName = subItem.GoodInfo.GoodName
  5107. order.Cnt = subItem.Count
  5108. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5109. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5110. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5111. order.OwnpayAmt = ""
  5112. order.SelfpayAmt = ""
  5113. order.Spec = ""
  5114. order.SpecUnt = ""
  5115. order.DrordBegnDate = s_tm
  5116. order.DrordStopDate = ""
  5117. order.DrordDrCodg = doctor_info.DoctorNumber
  5118. order.DrordDeptName = department.Name
  5119. order.DrordDeptCodg = department.Number
  5120. order.DrordDrName = doctor_info.UserName
  5121. order.DrordDrProfttl = "234"
  5122. order.CurrDrordFlag = "1"
  5123. orders = append(orders, &order)
  5124. }
  5125. }
  5126. }
  5127. //处方医嘱信息
  5128. }
  5129. fed.MatnStas = "0"
  5130. fed.MedfeeSumamt = "0"
  5131. fed.OwnpayAmt = "0"
  5132. fed.SelfpayAmt = "0"
  5133. fed.AcctPayamt = "0"
  5134. fed.MaAmt = "0"
  5135. fed.HifpPayamt = "0"
  5136. fed.SetlTotlnum = "1"
  5137. fed.Insutype = his.Insutype
  5138. fed.ReimFlag = "0"
  5139. fed.OutSetlFlag = "0"
  5140. var fopd []*models.FsiOperationDtosData
  5141. data := make(map[string]interface{})
  5142. data["fed"] = fed
  5143. data["fdd"] = fdds
  5144. data["fod"] = orders
  5145. data["pd"] = pd
  5146. data["pp"] = pp
  5147. data["fopd"] = fopd
  5148. data["trig_scen"] = trig_scen
  5149. fmt.Println(data)
  5150. fmt.Println(fed)
  5151. fmt.Println(fdds)
  5152. fmt.Println(orders)
  5153. fmt.Println(pd)
  5154. fmt.Println(pp)
  5155. fmt.Println(fopd)
  5156. client := &http.Client{}
  5157. bytesData, _ := json.Marshal(data)
  5158. var req *http.Request
  5159. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5160. if miConfig.MdtrtareaAdmvs == "320921" {
  5161. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5162. } else {
  5163. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5164. }
  5165. resp, _ := client.Do(req)
  5166. defer resp.Body.Close()
  5167. body, ioErr := ioutil.ReadAll(resp.Body)
  5168. if ioErr != nil {
  5169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5171. return res
  5172. }
  5173. var respJSON map[string]interface{}
  5174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5177. return res
  5178. }
  5179. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5180. fmt.Println(respJSON)
  5181. result, _ := json.Marshal(respJSON)
  5182. fmt.Println(result)
  5183. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5184. utils.ErrorLog("解析失败:%v", err)
  5185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5186. return res
  5187. }
  5188. return res
  5189. } else {
  5190. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5191. saveLog(output, input, "3101", "事前")
  5192. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5193. utils.ErrorLog("解析失败:%v", err)
  5194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5195. return
  5196. }
  5197. return res
  5198. }
  5199. return res
  5200. }
  5201. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5202. ////patient_id, _ := c.GetInt64("patient_id")
  5203. //order_id, _ := c.GetInt64("order_id")
  5204. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5205. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5206. //trig_scen := c.GetString("trig_scen")
  5207. adminUser := c.GetAdminUserInfo()
  5208. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5209. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5210. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5211. record_time := c.GetString("record_time")
  5212. order, _ := service.GetHisOrderByID(order_id)
  5213. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5214. timeLayout := "2006-01-02"
  5215. loc, _ := time.LoadLocation("Local")
  5216. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5217. if err != nil {
  5218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5219. return
  5220. }
  5221. recordDateTime := theTime.Unix()
  5222. var patientPrescription models.HisPrescriptionInfo
  5223. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5224. if patientPrescription.ID == 0 {
  5225. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5226. }
  5227. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5228. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5229. //
  5230. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5231. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5232. var pp models.PublicParams
  5233. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5234. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5235. pp.FixmedinsName = miConfig.OrgName
  5236. pp.FixmedinsCode = miConfig.Code
  5237. pp.RequestUrl = miConfig.Url
  5238. pp.Cainfo = miConfig.Cainfo
  5239. pp.SecretKey = miConfig.SecretKey
  5240. pp.AccessKey = miConfig.AccessKey
  5241. pp.OpterName = roles.UserName
  5242. var config []*models.HisXtDiagnoseConfig
  5243. for _, item := range diagnosis_ids {
  5244. id, _ := strconv.ParseInt(item, 10, 64)
  5245. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5246. config = append(config, &diagnosisConfig)
  5247. }
  5248. var pd models.PatientDtos
  5249. pd.PatnID = his.PsnNo
  5250. pd.PatnName = his.Name
  5251. pd.Gend = his.Gend
  5252. pd.Brdy = psn_info.Brdy
  5253. pd.Poolarea = his.InsuplcAdmdvs
  5254. pd.CurrMdtrtID = his.Number
  5255. var fed models.FsiEncounterDtos
  5256. fed.MdtrtID = his.Number
  5257. fed.MedinsID = miConfig.Code
  5258. fed.MedinsName = miConfig.OrgName
  5259. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5260. fed.MedMdtrtType = "1"
  5261. fed.MedinsType = "1"
  5262. fed.MedinsLv = "11"
  5263. tm := time.Unix(his.RecordDate, 0)
  5264. s_tm := tm.Format("2006-01-02 15:04:05")
  5265. fed.AdmDate = s_tm
  5266. fed.DscgDate = s_tm
  5267. fed.DscgMainDiseCodg = config[0].CountryCode
  5268. fed.DscgMainDiseName = config[0].CountryContentName
  5269. //诊断信息
  5270. var fdds []*models.FsiDiagnoseDtos
  5271. for index, item := range config {
  5272. if index == 0 {
  5273. var fdd models.FsiDiagnoseDtos
  5274. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5275. fdd.InoutDiseType = "1"
  5276. fdd.MaindiseFlag = "1"
  5277. fdd.DiseDate = s_tm
  5278. fdd.DiasSrtNo = "1"
  5279. fdd.DiseName = item.CountryContentName
  5280. fdd.DiseCodg = item.CountryCode
  5281. fdds = append(fdds, &fdd)
  5282. } else {
  5283. var fdd models.FsiDiagnoseDtos
  5284. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5285. fdd.InoutDiseType = "1"
  5286. fdd.MaindiseFlag = "1"
  5287. fdd.DiseDate = s_tm
  5288. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5289. fdd.DiseName = item.CountryContentName
  5290. fdd.DiseCodg = item.CountryCode
  5291. fdds = append(fdds, &fdd)
  5292. }
  5293. }
  5294. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5295. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5296. fed.AdmDeptName = department.Name
  5297. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5298. fed.DscgDeptName = department.Name
  5299. fed.MedType = order.MedType
  5300. //处方医嘱信息
  5301. var orders []*models.FsiOrderDtos
  5302. //for _, item := range prescriptions {
  5303. // for _, subItem := range item.HisDoctorAdviceInfo {
  5304. // var order models.FsiOrderDtos
  5305. // order.RxID = strconv.FormatInt(item.ID, 10)
  5306. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5307. // order.LongDrordFlag = "0"
  5308. // order.HilistType = "1"
  5309. // order.ChrgType = "1"
  5310. // order.DrordBhvr = "-"
  5311. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5312. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5313. // order.HilistLv = "1"
  5314. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5315. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5316. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5317. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5318. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5319. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5320. // order.OwnpayAmt = ""
  5321. // order.SelfpayAmt = ""
  5322. // order.Spec = ""
  5323. // order.SpecUnt = ""
  5324. // order.DrordBegnDate = s_tm
  5325. // order.DrordStopDate = ""
  5326. // order.DrordDrCodg = "1"
  5327. // order.DrordDeptName = department.Name
  5328. // order.DrordDrCodg = "1"
  5329. // order.DrordDrName = doctor_info.UserName
  5330. // order.DrordDrProfttl = ""
  5331. // order.CurrDrordFlag = "1"
  5332. // orders = append(orders, &order)
  5333. // }
  5334. // for _, subItem := range item.HisPrescriptionProject {
  5335. // if subItem.Type == 2 {
  5336. // var order models.FsiOrderDtos
  5337. // order.RxID = strconv.FormatInt(item.ID, 10)
  5338. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5339. // order.LongDrordFlag = "0"
  5340. // order.HilistType = "1"
  5341. // order.ChrgType = "1"
  5342. // order.DrordBhvr = "-"
  5343. // order.HilistCode = subItem.HisProject.MedicalCode
  5344. // order.HosplistName = subItem.HisProject.ProjectName
  5345. // order.HilistLv = "1"
  5346. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5347. // order.HosplistCode = subItem.HisProject.MedicalCode
  5348. // order.HosplistName = subItem.HisProject.ProjectName
  5349. // order.Cnt = subItem.Count
  5350. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5351. //
  5352. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5353. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5354. // order.OwnpayAmt = ""
  5355. // order.SelfpayAmt = ""
  5356. // order.Spec = ""
  5357. // order.SpecUnt = ""
  5358. // order.DrordBegnDate = s_tm
  5359. // order.DrordStopDate = ""
  5360. // order.DrordDrCodg = "1"
  5361. // order.DrordDeptName = department.Name
  5362. // order.DrordDrCodg = "1"
  5363. // order.DrordDrName = doctor_info.UserName
  5364. // order.DrordDrProfttl = ""
  5365. // order.CurrDrordFlag = "1"
  5366. // orders = append(orders, &order)
  5367. //
  5368. // }
  5369. // if subItem.Type == 3 {
  5370. //
  5371. // var order models.FsiOrderDtos
  5372. // order.RxID = strconv.FormatInt(item.ID, 10)
  5373. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5374. // order.LongDrordFlag = "0"
  5375. // order.HilistType = "1"
  5376. // order.ChrgType = "1"
  5377. // order.DrordBhvr = "-"
  5378. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5379. // order.HosplistName = subItem.GoodInfo.GoodName
  5380. // order.HilistLv = "1"
  5381. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5382. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5383. // order.HosplistName = subItem.GoodInfo.GoodName
  5384. // order.Cnt = subItem.Count
  5385. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5386. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5387. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5388. // order.OwnpayAmt = ""
  5389. // order.SelfpayAmt = ""
  5390. // order.Spec = ""
  5391. // order.SpecUnt = ""
  5392. // order.DrordBegnDate = s_tm
  5393. // order.DrordStopDate = ""
  5394. // order.DrordDrCodg = "1"
  5395. // order.DrordDeptName = department.Name
  5396. // order.DrordDrCodg = "1"
  5397. // order.DrordDrName = doctor_info.UserName
  5398. // order.DrordDrProfttl = ""
  5399. // order.CurrDrordFlag = "1"
  5400. // orders = append(orders, &order)
  5401. //
  5402. // }
  5403. // }
  5404. //}
  5405. for _, item := range prescriptions {
  5406. for _, subItem := range item.HisDoctorAdviceInfo {
  5407. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5408. var order models.FsiOrderDtos
  5409. order.RxID = strconv.FormatInt(item.ID, 10)
  5410. order.Rxno = strconv.FormatInt(item.ID, 10)
  5411. order.LongDrordFlag = "0"
  5412. order.HilistType = "1"
  5413. order.ChrgType = "1"
  5414. order.DrordBhvr = "-"
  5415. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5416. order.HosplistName = subItem.BaseDrugLib.DrugName
  5417. order.HilistLv = "1"
  5418. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5419. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5420. order.HosplistName = subItem.BaseDrugLib.DrugName
  5421. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5422. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5423. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5424. order.OwnpayAmt = ""
  5425. order.SelfpayAmt = ""
  5426. order.Spec = ""
  5427. order.SpecUnt = ""
  5428. order.DrordBegnDate = s_tm
  5429. order.DrordStopDate = ""
  5430. order.DrordDrCodg = doctor_info.DoctorNumber
  5431. order.DrordDeptName = department.Name
  5432. order.DrordDeptCodg = department.Number
  5433. order.DrordDrName = doctor_info.UserName
  5434. order.DrordDrProfttl = "234"
  5435. order.CurrDrordFlag = "1"
  5436. orders = append(orders, &order)
  5437. }
  5438. }
  5439. for _, subItem := range item.HisPrescriptionProject {
  5440. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5441. var order models.FsiOrderDtos
  5442. order.RxID = strconv.FormatInt(item.ID, 10)
  5443. order.Rxno = strconv.FormatInt(item.ID, 10)
  5444. order.LongDrordFlag = "0"
  5445. order.HilistType = "1"
  5446. order.ChrgType = "1"
  5447. order.DrordBhvr = "-"
  5448. order.HilistCode = subItem.HisProject.MedicalCode
  5449. order.HosplistName = subItem.HisProject.ProjectName
  5450. order.HilistLv = "1"
  5451. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5452. order.HosplistCode = subItem.HisProject.MedicalCode
  5453. order.HosplistName = subItem.HisProject.ProjectName
  5454. order.Cnt = subItem.Count
  5455. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5456. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5457. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5458. order.OwnpayAmt = ""
  5459. order.SelfpayAmt = ""
  5460. order.Spec = ""
  5461. order.SpecUnt = ""
  5462. order.DrordBegnDate = s_tm
  5463. order.DrordStopDate = ""
  5464. order.DrordDrCodg = doctor_info.DoctorNumber
  5465. order.DrordDeptName = department.Name
  5466. order.DrordDeptCodg = department.Number
  5467. order.DrordDrName = doctor_info.UserName
  5468. order.DrordDrProfttl = "234"
  5469. order.CurrDrordFlag = "1"
  5470. orders = append(orders, &order)
  5471. }
  5472. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5473. var order models.FsiOrderDtos
  5474. order.RxID = strconv.FormatInt(item.ID, 10)
  5475. order.Rxno = strconv.FormatInt(item.ID, 10)
  5476. order.LongDrordFlag = "0"
  5477. order.HilistType = "1"
  5478. order.ChrgType = "1"
  5479. order.DrordBhvr = "0"
  5480. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5481. order.HosplistName = subItem.GoodInfo.GoodName
  5482. order.HilistLv = "1"
  5483. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5484. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5485. order.HosplistName = subItem.GoodInfo.GoodName
  5486. order.Cnt = subItem.Count
  5487. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5488. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5489. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5490. order.OwnpayAmt = ""
  5491. order.SelfpayAmt = ""
  5492. order.Spec = ""
  5493. order.SpecUnt = ""
  5494. order.DrordBegnDate = s_tm
  5495. order.DrordStopDate = ""
  5496. order.DrordDrCodg = doctor_info.DoctorNumber
  5497. order.DrordDeptName = department.Name
  5498. order.DrordDeptCodg = department.Number
  5499. order.DrordDrName = doctor_info.UserName
  5500. order.DrordDrProfttl = "234"
  5501. order.CurrDrordFlag = "1"
  5502. orders = append(orders, &order)
  5503. }
  5504. }
  5505. }
  5506. //处方医嘱信息
  5507. fed.MatnStas = "0"
  5508. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5509. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  5510. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  5511. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  5512. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  5513. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  5514. fed.SetlTotlnum = "1"
  5515. fed.Insutype = his.Insutype
  5516. fed.ReimFlag = "0"
  5517. fed.OutSetlFlag = "0"
  5518. var fopd []*models.FsiOperationDtosData
  5519. data := make(map[string]interface{})
  5520. data["fed"] = fed
  5521. data["fdd"] = fdds
  5522. data["fod"] = orders
  5523. data["pd"] = pd
  5524. data["pp"] = pp
  5525. data["fopd"] = fopd
  5526. data["trig_scen"] = trig_scen
  5527. client := &http.Client{}
  5528. bytesData, _ := json.Marshal(data)
  5529. var req *http.Request
  5530. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5531. if miConfig.MdtrtareaAdmvs == "320921" {
  5532. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5533. } else {
  5534. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5535. }
  5536. resp, _ := client.Do(req)
  5537. defer resp.Body.Close()
  5538. body, ioErr := ioutil.ReadAll(resp.Body)
  5539. if ioErr != nil {
  5540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5542. return res
  5543. }
  5544. var respJSON map[string]interface{}
  5545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5548. return res
  5549. }
  5550. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5551. result, _ := json.Marshal(respJSON)
  5552. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5553. utils.ErrorLog("解析失败:%v", err)
  5554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5555. return res
  5556. }
  5557. return res
  5558. } else {
  5559. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5560. saveLog(output, input, "3102", "事中")
  5561. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5562. utils.ErrorLog("解析失败:%v", err)
  5563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5564. return
  5565. }
  5566. return res
  5567. }
  5568. return res
  5569. }
  5570. 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) {
  5571. var res Resultgd3101
  5572. adminUser := c.GetAdminUserInfo()
  5573. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5574. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5575. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5576. //record_time := c.GetString("record_time")
  5577. //trig_scen := c.GetString("trig_scen")
  5578. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5579. timeLayout := "2006-01-02"
  5580. loc, _ := time.LoadLocation("Local")
  5581. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5582. if err != nil {
  5583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5584. return res
  5585. }
  5586. recordDateTime := theTime.Unix()
  5587. var patientPrescription models.HisPrescriptionInfo
  5588. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5589. //if patientPrescription.ID == 0 {
  5590. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5591. //}
  5592. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5593. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5594. //
  5595. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5596. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5597. var pp models.PublicParams
  5598. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5599. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5600. pp.FixmedinsName = miConfig.OrgName
  5601. pp.FixmedinsCode = miConfig.Code
  5602. pp.RequestUrl = miConfig.Url
  5603. pp.Cainfo = miConfig.Cainfo
  5604. pp.SecretKey = miConfig.SecretKey
  5605. pp.AccessKey = miConfig.AccessKey
  5606. pp.OpterName = roles.UserName
  5607. var config []*models.HisXtDiagnoseConfig
  5608. for _, item := range diagnosis_ids {
  5609. id, _ := strconv.ParseInt(item, 10, 64)
  5610. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5611. config = append(config, &diagnosisConfig)
  5612. }
  5613. var pd models.PatientDtos
  5614. pd.PatnID = his.PsnNo
  5615. pd.PatnName = his.Name
  5616. pd.Gend = his.Gend
  5617. pd.Brdy = psn_info.Brdy
  5618. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5619. pd.CurrMdtrtID = his.Number
  5620. var fed models.FsiEncounterDtos
  5621. fed.MdtrtID = his.Number
  5622. fed.MedinsID = miConfig.Code
  5623. fed.MedinsName = miConfig.OrgName
  5624. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5625. fed.MedMdtrtType = "1"
  5626. fed.MedinsType = "1"
  5627. fed.MedinsLv = "11"
  5628. tm := time.Unix(his.RecordDate, 0)
  5629. s_tm := tm.Format("2006-01-02 15:04:05")
  5630. fed.AdmDate = s_tm
  5631. fed.DscgDate = s_tm
  5632. fed.DscgMainDiseCodg = config[0].CountryCode
  5633. fed.DscgMainDiseName = config[0].CountryContentName
  5634. //诊断信息
  5635. var fdds []*models.FsiDiagnoseDtos
  5636. for index, item := range config {
  5637. if index == 0 {
  5638. var fdd models.FsiDiagnoseDtos
  5639. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5640. fdd.InoutDiseType = "1"
  5641. fdd.MaindiseFlag = "1"
  5642. fdd.DiseDate = s_tm
  5643. fdd.DiasSrtNo = "1"
  5644. fdd.DiseName = item.CountryContentName
  5645. fdd.DiseCodg = item.CountryCode
  5646. fdds = append(fdds, &fdd)
  5647. } else {
  5648. var fdd models.FsiDiagnoseDtos
  5649. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5650. fdd.InoutDiseType = "1"
  5651. fdd.MaindiseFlag = "1"
  5652. fdd.DiseDate = s_tm
  5653. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5654. fdd.DiseName = item.CountryContentName
  5655. fdd.DiseCodg = item.CountryCode
  5656. fdds = append(fdds, &fdd)
  5657. }
  5658. }
  5659. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5660. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5661. fed.AdmDeptName = department.Name
  5662. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5663. fed.DscgDeptName = department.Name
  5664. fed.MedMdtrtType = "1"
  5665. fed.MedType = "11"
  5666. //if his.Insutype == "390" {
  5667. // fed.MedType = "1402"
  5668. //} else {
  5669. // fed.MedType = "9933"
  5670. //}
  5671. var orders []*models.FsiOrderDtos
  5672. if trig_scen == "2" {
  5673. //处方医嘱信息
  5674. for _, item := range prescriptions {
  5675. for _, subItem := range item.HisDoctorAdviceInfo {
  5676. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5677. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5678. var order models.FsiOrderDtos
  5679. order.RxID = strconv.FormatInt(item.ID, 10)
  5680. order.Rxno = strconv.FormatInt(item.ID, 10)
  5681. order.LongDrordFlag = "0"
  5682. order.HilistType = "1"
  5683. order.ChrgType = "1"
  5684. order.DrordBhvr = "0"
  5685. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5686. order.HosplistName = subItem.BaseDrugLib.DrugName
  5687. order.HilistLv = "1"
  5688. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5689. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5690. order.HosplistName = subItem.BaseDrugLib.DrugName
  5691. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5692. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5693. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5694. order.OwnpayAmt = ""
  5695. order.SelfpayAmt = ""
  5696. order.Spec = spec
  5697. order.SpecUnt = subItem.PrescribingNumberUnit
  5698. order.DrordBegnDate = s_tm
  5699. order.DrordStopDate = ""
  5700. order.DrordDrCodg = doctor_info.DoctorNumber
  5701. order.DrordDeptName = department.Name
  5702. order.DrordDeptCodg = department.Number
  5703. order.DrordDrName = doctor_info.UserName
  5704. order.DrordDrProfttl = "234"
  5705. order.CurrDrordFlag = "1"
  5706. orders = append(orders, &order)
  5707. }
  5708. }
  5709. for _, subItem := range item.HisPrescriptionProject {
  5710. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5711. var order models.FsiOrderDtos
  5712. order.RxID = strconv.FormatInt(item.ID, 10)
  5713. order.Rxno = strconv.FormatInt(item.ID, 10)
  5714. order.LongDrordFlag = "0"
  5715. order.HilistType = "1"
  5716. order.ChrgType = "1"
  5717. order.DrordBhvr = "0"
  5718. order.HilistCode = subItem.HisProject.MedicalCode
  5719. order.HosplistName = subItem.HisProject.ProjectName
  5720. order.HilistLv = "1"
  5721. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5722. order.HosplistCode = subItem.HisProject.MedicalCode
  5723. order.HosplistName = subItem.HisProject.ProjectName
  5724. order.Cnt = subItem.Count
  5725. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5726. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5727. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5728. order.OwnpayAmt = ""
  5729. order.SelfpayAmt = ""
  5730. order.Spec = subItem.Unit
  5731. order.SpecUnt = subItem.Unit
  5732. order.DrordBegnDate = s_tm
  5733. order.DrordStopDate = ""
  5734. order.DrordDrCodg = doctor_info.DoctorNumber
  5735. order.DrordDeptName = department.Name
  5736. order.DrordDeptCodg = department.Number
  5737. order.DrordDrName = doctor_info.UserName
  5738. order.DrordDrProfttl = "234"
  5739. order.CurrDrordFlag = "1"
  5740. orders = append(orders, &order)
  5741. }
  5742. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5743. var order models.FsiOrderDtos
  5744. order.RxID = strconv.FormatInt(item.ID, 10)
  5745. order.Rxno = strconv.FormatInt(item.ID, 10)
  5746. order.LongDrordFlag = "0"
  5747. order.HilistType = "1"
  5748. order.ChrgType = "1"
  5749. order.DrordBhvr = "0"
  5750. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5751. order.HosplistName = subItem.GoodInfo.GoodName
  5752. order.HilistLv = "1"
  5753. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5754. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5755. order.HosplistName = subItem.GoodInfo.GoodName
  5756. order.Cnt = subItem.Count
  5757. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5758. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5759. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5760. order.OwnpayAmt = ""
  5761. order.SelfpayAmt = ""
  5762. order.Spec = subItem.GoodInfo.SpecificationName
  5763. order.SpecUnt = subItem.Unit
  5764. order.DrordBegnDate = s_tm
  5765. order.DrordStopDate = ""
  5766. order.DrordDrCodg = doctor_info.DoctorNumber
  5767. order.DrordDeptName = department.Name
  5768. order.DrordDeptCodg = department.Number
  5769. order.DrordDrName = doctor_info.UserName
  5770. order.DrordDrProfttl = "234"
  5771. order.CurrDrordFlag = "1"
  5772. orders = append(orders, &order)
  5773. }
  5774. }
  5775. }
  5776. //处方医嘱信息
  5777. }
  5778. fed.MatnStas = "0"
  5779. fed.MedfeeSumamt = "0"
  5780. fed.OwnpayAmt = "0"
  5781. fed.SelfpayAmt = "0"
  5782. fed.AcctPayamt = "0"
  5783. fed.MaAmt = "0"
  5784. fed.HifpPayamt = "0"
  5785. fed.SetlTotlnum = "1"
  5786. fed.Insutype = his.Insutype
  5787. fed.ReimFlag = "0"
  5788. fed.OutSetlFlag = "0"
  5789. var fopd []*models.FsiOperationDtosData
  5790. data := make(map[string]interface{})
  5791. data["fed"] = fed
  5792. data["fdd"] = fdds
  5793. data["fod"] = orders
  5794. data["pd"] = pd
  5795. data["pp"] = pp
  5796. data["fopd"] = fopd
  5797. data["trig_scen"] = trig_scen
  5798. fmt.Println(data)
  5799. fmt.Println(fed)
  5800. fmt.Println(fdds)
  5801. fmt.Println(orders)
  5802. fmt.Println(pd)
  5803. fmt.Println(pp)
  5804. fmt.Println(fopd)
  5805. client := &http.Client{}
  5806. bytesData, _ := json.Marshal(data)
  5807. var req *http.Request
  5808. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5809. if miConfig.MdtrtareaAdmvs == "320921" {
  5810. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5811. } else {
  5812. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5813. }
  5814. resp, _ := client.Do(req)
  5815. defer resp.Body.Close()
  5816. body, ioErr := ioutil.ReadAll(resp.Body)
  5817. if ioErr != nil {
  5818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5820. return res
  5821. }
  5822. var respJSON map[string]interface{}
  5823. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5826. return res
  5827. }
  5828. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5829. fmt.Println(respJSON)
  5830. result, _ := json.Marshal(respJSON)
  5831. fmt.Println(result)
  5832. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5833. utils.ErrorLog("解析失败:%v", err)
  5834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5835. return res
  5836. }
  5837. return res
  5838. } else {
  5839. //if miConfig.MdtrtareaAdmvs == "441202" {
  5840. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5841. saveLog(output, input, "3101", "事前")
  5842. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5843. utils.ErrorLog("解析失败:%v", err)
  5844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5845. return
  5846. }
  5847. return res
  5848. //}
  5849. }
  5850. }
  5851. 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) {
  5852. adminUser := c.GetAdminUserInfo()
  5853. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5854. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5855. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5856. //record_time := c.GetString("record_time")
  5857. //trig_scen := c.GetString("trig_scen")
  5858. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5859. timeLayout := "2006-01-02"
  5860. loc, _ := time.LoadLocation("Local")
  5861. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5862. if err != nil {
  5863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5864. return res
  5865. }
  5866. recordDateTime := theTime.Unix()
  5867. var patientPrescription models.HisPrescriptionInfo
  5868. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5869. if patientPrescription.ID == 0 {
  5870. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5871. }
  5872. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5873. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5874. //
  5875. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5876. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5877. var pp models.PublicParams
  5878. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5879. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5880. pp.FixmedinsName = miConfig.OrgName
  5881. pp.FixmedinsCode = miConfig.Code
  5882. pp.RequestUrl = miConfig.Url
  5883. pp.Cainfo = miConfig.Cainfo
  5884. pp.SecretKey = miConfig.SecretKey
  5885. pp.AccessKey = miConfig.AccessKey
  5886. pp.OpterName = roles.UserName
  5887. var config []*models.HisXtDiagnoseConfig
  5888. for _, item := range diagnosis_ids {
  5889. id, _ := strconv.ParseInt(item, 10, 64)
  5890. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5891. config = append(config, &diagnosisConfig)
  5892. }
  5893. var pd models.PatientDtos
  5894. pd.PatnID = his.PsnNo
  5895. pd.PatnName = his.Name
  5896. pd.Gend = his.Gend
  5897. pd.Brdy = psn_info.Brdy
  5898. pd.Poolarea = his.InsuplcAdmdvs
  5899. pd.CurrMdtrtID = his.Number
  5900. var fed models.FsiEncounterDtos
  5901. fed.MdtrtID = his.Number
  5902. fed.MedinsID = miConfig.Code
  5903. fed.MedinsName = miConfig.OrgName
  5904. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5905. fed.MedMdtrtType = "1"
  5906. fed.MedinsType = "1"
  5907. fed.MedinsLv = "11"
  5908. tm := time.Unix(his.RecordDate, 0)
  5909. s_tm := tm.Format("2006-01-02 15:04:05")
  5910. fed.AdmDate = s_tm
  5911. fed.DscgDate = s_tm
  5912. fed.DscgMainDiseCodg = config[0].CountryCode
  5913. fed.DscgMainDiseName = config[0].CountryContentName
  5914. //诊断信息
  5915. var fdds []*models.FsiDiagnoseDtos
  5916. for index, item := range config {
  5917. if index == 0 {
  5918. var fdd models.FsiDiagnoseDtos
  5919. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5920. fdd.InoutDiseType = "1"
  5921. fdd.MaindiseFlag = "1"
  5922. fdd.DiseDate = s_tm
  5923. fdd.DiasSrtNo = "1"
  5924. fdd.DiseName = item.CountryContentName
  5925. fdd.DiseCodg = item.CountryCode
  5926. fdds = append(fdds, &fdd)
  5927. } else {
  5928. var fdd models.FsiDiagnoseDtos
  5929. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5930. fdd.InoutDiseType = "1"
  5931. fdd.MaindiseFlag = "1"
  5932. fdd.DiseDate = s_tm
  5933. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5934. fdd.DiseName = item.CountryContentName
  5935. fdd.DiseCodg = item.CountryCode
  5936. fdds = append(fdds, &fdd)
  5937. }
  5938. }
  5939. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5940. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5941. fed.AdmDeptName = department.Name
  5942. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5943. fed.DscgDeptName = department.Name
  5944. fed.MedMdtrtType = "1"
  5945. fed.MedType = "11"
  5946. //if his.Insutype == "390" {
  5947. // fed.MedType = "1402"
  5948. //} else {
  5949. // fed.MedType = "9933"
  5950. //}
  5951. var orders []*models.FsiOrderDtos
  5952. if trig_scen == "2" {
  5953. //处方医嘱信息
  5954. for _, item := range prescriptions {
  5955. for _, subItem := range item.HisDoctorAdviceInfo {
  5956. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5957. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5958. var order models.FsiOrderDtos
  5959. order.RxID = strconv.FormatInt(item.ID, 10)
  5960. order.Rxno = strconv.FormatInt(item.ID, 10)
  5961. order.LongDrordFlag = "0"
  5962. order.HilistType = "1"
  5963. order.ChrgType = "1"
  5964. order.DrordBhvr = "0"
  5965. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5966. order.HosplistName = subItem.BaseDrugLib.DrugName
  5967. order.HilistLv = "1"
  5968. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5969. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5970. order.HosplistName = subItem.BaseDrugLib.DrugName
  5971. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5972. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5973. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5974. order.OwnpayAmt = ""
  5975. order.SelfpayAmt = ""
  5976. order.Spec = spec
  5977. order.SpecUnt = subItem.PrescribingNumberUnit
  5978. order.DrordBegnDate = s_tm
  5979. order.DrordStopDate = ""
  5980. order.DrordDrCodg = doctor_info.DoctorNumber
  5981. order.DrordDeptName = department.Name
  5982. order.DrordDeptCodg = department.Number
  5983. order.DrordDrName = doctor_info.UserName
  5984. order.DrordDrProfttl = "234"
  5985. order.CurrDrordFlag = "1"
  5986. orders = append(orders, &order)
  5987. }
  5988. }
  5989. for _, subItem := range item.HisPrescriptionProject {
  5990. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5991. var order models.FsiOrderDtos
  5992. order.RxID = strconv.FormatInt(item.ID, 10)
  5993. order.Rxno = strconv.FormatInt(item.ID, 10)
  5994. order.LongDrordFlag = "0"
  5995. order.HilistType = "1"
  5996. order.ChrgType = "1"
  5997. order.DrordBhvr = "0"
  5998. order.HilistCode = subItem.HisProject.MedicalCode
  5999. order.HosplistName = subItem.HisProject.ProjectName
  6000. order.HilistLv = "1"
  6001. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6002. order.HosplistCode = subItem.HisProject.MedicalCode
  6003. order.HosplistName = subItem.HisProject.ProjectName
  6004. order.Cnt = subItem.Count
  6005. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6006. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6007. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6008. order.OwnpayAmt = ""
  6009. order.SelfpayAmt = ""
  6010. order.Spec = subItem.Unit
  6011. order.SpecUnt = subItem.Unit
  6012. order.DrordBegnDate = s_tm
  6013. order.DrordStopDate = ""
  6014. order.DrordDrCodg = doctor_info.DoctorNumber
  6015. order.DrordDeptName = department.Name
  6016. order.DrordDeptCodg = department.Number
  6017. order.DrordDrName = doctor_info.UserName
  6018. order.DrordDrProfttl = "234"
  6019. order.CurrDrordFlag = "1"
  6020. orders = append(orders, &order)
  6021. }
  6022. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6023. var order models.FsiOrderDtos
  6024. order.RxID = strconv.FormatInt(item.ID, 10)
  6025. order.Rxno = strconv.FormatInt(item.ID, 10)
  6026. order.LongDrordFlag = "0"
  6027. order.HilistType = "1"
  6028. order.ChrgType = "1"
  6029. order.DrordBhvr = "0"
  6030. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6031. order.HosplistName = subItem.GoodInfo.GoodName
  6032. order.HilistLv = "1"
  6033. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6034. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6035. order.HosplistName = subItem.GoodInfo.GoodName
  6036. order.Cnt = subItem.Count
  6037. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6038. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6039. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6040. order.OwnpayAmt = ""
  6041. order.SelfpayAmt = ""
  6042. order.Spec = subItem.GoodInfo.SpecificationName
  6043. order.SpecUnt = subItem.Unit
  6044. order.DrordBegnDate = s_tm
  6045. order.DrordStopDate = ""
  6046. order.DrordDrCodg = doctor_info.DoctorNumber
  6047. order.DrordDeptName = department.Name
  6048. order.DrordDeptCodg = department.Number
  6049. order.DrordDrName = doctor_info.UserName
  6050. order.DrordDrProfttl = "234"
  6051. order.CurrDrordFlag = "1"
  6052. orders = append(orders, &order)
  6053. }
  6054. }
  6055. }
  6056. //处方医嘱信息
  6057. }
  6058. fed.MatnStas = "0"
  6059. fed.MedfeeSumamt = "0"
  6060. fed.OwnpayAmt = "0"
  6061. fed.SelfpayAmt = "0"
  6062. fed.AcctPayamt = "0"
  6063. fed.MaAmt = "0"
  6064. fed.HifpPayamt = "0"
  6065. fed.SetlTotlnum = "1"
  6066. fed.Insutype = his.Insutype
  6067. fed.ReimFlag = "0"
  6068. fed.OutSetlFlag = "0"
  6069. var fopd []*models.FsiOperationDtosData
  6070. data := make(map[string]interface{})
  6071. data["fed"] = fed
  6072. data["fdd"] = fdds
  6073. data["fod"] = orders
  6074. data["pd"] = pd
  6075. data["pp"] = pp
  6076. data["fopd"] = fopd
  6077. data["trig_scen"] = trig_scen
  6078. fmt.Println(data)
  6079. fmt.Println(fed)
  6080. fmt.Println(fdds)
  6081. fmt.Println(orders)
  6082. fmt.Println(pd)
  6083. fmt.Println(pp)
  6084. fmt.Println(fopd)
  6085. client := &http.Client{}
  6086. bytesData, _ := json.Marshal(data)
  6087. var req *http.Request
  6088. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6089. if miConfig.MdtrtareaAdmvs == "320921" {
  6090. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6091. } else {
  6092. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6093. }
  6094. resp, _ := client.Do(req)
  6095. defer resp.Body.Close()
  6096. body, ioErr := ioutil.ReadAll(resp.Body)
  6097. if ioErr != nil {
  6098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6100. return res
  6101. }
  6102. var respJSON map[string]interface{}
  6103. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6106. return res
  6107. }
  6108. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6109. fmt.Println(respJSON)
  6110. result, _ := json.Marshal(respJSON)
  6111. fmt.Println(result)
  6112. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6113. utils.ErrorLog("解析失败:%v", err)
  6114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6115. return res
  6116. }
  6117. return res
  6118. } else {
  6119. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6120. saveLog(output, input, "3101", "事前")
  6121. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6122. utils.ErrorLog("解析失败:%v", err)
  6123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6124. return
  6125. }
  6126. return res
  6127. }
  6128. return res
  6129. }
  6130. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6131. ////patient_id, _ := c.GetInt64("patient_id")
  6132. //order_id, _ := c.GetInt64("order_id")
  6133. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6134. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6135. //trig_scen := c.GetString("trig_scen")
  6136. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6137. utils.ErrorLog("解析失败:%v", psn_info)
  6138. adminUser := c.GetAdminUserInfo()
  6139. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6140. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6141. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6142. record_time := c.GetString("record_time")
  6143. order, _ := service.GetHisOrderByID(order_id)
  6144. timeLayout := "2006-01-02"
  6145. loc, _ := time.LoadLocation("Local")
  6146. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6147. if err != nil {
  6148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6149. return
  6150. }
  6151. recordDateTime := theTime.Unix()
  6152. var patientPrescription models.HisPrescriptionInfo
  6153. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6154. if patientPrescription.ID == 0 {
  6155. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6156. }
  6157. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6158. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6159. //
  6160. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6161. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6162. var pp models.PublicParams
  6163. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6164. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6165. pp.FixmedinsName = miConfig.OrgName
  6166. pp.FixmedinsCode = miConfig.Code
  6167. pp.RequestUrl = miConfig.Url
  6168. pp.Cainfo = miConfig.Cainfo
  6169. pp.SecretKey = miConfig.SecretKey
  6170. pp.AccessKey = miConfig.AccessKey
  6171. pp.OpterName = roles.UserName
  6172. var config []*models.HisXtDiagnoseConfig
  6173. for _, item := range diagnosis_ids {
  6174. id, _ := strconv.ParseInt(item, 10, 64)
  6175. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6176. config = append(config, &diagnosisConfig)
  6177. }
  6178. var pd models.PatientDtos
  6179. pd.PatnID = his.PsnNo
  6180. pd.PatnName = his.Name
  6181. pd.Gend = his.Gend
  6182. pd.Brdy = psn_info.Brdy
  6183. pd.Poolarea = his.InsuplcAdmdvs
  6184. pd.CurrMdtrtID = his.Number
  6185. var fed models.FsiEncounterDtos
  6186. fed.MdtrtID = his.Number
  6187. fed.MedinsID = miConfig.Code
  6188. fed.MedinsName = miConfig.OrgName
  6189. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6190. fed.MedMdtrtType = "1"
  6191. fed.MedinsType = "1"
  6192. fed.MedinsLv = "11"
  6193. tm := time.Unix(his.RecordDate, 0)
  6194. s_tm := tm.Format("2006-01-02 15:04:05")
  6195. fed.AdmDate = s_tm
  6196. fed.DscgDate = s_tm
  6197. fed.DscgMainDiseCodg = config[0].CountryCode
  6198. fed.DscgMainDiseName = config[0].CountryContentName
  6199. //诊断信息
  6200. var fdds []*models.FsiDiagnoseDtos
  6201. for index, item := range config {
  6202. if index == 0 {
  6203. var fdd models.FsiDiagnoseDtos
  6204. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6205. fdd.InoutDiseType = "1"
  6206. fdd.MaindiseFlag = "1"
  6207. fdd.DiseDate = s_tm
  6208. fdd.DiasSrtNo = "1"
  6209. fdd.DiseName = item.CountryContentName
  6210. fdd.DiseCodg = item.CountryCode
  6211. fdds = append(fdds, &fdd)
  6212. } else {
  6213. var fdd models.FsiDiagnoseDtos
  6214. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6215. fdd.InoutDiseType = "1"
  6216. fdd.MaindiseFlag = "1"
  6217. fdd.DiseDate = s_tm
  6218. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6219. fdd.DiseName = item.CountryContentName
  6220. fdd.DiseCodg = item.CountryCode
  6221. fdds = append(fdds, &fdd)
  6222. }
  6223. }
  6224. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6225. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6226. fed.AdmDeptName = department.Name
  6227. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6228. fed.DscgDeptName = department.Name
  6229. fed.MedType = order.MedType
  6230. //处方医嘱信息
  6231. var orders []*models.FsiOrderDtos
  6232. //for _, item := range prescriptions {
  6233. // for _, subItem := range item.HisDoctorAdviceInfo {
  6234. // var order models.FsiOrderDtos
  6235. // order.RxID = strconv.FormatInt(item.ID, 10)
  6236. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6237. // order.LongDrordFlag = "0"
  6238. // order.HilistType = "1"
  6239. // order.ChrgType = "1"
  6240. // order.DrordBhvr = "-"
  6241. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6242. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6243. // order.HilistLv = "1"
  6244. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6245. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6246. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6247. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6248. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6249. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6250. // order.OwnpayAmt = ""
  6251. // order.SelfpayAmt = ""
  6252. // order.Spec = ""
  6253. // order.SpecUnt = ""
  6254. // order.DrordBegnDate = s_tm
  6255. // order.DrordStopDate = ""
  6256. // order.DrordDrCodg = "1"
  6257. // order.DrordDeptName = department.Name
  6258. // order.DrordDrCodg = "1"
  6259. // order.DrordDrName = doctor_info.UserName
  6260. // order.DrordDrProfttl = ""
  6261. // order.CurrDrordFlag = "1"
  6262. // orders = append(orders, &order)
  6263. // }
  6264. // for _, subItem := range item.HisPrescriptionProject {
  6265. // if subItem.Type == 2 {
  6266. // var order models.FsiOrderDtos
  6267. // order.RxID = strconv.FormatInt(item.ID, 10)
  6268. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6269. // order.LongDrordFlag = "0"
  6270. // order.HilistType = "1"
  6271. // order.ChrgType = "1"
  6272. // order.DrordBhvr = "-"
  6273. // order.HilistCode = subItem.HisProject.MedicalCode
  6274. // order.HosplistName = subItem.HisProject.ProjectName
  6275. // order.HilistLv = "1"
  6276. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6277. // order.HosplistCode = subItem.HisProject.MedicalCode
  6278. // order.HosplistName = subItem.HisProject.ProjectName
  6279. // order.Cnt = subItem.Count
  6280. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6281. //
  6282. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6283. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6284. // order.OwnpayAmt = ""
  6285. // order.SelfpayAmt = ""
  6286. // order.Spec = ""
  6287. // order.SpecUnt = ""
  6288. // order.DrordBegnDate = s_tm
  6289. // order.DrordStopDate = ""
  6290. // order.DrordDrCodg = "1"
  6291. // order.DrordDeptName = department.Name
  6292. // order.DrordDrCodg = "1"
  6293. // order.DrordDrName = doctor_info.UserName
  6294. // order.DrordDrProfttl = ""
  6295. // order.CurrDrordFlag = "1"
  6296. // orders = append(orders, &order)
  6297. //
  6298. // }
  6299. // if subItem.Type == 3 {
  6300. //
  6301. // var order models.FsiOrderDtos
  6302. // order.RxID = strconv.FormatInt(item.ID, 10)
  6303. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6304. // order.LongDrordFlag = "0"
  6305. // order.HilistType = "1"
  6306. // order.ChrgType = "1"
  6307. // order.DrordBhvr = "-"
  6308. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6309. // order.HosplistName = subItem.GoodInfo.GoodName
  6310. // order.HilistLv = "1"
  6311. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6312. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6313. // order.HosplistName = subItem.GoodInfo.GoodName
  6314. // order.Cnt = subItem.Count
  6315. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6316. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6317. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6318. // order.OwnpayAmt = ""
  6319. // order.SelfpayAmt = ""
  6320. // order.Spec = ""
  6321. // order.SpecUnt = ""
  6322. // order.DrordBegnDate = s_tm
  6323. // order.DrordStopDate = ""
  6324. // order.DrordDrCodg = "1"
  6325. // order.DrordDeptName = department.Name
  6326. // order.DrordDrCodg = "1"
  6327. // order.DrordDrName = doctor_info.UserName
  6328. // order.DrordDrProfttl = ""
  6329. // order.CurrDrordFlag = "1"
  6330. // orders = append(orders, &order)
  6331. //
  6332. // }
  6333. // }
  6334. //}
  6335. for _, item := range prescriptions {
  6336. for _, subItem := range item.HisDoctorAdviceInfo {
  6337. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6338. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6339. var order models.FsiOrderDtos
  6340. order.RxID = strconv.FormatInt(item.ID, 10)
  6341. order.Rxno = strconv.FormatInt(item.ID, 10)
  6342. order.LongDrordFlag = "0"
  6343. order.HilistType = "1"
  6344. order.ChrgType = "1"
  6345. order.DrordBhvr = "0"
  6346. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6347. order.HosplistName = subItem.BaseDrugLib.DrugName
  6348. order.HilistLv = "1"
  6349. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6350. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6351. order.HosplistName = subItem.BaseDrugLib.DrugName
  6352. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6353. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6354. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6355. order.OwnpayAmt = ""
  6356. order.SelfpayAmt = ""
  6357. order.Spec = spec
  6358. order.SpecUnt = subItem.PrescribingNumberUnit
  6359. order.DrordBegnDate = s_tm
  6360. order.DrordStopDate = ""
  6361. order.DrordDrCodg = doctor_info.DoctorNumber
  6362. order.DrordDeptName = department.Name
  6363. order.DrordDeptCodg = department.Number
  6364. order.DrordDrName = doctor_info.UserName
  6365. order.DrordDrProfttl = "234"
  6366. order.CurrDrordFlag = "1"
  6367. orders = append(orders, &order)
  6368. }
  6369. }
  6370. for _, subItem := range item.HisPrescriptionProject {
  6371. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6372. var order models.FsiOrderDtos
  6373. order.RxID = strconv.FormatInt(item.ID, 10)
  6374. order.Rxno = strconv.FormatInt(item.ID, 10)
  6375. order.LongDrordFlag = "0"
  6376. order.HilistType = "1"
  6377. order.ChrgType = "1"
  6378. order.DrordBhvr = "0"
  6379. order.HilistCode = subItem.HisProject.MedicalCode
  6380. order.HosplistName = subItem.HisProject.ProjectName
  6381. order.HilistLv = "1"
  6382. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6383. order.HosplistCode = subItem.HisProject.MedicalCode
  6384. order.HosplistName = subItem.HisProject.ProjectName
  6385. order.Cnt = subItem.Count
  6386. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6387. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6388. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6389. order.OwnpayAmt = ""
  6390. order.SelfpayAmt = ""
  6391. order.Spec = subItem.Unit
  6392. order.SpecUnt = subItem.Unit
  6393. order.DrordBegnDate = s_tm
  6394. order.DrordStopDate = ""
  6395. order.DrordDrCodg = doctor_info.DoctorNumber
  6396. order.DrordDeptName = department.Name
  6397. order.DrordDeptCodg = department.Number
  6398. order.DrordDrName = doctor_info.UserName
  6399. order.DrordDrProfttl = "234"
  6400. order.CurrDrordFlag = "1"
  6401. orders = append(orders, &order)
  6402. }
  6403. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6404. var order models.FsiOrderDtos
  6405. order.RxID = strconv.FormatInt(item.ID, 10)
  6406. order.Rxno = strconv.FormatInt(item.ID, 10)
  6407. order.LongDrordFlag = "0"
  6408. order.HilistType = "1"
  6409. order.ChrgType = "1"
  6410. order.DrordBhvr = "0"
  6411. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6412. order.HosplistName = subItem.GoodInfo.GoodName
  6413. order.HilistLv = "1"
  6414. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6415. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6416. order.HosplistName = subItem.GoodInfo.GoodName
  6417. order.Cnt = subItem.Count
  6418. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6419. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6420. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6421. order.OwnpayAmt = ""
  6422. order.SelfpayAmt = ""
  6423. order.Spec = subItem.GoodInfo.SpecificationName
  6424. order.SpecUnt = subItem.Unit
  6425. order.DrordBegnDate = s_tm
  6426. order.DrordStopDate = ""
  6427. order.DrordDrCodg = doctor_info.DoctorNumber
  6428. order.DrordDeptName = department.Name
  6429. order.DrordDeptCodg = department.Number
  6430. order.DrordDrName = doctor_info.UserName
  6431. order.DrordDrProfttl = "234"
  6432. order.CurrDrordFlag = "1"
  6433. orders = append(orders, &order)
  6434. }
  6435. }
  6436. }
  6437. //处方医嘱信息
  6438. fed.MatnStas = "0"
  6439. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6440. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6441. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6442. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6443. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6444. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6445. fed.SetlTotlnum = "1"
  6446. fed.Insutype = his.Insutype
  6447. fed.ReimFlag = "0"
  6448. fed.OutSetlFlag = "0"
  6449. var fopd []*models.FsiOperationDtosData
  6450. data := make(map[string]interface{})
  6451. data["fed"] = fed
  6452. data["fdd"] = fdds
  6453. data["fod"] = orders
  6454. data["pd"] = pd
  6455. data["pp"] = pp
  6456. data["fopd"] = fopd
  6457. data["trig_scen"] = trig_scen
  6458. client := &http.Client{}
  6459. bytesData, _ := json.Marshal(data)
  6460. var req *http.Request
  6461. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6462. if miConfig.MdtrtareaAdmvs == "320921" {
  6463. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6464. } else {
  6465. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6466. }
  6467. resp, _ := client.Do(req)
  6468. defer resp.Body.Close()
  6469. body, ioErr := ioutil.ReadAll(resp.Body)
  6470. if ioErr != nil {
  6471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6473. return res
  6474. }
  6475. var respJSON map[string]interface{}
  6476. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6479. return res
  6480. }
  6481. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6482. result, _ := json.Marshal(respJSON)
  6483. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6484. utils.ErrorLog("解析失败:%v", err)
  6485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6486. return res
  6487. }
  6488. return res
  6489. } else {
  6490. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6491. saveLog(output, input, "3102", "事中")
  6492. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6493. utils.ErrorLog("解析失败:%v", err)
  6494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6495. return
  6496. }
  6497. return res
  6498. }
  6499. return res
  6500. }
  6501. func (c *HisApiController) Check() {
  6502. psn_no := c.GetString("psn_no")
  6503. in := c.GetString("in")
  6504. mt := c.GetString("mt")
  6505. baseParams := models.BaseParams{
  6506. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  6507. FixmedinsCode: "H15049901371",
  6508. InsuplcAdmdvs: "150499",
  6509. MdtrtareaAdmvs: "150499",
  6510. OrgName: "赤峰费森血液透析中心",
  6511. Doctor: "1111",
  6512. }
  6513. service.Gdyb2001(baseParams, psn_no, in, mt)
  6514. }
  6515. func (c *HisApiController) GetPsnNcdsInfo() {
  6516. admin_user_id, _ := c.GetInt64("admin_user_id")
  6517. patient_id, _ := c.GetInt64("patient_id")
  6518. id, _ := c.GetInt64("id")
  6519. adminUser := c.GetAdminUserInfo()
  6520. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6521. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6522. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  6523. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6524. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6525. //
  6526. //if psn_record.ID == 0 {
  6527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6528. // return
  6529. //}
  6530. var res Result5301
  6531. var res10265 Result5301For10265
  6532. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6533. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6534. var api string
  6535. if miConfig.MdtrtareaAdmvs == "320921" {
  6536. 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 +
  6537. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6538. } else {
  6539. 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 +
  6540. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6541. }
  6542. resp, requestErr := http.Get(api)
  6543. if requestErr != nil {
  6544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6545. return
  6546. }
  6547. body, ioErr := ioutil.ReadAll(resp.Body)
  6548. if ioErr != nil {
  6549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6551. return
  6552. }
  6553. var respJSON map[string]interface{}
  6554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6557. return
  6558. }
  6559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6560. result, _ := json.Marshal(respJSON)
  6561. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6562. utils.ErrorLog("解析失败:%v", err)
  6563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6564. return
  6565. }
  6566. res.ErrMsg = res10265.ErrMsg
  6567. res.Output = res10265.Output
  6568. res.InfRefmsgid = res10265.InfRefmsgid
  6569. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6570. res.Infcode = infocode
  6571. } else if miConfig.MdtrtareaAdmvs == "341203" {
  6572. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6573. var api string
  6574. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  6575. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6576. resp, requestErr := http.Get(api)
  6577. if requestErr != nil {
  6578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6579. return
  6580. }
  6581. body, ioErr := ioutil.ReadAll(resp.Body)
  6582. if ioErr != nil {
  6583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6585. return
  6586. }
  6587. var respJSON map[string]interface{}
  6588. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6591. return
  6592. }
  6593. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6594. if status == "0" {
  6595. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6596. c.ServeSuccessJSON(map[string]interface{}{
  6597. "failed_code": -10,
  6598. "msg": err_msg,
  6599. })
  6600. return
  6601. }
  6602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6603. result, _ := json.Marshal(respJSON)
  6604. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6605. utils.ErrorLog("解析失败:%v", err)
  6606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6607. return
  6608. }
  6609. } else if miConfig.MdtrtareaAdmvs == "360302" {
  6610. p, _ := service.GetHisPatientById(patient_id)
  6611. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  6612. var dat map[string]interface{}
  6613. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6614. fmt.Println(dat)
  6615. } else {
  6616. fmt.Println(err)
  6617. }
  6618. userJSONBytes, _ := json.Marshal(dat)
  6619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6620. utils.ErrorLog("解析失败:%v", err)
  6621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6622. return
  6623. }
  6624. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6625. p, _ := service.GetHisPatientById(patient_id)
  6626. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  6627. var dat map[string]interface{}
  6628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6629. fmt.Println(dat)
  6630. } else {
  6631. fmt.Println(err)
  6632. }
  6633. userJSONBytes, _ := json.Marshal(dat)
  6634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6635. utils.ErrorLog("解析失败:%v", err)
  6636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6637. return
  6638. }
  6639. } else if miConfig.MdtrtareaAdmvs == "420200" {
  6640. p, _ := service.GetHisPatientById(patient_id)
  6641. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  6642. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6643. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6644. resp, requestErr := http.Get(api)
  6645. if requestErr != nil {
  6646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6647. return
  6648. }
  6649. body, ioErr := ioutil.ReadAll(resp.Body)
  6650. if ioErr != nil {
  6651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6653. return
  6654. }
  6655. var respJSON map[string]interface{}
  6656. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6659. return
  6660. }
  6661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6662. result, _ := json.Marshal(respJSON)
  6663. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6664. utils.ErrorLog("解析失败:%v", err)
  6665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6666. return
  6667. }
  6668. } else if miConfig.MdtrtareaAdmvs == "421182" {
  6669. p, _ := service.GetHisPatientById(patient_id)
  6670. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  6671. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6672. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6673. resp, requestErr := http.Get(api)
  6674. if requestErr != nil {
  6675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6676. return
  6677. }
  6678. body, ioErr := ioutil.ReadAll(resp.Body)
  6679. if ioErr != nil {
  6680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6682. return
  6683. }
  6684. var respJSON map[string]interface{}
  6685. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6688. return
  6689. }
  6690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6691. result, _ := json.Marshal(respJSON)
  6692. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6693. utils.ErrorLog("解析失败:%v", err)
  6694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6695. return
  6696. }
  6697. } else if miConfig.MdtrtareaAdmvs == "421300" {
  6698. p, _ := service.GetHisPatientById(patient_id)
  6699. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  6700. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6701. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6702. resp, requestErr := http.Get(api)
  6703. if requestErr != nil {
  6704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6705. return
  6706. }
  6707. body, ioErr := ioutil.ReadAll(resp.Body)
  6708. if ioErr != nil {
  6709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6711. return
  6712. }
  6713. var respJSON map[string]interface{}
  6714. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6717. return
  6718. }
  6719. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6720. result, _ := json.Marshal(respJSON)
  6721. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6722. utils.ErrorLog("解析失败:%v", err)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. return
  6725. }
  6726. } else if miConfig.MdtrtareaAdmvs == "441799" {
  6727. p, _ := service.GetHisPatientById(patient_id)
  6728. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  6729. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6730. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6731. resp, requestErr := http.Get(api)
  6732. if requestErr != nil {
  6733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6734. return
  6735. }
  6736. body, ioErr := ioutil.ReadAll(resp.Body)
  6737. if ioErr != nil {
  6738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6740. return
  6741. }
  6742. var respJSON map[string]interface{}
  6743. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6746. return
  6747. }
  6748. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6749. result, _ := json.Marshal(respJSON)
  6750. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6751. utils.ErrorLog("解析失败:%v", err)
  6752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6753. return
  6754. }
  6755. } else {
  6756. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6757. var dat map[string]interface{}
  6758. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6759. fmt.Println(dat)
  6760. } else {
  6761. fmt.Println(err)
  6762. }
  6763. userJSONBytes, _ := json.Marshal(dat)
  6764. if miConfig.Code == "H15049901371" {
  6765. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  6766. utils.ErrorLog("解析失败:%v", err)
  6767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6768. return
  6769. }
  6770. res.InfRefmsgid = res10265.InfRefmsgid
  6771. res.Output = res10265.Output
  6772. res.ErrMsg = res10265.ErrMsg
  6773. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6774. res.Infcode = infocode
  6775. } else {
  6776. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6777. utils.ErrorLog("解析失败:%v", err)
  6778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6779. return
  6780. }
  6781. }
  6782. }
  6783. if res.Infcode == 0 {
  6784. c.ServeSuccessJSON(map[string]interface{}{
  6785. "result": res.Output.Result,
  6786. })
  6787. }
  6788. }
  6789. func (c *HisApiController) CheckInsutype() {
  6790. his_patient_id, _ := c.GetInt64("his_patient_id")
  6791. admin_user_id, _ := c.GetInt64("admin_user_id")
  6792. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6793. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6794. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6795. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6796. var dat map[string]interface{}
  6797. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6798. fmt.Println(dat)
  6799. } else {
  6800. fmt.Println(err)
  6801. }
  6802. userJSONBytes, _ := json.Marshal(dat)
  6803. var res Result90100
  6804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6805. utils.ErrorLog("解析失败:%v", err)
  6806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6807. return
  6808. }
  6809. if res.Infcode != 0 {
  6810. c.ServeSuccessJSON(map[string]interface{}{
  6811. "failed_code": -10,
  6812. "msg": res.ErrMsg,
  6813. })
  6814. return
  6815. } else {
  6816. fmt.Println(res)
  6817. }
  6818. }
  6819. func (c *HisApiController) CheckCardPWD() {
  6820. card_pwd := c.GetString("card_pwd")
  6821. his_patient_id, _ := c.GetInt64("his_patient_id")
  6822. admin_user_id, _ := c.GetInt64("admin_user_id")
  6823. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6824. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6825. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6826. psn, _ := service.GetPsnByPatientId(his.PatientId)
  6827. bas := strings.Split(psn.CardInfo, "|")
  6828. basNumber := bas[2]
  6829. if psn.InsuplcAdmdvs[:4] == "4403" {
  6830. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  6831. var dat map[string]interface{}
  6832. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6833. fmt.Println(dat)
  6834. } else {
  6835. fmt.Println(err)
  6836. }
  6837. userJSONBytes, _ := json.Marshal(dat)
  6838. var res Result90991
  6839. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6840. utils.ErrorLog("解析失败:%v", err)
  6841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6842. return
  6843. }
  6844. if res.Infcode != 0 {
  6845. c.ServeSuccessJSON(map[string]interface{}{
  6846. "failed_code": -10,
  6847. "msg": res.ErrMsg,
  6848. })
  6849. return
  6850. } else {
  6851. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  6852. var msg string
  6853. switch res.Output.Result.CardStat {
  6854. case "00":
  6855. msg = "未激活"
  6856. break
  6857. case "10":
  6858. msg = "激活"
  6859. break
  6860. case "20":
  6861. msg = "窗口挂失"
  6862. break
  6863. case "21":
  6864. msg = "电话挂失"
  6865. break
  6866. case "22":
  6867. msg = "单位网上申报挂失"
  6868. break
  6869. case "23":
  6870. msg = "保健办挂失"
  6871. break
  6872. case "24":
  6873. msg = "个人网上挂失"
  6874. break
  6875. case "25":
  6876. msg = "网上服务大厅挂失"
  6877. break
  6878. case "30":
  6879. msg = "注销"
  6880. break
  6881. case "40":
  6882. msg = "回收"
  6883. break
  6884. case "99":
  6885. msg = "制卡中(无效卡)"
  6886. break
  6887. }
  6888. c.ServeSuccessJSON(map[string]interface{}{
  6889. "failed_code": -10,
  6890. "msg": msg,
  6891. })
  6892. return
  6893. } else {
  6894. c.ServeSuccessJSON(map[string]interface{}{
  6895. "msg": "校验成功",
  6896. })
  6897. return
  6898. }
  6899. }
  6900. } else {
  6901. c.ServeSuccessJSON(map[string]interface{}{
  6902. "msg": "校验成功",
  6903. })
  6904. return
  6905. }
  6906. }
  6907. func (c *HisApiController) CheckCardPWDTwo() {
  6908. //card_pwd := c.GetString("card_pwd")
  6909. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6910. admin_user_id, _ := c.GetInt64("admin_user_id")
  6911. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6912. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6913. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  6914. var dat map[string]interface{}
  6915. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6916. fmt.Println(dat)
  6917. } else {
  6918. fmt.Println(err)
  6919. }
  6920. userJSONBytes, _ := json.Marshal(dat)
  6921. var res Result90991
  6922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6923. utils.ErrorLog("解析失败:%v", err)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. return
  6926. }
  6927. if res.Infcode != 0 {
  6928. c.ServeSuccessJSON(map[string]interface{}{
  6929. "failed_code": -10,
  6930. "msg": res.ErrMsg,
  6931. })
  6932. return
  6933. } else {
  6934. if res.Output.Result.SscnoCheckStat == "0" {
  6935. var msg string
  6936. switch res.Output.Result.CardStat {
  6937. case "00":
  6938. msg = "未激活"
  6939. break
  6940. case "10":
  6941. msg = "激活"
  6942. break
  6943. case "20":
  6944. msg = "窗口挂失"
  6945. break
  6946. case "21":
  6947. msg = "电话挂失"
  6948. break
  6949. case "22":
  6950. msg = "单位网上申报挂失"
  6951. break
  6952. case "23":
  6953. msg = "保健办挂失"
  6954. break
  6955. case "24":
  6956. msg = "个人网上挂失"
  6957. break
  6958. case "25":
  6959. msg = "网上服务大厅挂失"
  6960. break
  6961. case "30":
  6962. msg = "注销"
  6963. break
  6964. case "40":
  6965. msg = "回收"
  6966. break
  6967. case "99":
  6968. msg = "制卡中(无效卡)"
  6969. break
  6970. }
  6971. c.ServeSuccessJSON(map[string]interface{}{
  6972. "failed_code": -10,
  6973. "msg": msg,
  6974. })
  6975. return
  6976. } else {
  6977. c.ServeSuccessJSON(map[string]interface{}{
  6978. "msg": "校验成功",
  6979. })
  6980. return
  6981. }
  6982. }
  6983. }
  6984. type ELeCertData struct {
  6985. Data struct {
  6986. Extra string `json:"extra"`
  6987. IDNo string `json:"idNo"`
  6988. IDType string `json:"idType"`
  6989. EcToken string `json:"ecToken"`
  6990. InsuOrg string `json:"insuOrg"`
  6991. UserName string `json:"userName"`
  6992. EcIndexNo string `json:"ecIndexNo"`
  6993. Gender string `json:"gender"`
  6994. Birthday string `json:"birthday"`
  6995. Nationality string `json:"nationality"`
  6996. Email string `json:"email"`
  6997. } `json:"OutData"`
  6998. }
  6999. func (c *HisApiController) ReadCard() {
  7000. id_card_type, _ := c.GetInt64("id_card_type")
  7001. admin_user_id, _ := c.GetInt64("admin_user_id")
  7002. certificates, _ := c.GetInt64("certificates")
  7003. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7004. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7005. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7006. switch id_card_type {
  7007. case 1:
  7008. if miConfig.MdtrtareaAdmvs == "421300" {
  7009. var res ResultTwo
  7010. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7011. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7012. "&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)
  7013. resp, requestErr := http.Get(api)
  7014. if requestErr != nil {
  7015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7016. return
  7017. }
  7018. body, ioErr := ioutil.ReadAll(resp.Body)
  7019. if ioErr != nil {
  7020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7022. return
  7023. }
  7024. var respJSON map[string]interface{}
  7025. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7028. return
  7029. }
  7030. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7031. result, _ := json.Marshal(respJSON)
  7032. fmt.Println("log")
  7033. fmt.Println(string(result))
  7034. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7035. utils.ErrorLog("解析失败:%v", err)
  7036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7037. return
  7038. }
  7039. if res.Infcode == 0 {
  7040. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7041. if err == gorm.ErrRecordNotFound {
  7042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7043. return
  7044. } else if err != nil {
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7046. return
  7047. } else {
  7048. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7049. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7050. infoStr := string(Iinfos)
  7051. idetinfoStr := string(Idetinfos)
  7052. var rf []*ResultFive
  7053. json.Unmarshal([]byte(infoStr), &rf)
  7054. var insutypes []*ResultFive
  7055. var insutype string
  7056. var is390 int = 0
  7057. var is310 int = 0
  7058. for _, item := range rf {
  7059. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7060. insutypes = append(insutypes, item)
  7061. }
  7062. }
  7063. if len(insutypes) == 1 {
  7064. insutype = insutypes[0].Insutype
  7065. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7066. } else {
  7067. for _, i := range insutypes {
  7068. if i.Insutype == "390" {
  7069. is390 = 1
  7070. }
  7071. if i.Insutype == "310" {
  7072. is310 = 1
  7073. }
  7074. }
  7075. }
  7076. if is390 == 1 {
  7077. insutype = "390"
  7078. }
  7079. if is310 == 1 {
  7080. insutype = "310"
  7081. }
  7082. if len(insutypes) == 0 {
  7083. insutype = "390"
  7084. }
  7085. var insuplc_admdvs string
  7086. for _, item := range rf {
  7087. if item.Insutype == insutype {
  7088. insuplc_admdvs = item.InsuplcAdmdvs
  7089. }
  7090. }
  7091. if strings.Contains(insuplc_admdvs, "4213") {
  7092. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7093. }
  7094. psn := &models.HisPsn{
  7095. PsnNo: res.Output.Baseinfo.PsnNo,
  7096. PatientId: patient.ID,
  7097. Certno: res.Output.Baseinfo.Certno,
  7098. Gend: res.Output.Baseinfo.Gend,
  7099. Naty: res.Output.Baseinfo.Naty,
  7100. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7101. PsnName: res.Output.Baseinfo.PsnName,
  7102. Idetinfo: idetinfoStr,
  7103. Insuinfo: infoStr,
  7104. InsuplcAdmdvs: insuplc_admdvs,
  7105. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7106. }
  7107. service.CreateHisPsn(psn)
  7108. c.ServeSuccessJSON(map[string]interface{}{
  7109. "patient": patient,
  7110. "number": res.Output.Baseinfo.Certno,
  7111. })
  7112. }
  7113. } else {
  7114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7115. return
  7116. }
  7117. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7118. var res ResultTwo
  7119. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7120. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7121. "&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)
  7122. resp, requestErr := http.Get(api)
  7123. if requestErr != nil {
  7124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7125. return
  7126. }
  7127. body, ioErr := ioutil.ReadAll(resp.Body)
  7128. if ioErr != nil {
  7129. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7131. return
  7132. }
  7133. var respJSON map[string]interface{}
  7134. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7137. return
  7138. }
  7139. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7140. result, _ := json.Marshal(respJSON)
  7141. fmt.Println("log")
  7142. fmt.Println(string(result))
  7143. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7144. utils.ErrorLog("解析失败:%v", err)
  7145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7146. return
  7147. }
  7148. if res.Infcode == 0 {
  7149. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7150. if err == gorm.ErrRecordNotFound {
  7151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7152. return
  7153. } else if err != nil {
  7154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7155. return
  7156. } else {
  7157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7159. infoStr := string(Iinfos)
  7160. idetinfoStr := string(Idetinfos)
  7161. psn := &models.HisPsn{
  7162. PsnNo: res.Output.Baseinfo.PsnNo,
  7163. PatientId: patient.ID,
  7164. Certno: res.Output.Baseinfo.Certno,
  7165. Gend: res.Output.Baseinfo.Gend,
  7166. Naty: res.Output.Baseinfo.Naty,
  7167. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7168. PsnName: res.Output.Baseinfo.PsnName,
  7169. Idetinfo: idetinfoStr,
  7170. Insuinfo: infoStr,
  7171. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7172. }
  7173. service.CreateHisPsn(psn)
  7174. var rf []*ResultFive
  7175. json.Unmarshal([]byte(infoStr), &rf)
  7176. var insutypes []*ResultFive
  7177. var insutype string
  7178. var is390 int = 0
  7179. var is310 int = 0
  7180. for _, item := range rf {
  7181. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7182. insutypes = append(insutypes, item)
  7183. }
  7184. }
  7185. if len(insutypes) == 1 {
  7186. insutype = insutypes[0].Insutype
  7187. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7188. } else {
  7189. for _, i := range insutypes {
  7190. if i.Insutype == "390" {
  7191. is390 = 1
  7192. }
  7193. if i.Insutype == "310" {
  7194. is310 = 1
  7195. }
  7196. }
  7197. }
  7198. if is390 == 1 {
  7199. insutype = "390"
  7200. }
  7201. if is310 == 1 {
  7202. insutype = "310"
  7203. }
  7204. if len(insutypes) == 0 {
  7205. insutype = "310"
  7206. }
  7207. c.ServeSuccessJSON(map[string]interface{}{
  7208. "patient": patient,
  7209. "number": res.Output.Baseinfo.Certno,
  7210. "insutype": insutype,
  7211. })
  7212. }
  7213. } else {
  7214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7215. return
  7216. }
  7217. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7218. var res ResultTwo
  7219. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  7220. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7221. "&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)
  7222. resp, requestErr := http.Get(api)
  7223. if requestErr != nil {
  7224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7225. return
  7226. }
  7227. body, ioErr := ioutil.ReadAll(resp.Body)
  7228. if ioErr != nil {
  7229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7231. return
  7232. }
  7233. var respJSON map[string]interface{}
  7234. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7237. return
  7238. }
  7239. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7240. result, _ := json.Marshal(respJSON)
  7241. fmt.Println("log")
  7242. fmt.Println(string(result))
  7243. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7244. utils.ErrorLog("解析失败:%v", err)
  7245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7246. return
  7247. }
  7248. if res.Infcode == 0 {
  7249. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7250. if err == gorm.ErrRecordNotFound {
  7251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7252. return
  7253. } else if err != nil {
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7255. return
  7256. } else {
  7257. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7258. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7259. infoStr := string(Iinfos)
  7260. idetinfoStr := string(Idetinfos)
  7261. psn := &models.HisPsn{
  7262. PsnNo: res.Output.Baseinfo.PsnNo,
  7263. PatientId: patient.ID,
  7264. Certno: res.Output.Baseinfo.Certno,
  7265. Gend: res.Output.Baseinfo.Gend,
  7266. Naty: res.Output.Baseinfo.Naty,
  7267. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7268. PsnName: res.Output.Baseinfo.PsnName,
  7269. Idetinfo: idetinfoStr,
  7270. Insuinfo: infoStr,
  7271. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7272. }
  7273. service.CreateHisPsn(psn)
  7274. var rf []*ResultFive
  7275. json.Unmarshal([]byte(infoStr), &rf)
  7276. var insutypes []*ResultFive
  7277. var insutype string
  7278. var is390 int = 0
  7279. var is310 int = 0
  7280. for _, item := range rf {
  7281. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7282. insutypes = append(insutypes, item)
  7283. }
  7284. }
  7285. if len(insutypes) == 1 {
  7286. insutype = insutypes[0].Insutype
  7287. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7288. } else {
  7289. for _, i := range insutypes {
  7290. if i.Insutype == "390" {
  7291. is390 = 1
  7292. }
  7293. if i.Insutype == "310" {
  7294. is310 = 1
  7295. }
  7296. }
  7297. }
  7298. if is390 == 1 {
  7299. insutype = "390"
  7300. }
  7301. if is310 == 1 {
  7302. insutype = "310"
  7303. }
  7304. if len(insutypes) == 0 {
  7305. insutype = "310"
  7306. }
  7307. c.ServeSuccessJSON(map[string]interface{}{
  7308. "patient": patient,
  7309. "number": res.Output.Baseinfo.Certno,
  7310. "insutype": insutype,
  7311. })
  7312. }
  7313. } else {
  7314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7315. return
  7316. }
  7317. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7318. var api string
  7319. if miConfig.MdtrtareaAdmvs == "320921" {
  7320. 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 +
  7321. "&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
  7322. fmt.Println(api)
  7323. } else {
  7324. 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 +
  7325. "&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)
  7326. }
  7327. resp, requestErr := http.Get(api)
  7328. if requestErr != nil {
  7329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7330. return
  7331. }
  7332. body, ioErr := ioutil.ReadAll(resp.Body)
  7333. if ioErr != nil {
  7334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7336. return
  7337. }
  7338. var respJSON map[string]interface{}
  7339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7342. return
  7343. }
  7344. var status string
  7345. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7346. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7347. //console.log()
  7348. fmt.Println("type===")
  7349. fmt.Println(card_type)
  7350. var token string
  7351. var res ResultTwo //1101结果
  7352. var res10265 ResultTwo10265 //1101结果
  7353. var card_info string //卡信息
  7354. var busi_card_info string
  7355. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7356. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7357. if status == "0" { //读卡成功
  7358. if card_type == "1" {
  7359. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7360. result, _ := json.Marshal(respJSON)
  7361. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7362. utils.ErrorLog("解析失败:%v", err)
  7363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7364. return
  7365. }
  7366. res.ErrMsg = res10265.ErrMsg
  7367. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7368. res.Infcode = infocode
  7369. res.Output = res10265.Output
  7370. res.InfRefmsgid = res10265.InfRefmsgid
  7371. } else {
  7372. //var card_info string //卡信息
  7373. //var busi_card_info string
  7374. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7375. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7376. //fmt.Println(card_info)
  7377. //fmt.Println(busi_card_info)
  7378. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7379. result, _ := json.Marshal(respJSON)
  7380. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7381. utils.ErrorLog("解析失败:%v", err)
  7382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7383. return
  7384. }
  7385. res.ErrMsg = res10265.ErrMsg
  7386. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7387. res.Infcode = infocode
  7388. res.Output = res10265.Output
  7389. res.InfRefmsgid = res10265.InfRefmsgid
  7390. }
  7391. if res.Infcode == 0 {
  7392. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7393. if err == gorm.ErrRecordNotFound {
  7394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7395. return
  7396. } else if err != nil {
  7397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7398. return
  7399. } else {
  7400. if card_type == "1" {
  7401. bas := strings.Split(card_info, "|")
  7402. basNumber := bas[2]
  7403. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7404. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7405. infoStr := string(Iinfos)
  7406. idetinfoStr := string(Idetinfos)
  7407. psn := &models.HisPsn{
  7408. PsnNo: res.Output.Baseinfo.PsnNo,
  7409. PatientId: patient.ID,
  7410. Certno: res.Output.Baseinfo.Certno,
  7411. //Brdy: res.Output.Baseinfo.Brdy,
  7412. Gend: res.Output.Baseinfo.Gend,
  7413. Naty: res.Output.Baseinfo.Naty,
  7414. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7415. PsnName: res.Output.Baseinfo.PsnName,
  7416. Idetinfo: idetinfoStr,
  7417. Insuinfo: infoStr,
  7418. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7419. CardInfo: card_info,
  7420. VerifyNumber: busi_card_info,
  7421. }
  7422. service.CreateHisPsn(psn)
  7423. var rf []*ResultFive
  7424. json.Unmarshal([]byte(infoStr), &rf)
  7425. var insutypes []*ResultFive
  7426. var insutype string
  7427. var is390 int = 0
  7428. var is310 int = 0
  7429. for _, item := range rf {
  7430. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7431. insutypes = append(insutypes, item)
  7432. }
  7433. }
  7434. if len(insutypes) == 1 {
  7435. insutype = insutypes[0].Insutype
  7436. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7437. } else {
  7438. for _, i := range insutypes {
  7439. if i.Insutype == "390" {
  7440. is390 = 1
  7441. }
  7442. if i.Insutype == "310" {
  7443. is310 = 1
  7444. }
  7445. }
  7446. }
  7447. if is390 == 1 {
  7448. insutype = "390"
  7449. }
  7450. if is310 == 1 {
  7451. insutype = "310"
  7452. }
  7453. if len(insutypes) == 0 {
  7454. insutype = "310"
  7455. }
  7456. c.ServeSuccessJSON(map[string]interface{}{
  7457. "patient": patient,
  7458. "number": basNumber,
  7459. "insutype": insutype,
  7460. })
  7461. } else {
  7462. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7463. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7464. infoStr := string(Iinfos)
  7465. idetinfoStr := string(Idetinfos)
  7466. psn := &models.HisPsn{
  7467. PsnNo: res.Output.Baseinfo.PsnNo,
  7468. PatientId: patient.ID,
  7469. Certno: res.Output.Baseinfo.Certno,
  7470. Gend: res.Output.Baseinfo.Gend,
  7471. Naty: res.Output.Baseinfo.Naty,
  7472. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7473. PsnName: res.Output.Baseinfo.PsnName,
  7474. Idetinfo: idetinfoStr,
  7475. Insuinfo: infoStr,
  7476. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7477. CardInfo: card_info,
  7478. VerifyNumber: token,
  7479. }
  7480. service.CreateHisPsn(psn)
  7481. c.ServeSuccessJSON(map[string]interface{}{
  7482. "patient": patient,
  7483. "number": token,
  7484. })
  7485. }
  7486. }
  7487. } else {
  7488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7489. return
  7490. }
  7491. } else { //读卡失败
  7492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7493. return
  7494. }
  7495. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7496. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  7497. cardnum = DeleteExtraSpaceTwo(cardnum)
  7498. cardCode = DeleteExtraSpaceTwo(cardCode)
  7499. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  7500. name = DeleteExtraSpaceTwo(name)
  7501. errmsg = DeleteExtraSpaceTwo(errmsg)
  7502. cardnum = Remove0000(cardnum)
  7503. cardCode = Remove0000(cardCode)
  7504. id_card_no = Remove0000(id_card_no)
  7505. name = Remove0000(name)
  7506. errmsg = Remove0000(errmsg)
  7507. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  7508. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  7509. //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)
  7510. //fmt.Println(result2)
  7511. //fmt.Println(requestLog2)
  7512. //fmt.Println(errMsgLog2)
  7513. 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)
  7514. saveLog(result, requestLog, "1101", "获取人员信息")
  7515. fmt.Println(errMsgLog)
  7516. if len(errMsgLog) > 0 {
  7517. } else {
  7518. var dat map[string]interface{}
  7519. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7520. fmt.Println(dat)
  7521. } else {
  7522. fmt.Println(err)
  7523. }
  7524. userJSONBytes, _ := json.Marshal(dat)
  7525. var res ResultTwo
  7526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7527. utils.ErrorLog("解析失败:%v", err)
  7528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7529. return
  7530. }
  7531. res.ErrMsg = errMsgLog
  7532. if res.Infcode == 0 {
  7533. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7534. if err == gorm.ErrRecordNotFound {
  7535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7536. return
  7537. } else if err != nil {
  7538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7539. return
  7540. } else {
  7541. fmt.Println(res)
  7542. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7543. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7544. infoStr := string(Iinfos)
  7545. idetinfoStr := string(Idetinfos)
  7546. var rf []*ResultFive
  7547. json.Unmarshal([]byte(infoStr), &rf)
  7548. var insutypes []*ResultFive
  7549. var insutype string
  7550. var is390 int = 0
  7551. var is310 int = 0
  7552. for _, item := range rf {
  7553. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7554. insutypes = append(insutypes, item)
  7555. }
  7556. }
  7557. if len(insutypes) == 1 {
  7558. insutype = insutypes[0].Insutype
  7559. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7560. } else {
  7561. for _, i := range insutypes {
  7562. if i.Insutype == "390" {
  7563. is390 = 1
  7564. }
  7565. if i.Insutype == "310" {
  7566. is310 = 1
  7567. }
  7568. }
  7569. }
  7570. if is390 == 1 {
  7571. insutype = "390"
  7572. }
  7573. if is310 == 1 {
  7574. insutype = "310"
  7575. }
  7576. if len(insutypes) == 0 {
  7577. insutype = "390"
  7578. }
  7579. var insuplc_admdvs string
  7580. for _, item := range rf {
  7581. if item.Insutype == insutype {
  7582. insuplc_admdvs = item.InsuplcAdmdvs
  7583. }
  7584. }
  7585. psn := &models.HisPsn{
  7586. PsnNo: res.Output.Baseinfo.PsnNo,
  7587. PatientId: patient.ID,
  7588. Certno: res.Output.Baseinfo.Certno,
  7589. Gend: res.Output.Baseinfo.Gend,
  7590. Naty: res.Output.Baseinfo.Naty,
  7591. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7592. PsnName: res.Output.Baseinfo.PsnName,
  7593. Idetinfo: idetinfoStr,
  7594. Insuinfo: infoStr,
  7595. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7596. CardInfo: basStr,
  7597. VerifyNumber: "",
  7598. InsuplcAdmdvs: insuplc_admdvs,
  7599. }
  7600. service.CreateHisPsn(psn)
  7601. c.ServeSuccessJSON(map[string]interface{}{
  7602. "patient": patient,
  7603. "number": cardnum,
  7604. "insutype": insutype,
  7605. })
  7606. }
  7607. } else {
  7608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7609. return
  7610. }
  7611. }
  7612. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7613. fmt.Println(initFlag)
  7614. fmt.Println("initFlag")
  7615. if initFlag == 0 {
  7616. c.TestGetJiangXiBasBaseInit()
  7617. }
  7618. basStr := c.GetBasBaseInfo()
  7619. if len(basStr) == 0 {
  7620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7621. return
  7622. }
  7623. fmt.Println(basStr)
  7624. bas := strings.Split(basStr, "|")
  7625. basNumber := bas[1]
  7626. fmt.Println(basNumber)
  7627. card_sn := bas[3]
  7628. fmt.Println(card_sn)
  7629. 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, "")
  7630. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  7631. var dat map[string]interface{}
  7632. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7633. fmt.Println(dat)
  7634. } else {
  7635. fmt.Println(err)
  7636. }
  7637. userJSONBytes, _ := json.Marshal(dat)
  7638. var res ResultTwo
  7639. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7640. utils.ErrorLog("解析失败:%v", err)
  7641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7642. return
  7643. }
  7644. if res.Infcode == 0 {
  7645. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  7646. if err == gorm.ErrRecordNotFound {
  7647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7648. return
  7649. } else if err != nil {
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7651. return
  7652. } else {
  7653. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7654. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7655. infoStr := string(Iinfos)
  7656. idetinfoStr := string(Idetinfos)
  7657. var rf []*ResultFive
  7658. json.Unmarshal([]byte(infoStr), &rf)
  7659. var insutypes []*ResultFive
  7660. var insutype string
  7661. var is390 int = 0
  7662. var is310 int = 0
  7663. var insuplc_admdvs string
  7664. for _, item := range rf {
  7665. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7666. insutypes = append(insutypes, item)
  7667. }
  7668. }
  7669. if len(insutypes) == 1 {
  7670. insutype = insutypes[0].Insutype
  7671. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7672. } else {
  7673. for _, i := range insutypes {
  7674. if i.Insutype == "390" {
  7675. is390 = 1
  7676. }
  7677. if i.Insutype == "310" {
  7678. is310 = 1
  7679. }
  7680. }
  7681. }
  7682. if is390 == 1 {
  7683. insutype = "390"
  7684. }
  7685. if is310 == 1 {
  7686. insutype = "310"
  7687. }
  7688. if len(insutypes) == 0 {
  7689. insutype = "310"
  7690. }
  7691. for _, item := range rf {
  7692. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  7693. insuplc_admdvs = item.InsuplcAdmdvs
  7694. }
  7695. }
  7696. psn := &models.HisPsn{
  7697. PsnNo: res.Output.Baseinfo.PsnNo,
  7698. PatientId: patient.ID,
  7699. Certno: res.Output.Baseinfo.Certno,
  7700. Gend: res.Output.Baseinfo.Gend,
  7701. Naty: res.Output.Baseinfo.Naty,
  7702. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7703. PsnName: res.Output.Baseinfo.PsnName,
  7704. Idetinfo: idetinfoStr,
  7705. Insuinfo: infoStr,
  7706. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7707. CardInfo: basStr,
  7708. InsuplcAdmdvs: insuplc_admdvs,
  7709. VerifyNumber: "",
  7710. }
  7711. service.CreateHisPsn(psn)
  7712. c.ServeSuccessJSON(map[string]interface{}{
  7713. "patient": patient,
  7714. "number": basNumber,
  7715. "insutype": insutype,
  7716. })
  7717. }
  7718. } else {
  7719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7720. return
  7721. }
  7722. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7723. fmt.Println(initFlag)
  7724. fmt.Println("initFlag")
  7725. if initFlag == 0 {
  7726. c.TestGetHnBasBaseInit()
  7727. }
  7728. basStr := c.GetBasBaseInfo()
  7729. if len(basStr) == 0 {
  7730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7731. return
  7732. }
  7733. fmt.Println(basStr)
  7734. bas := strings.Split(basStr, "|")
  7735. basNumber := bas[1]
  7736. fmt.Println(basNumber)
  7737. card_sn := bas[3]
  7738. card_no := bas[2]
  7739. fmt.Println(card_sn)
  7740. name := bas[4]
  7741. name = ConvertToString(name, "gbk", "utf-8")
  7742. 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)
  7743. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  7744. var dat map[string]interface{}
  7745. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7746. fmt.Println(dat)
  7747. } else {
  7748. fmt.Println(err)
  7749. }
  7750. userJSONBytes, _ := json.Marshal(dat)
  7751. var res ResultTwo
  7752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7753. utils.ErrorLog("解析失败:%v", err)
  7754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7755. return
  7756. }
  7757. if res.Infcode == 0 {
  7758. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  7759. if err == gorm.ErrRecordNotFound {
  7760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7761. return
  7762. } else if err != nil {
  7763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7764. return
  7765. } else {
  7766. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7767. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7768. infoStr := string(Iinfos)
  7769. idetinfoStr := string(Idetinfos)
  7770. psn := &models.HisPsn{
  7771. PsnNo: res.Output.Baseinfo.PsnNo,
  7772. PatientId: patient.ID,
  7773. Certno: res.Output.Baseinfo.Certno,
  7774. Gend: res.Output.Baseinfo.Gend,
  7775. Naty: res.Output.Baseinfo.Naty,
  7776. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7777. PsnName: res.Output.Baseinfo.PsnName,
  7778. Idetinfo: idetinfoStr,
  7779. Insuinfo: infoStr,
  7780. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7781. CardInfo: basStr,
  7782. VerifyNumber: "",
  7783. }
  7784. service.CreateHisPsn(psn)
  7785. var rf []*ResultFive
  7786. json.Unmarshal([]byte(infoStr), &rf)
  7787. var insutypes []*ResultFive
  7788. var insutype string
  7789. var is390 int = 0
  7790. var is310 int = 0
  7791. for _, item := range rf {
  7792. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7793. insutypes = append(insutypes, item)
  7794. }
  7795. }
  7796. if len(insutypes) == 1 {
  7797. insutype = insutypes[0].Insutype
  7798. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7799. } else {
  7800. for _, i := range insutypes {
  7801. if i.Insutype == "390" {
  7802. is390 = 1
  7803. }
  7804. if i.Insutype == "310" {
  7805. is310 = 1
  7806. }
  7807. }
  7808. }
  7809. if is390 == 1 {
  7810. insutype = "390"
  7811. }
  7812. if is310 == 1 {
  7813. insutype = "310"
  7814. }
  7815. if len(insutypes) == 0 {
  7816. insutype = "310"
  7817. }
  7818. c.ServeSuccessJSON(map[string]interface{}{
  7819. "patient": patient,
  7820. "number": basNumber,
  7821. "insutype": insutype,
  7822. })
  7823. }
  7824. } else {
  7825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7826. return
  7827. }
  7828. } else if miConfig.MdtrtareaAdmvs == "150499" {
  7829. var api string
  7830. 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 +
  7831. "&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
  7832. fmt.Println(api)
  7833. resp, requestErr := http.Get(api)
  7834. if requestErr != nil {
  7835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7836. return
  7837. }
  7838. body, ioErr := ioutil.ReadAll(resp.Body)
  7839. if ioErr != nil {
  7840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7842. return
  7843. }
  7844. var respJSON map[string]interface{}
  7845. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7848. return
  7849. }
  7850. var res ResultTwo //1101结果
  7851. var res10265 ResultTwo10265 //1101结果
  7852. var card_info string //卡信息
  7853. token := respJSON["data"].(map[string]interface{})["token"].(string)
  7854. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7855. result, _ := json.Marshal(respJSON)
  7856. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7857. utils.ErrorLog("解析失败:%v", err)
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7859. return
  7860. }
  7861. res.ErrMsg = res10265.ErrMsg
  7862. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7863. res.Infcode = infocode
  7864. res.Output = res10265.Output
  7865. res.InfRefmsgid = res10265.InfRefmsgid
  7866. if res.Infcode == 0 {
  7867. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7868. if err == gorm.ErrRecordNotFound {
  7869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7870. return
  7871. } else if err != nil {
  7872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7873. return
  7874. } else {
  7875. bas := strings.Split(card_info, "|")
  7876. basNumber := bas[2]
  7877. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7878. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7879. infoStr := string(Iinfos)
  7880. idetinfoStr := string(Idetinfos)
  7881. psn := &models.HisPsn{
  7882. PsnNo: res.Output.Baseinfo.PsnNo,
  7883. PatientId: patient.ID,
  7884. Certno: res.Output.Baseinfo.Certno,
  7885. Gend: res.Output.Baseinfo.Gend,
  7886. Naty: res.Output.Baseinfo.Naty,
  7887. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7888. PsnName: res.Output.Baseinfo.PsnName,
  7889. Idetinfo: idetinfoStr,
  7890. Insuinfo: infoStr,
  7891. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7892. CardInfo: card_info,
  7893. VerifyNumber: token,
  7894. }
  7895. service.CreateHisPsn(psn)
  7896. var rf []*ResultFive
  7897. json.Unmarshal([]byte(infoStr), &rf)
  7898. var insutypes []*ResultFive
  7899. var insutype string
  7900. var is390 int = 0
  7901. var is310 int = 0
  7902. for _, item := range rf {
  7903. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7904. insutypes = append(insutypes, item)
  7905. }
  7906. }
  7907. if len(insutypes) == 1 {
  7908. insutype = insutypes[0].Insutype
  7909. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7910. } else {
  7911. for _, i := range insutypes {
  7912. if i.Insutype == "390" {
  7913. is390 = 1
  7914. }
  7915. if i.Insutype == "310" {
  7916. is310 = 1
  7917. }
  7918. }
  7919. }
  7920. if is390 == 1 {
  7921. insutype = "390"
  7922. }
  7923. if is310 == 1 {
  7924. insutype = "310"
  7925. }
  7926. if len(insutypes) == 0 {
  7927. insutype = "310"
  7928. }
  7929. c.ServeSuccessJSON(map[string]interface{}{
  7930. "patient": patient,
  7931. "number": basNumber,
  7932. "insutype": insutype,
  7933. })
  7934. }
  7935. } else {
  7936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7937. return
  7938. }
  7939. } else if miConfig.MdtrtareaAdmvs == "450721" {
  7940. res := c.GetoleInfo()
  7941. if res.Infcode == 0 {
  7942. var result string
  7943. if res.Output.MdtrtCertType == "01" {
  7944. 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)
  7945. } else if res.Output.MdtrtCertType == "02" {
  7946. 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)
  7947. } else if res.Output.MdtrtCertType == "03" {
  7948. 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)
  7949. }
  7950. var dat map[string]interface{}
  7951. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7952. fmt.Println(dat)
  7953. } else {
  7954. fmt.Println(err)
  7955. }
  7956. userJSONBytes, _ := json.Marshal(dat)
  7957. var res2 ResultTwo
  7958. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7959. utils.ErrorLog("解析失败:%v", err)
  7960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7961. return
  7962. }
  7963. if res2.Infcode == 0 {
  7964. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  7965. if err == gorm.ErrRecordNotFound {
  7966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7967. return
  7968. } else if err != nil {
  7969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7970. return
  7971. } else {
  7972. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  7973. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  7974. infoStr := string(Iinfos)
  7975. idetinfoStr := string(Idetinfos)
  7976. var rf []*ResultFive
  7977. json.Unmarshal([]byte(infoStr), &rf)
  7978. var insutypes []*ResultFive
  7979. var insutype string
  7980. var is390 int = 0
  7981. var is310 int = 0
  7982. //var insuplc_admdvs string
  7983. for _, item := range rf {
  7984. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7985. insutypes = append(insutypes, item)
  7986. }
  7987. }
  7988. if len(insutypes) == 1 {
  7989. insutype = insutypes[0].Insutype
  7990. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7991. } else {
  7992. for _, i := range insutypes {
  7993. if i.Insutype == "390" {
  7994. is390 = 1
  7995. }
  7996. if i.Insutype == "310" {
  7997. is310 = 1
  7998. }
  7999. }
  8000. }
  8001. if is390 == 1 {
  8002. insutype = "390"
  8003. }
  8004. if is310 == 1 {
  8005. insutype = "310"
  8006. }
  8007. if len(insutypes) == 0 {
  8008. insutype = "310"
  8009. }
  8010. psn := &models.HisPsn{
  8011. PsnNo: res2.Output.Baseinfo.PsnNo,
  8012. PatientId: patient.ID,
  8013. Certno: res2.Output.Baseinfo.Certno,
  8014. Gend: res2.Output.Baseinfo.Gend,
  8015. Naty: res2.Output.Baseinfo.Naty,
  8016. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8017. PsnName: res2.Output.Baseinfo.PsnName,
  8018. Idetinfo: idetinfoStr,
  8019. Insuinfo: infoStr,
  8020. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8021. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8022. VerifyNumber: res.Output.EcToken,
  8023. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8024. }
  8025. if res.Output.MdtrtCertType == "01" {
  8026. psn.VerifyNumber = res.Output.EcToken
  8027. //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)
  8028. } else if res.Output.MdtrtCertType == "02" {
  8029. psn.VerifyNumber = res.Output.MdtrtCertNo
  8030. //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)
  8031. } else if res.Output.MdtrtCertType == "03" {
  8032. psn.VerifyNumber = res.Output.MdtrtCertNo
  8033. //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)
  8034. }
  8035. var balc float64
  8036. for _, item := range rf {
  8037. if item.Insutype == insutype {
  8038. balc = item.Balc
  8039. }
  8040. }
  8041. service.CreateHisPsn(psn)
  8042. c.ServeSuccessJSON(map[string]interface{}{
  8043. "patient": patient,
  8044. "number": res.Output.CardNo,
  8045. "insutype": insutype,
  8046. "blac": balc,
  8047. "desc": idetinfoStr,
  8048. })
  8049. }
  8050. } else {
  8051. c.ServeSuccessJSON(map[string]interface{}{
  8052. "failed_code": -10,
  8053. "msg": res2.ErrMsg,
  8054. })
  8055. }
  8056. } else {
  8057. c.ServeSuccessJSON(map[string]interface{}{
  8058. "failed_code": -10,
  8059. "msg": res.ErrMsg,
  8060. })
  8061. }
  8062. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8063. var api string
  8064. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8065. "&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
  8066. fmt.Println(api)
  8067. resp, requestErr := http.Get(api)
  8068. if requestErr != nil {
  8069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8070. return
  8071. }
  8072. body, ioErr := ioutil.ReadAll(resp.Body)
  8073. if ioErr != nil {
  8074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8076. return
  8077. }
  8078. var respJSON map[string]interface{}
  8079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8082. return
  8083. }
  8084. var status string
  8085. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8086. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8087. //console.log()
  8088. fmt.Println("type===")
  8089. fmt.Println(card_type)
  8090. var token string
  8091. var res ResultTwo //1101结果
  8092. //var res10265 ResultTwoesultTwo10265 //1101结果
  8093. var card_info string //卡信息
  8094. var busi_card_info string
  8095. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8096. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8097. if status == "0" { //读卡成功
  8098. if card_type == "1" {
  8099. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8100. result, _ := json.Marshal(respJSON)
  8101. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8102. utils.ErrorLog("解析失败:%v", err)
  8103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8104. return
  8105. }
  8106. } else {
  8107. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8108. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8109. result, _ := json.Marshal(respJSON)
  8110. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8111. utils.ErrorLog("解析失败:%v", err)
  8112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8113. return
  8114. }
  8115. }
  8116. if res.Infcode == 0 {
  8117. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8118. if err == gorm.ErrRecordNotFound {
  8119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8120. return
  8121. } else if err != nil {
  8122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8123. return
  8124. } else {
  8125. if card_type == "1" {
  8126. bas := strings.Split(card_info, "|")
  8127. basNumber := bas[2]
  8128. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8129. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8130. infoStr := string(Iinfos)
  8131. idetinfoStr := string(Idetinfos)
  8132. psn := &models.HisPsn{
  8133. PsnNo: res.Output.Baseinfo.PsnNo,
  8134. PatientId: patient.ID,
  8135. Certno: res.Output.Baseinfo.Certno,
  8136. Gend: res.Output.Baseinfo.Gend,
  8137. Naty: res.Output.Baseinfo.Naty,
  8138. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8139. PsnName: res.Output.Baseinfo.PsnName,
  8140. Idetinfo: idetinfoStr,
  8141. Insuinfo: infoStr,
  8142. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8143. CardInfo: card_info,
  8144. VerifyNumber: busi_card_info,
  8145. }
  8146. service.CreateHisPsn(psn)
  8147. var rf []*ResultFive
  8148. json.Unmarshal([]byte(infoStr), &rf)
  8149. var insutypes []*ResultFive
  8150. var insutype string
  8151. var is390 int = 0
  8152. var is310 int = 0
  8153. for _, item := range rf {
  8154. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8155. insutypes = append(insutypes, item)
  8156. }
  8157. }
  8158. if len(insutypes) == 1 {
  8159. insutype = insutypes[0].Insutype
  8160. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8161. } else {
  8162. for _, i := range insutypes {
  8163. if i.Insutype == "390" {
  8164. is390 = 1
  8165. }
  8166. if i.Insutype == "310" {
  8167. is310 = 1
  8168. }
  8169. }
  8170. }
  8171. if is390 == 1 {
  8172. insutype = "390"
  8173. }
  8174. if is310 == 1 {
  8175. insutype = "310"
  8176. }
  8177. if len(insutypes) == 0 {
  8178. insutype = "310"
  8179. }
  8180. c.ServeSuccessJSON(map[string]interface{}{
  8181. "patient": patient,
  8182. "number": basNumber,
  8183. "insutype": insutype,
  8184. })
  8185. } else {
  8186. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8187. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8188. infoStr := string(Iinfos)
  8189. idetinfoStr := string(Idetinfos)
  8190. psn := &models.HisPsn{
  8191. PsnNo: res.Output.Baseinfo.PsnNo,
  8192. PatientId: patient.ID,
  8193. Certno: res.Output.Baseinfo.Certno,
  8194. Gend: res.Output.Baseinfo.Gend,
  8195. Naty: res.Output.Baseinfo.Naty,
  8196. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8197. PsnName: res.Output.Baseinfo.PsnName,
  8198. Idetinfo: idetinfoStr,
  8199. Insuinfo: infoStr,
  8200. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8201. CardInfo: card_info,
  8202. VerifyNumber: token,
  8203. }
  8204. service.CreateHisPsn(psn)
  8205. c.ServeSuccessJSON(map[string]interface{}{
  8206. "patient": patient,
  8207. "number": token,
  8208. })
  8209. }
  8210. }
  8211. } else {
  8212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8213. return
  8214. }
  8215. } else { //读卡失败
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8217. return
  8218. }
  8219. } else {
  8220. if initFlag == 0 {
  8221. c.TestGetBasBaseInit()
  8222. }
  8223. basStr := c.GetBasBaseInfo()
  8224. if len(basStr) == 0 {
  8225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8226. return
  8227. }
  8228. fmt.Println(basStr)
  8229. bas := strings.Split(basStr, "|")
  8230. basNumber := bas[1]
  8231. fmt.Println(basNumber)
  8232. card_sn := bas[3]
  8233. fmt.Println(card_sn)
  8234. cardNumber := bas[2]
  8235. fmt.Println(cardNumber)
  8236. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  8237. var result string
  8238. if bas[0][:2] == "44" {
  8239. 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)
  8240. } else {
  8241. 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)
  8242. }
  8243. var dat map[string]interface{}
  8244. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8245. fmt.Println(dat)
  8246. } else {
  8247. fmt.Println(err)
  8248. }
  8249. userJSONBytes, _ := json.Marshal(dat)
  8250. var res ResultTwo
  8251. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8252. utils.ErrorLog("解析失败:%v", err)
  8253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8254. return
  8255. }
  8256. if res.Infcode == 0 {
  8257. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8258. if err == gorm.ErrRecordNotFound {
  8259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8260. return
  8261. } else if err != nil {
  8262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8263. return
  8264. } else {
  8265. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8266. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8267. infoStr := string(Iinfos)
  8268. idetinfoStr := string(Idetinfos)
  8269. var rf []*ResultFive
  8270. json.Unmarshal([]byte(infoStr), &rf)
  8271. var insutypes []*ResultFive
  8272. var insutype string
  8273. var is390 int = 0
  8274. var is310 int = 0
  8275. var insuplc_admdvs string
  8276. for _, item := range rf {
  8277. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8278. insutypes = append(insutypes, item)
  8279. }
  8280. }
  8281. if len(insutypes) == 1 {
  8282. insutype = insutypes[0].Insutype
  8283. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8284. } else {
  8285. for _, i := range insutypes {
  8286. if i.Insutype == "390" {
  8287. is390 = 1
  8288. }
  8289. if i.Insutype == "310" {
  8290. is310 = 1
  8291. }
  8292. }
  8293. }
  8294. if is390 == 1 {
  8295. insutype = "390"
  8296. }
  8297. if is310 == 1 {
  8298. insutype = "310"
  8299. }
  8300. if len(insutypes) == 0 {
  8301. insutype = "310"
  8302. }
  8303. for _, item := range rf {
  8304. if item.Insutype == insutype {
  8305. insuplc_admdvs = item.InsuplcAdmdvs
  8306. }
  8307. }
  8308. psn := &models.HisPsn{
  8309. PsnNo: res.Output.Baseinfo.PsnNo,
  8310. PatientId: patient.ID,
  8311. Certno: res.Output.Baseinfo.Certno,
  8312. Gend: res.Output.Baseinfo.Gend,
  8313. Naty: res.Output.Baseinfo.Naty,
  8314. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8315. PsnName: res.Output.Baseinfo.PsnName,
  8316. Idetinfo: idetinfoStr,
  8317. Insuinfo: infoStr,
  8318. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8319. CardInfo: basStr,
  8320. VerifyNumber: "",
  8321. InsuplcAdmdvs: insuplc_admdvs,
  8322. }
  8323. service.CreateHisPsn(psn)
  8324. c.ServeSuccessJSON(map[string]interface{}{
  8325. "patient": patient,
  8326. "number": basNumber,
  8327. })
  8328. }
  8329. } else {
  8330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8331. return
  8332. }
  8333. break
  8334. }
  8335. case 2:
  8336. if miConfig.MdtrtareaAdmvs == "430800" {
  8337. if initFlag == 0 {
  8338. c.TestGetHnBasBaseInit()
  8339. }
  8340. SFZStr := c.GetSFZBaseInfo()
  8341. if len(SFZStr) == 0 {
  8342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8343. return
  8344. }
  8345. fmt.Println(SFZStr)
  8346. id_card_str := strings.Split(SFZStr, "^")
  8347. card_no := id_card_str[0]
  8348. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8349. //name := id_card_str[1]
  8350. //name = ConvertToString(name, "gbk", "utf-8")
  8351. 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)
  8352. var dat map[string]interface{}
  8353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8354. fmt.Println(dat)
  8355. } else {
  8356. fmt.Println(err)
  8357. }
  8358. userJSONBytes, _ := json.Marshal(dat)
  8359. var res ResultTwo
  8360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8361. utils.ErrorLog("解析失败:%v", err)
  8362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8363. return
  8364. }
  8365. if res.Infcode == 0 {
  8366. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8367. if err == gorm.ErrRecordNotFound {
  8368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8369. return
  8370. } else if err != nil {
  8371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8372. return
  8373. } else {
  8374. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8375. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8376. infoStr := string(Iinfos)
  8377. idetinfoStr := string(Idetinfos)
  8378. var rf []*ResultFive
  8379. json.Unmarshal([]byte(infoStr), &rf)
  8380. var insutypes []*ResultFive
  8381. var insutype string
  8382. var is390 int = 0
  8383. var is310 int = 0
  8384. for _, item := range rf {
  8385. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8386. insutypes = append(insutypes, item)
  8387. }
  8388. }
  8389. if len(insutypes) == 1 {
  8390. insutype = insutypes[0].Insutype
  8391. } else {
  8392. for _, i := range insutypes {
  8393. if i.Insutype == "390" {
  8394. is390 = 1
  8395. }
  8396. if i.Insutype == "310" {
  8397. is310 = 1
  8398. }
  8399. }
  8400. }
  8401. if is390 == 1 {
  8402. insutype = "390"
  8403. }
  8404. if is310 == 1 {
  8405. insutype = "310"
  8406. }
  8407. if len(insutypes) == 0 {
  8408. insutype = "310"
  8409. }
  8410. var InsuplcAdmdvs string
  8411. for _, item := range rf {
  8412. if item.Insutype == insutype {
  8413. InsuplcAdmdvs = item.InsuplcAdmdvs
  8414. }
  8415. }
  8416. psn := &models.HisPsn{
  8417. PsnNo: res.Output.Baseinfo.PsnNo,
  8418. PatientId: patient.ID,
  8419. Certno: res.Output.Baseinfo.Certno,
  8420. Gend: res.Output.Baseinfo.Gend,
  8421. Naty: res.Output.Baseinfo.Naty,
  8422. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8423. PsnName: res.Output.Baseinfo.PsnName,
  8424. Idetinfo: idetinfoStr,
  8425. Insuinfo: infoStr,
  8426. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8427. CardInfo: SFZStr,
  8428. VerifyNumber: "",
  8429. InsuplcAdmdvs: InsuplcAdmdvs,
  8430. }
  8431. service.CreateHisPsn(psn)
  8432. c.ServeSuccessJSON(map[string]interface{}{
  8433. "patient": patient,
  8434. "number": card_no,
  8435. "insutype": insutype,
  8436. })
  8437. }
  8438. } else {
  8439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8440. return
  8441. }
  8442. } else if miConfig.MdtrtareaAdmvs == "420200" {
  8443. var res ResultTwo
  8444. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  8445. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8446. "&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)
  8447. resp, requestErr := http.Get(api)
  8448. if requestErr != nil {
  8449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8450. return
  8451. }
  8452. body, ioErr := ioutil.ReadAll(resp.Body)
  8453. if ioErr != nil {
  8454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8456. return
  8457. }
  8458. var respJSON map[string]interface{}
  8459. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8462. return
  8463. }
  8464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8465. result, _ := json.Marshal(respJSON)
  8466. fmt.Println("log")
  8467. fmt.Println(string(result))
  8468. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8469. utils.ErrorLog("解析失败:%v", err)
  8470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8471. return
  8472. }
  8473. if res.Infcode == 0 {
  8474. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8475. if err == gorm.ErrRecordNotFound {
  8476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8477. return
  8478. } else if err != nil {
  8479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8480. return
  8481. } else {
  8482. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8483. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8484. infoStr := string(Iinfos)
  8485. idetinfoStr := string(Idetinfos)
  8486. psn := &models.HisPsn{
  8487. PsnNo: res.Output.Baseinfo.PsnNo,
  8488. PatientId: patient.ID,
  8489. Certno: res.Output.Baseinfo.Certno,
  8490. Gend: res.Output.Baseinfo.Gend,
  8491. Naty: res.Output.Baseinfo.Naty,
  8492. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8493. PsnName: res.Output.Baseinfo.PsnName,
  8494. Idetinfo: idetinfoStr,
  8495. Insuinfo: infoStr,
  8496. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8497. }
  8498. service.CreateHisPsn(psn)
  8499. c.ServeSuccessJSON(map[string]interface{}{
  8500. "patient": patient,
  8501. "number": res.Output.Baseinfo.Certno,
  8502. })
  8503. }
  8504. } else {
  8505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8506. return
  8507. }
  8508. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8509. var res ResultTwo
  8510. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  8511. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8512. "&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)
  8513. resp, requestErr := http.Get(api)
  8514. if requestErr != nil {
  8515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8516. return
  8517. }
  8518. body, ioErr := ioutil.ReadAll(resp.Body)
  8519. if ioErr != nil {
  8520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8522. return
  8523. }
  8524. var respJSON map[string]interface{}
  8525. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8531. result, _ := json.Marshal(respJSON)
  8532. fmt.Println("log")
  8533. fmt.Println(string(result))
  8534. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8535. utils.ErrorLog("解析失败:%v", err)
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. return
  8538. }
  8539. if res.Infcode == 0 {
  8540. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8541. if err == gorm.ErrRecordNotFound {
  8542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8543. return
  8544. } else if err != nil {
  8545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8546. return
  8547. } else {
  8548. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8549. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8550. infoStr := string(Iinfos)
  8551. idetinfoStr := string(Idetinfos)
  8552. psn := &models.HisPsn{
  8553. PsnNo: res.Output.Baseinfo.PsnNo,
  8554. PatientId: patient.ID,
  8555. Certno: res.Output.Baseinfo.Certno,
  8556. Gend: res.Output.Baseinfo.Gend,
  8557. Naty: res.Output.Baseinfo.Naty,
  8558. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8559. PsnName: res.Output.Baseinfo.PsnName,
  8560. Idetinfo: idetinfoStr,
  8561. Insuinfo: infoStr,
  8562. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8563. }
  8564. service.CreateHisPsn(psn)
  8565. c.ServeSuccessJSON(map[string]interface{}{
  8566. "patient": patient,
  8567. "number": res.Output.Baseinfo.Certno,
  8568. })
  8569. }
  8570. } else {
  8571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8572. return
  8573. }
  8574. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8575. res := c.GetoleInfo()
  8576. if res.Infcode == 0 {
  8577. var result string
  8578. if res.Output.MdtrtCertType == "01" {
  8579. 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)
  8580. } else if res.Output.MdtrtCertType == "02" {
  8581. 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)
  8582. } else if res.Output.MdtrtCertType == "03" {
  8583. 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)
  8584. }
  8585. var dat map[string]interface{}
  8586. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8587. fmt.Println(dat)
  8588. } else {
  8589. fmt.Println(err)
  8590. }
  8591. userJSONBytes, _ := json.Marshal(dat)
  8592. var res2 ResultTwo
  8593. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8594. utils.ErrorLog("解析失败:%v", err)
  8595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8596. return
  8597. }
  8598. if res2.Infcode == 0 {
  8599. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8600. if err == gorm.ErrRecordNotFound {
  8601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8602. return
  8603. } else if err != nil {
  8604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8605. return
  8606. } else {
  8607. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8608. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8609. infoStr := string(Iinfos)
  8610. idetinfoStr := string(Idetinfos)
  8611. var rf []*ResultFive
  8612. json.Unmarshal([]byte(infoStr), &rf)
  8613. var insutypes []*ResultFive
  8614. var insutype string
  8615. var is390 int = 0
  8616. var is310 int = 0
  8617. //var insuplc_admdvs string
  8618. for _, item := range rf {
  8619. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8620. insutypes = append(insutypes, item)
  8621. }
  8622. }
  8623. if len(insutypes) == 1 {
  8624. insutype = insutypes[0].Insutype
  8625. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8626. } else {
  8627. for _, i := range insutypes {
  8628. if i.Insutype == "390" {
  8629. is390 = 1
  8630. }
  8631. if i.Insutype == "310" {
  8632. is310 = 1
  8633. }
  8634. }
  8635. }
  8636. if is390 == 1 {
  8637. insutype = "390"
  8638. }
  8639. if is310 == 1 {
  8640. insutype = "310"
  8641. }
  8642. if len(insutypes) == 0 {
  8643. insutype = "310"
  8644. }
  8645. psn := &models.HisPsn{
  8646. PsnNo: res2.Output.Baseinfo.PsnNo,
  8647. PatientId: patient.ID,
  8648. //Brdy: res2.Output.Baseinfo.Brdy,
  8649. Certno: res2.Output.Baseinfo.Certno,
  8650. Gend: res2.Output.Baseinfo.Gend,
  8651. Naty: res2.Output.Baseinfo.Naty,
  8652. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8653. PsnName: res2.Output.Baseinfo.PsnName,
  8654. Idetinfo: idetinfoStr,
  8655. Insuinfo: infoStr,
  8656. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8657. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8658. VerifyNumber: res.Output.EcToken,
  8659. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8660. }
  8661. service.CreateHisPsn(psn)
  8662. var balc float64
  8663. for _, item := range rf {
  8664. if item.Insutype == insutype {
  8665. balc = item.Balc
  8666. }
  8667. }
  8668. c.ServeSuccessJSON(map[string]interface{}{
  8669. "patient": patient,
  8670. "number": res.Output.CardNo,
  8671. "insutype": insutype,
  8672. "blac": balc,
  8673. "desc": idetinfoStr,
  8674. })
  8675. }
  8676. } else {
  8677. c.ServeSuccessJSON(map[string]interface{}{
  8678. "failed_code": -10,
  8679. "msg": res2.ErrMsg,
  8680. })
  8681. }
  8682. } else {
  8683. c.ServeSuccessJSON(map[string]interface{}{
  8684. "failed_code": -10,
  8685. "msg": res.ErrMsg,
  8686. })
  8687. }
  8688. } else {
  8689. SFZStr := c.GetSFZBaseInfo()
  8690. id_card_str := strings.Split(SFZStr, "^")
  8691. id_card_number := id_card_str[0]
  8692. card_sn := ""
  8693. 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)
  8694. var dat map[string]interface{}
  8695. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8696. fmt.Println(dat)
  8697. } else {
  8698. fmt.Println(err)
  8699. }
  8700. userJSONBytes, _ := json.Marshal(dat)
  8701. var res ResultTwo
  8702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8703. utils.ErrorLog("解析失败:%v", err)
  8704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8705. return
  8706. }
  8707. if res.Infcode == 0 {
  8708. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  8709. if err == gorm.ErrRecordNotFound {
  8710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8711. return
  8712. } else if err != nil {
  8713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8714. return
  8715. } else {
  8716. c.ServeSuccessJSON(map[string]interface{}{
  8717. "patient": patient,
  8718. "number": id_card_number,
  8719. })
  8720. }
  8721. } else {
  8722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8723. return
  8724. }
  8725. }
  8726. break
  8727. case 3:
  8728. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8729. var api string
  8730. if miConfig.MdtrtareaAdmvs == "320921" {
  8731. 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 +
  8732. "&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
  8733. fmt.Println(api)
  8734. } else {
  8735. 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 +
  8736. "&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)
  8737. }
  8738. resp, requestErr := http.Get(api)
  8739. if requestErr != nil {
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. body, ioErr := ioutil.ReadAll(resp.Body)
  8744. if ioErr != nil {
  8745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8747. return
  8748. }
  8749. var respJSON map[string]interface{}
  8750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8753. return
  8754. }
  8755. var status string
  8756. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8757. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8758. var token string
  8759. var res ResultTwo //1101结果
  8760. var res10265 ResultTwo10265 //1101结果
  8761. var card_info string //卡信息
  8762. var busi_card_info string
  8763. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8764. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8765. if status == "0" { //读卡成功
  8766. if card_type == "1" {
  8767. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8768. result, _ := json.Marshal(respJSON)
  8769. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8770. utils.ErrorLog("解析失败:%v", err)
  8771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8772. return
  8773. }
  8774. res.ErrMsg = res10265.ErrMsg
  8775. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8776. res.Infcode = infocode
  8777. res.Output = res10265.Output
  8778. res.InfRefmsgid = res10265.InfRefmsgid
  8779. } else {
  8780. //var card_info string //卡信息
  8781. //var busi_card_info string
  8782. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8783. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8784. //fmt.Println(card_info)
  8785. //fmt.Println(busi_card_info)
  8786. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8787. result, _ := json.Marshal(respJSON)
  8788. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8789. utils.ErrorLog("解析失败:%v", err)
  8790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8791. return
  8792. }
  8793. res.ErrMsg = res10265.ErrMsg
  8794. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8795. res.Infcode = infocode
  8796. res.Output = res10265.Output
  8797. res.InfRefmsgid = res10265.InfRefmsgid
  8798. }
  8799. if res.Infcode == 0 {
  8800. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8801. if err == gorm.ErrRecordNotFound {
  8802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8803. return
  8804. } else if err != nil {
  8805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8806. return
  8807. } else {
  8808. if card_type == "1" {
  8809. bas := strings.Split(card_info, "|")
  8810. basNumber := bas[2]
  8811. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8812. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8813. infoStr := string(Iinfos)
  8814. idetinfoStr := string(Idetinfos)
  8815. psn := &models.HisPsn{
  8816. PsnNo: res.Output.Baseinfo.PsnNo,
  8817. PatientId: patient.ID,
  8818. Certno: res.Output.Baseinfo.Certno,
  8819. //Brdy: res.Output.Baseinfo.Brdy,
  8820. Gend: res.Output.Baseinfo.Gend,
  8821. Naty: res.Output.Baseinfo.Naty,
  8822. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8823. PsnName: res.Output.Baseinfo.PsnName,
  8824. Idetinfo: idetinfoStr,
  8825. Insuinfo: infoStr,
  8826. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8827. CardInfo: card_info,
  8828. VerifyNumber: busi_card_info,
  8829. }
  8830. service.CreateHisPsn(psn)
  8831. c.ServeSuccessJSON(map[string]interface{}{
  8832. "patient": patient,
  8833. "number": basNumber,
  8834. })
  8835. } else {
  8836. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8837. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8838. infoStr := string(Iinfos)
  8839. idetinfoStr := string(Idetinfos)
  8840. psn := &models.HisPsn{
  8841. PsnNo: res.Output.Baseinfo.PsnNo,
  8842. PatientId: patient.ID,
  8843. Certno: res.Output.Baseinfo.Certno,
  8844. Gend: res.Output.Baseinfo.Gend,
  8845. Naty: res.Output.Baseinfo.Naty,
  8846. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8847. PsnName: res.Output.Baseinfo.PsnName,
  8848. Idetinfo: idetinfoStr,
  8849. Insuinfo: infoStr,
  8850. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8851. CardInfo: card_info,
  8852. VerifyNumber: token,
  8853. }
  8854. service.CreateHisPsn(psn)
  8855. var rf []*ResultFive
  8856. json.Unmarshal([]byte(infoStr), &rf)
  8857. var insutypes []*ResultFive
  8858. var insutype string
  8859. var is390 int = 0
  8860. var is310 int = 0
  8861. for _, item := range rf {
  8862. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8863. insutypes = append(insutypes, item)
  8864. }
  8865. }
  8866. if len(insutypes) == 1 {
  8867. insutype = insutypes[0].Insutype
  8868. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8869. } else {
  8870. for _, i := range insutypes {
  8871. if i.Insutype == "390" {
  8872. is390 = 1
  8873. }
  8874. if i.Insutype == "310" {
  8875. is310 = 1
  8876. }
  8877. }
  8878. }
  8879. if is390 == 1 {
  8880. insutype = "390"
  8881. }
  8882. if is310 == 1 {
  8883. insutype = "310"
  8884. }
  8885. if len(insutypes) == 0 {
  8886. insutype = "310"
  8887. }
  8888. c.ServeSuccessJSON(map[string]interface{}{
  8889. "patient": patient,
  8890. "number": token,
  8891. "insutype": insutype,
  8892. })
  8893. }
  8894. }
  8895. } else {
  8896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8897. return
  8898. }
  8899. } else { //读卡失败
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8901. return
  8902. }
  8903. }
  8904. break
  8905. case 4:
  8906. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8907. var api string
  8908. if miConfig.MdtrtareaAdmvs == "320921" {
  8909. 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 +
  8910. "&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
  8911. fmt.Println(api)
  8912. } else {
  8913. 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 +
  8914. "&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)
  8915. }
  8916. resp, requestErr := http.Get(api)
  8917. if requestErr != nil {
  8918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8919. return
  8920. }
  8921. body, ioErr := ioutil.ReadAll(resp.Body)
  8922. if ioErr != nil {
  8923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8925. return
  8926. }
  8927. var respJSON map[string]interface{}
  8928. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8931. return
  8932. }
  8933. var status string
  8934. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8935. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8936. var token string
  8937. var res ResultTwo //1101结果
  8938. var res10265 ResultTwo10265 //1101结果
  8939. if status == "0" { //读卡成功
  8940. var card_info string //卡信息
  8941. var busi_card_info string
  8942. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8943. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8944. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8945. fmt.Println(card_info)
  8946. fmt.Println(busi_card_info)
  8947. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8948. result, _ := json.Marshal(respJSON)
  8949. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8950. utils.ErrorLog("解析失败:%v", err)
  8951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8952. return
  8953. }
  8954. res.ErrMsg = res10265.ErrMsg
  8955. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8956. res.Infcode = infocode
  8957. res.Output = res10265.Output
  8958. res.InfRefmsgid = res10265.InfRefmsgid
  8959. if res.Infcode == 0 {
  8960. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8961. if err == gorm.ErrRecordNotFound {
  8962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8963. return
  8964. } else if err != nil {
  8965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8966. return
  8967. } else {
  8968. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8969. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8970. infoStr := string(Iinfos)
  8971. idetinfoStr := string(Idetinfos)
  8972. psn := &models.HisPsn{
  8973. PsnNo: res.Output.Baseinfo.PsnNo,
  8974. PatientId: patient.ID,
  8975. Certno: res.Output.Baseinfo.Certno,
  8976. //Brdy: res.Output.Baseinfo.Brdy,
  8977. Gend: res.Output.Baseinfo.Gend,
  8978. Naty: res.Output.Baseinfo.Naty,
  8979. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8980. PsnName: res.Output.Baseinfo.PsnName,
  8981. Idetinfo: idetinfoStr,
  8982. Insuinfo: infoStr,
  8983. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8984. CardInfo: card_info,
  8985. VerifyNumber: token,
  8986. }
  8987. var rf []*ResultFive
  8988. json.Unmarshal([]byte(infoStr), &rf)
  8989. var insutypes []*ResultFive
  8990. var insutype string
  8991. var is390 int = 0
  8992. var is310 int = 0
  8993. for _, item := range rf {
  8994. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8995. insutypes = append(insutypes, item)
  8996. }
  8997. }
  8998. if len(insutypes) == 1 {
  8999. insutype = insutypes[0].Insutype
  9000. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9001. } else {
  9002. for _, i := range insutypes {
  9003. if i.Insutype == "390" {
  9004. is390 = 1
  9005. }
  9006. if i.Insutype == "310" {
  9007. is310 = 1
  9008. }
  9009. }
  9010. }
  9011. if is390 == 1 {
  9012. insutype = "390"
  9013. }
  9014. if is310 == 1 {
  9015. insutype = "310"
  9016. }
  9017. if len(insutypes) == 0 {
  9018. insutype = "310"
  9019. }
  9020. service.CreateHisPsn(psn)
  9021. c.ServeSuccessJSON(map[string]interface{}{
  9022. "patient": patient,
  9023. "number": token,
  9024. "insutype": insutype,
  9025. })
  9026. }
  9027. } else {
  9028. c.ServeSuccessJSON(map[string]interface{}{
  9029. "failed_code": -10,
  9030. "msg": res.ErrMsg,
  9031. })
  9032. }
  9033. } else { //读卡失败
  9034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9035. return
  9036. }
  9037. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9038. var api string
  9039. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9040. "&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
  9041. resp, requestErr := http.Get(api)
  9042. if requestErr != nil {
  9043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9044. return
  9045. }
  9046. body, ioErr := ioutil.ReadAll(resp.Body)
  9047. if ioErr != nil {
  9048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9050. return
  9051. }
  9052. var respJSON map[string]interface{}
  9053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9056. return
  9057. }
  9058. var status string
  9059. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9060. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9061. var token string
  9062. var res ResultTwo //1101结果
  9063. if status == "1" { //读卡成功
  9064. var card_info string //卡信息
  9065. var busi_card_info string
  9066. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9067. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9068. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9069. fmt.Println(card_info)
  9070. fmt.Println(busi_card_info)
  9071. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9072. result, _ := json.Marshal(respJSON)
  9073. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9074. utils.ErrorLog("解析失败:%v", err)
  9075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9076. return
  9077. }
  9078. if res.Infcode == 0 {
  9079. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9080. if err == gorm.ErrRecordNotFound {
  9081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9082. return
  9083. } else if err != nil {
  9084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9085. return
  9086. } else {
  9087. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9088. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9089. infoStr := string(Iinfos)
  9090. idetinfoStr := string(Idetinfos)
  9091. psn := &models.HisPsn{
  9092. PsnNo: res.Output.Baseinfo.PsnNo,
  9093. PatientId: patient.ID,
  9094. Certno: res.Output.Baseinfo.Certno,
  9095. Gend: res.Output.Baseinfo.Gend,
  9096. Naty: res.Output.Baseinfo.Naty,
  9097. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9098. PsnName: res.Output.Baseinfo.PsnName,
  9099. Idetinfo: idetinfoStr,
  9100. Insuinfo: infoStr,
  9101. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9102. CardInfo: card_info,
  9103. VerifyNumber: token,
  9104. }
  9105. var rf []*ResultFive
  9106. json.Unmarshal([]byte(infoStr), &rf)
  9107. var insutypes []*ResultFive
  9108. var insutype string
  9109. var is390 int = 0
  9110. var is310 int = 0
  9111. for _, item := range rf {
  9112. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9113. insutypes = append(insutypes, item)
  9114. }
  9115. }
  9116. if len(insutypes) == 1 {
  9117. insutype = insutypes[0].Insutype
  9118. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9119. } else {
  9120. for _, i := range insutypes {
  9121. if i.Insutype == "390" {
  9122. is390 = 1
  9123. }
  9124. if i.Insutype == "310" {
  9125. is310 = 1
  9126. }
  9127. }
  9128. }
  9129. if is390 == 1 {
  9130. insutype = "390"
  9131. }
  9132. if is310 == 1 {
  9133. insutype = "310"
  9134. }
  9135. if len(insutypes) == 0 {
  9136. insutype = "310"
  9137. }
  9138. service.CreateHisPsn(psn)
  9139. c.ServeSuccessJSON(map[string]interface{}{
  9140. "patient": patient,
  9141. "number": token,
  9142. "insutype": insutype,
  9143. })
  9144. }
  9145. } else {
  9146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9147. return
  9148. }
  9149. } else { //读卡失败
  9150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9151. return
  9152. }
  9153. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9154. idNo := c.GetString("idNo")
  9155. userName := c.GetString("userName")
  9156. ecToken := c.GetString("ecToken")
  9157. insuOrg := c.GetString("insuOrg")
  9158. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9159. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9160. var res ResultTwo
  9161. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9162. utils.ErrorLog("解析失败:%v", err)
  9163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9164. return
  9165. }
  9166. if res.Infcode == 0 {
  9167. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9168. if err == gorm.ErrRecordNotFound {
  9169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9170. return
  9171. } else if err != nil {
  9172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9173. return
  9174. } else {
  9175. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9176. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9177. infoStr := string(Iinfos)
  9178. idetinfoStr := string(Idetinfos)
  9179. psn := &models.HisPsn{
  9180. PsnNo: res.Output.Baseinfo.PsnNo,
  9181. PatientId: patient.ID,
  9182. Certno: res.Output.Baseinfo.Certno,
  9183. Gend: res.Output.Baseinfo.Gend,
  9184. Naty: res.Output.Baseinfo.Naty,
  9185. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9186. PsnName: res.Output.Baseinfo.PsnName,
  9187. Idetinfo: idetinfoStr,
  9188. Insuinfo: infoStr,
  9189. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9190. CardInfo: "",
  9191. Stage: "1",
  9192. VerifyNumber: ecToken,
  9193. InsuplcAdmdvs: insuOrg,
  9194. }
  9195. service.CreateHisPsn(psn)
  9196. var rf []*ResultFive
  9197. json.Unmarshal([]byte(infoStr), &rf)
  9198. var insutypes []*ResultFive
  9199. var insutype string
  9200. var is390 int = 0
  9201. var is310 int = 0
  9202. for _, item := range rf {
  9203. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9204. insutypes = append(insutypes, item)
  9205. }
  9206. }
  9207. if len(insutypes) == 1 {
  9208. insutype = insutypes[0].Insutype
  9209. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9210. } else {
  9211. for _, i := range insutypes {
  9212. if i.Insutype == "390" {
  9213. is390 = 1
  9214. }
  9215. if i.Insutype == "310" {
  9216. is310 = 1
  9217. }
  9218. }
  9219. }
  9220. if is390 == 1 {
  9221. insutype = "390"
  9222. }
  9223. if is310 == 1 {
  9224. insutype = "310"
  9225. }
  9226. if len(insutypes) == 0 {
  9227. insutype = "310"
  9228. }
  9229. c.ServeSuccessJSON(map[string]interface{}{
  9230. "patient": patient,
  9231. "number": ecToken,
  9232. "insutype": insutype,
  9233. })
  9234. }
  9235. } else {
  9236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9237. return
  9238. }
  9239. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9240. //if initFlag == 0 {
  9241. //c.TestGetJiangXiBasBaseInit()
  9242. //}
  9243. //if initEleFlag == 0 {
  9244. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9245. //}
  9246. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  9247. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  9248. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9249. type ELeData struct {
  9250. Data struct {
  9251. IdNo string `json:"idNo"`
  9252. IdType string `json:"idType"`
  9253. UserName string `json:"userName"`
  9254. EcToken string `json:"ecToken"`
  9255. InsuOrg string `json:"insuOrg"`
  9256. Gender string `json:"gender"`
  9257. Birthday string `json:"birthday"`
  9258. Nationality string `json:"nationality"`
  9259. Email string `json:"email"`
  9260. Extra string `json:"extra"`
  9261. } `json:"data"`
  9262. Code int `json:"code"`
  9263. Message string `json:"message"`
  9264. }
  9265. var ele ELeData
  9266. err := json.Unmarshal([]byte(result), &ele)
  9267. if err != nil {
  9268. utils.ErrorLog("解析失败:%v", err)
  9269. }
  9270. token := ele.Data.EcToken
  9271. token = Remove0000(token)
  9272. 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)
  9273. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9274. var res ResultTwo
  9275. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9276. utils.ErrorLog("解析失败:%v", err)
  9277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9278. return
  9279. }
  9280. if res.Infcode == 0 {
  9281. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9282. if err == gorm.ErrRecordNotFound {
  9283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9284. return
  9285. } else if err != nil {
  9286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9287. return
  9288. } else {
  9289. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9290. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9291. infoStr := string(Iinfos)
  9292. idetinfoStr := string(Idetinfos)
  9293. psn := &models.HisPsn{
  9294. PsnNo: res.Output.Baseinfo.PsnNo,
  9295. PatientId: patient.ID,
  9296. Certno: res.Output.Baseinfo.Certno,
  9297. Gend: res.Output.Baseinfo.Gend,
  9298. Naty: res.Output.Baseinfo.Naty,
  9299. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9300. PsnName: res.Output.Baseinfo.PsnName,
  9301. Idetinfo: idetinfoStr,
  9302. Insuinfo: infoStr,
  9303. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9304. CardInfo: "",
  9305. VerifyNumber: token,
  9306. }
  9307. service.CreateHisPsn(psn)
  9308. var rf []*ResultFive
  9309. json.Unmarshal([]byte(infoStr), &rf)
  9310. var insutypes []*ResultFive
  9311. var insutype string
  9312. var is390 int = 0
  9313. var is310 int = 0
  9314. for _, item := range rf {
  9315. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9316. insutypes = append(insutypes, item)
  9317. }
  9318. }
  9319. if len(insutypes) == 1 {
  9320. insutype = insutypes[0].Insutype
  9321. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9322. } else {
  9323. for _, i := range insutypes {
  9324. if i.Insutype == "390" {
  9325. is390 = 1
  9326. }
  9327. if i.Insutype == "310" {
  9328. is310 = 1
  9329. }
  9330. }
  9331. }
  9332. if is390 == 1 {
  9333. insutype = "390"
  9334. }
  9335. if is310 == 1 {
  9336. insutype = "310"
  9337. }
  9338. if len(insutypes) == 0 {
  9339. insutype = "310"
  9340. }
  9341. c.ServeSuccessJSON(map[string]interface{}{
  9342. "patient": patient,
  9343. "number": token,
  9344. "insutype": insutype,
  9345. })
  9346. }
  9347. } else {
  9348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9349. return
  9350. }
  9351. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9352. //if initFlag == 0 {
  9353. c.TestGetJiangXiBasBaseInit()
  9354. //}
  9355. //if initEleFlag == 0 {
  9356. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9357. //}
  9358. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9359. type ELeData struct {
  9360. Data struct {
  9361. IdNo string `json:"idNo"`
  9362. IdType string `json:"idType"`
  9363. UserName string `json:"userName"`
  9364. EcToken string `json:"ecToken"`
  9365. InsuOrg string `json:"insuOrg"`
  9366. Gender string `json:"gender"`
  9367. Birthday string `json:"birthday"`
  9368. Nationality string `json:"nationality"`
  9369. Email string `json:"email"`
  9370. Extra string `json:"extra"`
  9371. } `json:"data"`
  9372. Code int `json:"code"`
  9373. Message string `json:"message"`
  9374. }
  9375. var ele ELeData
  9376. err := json.Unmarshal([]byte(json_result), &ele)
  9377. if err != nil {
  9378. utils.ErrorLog("解析失败:%v", err)
  9379. }
  9380. token := ele.Data.EcToken
  9381. token = Remove0000(token)
  9382. 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)
  9383. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9384. var res ResultTwo
  9385. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9386. utils.ErrorLog("解析失败:%v", err)
  9387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9388. return
  9389. }
  9390. if res.Infcode == 0 {
  9391. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9392. if err == gorm.ErrRecordNotFound {
  9393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9394. return
  9395. } else if err != nil {
  9396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9397. return
  9398. } else {
  9399. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9400. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9401. infoStr := string(Iinfos)
  9402. idetinfoStr := string(Idetinfos)
  9403. psn := &models.HisPsn{
  9404. PsnNo: res.Output.Baseinfo.PsnNo,
  9405. PatientId: patient.ID,
  9406. Certno: res.Output.Baseinfo.Certno,
  9407. Gend: res.Output.Baseinfo.Gend,
  9408. Naty: res.Output.Baseinfo.Naty,
  9409. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9410. PsnName: res.Output.Baseinfo.PsnName,
  9411. Idetinfo: idetinfoStr,
  9412. Insuinfo: infoStr,
  9413. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9414. CardInfo: "",
  9415. VerifyNumber: token,
  9416. }
  9417. service.CreateHisPsn(psn)
  9418. var rf []*ResultFive
  9419. json.Unmarshal([]byte(infoStr), &rf)
  9420. var insutypes []*ResultFive
  9421. var insutype string
  9422. var is390 int = 0
  9423. var is310 int = 0
  9424. for _, item := range rf {
  9425. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9426. insutypes = append(insutypes, item)
  9427. }
  9428. }
  9429. if len(insutypes) == 1 {
  9430. insutype = insutypes[0].Insutype
  9431. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9432. } else {
  9433. for _, i := range insutypes {
  9434. if i.Insutype == "390" {
  9435. is390 = 1
  9436. }
  9437. if i.Insutype == "310" {
  9438. is310 = 1
  9439. }
  9440. }
  9441. }
  9442. if is390 == 1 {
  9443. insutype = "390"
  9444. }
  9445. if is310 == 1 {
  9446. insutype = "310"
  9447. }
  9448. if len(insutypes) == 0 {
  9449. insutype = "310"
  9450. }
  9451. c.ServeSuccessJSON(map[string]interface{}{
  9452. "patient": patient,
  9453. "number": token,
  9454. "insutype": insutype,
  9455. })
  9456. }
  9457. } else {
  9458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9459. return
  9460. }
  9461. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9462. type ELeData struct {
  9463. Code string `json:"code"`
  9464. Data struct {
  9465. Aac002 string `json:"aac002"`
  9466. Aaz500 string `json:"aaz500"`
  9467. ActCardNo string `json:"actCardNo"`
  9468. Bab520 string `json:"bab520"`
  9469. Bkz543 string `json:"bkz543"`
  9470. BusinessType string `json:"businessType"`
  9471. CertfCodg string `json:"certfCodg"`
  9472. EcIndexNo string `json:"ecIndexNo"`
  9473. EcToken string `json:"ecToken"`
  9474. ID0000 string `json:"id0000"`
  9475. IDNo string `json:"idNo"`
  9476. IDType string `json:"idType"`
  9477. Idcode string `json:"idcode"`
  9478. IdentityToken string `json:"identity_token"`
  9479. InsuOrg string `json:"insuOrg"`
  9480. OfficeID string `json:"officeId"`
  9481. OfficeName string `json:"officeName"`
  9482. OperatorID string `json:"operatorId"`
  9483. OperatorName string `json:"operatorName"`
  9484. OrgID string `json:"orgId"`
  9485. UserName string `json:"userName"`
  9486. } `json:"data"`
  9487. Infno interface{} `json:"infno"`
  9488. Message string `json:"message"`
  9489. OrgID string `json:"orgId"`
  9490. TransType string `json:"transType"`
  9491. }
  9492. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  9493. outPutInfo = Remove0000(outPutInfo)
  9494. if len(outPutInfo) > 0 {
  9495. var ele ELeData
  9496. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9497. if err != nil {
  9498. utils.ErrorLog("解析失败:%v", err)
  9499. }
  9500. token := ele.Data.EcToken
  9501. fmt.Println(inputInfo)
  9502. fmt.Println(outPutInfo)
  9503. 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)
  9504. saveLog(result, requestLog, "1101", "获取人员信息")
  9505. var dat map[string]interface{}
  9506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9507. fmt.Println(dat)
  9508. } else {
  9509. fmt.Println(err)
  9510. }
  9511. userJSONBytes, _ := json.Marshal(dat)
  9512. var res ResultTwo
  9513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9514. utils.ErrorLog("解析失败:%v", err)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. return
  9517. }
  9518. res.ErrMsg = errMsgLog
  9519. if res.Infcode == 0 {
  9520. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  9521. if err == gorm.ErrRecordNotFound {
  9522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9523. return
  9524. } else if err != nil {
  9525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9526. return
  9527. } else {
  9528. fmt.Println(res)
  9529. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9530. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9531. infoStr := string(Iinfos)
  9532. idetinfoStr := string(Idetinfos)
  9533. psn := &models.HisPsn{
  9534. PsnNo: res.Output.Baseinfo.PsnNo,
  9535. PatientId: patient.ID,
  9536. Certno: res.Output.Baseinfo.Certno,
  9537. Gend: res.Output.Baseinfo.Gend,
  9538. Naty: res.Output.Baseinfo.Naty,
  9539. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9540. PsnName: res.Output.Baseinfo.PsnName,
  9541. Idetinfo: idetinfoStr,
  9542. Insuinfo: infoStr,
  9543. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9544. CardInfo: outPutInfo,
  9545. VerifyNumber: token,
  9546. InsuplcAdmdvs: ele.Data.InsuOrg,
  9547. }
  9548. service.CreateHisPsn(psn)
  9549. var rf []*ResultFive
  9550. json.Unmarshal([]byte(infoStr), &rf)
  9551. var insutypes []*ResultFive
  9552. var insutype string
  9553. var is390 int = 0
  9554. var is310 int = 0
  9555. for _, item := range rf {
  9556. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9557. insutypes = append(insutypes, item)
  9558. }
  9559. }
  9560. if len(insutypes) == 1 {
  9561. insutype = insutypes[0].Insutype
  9562. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9563. } else {
  9564. for _, i := range insutypes {
  9565. if i.Insutype == "390" {
  9566. is390 = 1
  9567. }
  9568. if i.Insutype == "310" {
  9569. is310 = 1
  9570. }
  9571. }
  9572. }
  9573. if is390 == 1 {
  9574. insutype = "390"
  9575. }
  9576. if is310 == 1 {
  9577. insutype = "310"
  9578. }
  9579. if len(insutypes) == 0 {
  9580. insutype = "310"
  9581. }
  9582. c.ServeSuccessJSON(map[string]interface{}{
  9583. "patient": patient,
  9584. "number": token,
  9585. "insutype": insutype,
  9586. })
  9587. }
  9588. } else {
  9589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9590. return
  9591. }
  9592. }
  9593. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9594. var api string
  9595. 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 +
  9596. "&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
  9597. resp, requestErr := http.Get(api)
  9598. if requestErr != nil {
  9599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9600. return
  9601. }
  9602. body, ioErr := ioutil.ReadAll(resp.Body)
  9603. if ioErr != nil {
  9604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9606. return
  9607. }
  9608. var respJSON map[string]interface{}
  9609. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9612. return
  9613. }
  9614. var status string
  9615. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9616. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9617. var token string
  9618. var res ResultTwo //1101结果
  9619. var res10265 ResultTwo10265 //1101结果
  9620. if status == "0" { //读卡成功
  9621. var card_info string //卡信息
  9622. var busi_card_info string
  9623. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9624. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9625. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9626. fmt.Println(card_info)
  9627. fmt.Println(busi_card_info)
  9628. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9629. result, _ := json.Marshal(respJSON)
  9630. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9631. utils.ErrorLog("解析失败:%v", err)
  9632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9633. return
  9634. }
  9635. res.ErrMsg = res10265.ErrMsg
  9636. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9637. res.Infcode = infocode
  9638. res.Output = res10265.Output
  9639. res.InfRefmsgid = res10265.InfRefmsgid
  9640. if res.Infcode == 0 {
  9641. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9642. if err == gorm.ErrRecordNotFound {
  9643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9644. return
  9645. } else if err != nil {
  9646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9647. return
  9648. } else {
  9649. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9650. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9651. infoStr := string(Iinfos)
  9652. idetinfoStr := string(Idetinfos)
  9653. psn := &models.HisPsn{
  9654. PsnNo: res.Output.Baseinfo.PsnNo,
  9655. PatientId: patient.ID,
  9656. Certno: res.Output.Baseinfo.Certno,
  9657. Gend: res.Output.Baseinfo.Gend,
  9658. Naty: res.Output.Baseinfo.Naty,
  9659. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9660. PsnName: res.Output.Baseinfo.PsnName,
  9661. Idetinfo: idetinfoStr,
  9662. Insuinfo: infoStr,
  9663. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9664. CardInfo: card_info,
  9665. VerifyNumber: token,
  9666. }
  9667. var rf []*ResultFive
  9668. json.Unmarshal([]byte(infoStr), &rf)
  9669. var insutypes []*ResultFive
  9670. var insutype string
  9671. var is390 int = 0
  9672. var is310 int = 0
  9673. for _, item := range rf {
  9674. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9675. insutypes = append(insutypes, item)
  9676. }
  9677. }
  9678. if len(insutypes) == 1 {
  9679. insutype = insutypes[0].Insutype
  9680. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9681. } else {
  9682. for _, i := range insutypes {
  9683. if i.Insutype == "390" {
  9684. is390 = 1
  9685. }
  9686. if i.Insutype == "310" {
  9687. is310 = 1
  9688. }
  9689. }
  9690. }
  9691. if is390 == 1 {
  9692. insutype = "390"
  9693. }
  9694. if is310 == 1 {
  9695. insutype = "310"
  9696. }
  9697. if len(insutypes) == 0 {
  9698. insutype = "310"
  9699. }
  9700. service.CreateHisPsn(psn)
  9701. c.ServeSuccessJSON(map[string]interface{}{
  9702. "patient": patient,
  9703. "number": token,
  9704. "insutype": insutype,
  9705. })
  9706. }
  9707. } else {
  9708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9709. return
  9710. }
  9711. } else { //读卡失败
  9712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9713. return
  9714. }
  9715. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9716. res := c.GetoleInfo()
  9717. if res.Infcode == 0 {
  9718. var result string
  9719. if res.Output.MdtrtCertType == "01" {
  9720. 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)
  9721. } else if res.Output.MdtrtCertType == "02" {
  9722. 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)
  9723. } else if res.Output.MdtrtCertType == "03" {
  9724. 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)
  9725. }
  9726. var dat map[string]interface{}
  9727. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9728. fmt.Println(dat)
  9729. } else {
  9730. fmt.Println(err)
  9731. }
  9732. userJSONBytes, _ := json.Marshal(dat)
  9733. var res2 ResultTwo
  9734. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9735. utils.ErrorLog("解析失败:%v", err)
  9736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9737. return
  9738. }
  9739. if res2.Infcode == 0 {
  9740. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9741. if err == gorm.ErrRecordNotFound {
  9742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9743. return
  9744. } else if err != nil {
  9745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9746. return
  9747. } else {
  9748. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9749. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9750. infoStr := string(Iinfos)
  9751. idetinfoStr := string(Idetinfos)
  9752. var rf []*ResultFive
  9753. json.Unmarshal([]byte(infoStr), &rf)
  9754. var insutypes []*ResultFive
  9755. var insutype string
  9756. var is390 int = 0
  9757. var is310 int = 0
  9758. //var insuplc_admdvs string
  9759. for _, item := range rf {
  9760. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9761. insutypes = append(insutypes, item)
  9762. }
  9763. }
  9764. if len(insutypes) == 1 {
  9765. insutype = insutypes[0].Insutype
  9766. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9767. } else {
  9768. for _, i := range insutypes {
  9769. if i.Insutype == "390" {
  9770. is390 = 1
  9771. }
  9772. if i.Insutype == "310" {
  9773. is310 = 1
  9774. }
  9775. }
  9776. }
  9777. if is390 == 1 {
  9778. insutype = "390"
  9779. }
  9780. if is310 == 1 {
  9781. insutype = "310"
  9782. }
  9783. if len(insutypes) == 0 {
  9784. insutype = "310"
  9785. }
  9786. psn := &models.HisPsn{
  9787. PsnNo: res2.Output.Baseinfo.PsnNo,
  9788. PatientId: patient.ID,
  9789. Certno: res2.Output.Baseinfo.Certno,
  9790. Gend: res2.Output.Baseinfo.Gend,
  9791. Naty: res2.Output.Baseinfo.Naty,
  9792. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9793. PsnName: res2.Output.Baseinfo.PsnName,
  9794. Idetinfo: idetinfoStr,
  9795. Insuinfo: infoStr,
  9796. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9797. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9798. VerifyNumber: res.Output.EcToken,
  9799. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9800. }
  9801. if res.Output.MdtrtCertType == "01" {
  9802. psn.VerifyNumber = res.Output.EcToken
  9803. //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)
  9804. } else if res.Output.MdtrtCertType == "02" {
  9805. psn.VerifyNumber = res.Output.CardNo
  9806. //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)
  9807. } else if res.Output.MdtrtCertType == "03" {
  9808. psn.VerifyNumber = res.Output.MdtrtCertNo
  9809. //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)
  9810. }
  9811. service.CreateHisPsn(psn)
  9812. var balc float64
  9813. for _, item := range rf {
  9814. if item.Insutype == insutype {
  9815. balc = item.Balc
  9816. }
  9817. }
  9818. c.ServeSuccessJSON(map[string]interface{}{
  9819. "patient": patient,
  9820. "number": res.Output.CardNo,
  9821. "insutype": insutype,
  9822. "blac": balc,
  9823. "desc": idetinfoStr,
  9824. })
  9825. }
  9826. } else {
  9827. c.ServeSuccessJSON(map[string]interface{}{
  9828. "failed_code": -10,
  9829. "msg": res2.ErrMsg,
  9830. })
  9831. }
  9832. } else {
  9833. c.ServeSuccessJSON(map[string]interface{}{
  9834. "failed_code": -10,
  9835. "msg": res.ErrMsg,
  9836. })
  9837. }
  9838. } else {
  9839. type ELeData struct {
  9840. Code string `json:"code"`
  9841. Data struct {
  9842. Aac002 string `json:"aac002"`
  9843. Aaz500 string `json:"aaz500"`
  9844. ActCardNo string `json:"actCardNo"`
  9845. Bab520 string `json:"bab520"`
  9846. Bkz543 string `json:"bkz543"`
  9847. BusinessType string `json:"businessType"`
  9848. CertfCodg string `json:"certfCodg"`
  9849. EcIndexNo string `json:"ecIndexNo"`
  9850. EcToken string `json:"ecToken"`
  9851. ID0000 string `json:"id0000"`
  9852. IDNo string `json:"idNo"`
  9853. IDType string `json:"idType"`
  9854. Idcode string `json:"idcode"`
  9855. IdentityToken string `json:"identity_token"`
  9856. InsuOrg string `json:"insuOrg"`
  9857. OfficeID string `json:"officeId"`
  9858. OfficeName string `json:"officeName"`
  9859. OperatorID string `json:"operatorId"`
  9860. OperatorName string `json:"operatorName"`
  9861. OrgID string `json:"orgId"`
  9862. UserName string `json:"userName"`
  9863. } `json:"data"`
  9864. Infno interface{} `json:"infno"`
  9865. Message string `json:"message"`
  9866. OrgID string `json:"orgId"`
  9867. TransType string `json:"transType"`
  9868. }
  9869. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  9870. fmt.Println(result)
  9871. outPutInfo := Remove0000(result)
  9872. fmt.Println(outPutInfo)
  9873. if len(outPutInfo) > 0 {
  9874. var ele ELeData
  9875. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9876. if err != nil {
  9877. utils.ErrorLog("解析失败:%v", err)
  9878. }
  9879. token := ele.Data.EcToken
  9880. fmt.Println(outPutInfo)
  9881. 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)
  9882. saveLog(result, requestLog, "1101", "获取人员信息")
  9883. var dat map[string]interface{}
  9884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9885. fmt.Println(dat)
  9886. } else {
  9887. fmt.Println(err)
  9888. }
  9889. userJSONBytes, _ := json.Marshal(dat)
  9890. var res ResultTwo
  9891. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9892. utils.ErrorLog("解析失败:%v", err)
  9893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9894. return
  9895. }
  9896. if res.Infcode == 0 {
  9897. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  9898. if err == gorm.ErrRecordNotFound {
  9899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9900. return
  9901. } else if err != nil {
  9902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9903. return
  9904. } else {
  9905. fmt.Println(res)
  9906. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9907. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9908. infoStr := string(Iinfos)
  9909. idetinfoStr := string(Idetinfos)
  9910. psn := &models.HisPsn{
  9911. PsnNo: res.Output.Baseinfo.PsnNo,
  9912. PatientId: patient.ID,
  9913. Certno: res.Output.Baseinfo.Certno,
  9914. Gend: res.Output.Baseinfo.Gend,
  9915. Naty: res.Output.Baseinfo.Naty,
  9916. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9917. PsnName: res.Output.Baseinfo.PsnName,
  9918. Idetinfo: idetinfoStr,
  9919. Insuinfo: infoStr,
  9920. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9921. CardInfo: outPutInfo,
  9922. VerifyNumber: token,
  9923. InsuplcAdmdvs: ele.Data.InsuOrg,
  9924. }
  9925. service.CreateHisPsn(psn)
  9926. var rf []*ResultFive
  9927. json.Unmarshal([]byte(infoStr), &rf)
  9928. var insutypes []*ResultFive
  9929. var insutype string
  9930. var is390 int = 0
  9931. var is310 int = 0
  9932. for _, item := range rf {
  9933. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9934. insutypes = append(insutypes, item)
  9935. }
  9936. }
  9937. if len(insutypes) == 1 {
  9938. insutype = insutypes[0].Insutype
  9939. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9940. } else {
  9941. for _, i := range insutypes {
  9942. if i.Insutype == "390" {
  9943. is390 = 1
  9944. }
  9945. if i.Insutype == "310" {
  9946. is310 = 1
  9947. }
  9948. }
  9949. }
  9950. if is390 == 1 {
  9951. insutype = "390"
  9952. }
  9953. if is310 == 1 {
  9954. insutype = "310"
  9955. }
  9956. if len(insutypes) == 0 {
  9957. insutype = "310"
  9958. }
  9959. c.ServeSuccessJSON(map[string]interface{}{
  9960. "patient": patient,
  9961. "number": token,
  9962. "insutype": insutype,
  9963. })
  9964. }
  9965. } else {
  9966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9967. return
  9968. }
  9969. }
  9970. //fmt.Println(result)
  9971. //
  9972. //if initFlag == 0 {
  9973. // c.TestGetBasBaseInit()
  9974. //}
  9975. //token := c.GetEleBaseInfo()
  9976. //
  9977. //token = Remove0000(token)
  9978. //
  9979. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  9980. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  9981. ////
  9982. //var res ResultTwo
  9983. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9984. // utils.ErrorLog("解析失败:%v", err)
  9985. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9986. // return
  9987. //}
  9988. //
  9989. //if res.Infcode == 0 {
  9990. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9991. // if err == gorm.ErrRecordNotFound {
  9992. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9993. // return
  9994. // } else if err != nil {
  9995. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9996. // return
  9997. //
  9998. // } else {
  9999. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10000. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10001. // infoStr := string(Iinfos)
  10002. // idetinfoStr := string(Idetinfos)
  10003. //
  10004. //
  10005. //
  10006. //
  10007. // var rf []*ResultFive
  10008. // json.Unmarshal([]byte(infoStr), &rf)
  10009. //
  10010. // var insutypes []*ResultFive
  10011. // var insutype string
  10012. // var is390 int = 0
  10013. // var is310 int = 0
  10014. // var insuplc_admdvs string
  10015. //
  10016. // for _, item := range rf {
  10017. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10018. // insutypes = append(insutypes, item)
  10019. // }
  10020. // }
  10021. //
  10022. // if len(insutypes) == 1 {
  10023. // insutype = insutypes[0].Insutype
  10024. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10025. // } else {
  10026. // for _, i := range insutypes {
  10027. // if i.Insutype == "390" {
  10028. // is390 = 1
  10029. // }
  10030. //
  10031. // if i.Insutype == "310" {
  10032. // is310 = 1
  10033. // }
  10034. // }
  10035. // }
  10036. // if is390 == 1 {
  10037. // insutype = "390"
  10038. // }
  10039. //
  10040. // if is310 == 1 {
  10041. // insutype = "310"
  10042. // }
  10043. // if len(insutypes) == 0 {
  10044. // insutype = "310"
  10045. // }
  10046. // for _, item := range rf {
  10047. // if item.Insutype == insutype {
  10048. // insuplc_admdvs = item.InsuplcAdmdvs
  10049. // }
  10050. // }
  10051. // psn := &models.HisPsn{
  10052. // PsnNo: res.Output.Baseinfo.PsnNo,
  10053. // Age: res.Output.Baseinfo.Age,
  10054. // PatientId: patient.ID,
  10055. // Certno: res.Output.Baseinfo.Certno,
  10056. // Brdy: res.Output.Baseinfo.Brdy,
  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. // InsuplcAdmdvs: insuplc_admdvs,
  10067. // }
  10068. // service.CreateHisPsn(psn)
  10069. //
  10070. // c.ServeSuccessJSON(map[string]interface{}{
  10071. // "patient": patient,
  10072. // "number": token,
  10073. // })
  10074. // }
  10075. //} else {
  10076. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10077. // return
  10078. //}
  10079. }
  10080. break
  10081. case 5:
  10082. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10083. var api string
  10084. if miConfig.MdtrtareaAdmvs == "320921" {
  10085. 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 +
  10086. "&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
  10087. fmt.Println(api)
  10088. } else {
  10089. 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 +
  10090. "&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)
  10091. }
  10092. resp, requestErr := http.Get(api)
  10093. if requestErr != nil {
  10094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10095. return
  10096. }
  10097. body, ioErr := ioutil.ReadAll(resp.Body)
  10098. if ioErr != nil {
  10099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10101. return
  10102. }
  10103. var respJSON map[string]interface{}
  10104. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10107. return
  10108. }
  10109. var status string
  10110. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10111. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10112. var token string
  10113. var res ResultTwo //1101结果
  10114. var res10265 ResultTwo10265 //1101结果
  10115. if status == "0" { //读卡成功
  10116. var card_info string //卡信息
  10117. //var busi_card_info string
  10118. var auth_info string
  10119. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10120. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10121. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10122. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  10123. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10124. result, _ := json.Marshal(respJSON)
  10125. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10126. utils.ErrorLog("解析失败:%v", err)
  10127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10128. return
  10129. }
  10130. res.ErrMsg = res10265.ErrMsg
  10131. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10132. res.Infcode = infocode
  10133. res.Output = res10265.Output
  10134. res.InfRefmsgid = res10265.InfRefmsgid
  10135. if res.Infcode == 0 {
  10136. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10137. if err == gorm.ErrRecordNotFound {
  10138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10139. return
  10140. } else if err != nil {
  10141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10142. return
  10143. } else {
  10144. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10145. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10146. infoStr := string(Iinfos)
  10147. idetinfoStr := string(Idetinfos)
  10148. psn := &models.HisPsn{
  10149. PsnNo: res.Output.Baseinfo.PsnNo,
  10150. PatientId: patient.ID,
  10151. Certno: res.Output.Baseinfo.Certno,
  10152. Gend: res.Output.Baseinfo.Gend,
  10153. //Brdy: res.Output.Baseinfo.Brdy,
  10154. Naty: res.Output.Baseinfo.Naty,
  10155. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10156. PsnName: res.Output.Baseinfo.PsnName,
  10157. Idetinfo: idetinfoStr,
  10158. Insuinfo: infoStr,
  10159. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10160. CardInfo: card_info,
  10161. VerifyNumber: token,
  10162. AuthInfo: auth_info,
  10163. }
  10164. var rf []*ResultFive
  10165. json.Unmarshal([]byte(infoStr), &rf)
  10166. var insutypes []*ResultFive
  10167. var insutype string
  10168. var is390 int = 0
  10169. var is310 int = 0
  10170. for _, item := range rf {
  10171. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10172. insutypes = append(insutypes, item)
  10173. }
  10174. }
  10175. if len(insutypes) == 1 {
  10176. insutype = insutypes[0].Insutype
  10177. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10178. } else {
  10179. for _, i := range insutypes {
  10180. if i.Insutype == "390" {
  10181. is390 = 1
  10182. }
  10183. if i.Insutype == "310" {
  10184. is310 = 1
  10185. }
  10186. }
  10187. }
  10188. if is390 == 1 {
  10189. insutype = "390"
  10190. }
  10191. if is310 == 1 {
  10192. insutype = "310"
  10193. }
  10194. if len(insutypes) == 0 {
  10195. insutype = "310"
  10196. }
  10197. service.CreateHisPsn(psn)
  10198. c.ServeSuccessJSON(map[string]interface{}{
  10199. "patient": patient,
  10200. "number": token,
  10201. "insutype": insutype,
  10202. })
  10203. }
  10204. } else {
  10205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10206. return
  10207. }
  10208. } else { //读卡失败
  10209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10210. return
  10211. }
  10212. }
  10213. break
  10214. }
  10215. }
  10216. var initFlag int64 = 0
  10217. var initEleFlag int64 = 0
  10218. func (c *HisApiController) TestGetBasBaseInit() {
  10219. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10220. Iinit := DllDef.MustFindProc("Init")
  10221. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10222. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  10223. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  10224. if ret != 0 {
  10225. fmt.Println("SSCard的报错原因:", err)
  10226. fmt.Println("SSCard的运算结果为:", ret)
  10227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10228. return
  10229. }
  10230. result := int(ret)
  10231. fmt.Println("SSCard的运算结果为1:", result)
  10232. initFlag = 1
  10233. return
  10234. }
  10235. func (c *HisApiController) HandleJiangXiReadCard() {
  10236. fmt.Println("~~~~~~")
  10237. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10238. admin_user_id, _ := c.GetInt64("admin_user_id")
  10239. id_card_type, _ := c.GetInt64("id_card_type")
  10240. //certificates, _ := c.GetInt64("certificates")
  10241. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10242. if initFlag == 0 {
  10243. c.TestGetJiangXiBasBaseInit()
  10244. }
  10245. basStr := c.GetBasBaseInfo()
  10246. if len(basStr) == 0 {
  10247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10248. return
  10249. }
  10250. fmt.Println(basStr)
  10251. bas := strings.Split(basStr, "|")
  10252. basNumber := bas[1]
  10253. fmt.Println(basNumber)
  10254. card_sn := bas[3]
  10255. fmt.Println(card_sn)
  10256. 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, "")
  10257. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  10258. var dat map[string]interface{}
  10259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10260. fmt.Println(dat)
  10261. } else {
  10262. fmt.Println(err)
  10263. }
  10264. userJSONBytes, _ := json.Marshal(dat)
  10265. var res ResultTwo
  10266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10267. utils.ErrorLog("解析失败:%v", err)
  10268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10269. return
  10270. }
  10271. if res.Infcode == 0 {
  10272. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  10273. if err == gorm.ErrRecordNotFound {
  10274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10275. return
  10276. } else if err != nil {
  10277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10278. return
  10279. } else {
  10280. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10281. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10282. infoStr := string(Iinfos)
  10283. idetinfoStr := string(Idetinfos)
  10284. psn := &models.HisPsn{
  10285. PsnNo: res.Output.Baseinfo.PsnNo,
  10286. PatientId: patient.ID,
  10287. Certno: res.Output.Baseinfo.Certno,
  10288. Gend: res.Output.Baseinfo.Gend,
  10289. Naty: res.Output.Baseinfo.Naty,
  10290. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10291. PsnName: res.Output.Baseinfo.PsnName,
  10292. Idetinfo: idetinfoStr,
  10293. Insuinfo: infoStr,
  10294. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10295. CardInfo: basStr,
  10296. VerifyNumber: "",
  10297. }
  10298. service.CreateHisPsn(psn)
  10299. c.ServeSuccessJSON(map[string]interface{}{
  10300. "patient": patient,
  10301. "number": basNumber,
  10302. })
  10303. }
  10304. } else {
  10305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10306. return
  10307. }
  10308. }
  10309. func (c *HisApiController) TestGetHnBasBaseInit() {
  10310. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10311. Iinit := DllDef.MustFindProc("Init")
  10312. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10313. //http://10.77.211.236/CSB/hsa-fsi-1303
  10314. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  10315. if ret != 0 {
  10316. fmt.Println("SSCard的报错原因:", err)
  10317. fmt.Println("SSCard的运算结果为:", ret)
  10318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10319. return
  10320. }
  10321. result := int(ret)
  10322. fmt.Println("SSCard的运算结果为1:", result)
  10323. initFlag = 1
  10324. return
  10325. }
  10326. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  10327. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10328. Iinit := DllDef.MustFindProc("Init")
  10329. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10330. //http://10.77.211.236/CSB/hsa-fsi-1303
  10331. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  10332. if ret != 0 {
  10333. fmt.Println("SSCard的报错原因:", err)
  10334. fmt.Println("SSCard的运算结果为:", ret)
  10335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10336. return
  10337. }
  10338. result := int(ret)
  10339. fmt.Println("SSCard的运算结果为1:", result)
  10340. initFlag = 1
  10341. return
  10342. }
  10343. func (c *HisApiController) GetSFZBaseInfo() string {
  10344. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10345. readCard := DllDef.MustFindProc("ReadSFZ")
  10346. if readCard == nil {
  10347. fmt.Println("readcard is nil")
  10348. readCard = DllDef.MustFindProc("ReadSFZ")
  10349. }
  10350. str := make([]byte, 8096)
  10351. str1 := make([]byte, 8096)
  10352. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  10353. fmt.Println(r)
  10354. return Remove0000(string(str))
  10355. }
  10356. func (c *HisApiController) GetEleBaseInfo() string {
  10357. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10358. readCard := DllDef.MustFindProc("GetQRBase")
  10359. fmt.Println(readCard)
  10360. if readCard == nil {
  10361. fmt.Println("readcard is nil")
  10362. readCard = DllDef.MustFindProc("GetQRBase")
  10363. }
  10364. str := make([]byte, 1024)
  10365. str1 := make([]byte, 1024)
  10366. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  10367. fmt.Println(ret2)
  10368. fmt.Println(string(str1))
  10369. fmt.Println(string(str))
  10370. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10371. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10372. if ret2 != 0 {
  10373. return ""
  10374. }
  10375. return string(str)
  10376. }
  10377. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10378. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10379. readCard := DllDef.MustFindProc("NationEcTrans")
  10380. fmt.Println(readCard)
  10381. fmt.Println("!!!!!")
  10382. pBusiCardInfo := make([]byte, 2048)
  10383. input := make(map[string]interface{})
  10384. inputData := make(map[string]interface{})
  10385. inputData["orgId"] = code
  10386. inputData["businessType"] = "01101"
  10387. inputData["operatorId"] = "1"
  10388. inputData["operatorName"] = "admin"
  10389. inputData["officeId"] = "001"
  10390. inputData["officeName"] = "血透室"
  10391. inputData["deviceType"] = ""
  10392. input["data"] = inputData
  10393. input["orgId"] = code
  10394. input["transType"] = "ec.query"
  10395. bytesData, _ := json.Marshal(input)
  10396. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  10397. fmt.Println(ret2)
  10398. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10399. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10400. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  10401. }
  10402. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10403. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10404. readCard := DllDef.MustFindProc("NationEcTrans")
  10405. fmt.Println(readCard)
  10406. fmt.Println("!!!!!")
  10407. pBusiCardInfo := make([]byte, 2048)
  10408. input := make(map[string]interface{})
  10409. inputData := make(map[string]interface{})
  10410. inputData["orgId"] = code
  10411. inputData["businessType"] = "01101"
  10412. inputData["operatorId"] = "9"
  10413. inputData["operatorName"] = "admin"
  10414. inputData["officeId"] = "001"
  10415. inputData["officeName"] = "血透室"
  10416. inputData["deviceType"] = ""
  10417. input["data"] = inputData
  10418. input["orgId"] = code
  10419. input["transType"] = "ec.query"
  10420. bytesData, _ := json.Marshal(input)
  10421. 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])))
  10422. fmt.Println(ret2)
  10423. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10424. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10425. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10426. }
  10427. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  10428. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10429. readCard := DllDef.MustFindProc("NationEcTrans")
  10430. fmt.Println(readCard)
  10431. fmt.Println("!!!!!")
  10432. pBusiCardInfo := make([]byte, 2048)
  10433. input := make(map[string]interface{})
  10434. inputData := make(map[string]interface{})
  10435. inputData["orgId"] = code
  10436. inputData["businessType"] = "01301"
  10437. inputData["operatorId"] = "9"
  10438. inputData["operatorName"] = "admin"
  10439. inputData["officeId"] = "001"
  10440. inputData["officeName"] = "血透室"
  10441. inputData["deviceType"] = ""
  10442. input["data"] = inputData
  10443. input["orgId"] = code
  10444. input["transType"] = "ec.query"
  10445. bytesData, _ := json.Marshal(input)
  10446. 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])))
  10447. fmt.Println(ret2)
  10448. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10449. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10450. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10451. }
  10452. func GetJxEleBaseInfo(org_id int64) string {
  10453. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10454. readCard := DllDef.MustFindProc("NationEcTrans")
  10455. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10456. if readCard == nil {
  10457. fmt.Println("readcard is nil")
  10458. readCard = DllDef.MustFindProc("NationEcTrans")
  10459. }
  10460. str1 := make([]byte, 1024)
  10461. data := make(map[string]interface{})
  10462. inputData := make(map[string]interface{})
  10463. inputData["orgId"] = miConfig.Code
  10464. inputData["businessType"] = "01101"
  10465. inputData["operatorId"] = "test001"
  10466. inputData["operatorName"] = "cn"
  10467. inputData["officeId"] = "32760"
  10468. inputData["officeName"] = "waike"
  10469. inputData["deviceType"] = ""
  10470. data["data"] = inputData
  10471. data["transType"] = "ec.query"
  10472. data["extra "] = ""
  10473. data["orgId"] = miConfig.Code
  10474. bytesData, _ := json.Marshal(data)
  10475. //bytesData, _ := json.Marshal(data)
  10476. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10477. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10478. fmt.Println(ret2)
  10479. fmt.Println(string(str1))
  10480. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10481. if ret2 != 0 {
  10482. return ""
  10483. }
  10484. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10485. }
  10486. func GetJxEleBaseInitInfo(org_id int64) string {
  10487. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10488. readCard := DllDef.MustFindProc("NationEcTrans")
  10489. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10490. if readCard == nil {
  10491. fmt.Println("readcard is nil")
  10492. readCard = DllDef.MustFindProc("NationEcTrans")
  10493. }
  10494. str1 := make([]byte, 2048)
  10495. data := make(map[string]interface{})
  10496. inputData := make(map[string]interface{})
  10497. inputData["orgId"] = miConfig.Code
  10498. inputData["businessType"] = "01101"
  10499. inputData["operatorId"] = "1"
  10500. inputData["operatorName"] = "huangchuang"
  10501. inputData["officeId"] = "101"
  10502. inputData["officeName"] = "xuetou"
  10503. inputData["deviceType"] = ""
  10504. data["data"] = inputData
  10505. data["transType"] = "ec.query"
  10506. data["orgId"] = miConfig.Code
  10507. bytesData, _ := json.Marshal(data)
  10508. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10509. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10510. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  10511. fmt.Println(ret2)
  10512. fmt.Println(string(str1))
  10513. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10514. if ret2 != 0 {
  10515. return ""
  10516. }
  10517. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  10518. initEleFlag = 1
  10519. }
  10520. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10521. }
  10522. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  10523. // // 构建命令
  10524. // cmd := exec.Command("python", "b.py")
  10525. //
  10526. // // 执行命令并等待完成
  10527. // output, err := cmd.CombinedOutput()
  10528. // if err != nil {
  10529. // fmt.Println("Error executing Python script:", err)
  10530. // return
  10531. // }
  10532. //
  10533. // // 打印Python脚本的输出
  10534. // fmt.Println(string(output))
  10535. //}
  10536. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  10537. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  10538. readCard := DllDef.MustFindProc("gxyb_call")
  10539. if readCard == nil {
  10540. fmt.Println("readcard is nil")
  10541. readCard = DllDef.MustFindProc("gxyb_call")
  10542. }
  10543. str := make([]byte, 1024)
  10544. str1 := make([]byte, 1024)
  10545. //data := make(map[string]interface{})
  10546. currentTime := time.Now()
  10547. // 格式化时间为 "YYYYMMDDHH24MISS"
  10548. formattedTime := currentTime.Format("20060102150405")
  10549. inputData := make(map[string]interface{})
  10550. inputData2 := make(map[string]interface{})
  10551. inputData["transNo"] = "1401"
  10552. inputData["transType"] = "passwordCheck"
  10553. inputData["timestamp"] = formattedTime
  10554. inputData2["fixmedinsCode"] = code
  10555. inputData2["psnNo"] = ""
  10556. inputData["data"] = inputData2
  10557. jsonBytes, err := json.Marshal(inputData)
  10558. if err != nil {
  10559. fmt.Println("Error encoding map to JSON:", err)
  10560. }
  10561. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10562. fmt.Println(string(str1))
  10563. fmt.Println(string(str))
  10564. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10565. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10566. if ret2 != 0 {
  10567. return ""
  10568. }
  10569. return string(str)
  10570. }
  10571. func (c *HisApiController) GetoleInfo() Response {
  10572. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  10573. defer ole.CoUninitialize()
  10574. // Replace with the ProgID or CLSID of your COM object
  10575. progID := "YinHai.XJ.Actual.Interface.New"
  10576. // Create COM object
  10577. unknown, err := oleutil.CreateObject(progID)
  10578. if err != nil {
  10579. fmt.Println("Unable to create COM object:", err)
  10580. }
  10581. defer unknown.Release()
  10582. // Query for the IDispatch interface
  10583. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  10584. if err != nil {
  10585. fmt.Println("Unable to get IDispatch interface:", err)
  10586. }
  10587. defer dispatch.Release()
  10588. // Prepare parameters
  10589. transNo := "1401"
  10590. transType := "passwordCheck"
  10591. timestamp := time.Now().Unix()
  10592. fixmedinsCode := "H45072101171"
  10593. psnNo := ""
  10594. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  10595. result2 := ""
  10596. // Call COM object's method using the IDispatch interface
  10597. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  10598. fmt.Println(resulr)
  10599. fmt.Println(result2)
  10600. if err != nil {
  10601. fmt.Println("调用COM对象方法失败:", err)
  10602. }
  10603. var response Response
  10604. err2 := json.Unmarshal([]byte(result2), &response)
  10605. if err2 != nil {
  10606. fmt.Println("解析JSON失败:", err)
  10607. }
  10608. return response
  10609. }
  10610. func (c *HisApiController) GetBasBaseInfo() string {
  10611. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10612. readCard := DllDef.MustFindProc("ReadCardBas")
  10613. if readCard == nil {
  10614. fmt.Println("readcard is nil")
  10615. readCard = DllDef.MustFindProc("ReadCardBas")
  10616. }
  10617. str := make([]byte, 1024)
  10618. str1 := make([]byte, 1024)
  10619. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  10620. fmt.Println(string(str1))
  10621. fmt.Println(string(str))
  10622. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10623. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10624. if ret2 != 0 {
  10625. return ""
  10626. }
  10627. return string(str)
  10628. }
  10629. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  10630. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  10631. readCard := DllDef.MustFindProc("read_cardinfo")
  10632. if readCard == nil {
  10633. fmt.Println("readcard is nil")
  10634. readCard = DllDef.MustFindProc("read_cardinfo")
  10635. }
  10636. str := make([]byte, 1024) //卡号
  10637. str1 := make([]byte, 1024) //卡识别码
  10638. str2 := make([]byte, 1024) //身份证号
  10639. str3 := make([]byte, 1024) //姓名
  10640. str4 := make([]byte, 1024) //错误信息
  10641. 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])))
  10642. fmt.Println(string(str1))
  10643. fmt.Println(string(str))
  10644. fmt.Println(string(str2))
  10645. fmt.Println(string(str3))
  10646. fmt.Println(string(str4))
  10647. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10648. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10649. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  10650. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  10651. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  10652. if ret2 != 0 {
  10653. return "", "", "", "", ""
  10654. }
  10655. return string(str), string(str1), string(str2), string(str3), string(str4)
  10656. }
  10657. type CustomFundPay struct {
  10658. FundPayType string `json:"fund_pay_type"`
  10659. FundPayamt float64 `json:"fund_payamt"`
  10660. InscpScpAmt float64 `json:"inscp_scp_amt"`
  10661. }
  10662. //func (c *HisApiController) GetBatchSettleList() {
  10663. // start_time_str := c.GetString("start_time")
  10664. // //end_time_str := c.GetString("end_time")
  10665. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10666. //
  10667. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  10668. //
  10669. // for _, item := range orders {
  10670. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  10671. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  10672. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10673. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  10674. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10675. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  10676. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10677. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  10678. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  10679. //
  10680. // if order.ID == 0 {
  10681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  10682. // return
  10683. // }
  10684. //
  10685. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  10686. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  10687. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  10688. // //fmt.Println(count)
  10689. // //var zero string
  10690. // //number := count + 1
  10691. // //if number >= 1000 {
  10692. // // zero = "0000" + strconv.FormatInt(number, 10)
  10693. // //} else if number >= 10000 {
  10694. // // zero = "000" + strconv.FormatInt(number, 10)
  10695. // //} else if number >= 100000 {
  10696. // // zero = "00" + strconv.FormatInt(number, 10)
  10697. // //} else if number >= 1000000 {
  10698. // // zero = "0" + strconv.FormatInt(number, 10)
  10699. // //} else {
  10700. // // zero = strconv.FormatInt(number, 10)
  10701. // //}
  10702. // //fmt.Println(zero)
  10703. //
  10704. // struct4101 := service.Struct4101{
  10705. // PsnNo: order.PsnNo,
  10706. // MdtrtId: order.MdtrtId,
  10707. // SetlId: order.SetlId,
  10708. // PsnName: order.PsnName,
  10709. // Gend: order.Gend,
  10710. // Brdy: his.Brdy,
  10711. // Age: his.Age,
  10712. // Naty: order.Naty,
  10713. // PatnCertType: "01",
  10714. // Certno: order.Certno,
  10715. // Prfs: "90",
  10716. // ConerName: roles[0].UserName,
  10717. // PatnRlts: "99",
  10718. // ConerAddr: miConfig.OrgName,
  10719. // ConerTel: admin.Mobile,
  10720. // HiType: order.Insutype,
  10721. // Insuplc: miConfig.InsuplcAdmdvs,
  10722. // MaindiagFlag: "1",
  10723. // BillCode: order.SetlId,
  10724. // BillNo: order.SetlId,
  10725. // BizSn: order.Number,
  10726. // PsnSelfPay: order.PsnPartAmt,
  10727. // PsnOwnPay: order.PsnPartAmt,
  10728. // AcctPay: order.AcctPay,
  10729. // PsnCashpay: order.PsnCashPay,
  10730. // HiPaymtd: "1",
  10731. // Hsorg: miConfig.InsuplcAdmdvs,
  10732. // HsorgOpter: miConfig.InsuplcAdmdvs,
  10733. // MedinsFillPsn: curRoles.UserName,
  10734. // MedinsFillDept: miConfig.OrgName,
  10735. // IptMedType: "2",
  10736. // }
  10737. // struct4101.SetlBegnDate = order.SetlTime
  10738. // struct4101.SetlEndDate = order.SetlTime
  10739. // time_arr := strings.Split(order.SetlTime, " ")
  10740. // struct4101.AdmTime = time_arr[0]
  10741. // struct4101.AdmEndTime = time_arr[0]
  10742. //
  10743. // var rf []CustomFundPay
  10744. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  10745. //
  10746. // var tempFunPays []service.CustomStruct
  10747. // for _, item := range rf {
  10748. // var tempFunPay service.CustomStruct
  10749. // tempFunPay.FundPayamt = item.FundPayamt
  10750. // tempFunPay.FundPayType = item.FundPayType
  10751. // tempFunPays = append(tempFunPays, tempFunPay)
  10752. // }
  10753. // struct4101.CustomStruct = tempFunPays
  10754. //
  10755. // var tempDiaginfos []service.DiaginfoStructTwo
  10756. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  10757. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  10758. //
  10759. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10760. // var config []*models.HisXtDiagnoseConfig
  10761. // for _, item := range diagnosis_ids {
  10762. // id, _ := strconv.ParseInt(item, 10, 64)
  10763. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  10764. // config = append(config, &diagnosisConfig)
  10765. // }
  10766. //
  10767. // for index, item := range config {
  10768. // if index == 0 {
  10769. // var tempDiaginfo service.DiaginfoStructTwo
  10770. // tempDiaginfo.DiagCode = item.CountryCode
  10771. // tempDiaginfo.DiagName = item.CountryContentName
  10772. // tempDiaginfo.DiagType = "1"
  10773. // tempDiaginfo.MaindiagFlag = "1"
  10774. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  10775. // } else {
  10776. // var tempDiaginfo service.DiaginfoStructTwo
  10777. // tempDiaginfo.DiagCode = item.CountryCode
  10778. // tempDiaginfo.DiagName = item.CountryContentName
  10779. // tempDiaginfo.DiagType = "1"
  10780. // tempDiaginfo.MaindiagFlag = "0"
  10781. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  10782. // }
  10783. // }
  10784. // struct4101.Diseinfo = tempDiaginfos
  10785. //
  10786. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  10787. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  10788. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  10789. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  10790. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  10791. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  10792. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  10793. //
  10794. // var iteminfo service.IteminfoStruct
  10795. //
  10796. // var bedCostTotal float64 = 0 //床位总费
  10797. // var bedCostSelfTotal float64 = 0 //床位自费
  10798. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  10799. //
  10800. // var operationCostTotal float64 = 0 //手术费
  10801. // var operationCostSelfTotal float64 = 0 //手术费
  10802. // var operationCostPartSelfTotal float64 = 0 //手术费
  10803. //
  10804. // var otherCostTotal float64 = 0 //其他费用
  10805. // var otherCostSelfTotal float64 = 0 //其他费用
  10806. // var otherCostPartSelfTotal float64 = 0 //其他费用
  10807. //
  10808. // var materialCostTotal float64 = 0 //材料费
  10809. // var materialCostSelfTotal float64 = 0 //材料费
  10810. // var materialCostPartSelfTotal float64 = 0 //材料费
  10811. //
  10812. // var westernMedicineCostTotal float64 = 0 //西药费
  10813. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  10814. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  10815. //
  10816. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  10817. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  10818. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  10819. //
  10820. // var checkCostTotal float64 = 0 //检查费
  10821. // var checkCostSelfTotal float64 = 0 //检查费
  10822. // var checkCostPartSelfTotal float64 = 0 //检查费
  10823. //
  10824. // var laboratoryCostTotal float64 = 0 //化验费
  10825. // var laboratoryCostSelfTotal float64 = 0 //化验费
  10826. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  10827. //
  10828. // var treatCostTotal float64 = 0 //治疗费用
  10829. // var treatCostSelfTotal float64 = 0 //治疗费用
  10830. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  10831. //
  10832. // decimal.DivisionPrecision = 2
  10833. //
  10834. // var bed_fulamt_ownpay_amt float64 = 0
  10835. // var operation_fulamt_ownpay_amt float64 = 0
  10836. // var other_fulamt_ownpay_amt float64 = 0
  10837. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  10838. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  10839. // var check_fulamt_ownpay_amt float64 = 0
  10840. // var material_fulamt_ownpay_amt float64 = 0
  10841. // var laboratory_fulamt_ownpay_amt float64 = 0
  10842. // var treat_fulamt_ownpay_amt float64 = 0
  10843. //
  10844. // var bed_claa_sunmfee float64 = 0
  10845. // var bed_clab_amt float64 = 0
  10846. // var bed_other_amt float64 = 0
  10847. //
  10848. // var operation_claa_sunmfee float64 = 0
  10849. // var operation_clab_amt float64 = 0
  10850. // var operation_other_amt float64 = 0
  10851. //
  10852. // var other_claa_sunmfee float64 = 0
  10853. // var other_clab_amt float64 = 0
  10854. // var other_other_amt float64 = 0
  10855. //
  10856. // var westernMedicine_claa_sunmfee float64 = 0
  10857. // var westernMedicine_clab_amt float64 = 0
  10858. // var westernMedicine_other_amt float64 = 0
  10859. //
  10860. // var chineseTraditional_claa_sunmfee float64 = 0
  10861. // var chineseTraditional_clab_amt float64 = 0
  10862. // var chineseTraditional_other_amt float64 = 0
  10863. //
  10864. // var check_claa_sunmfee float64 = 0
  10865. // var check_clab_amt float64 = 0
  10866. // var check_other_amt float64 = 0
  10867. //
  10868. // var material_claa_sunmfee float64 = 0
  10869. // var material_clab_amt float64 = 0
  10870. // var material_other_amt float64 = 0
  10871. //
  10872. // var laboratory_claa_sunmfee float64 = 0
  10873. // var laboratory_clab_amt float64 = 0
  10874. // var laboratory_other_amt float64 = 0
  10875. //
  10876. // var treat_claa_sunmfee float64 = 0
  10877. // var treat_clab_amt float64 = 0
  10878. // var treat_other_amt float64 = 0
  10879. //
  10880. // for _, item := range order.HisOrderInfo {
  10881. // if item.MedChrgitmType == "01" { //床位费
  10882. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10883. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10884. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10885. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10886. // if item.ChrgitmLv == "1" {
  10887. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10888. // }
  10889. // if item.ChrgitmLv == "2" {
  10890. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10891. //
  10892. // }
  10893. // if item.ChrgitmLv == "3" {
  10894. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10895. // }
  10896. //
  10897. // }
  10898. //
  10899. // if item.MedChrgitmType == "03" { //检查费
  10900. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10901. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10902. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10903. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10904. // if item.ChrgitmLv == "1" {
  10905. //
  10906. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10907. //
  10908. // }
  10909. // if item.ChrgitmLv == "2" {
  10910. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10911. //
  10912. // }
  10913. // if item.ChrgitmLv == "3" {
  10914. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10915. // }
  10916. // }
  10917. //
  10918. // if item.MedChrgitmType == "04" { //化验费
  10919. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10920. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10921. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10922. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10923. // if item.ChrgitmLv == "1" {
  10924. //
  10925. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10926. //
  10927. // }
  10928. // if item.ChrgitmLv == "2" {
  10929. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10930. //
  10931. // }
  10932. // if item.ChrgitmLv == "3" {
  10933. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10934. // }
  10935. // }
  10936. //
  10937. // if item.MedChrgitmType == "05" { //治疗费
  10938. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10939. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10940. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10941. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10942. // if item.ChrgitmLv == "1" {
  10943. //
  10944. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10945. //
  10946. // }
  10947. // if item.ChrgitmLv == "2" {
  10948. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10949. //
  10950. // }
  10951. // if item.ChrgitmLv == "3" {
  10952. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10953. // }
  10954. // }
  10955. //
  10956. // if item.MedChrgitmType == "06" { //手术费
  10957. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10958. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10959. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10960. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10961. //
  10962. // if item.ChrgitmLv == "1" {
  10963. //
  10964. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10965. //
  10966. // }
  10967. // if item.ChrgitmLv == "2" {
  10968. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10969. //
  10970. // }
  10971. // if item.ChrgitmLv == "3" {
  10972. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10973. // }
  10974. // }
  10975. //
  10976. // if item.MedChrgitmType == "08" { //材料费
  10977. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10978. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10979. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10980. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10981. // if item.ChrgitmLv == "1" {
  10982. //
  10983. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10984. //
  10985. // }
  10986. // if item.ChrgitmLv == "2" {
  10987. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10988. //
  10989. // }
  10990. // if item.ChrgitmLv == "3" {
  10991. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10992. // }
  10993. // }
  10994. //
  10995. // if item.MedChrgitmType == "09" { //西药费
  10996. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10997. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10998. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10999. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11000. // if item.ChrgitmLv == "1" {
  11001. //
  11002. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11003. //
  11004. // }
  11005. // if item.ChrgitmLv == "2" {
  11006. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11007. //
  11008. // }
  11009. // if item.ChrgitmLv == "3" {
  11010. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11011. // }
  11012. // }
  11013. //
  11014. // if item.MedChrgitmType == "11" { //中成费
  11015. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11016. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11017. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11018. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11019. // if item.ChrgitmLv == "1" {
  11020. //
  11021. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11022. //
  11023. // }
  11024. // if item.ChrgitmLv == "2" {
  11025. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11026. //
  11027. // }
  11028. // if item.ChrgitmLv == "3" {
  11029. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11030. // }
  11031. // }
  11032. //
  11033. // if item.MedChrgitmType == "14" { //其他费
  11034. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11035. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11036. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11037. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11038. // if item.ChrgitmLv == "1" {
  11039. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11040. //
  11041. // }
  11042. // if item.ChrgitmLv == "2" {
  11043. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11044. //
  11045. // }
  11046. // if item.ChrgitmLv == "3" {
  11047. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11048. // }
  11049. // }
  11050. //
  11051. // }
  11052. //
  11053. // var iteminfoStructs []service.IteminfoStruct
  11054. //
  11055. // if bedCostTotal != 0 {
  11056. // iteminfo.MedChrgitm = "01"
  11057. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11058. // iteminfo.Amt = bedCostTotal
  11059. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  11060. // iteminfo.ClabAmt = bed_clab_amt
  11061. // iteminfo.OthAmt = bed_other_amt
  11062. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11063. // }
  11064. //
  11065. // if checkCostTotal != 0 {
  11066. // iteminfo.MedChrgitm = "03"
  11067. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11068. // iteminfo.Amt = checkCostTotal
  11069. // iteminfo.ClaaSumfee = check_claa_sunmfee
  11070. // iteminfo.ClabAmt = check_clab_amt
  11071. // iteminfo.OthAmt = check_other_amt
  11072. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11073. //
  11074. // }
  11075. //
  11076. // if laboratoryCostTotal != 0 {
  11077. // iteminfo.MedChrgitm = "04"
  11078. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11079. // iteminfo.Amt = laboratoryCostTotal
  11080. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11081. // iteminfo.ClabAmt = laboratory_clab_amt
  11082. // iteminfo.OthAmt = laboratory_other_amt
  11083. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11084. //
  11085. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11086. //
  11087. // }
  11088. //
  11089. // if treatCostTotal != 0 {
  11090. // iteminfo.MedChrgitm = "05"
  11091. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11092. // iteminfo.Amt = treatCostTotal
  11093. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  11094. // iteminfo.ClabAmt = treat_clab_amt
  11095. // iteminfo.OthAmt = treat_other_amt
  11096. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11097. // //(struct4101.IteminfoStruct, iteminfo)
  11098. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11099. // }
  11100. //
  11101. // if operationCostTotal != 0 {
  11102. // iteminfo.MedChrgitm = "06"
  11103. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11104. // iteminfo.Amt = operationCostTotal
  11105. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  11106. // iteminfo.ClabAmt = operation_clab_amt
  11107. // iteminfo.OthAmt = operation_other_amt
  11108. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11109. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11110. // }
  11111. //
  11112. // if materialCostTotal != 0 {
  11113. // iteminfo.MedChrgitm = "08"
  11114. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11115. // iteminfo.Amt = materialCostTotal
  11116. // iteminfo.ClaaSumfee = material_claa_sunmfee
  11117. // iteminfo.ClabAmt = material_clab_amt
  11118. // iteminfo.OthAmt = material_other_amt
  11119. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11120. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11121. // }
  11122. //
  11123. // if westernMedicineCostTotal != 0 {
  11124. // iteminfo.MedChrgitm = "09"
  11125. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11126. // iteminfo.Amt = westernMedicineCostTotal
  11127. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11128. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11129. // iteminfo.OthAmt = westernMedicine_other_amt
  11130. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11131. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11132. //
  11133. // }
  11134. // if chineseTraditionalMedicineCostTotal != 0 {
  11135. // iteminfo.MedChrgitm = "11"
  11136. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11137. // iteminfo.Amt = westernMedicineCostTotal
  11138. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11139. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11140. // iteminfo.OthAmt = westernMedicine_other_amt
  11141. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11142. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11143. //
  11144. // }
  11145. // if otherCostTotal != 0 {
  11146. // iteminfo.MedChrgitm = "14"
  11147. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  11148. // iteminfo.Amt = otherCostTotal
  11149. // iteminfo.ClaaSumfee = other_claa_sunmfee
  11150. // iteminfo.ClabAmt = other_clab_amt
  11151. // iteminfo.OthAmt = other_other_amt
  11152. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11153. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11154. //
  11155. // }
  11156. // struct4101.IteminfoStruct = iteminfoStructs
  11157. // struct4101.Ntly = "中国"
  11158. // struct4101.AdmCaty = "A03.06"
  11159. //
  11160. // struct4101.DoctorName = doctor.UserName
  11161. // struct4101.DoctorCode = doctor.DoctorNumber
  11162. //
  11163. // var res ResultSeventeen
  11164. //
  11165. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11166. // struct4101.BillCode = order.Number
  11167. // struct4101.BillNo = order.SetlId
  11168. // var resOther ResultSeventeenOther
  11169. // var pp models.PublicParams
  11170. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11171. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11172. // pp.FixmedinsName = miConfig.OrgName
  11173. // pp.FixmedinsCode = miConfig.Code
  11174. // pp.RequestUrl = miConfig.Url
  11175. // pp.Cainfo = miConfig.Cainfo
  11176. // pp.SecretKey = miConfig.SecretKey
  11177. // pp.AccessKey = miConfig.AccessKey
  11178. // pp.OpterName = curRoles.UserName
  11179. //
  11180. // client := &http.Client{}
  11181. // var req *http.Request
  11182. // data := make(map[string]interface{})
  11183. // data["struct4101"] = struct4101
  11184. // data["pp"] = pp
  11185. // bytesData, _ := json.Marshal(data)
  11186. // if miConfig.MdtrtareaAdmvs == "320921" {
  11187. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11188. // } else {
  11189. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11190. // }
  11191. // resp, _ := client.Do(req)
  11192. // defer resp.Body.Close()
  11193. // body, ioErr := ioutil.ReadAll(resp.Body)
  11194. // if ioErr != nil {
  11195. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11197. // return
  11198. // }
  11199. // var respJSON map[string]interface{}
  11200. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11201. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11203. // return
  11204. // }
  11205. //
  11206. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11207. // userJSONBytes, _ := json.Marshal(respJSON)
  11208. // fmt.Println("log")
  11209. // fmt.Println(string(userJSONBytes))
  11210. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11211. // utils.ErrorLog("解析失败:%v", err)
  11212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11213. // return
  11214. // }
  11215. // res.InfRefmsgid = resOther.InfRefmsgid
  11216. // res.Output = resOther.Output
  11217. // res.ErrMsg = resOther.ErrMsg
  11218. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11219. // res.Infcode = infocode
  11220. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  11221. //
  11222. // var pp models.PublicParams
  11223. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11224. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11225. // pp.FixmedinsName = miConfig.OrgName
  11226. // pp.FixmedinsCode = miConfig.Code
  11227. // pp.RequestUrl = miConfig.Url
  11228. // pp.Cainfo = miConfig.Cainfo
  11229. // pp.SecretKey = miConfig.SecretKey
  11230. // pp.AccessKey = miConfig.AccessKey
  11231. // pp.OpterName = curRoles.UserName
  11232. // result, _ := service.Jxyb4101(struct4101, pp)
  11233. // var dat map[string]interface{}
  11234. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11235. // fmt.Println(dat)
  11236. // } else {
  11237. // fmt.Println(err)
  11238. // }
  11239. // userJSONBytes, _ := json.Marshal(dat)
  11240. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11241. // utils.ErrorLog("解析失败:%v", err)
  11242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11243. // return
  11244. // }
  11245. //
  11246. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  11247. // var pp models.PublicParams
  11248. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11249. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11250. // pp.FixmedinsName = miConfig.OrgName
  11251. // pp.FixmedinsCode = miConfig.Code
  11252. // pp.RequestUrl = miConfig.Url
  11253. // pp.Cainfo = miConfig.Cainfo
  11254. // pp.SecretKey = miConfig.SecretKey
  11255. // pp.AccessKey = miConfig.AccessKey
  11256. // pp.OpterName = curRoles.UserName
  11257. // result, _ := service.Hnyb4101(struct4101, pp)
  11258. // var dat map[string]interface{}
  11259. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11260. // fmt.Println(dat)
  11261. // } else {
  11262. // fmt.Println(err)
  11263. // }
  11264. // userJSONBytes, _ := json.Marshal(dat)
  11265. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11266. // utils.ErrorLog("解析失败:%v", err)
  11267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11268. // return
  11269. // }
  11270. //
  11271. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  11272. // var resOther ResultSeventeenOther
  11273. //
  11274. // var pp models.PublicParams
  11275. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11276. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11277. // pp.FixmedinsName = miConfig.OrgName
  11278. // pp.FixmedinsCode = miConfig.Code
  11279. // pp.RequestUrl = miConfig.Url
  11280. // pp.Cainfo = miConfig.Cainfo
  11281. // pp.SecretKey = miConfig.SecretKey
  11282. // pp.AccessKey = miConfig.AccessKey
  11283. // pp.OpterName = curRoles.UserName
  11284. // client := &http.Client{}
  11285. // var req *http.Request
  11286. // data := make(map[string]interface{})
  11287. // data["struct4101"] = struct4101
  11288. // data["pp"] = pp
  11289. // bytesData, _ := json.Marshal(data)
  11290. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  11291. // resp, _ := client.Do(req)
  11292. // defer resp.Body.Close()
  11293. // body, ioErr := ioutil.ReadAll(resp.Body)
  11294. // if ioErr != nil {
  11295. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11297. // return
  11298. // }
  11299. // var respJSON map[string]interface{}
  11300. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11301. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11302. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11303. // return
  11304. // }
  11305. //
  11306. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11307. // userJSONBytes, _ := json.Marshal(respJSON)
  11308. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11309. // utils.ErrorLog("解析失败:%v", err)
  11310. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11311. // return
  11312. // }
  11313. // res.InfRefmsgid = resOther.InfRefmsgid
  11314. // res.Output = resOther.Output
  11315. // res.ErrMsg = resOther.ErrMsg
  11316. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11317. // res.Infcode = infocode
  11318. //
  11319. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  11320. // var pp models.PublicParams
  11321. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11322. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11323. // pp.FixmedinsName = miConfig.OrgName
  11324. // pp.FixmedinsCode = miConfig.Code
  11325. // pp.RequestUrl = miConfig.Url
  11326. // pp.Cainfo = miConfig.Cainfo
  11327. // pp.SecretKey = miConfig.SecretKey
  11328. // pp.AccessKey = miConfig.AccessKey
  11329. // pp.OpterName = curRoles.UserName
  11330. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  11331. // fmt.Println(requestLog)
  11332. // fmt.Println(errMsgLog)
  11333. //
  11334. // saveLog(result, requestLog, "4101a", "上传清单")
  11335. //
  11336. // var dat map[string]interface{}
  11337. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11338. // fmt.Println(dat)
  11339. // } else {
  11340. // fmt.Println(err)
  11341. // }
  11342. // userJSONBytes, _ := json.Marshal(dat)
  11343. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11344. // utils.ErrorLog("解析失败:%v", err)
  11345. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11346. // return
  11347. // }
  11348. //
  11349. // } else {
  11350. //
  11351. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  11352. // var dat map[string]interface{}
  11353. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11354. // fmt.Println(dat)
  11355. // } else {
  11356. // fmt.Println(err)
  11357. // }
  11358. // userJSONBytes, _ := json.Marshal(dat)
  11359. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11360. // utils.ErrorLog("解析失败:%v", err)
  11361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11362. // return
  11363. // }
  11364. // }
  11365. //
  11366. // if res.Infcode != 0 {
  11367. // adminUser := c.GetAdminUserInfo()
  11368. // errlog := &models.HisOrderError{
  11369. // UserOrgId: adminUser.CurrentOrgId,
  11370. // Ctime: time.Now().Unix(),
  11371. // Mtime: time.Now().Unix(),
  11372. // ErrMsg: res.ErrMsg,
  11373. // Status: 1,
  11374. // PatientId: order.ID,
  11375. // Stage: 10265,
  11376. // }
  11377. // service.CreateErrMsgLog(errlog)
  11378. // continue
  11379. // } else {
  11380. // //order.FaPiaoNumber = zero
  11381. // //order.FaPiaoCode = last_order.FaPiaoCode
  11382. // //service.UpdateOrder(order)
  11383. // hisFundSettleListResult := &models.HisFundSettleListResult{
  11384. // Number: res.Output.SetlListId,
  11385. // Status: 1,
  11386. // Ctime: time.Now().Unix(),
  11387. // Mtime: time.Now().Unix(),
  11388. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11389. // IsUpload: 1,
  11390. // OrderId: order.ID,
  11391. // }
  11392. // service.CreateUploadRecord(hisFundSettleListResult)
  11393. // c.ServeSuccessJSON(map[string]interface{}{
  11394. // "msg": "上传成功",
  11395. // "result": hisFundSettleListResult,
  11396. // })
  11397. // continue
  11398. // }
  11399. // }
  11400. //}
  11401. func (c *HisApiController) GetbatchSettleList() {
  11402. //order_id, _ := c.GetInt64("order_id")
  11403. admin_user_id, _ := c.GetInt64("admin_user_id")
  11404. orders, _ := service.GetAllHisOrderTwo10485()
  11405. for _, item := range orders {
  11406. order, _ := service.GetHisOrderByIDTwo(item.ID)
  11407. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11408. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11409. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11410. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11411. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11412. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11413. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11414. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11415. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11416. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11417. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11418. //fmt.Println(count)
  11419. //var zero string
  11420. //number := count + 1
  11421. //if number >= 1000 {
  11422. // zero = "0000" + strconv.FormatInt(number, 10)
  11423. //} else if number >= 10000 {
  11424. // zero = "000" + strconv.FormatInt(number, 10)
  11425. //} else if number >= 100000 {
  11426. // zero = "00" + strconv.FormatInt(number, 10)
  11427. //} else if number >= 1000000 {
  11428. // zero = "0" + strconv.FormatInt(number, 10)
  11429. //} else {
  11430. // zero = strconv.FormatInt(number, 10)
  11431. //}
  11432. //fmt.Println(zero)
  11433. struct4101 := service.Struct4101{
  11434. PsnNo: order.PsnNo,
  11435. MdtrtId: order.MdtrtId,
  11436. SetlId: order.SetlId,
  11437. PsnName: order.PsnName,
  11438. Gend: order.Gend,
  11439. Brdy: his.Brdy,
  11440. Age: his.Age,
  11441. Naty: order.Naty,
  11442. PatnCertType: "01",
  11443. Certno: order.Certno,
  11444. Prfs: "90",
  11445. ConerName: roles[0].UserName,
  11446. PatnRlts: "99",
  11447. ConerAddr: miConfig.OrgName,
  11448. ConerTel: admin.Mobile,
  11449. HiType: order.Insutype,
  11450. Insuplc: miConfig.InsuplcAdmdvs,
  11451. MaindiagFlag: "1",
  11452. BillCode: order.SetlId,
  11453. BillNo: order.SetlId,
  11454. BizSn: order.Number,
  11455. PsnSelfPay: order.PsnPartAmt,
  11456. PsnOwnPay: order.PsnPartAmt,
  11457. AcctPay: order.AcctPay,
  11458. PsnCashpay: order.PsnCashPay,
  11459. HiPaymtd: "1",
  11460. Hsorg: miConfig.InsuplcAdmdvs,
  11461. HsorgOpter: miConfig.InsuplcAdmdvs,
  11462. MedinsFillPsn: curRoles.UserName,
  11463. MedinsFillDept: miConfig.OrgName,
  11464. IptMedType: "2",
  11465. }
  11466. struct4101.SetlBegnDate = order.SetlTime
  11467. struct4101.SetlEndDate = order.SetlTime
  11468. time_arr := strings.Split(order.SetlTime, " ")
  11469. struct4101.AdmTime = time_arr[0]
  11470. struct4101.AdmEndTime = time_arr[0]
  11471. //var rf []CustomFundPay
  11472. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  11473. //
  11474. //var tempFunPays []service.CustomStruct
  11475. //for _, item := range rf {
  11476. // var tempFunPay service.CustomStruct
  11477. // tempFunPay.FundPayamt = item.FundPayamt
  11478. // tempFunPay.FundPayType = item.FundPayType
  11479. // tempFunPays = append(tempFunPays, tempFunPay)
  11480. //}
  11481. //struct4101.CustomStruct = tempFunPays
  11482. var tempDiaginfos []service.DiaginfoStructTwo
  11483. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11484. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11485. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11486. var config []*models.HisXtDiagnoseConfig
  11487. for _, item := range diagnosis_ids {
  11488. id, _ := strconv.ParseInt(item, 10, 64)
  11489. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11490. config = append(config, &diagnosisConfig)
  11491. }
  11492. for index, item := range config {
  11493. if index == 0 {
  11494. var tempDiaginfo service.DiaginfoStructTwo
  11495. tempDiaginfo.DiagCode = item.CountryCode
  11496. tempDiaginfo.DiagName = item.CountryContentName
  11497. tempDiaginfo.DiagType = "1"
  11498. tempDiaginfo.MaindiagFlag = "1"
  11499. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11500. } else {
  11501. var tempDiaginfo service.DiaginfoStructTwo
  11502. tempDiaginfo.DiagCode = item.CountryCode
  11503. tempDiaginfo.DiagName = item.CountryContentName
  11504. tempDiaginfo.DiagType = "1"
  11505. tempDiaginfo.MaindiagFlag = "0"
  11506. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11507. }
  11508. }
  11509. struct4101.Diseinfo = tempDiaginfos
  11510. sickConfigTwo, _ := service.FindSickById(his.SickType)
  11511. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11512. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11513. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11514. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11515. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11516. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11517. var iteminfo service.IteminfoStruct
  11518. var bedCostTotal float64 = 0 //床位总费
  11519. var bedCostSelfTotal float64 = 0 //床位自费
  11520. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11521. var operationCostTotal float64 = 0 //手术费
  11522. var operationCostSelfTotal float64 = 0 //手术费
  11523. var operationCostPartSelfTotal float64 = 0 //手术费
  11524. var otherCostTotal float64 = 0 //其他费用
  11525. var otherCostSelfTotal float64 = 0 //其他费用
  11526. var otherCostPartSelfTotal float64 = 0 //其他费用
  11527. var materialCostTotal float64 = 0 //材料费
  11528. var materialCostSelfTotal float64 = 0 //材料费
  11529. var materialCostPartSelfTotal float64 = 0 //材料费
  11530. var westernMedicineCostTotal float64 = 0 //西药费
  11531. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11532. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11533. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11534. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11535. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11536. var checkCostTotal float64 = 0 //检查费
  11537. var checkCostSelfTotal float64 = 0 //检查费
  11538. var checkCostPartSelfTotal float64 = 0 //检查费
  11539. var laboratoryCostTotal float64 = 0 //化验费
  11540. var laboratoryCostSelfTotal float64 = 0 //化验费
  11541. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11542. var treatCostTotal float64 = 0 //治疗费用
  11543. var treatCostSelfTotal float64 = 0 //治疗费用
  11544. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11545. decimal.DivisionPrecision = 2
  11546. var bed_fulamt_ownpay_amt float64 = 0
  11547. var operation_fulamt_ownpay_amt float64 = 0
  11548. var other_fulamt_ownpay_amt float64 = 0
  11549. var westernMedicine_fulamt_ownpay_amt float64 = 0
  11550. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11551. var check_fulamt_ownpay_amt float64 = 0
  11552. var material_fulamt_ownpay_amt float64 = 0
  11553. var laboratory_fulamt_ownpay_amt float64 = 0
  11554. var treat_fulamt_ownpay_amt float64 = 0
  11555. var bed_claa_sunmfee float64 = 0
  11556. var bed_clab_amt float64 = 0
  11557. var bed_other_amt float64 = 0
  11558. var operation_claa_sunmfee float64 = 0
  11559. var operation_clab_amt float64 = 0
  11560. var operation_other_amt float64 = 0
  11561. var other_claa_sunmfee float64 = 0
  11562. var other_clab_amt float64 = 0
  11563. var other_other_amt float64 = 0
  11564. var westernMedicine_claa_sunmfee float64 = 0
  11565. var westernMedicine_clab_amt float64 = 0
  11566. var westernMedicine_other_amt float64 = 0
  11567. var chineseTraditional_claa_sunmfee float64 = 0
  11568. var chineseTraditional_clab_amt float64 = 0
  11569. var chineseTraditional_other_amt float64 = 0
  11570. var check_claa_sunmfee float64 = 0
  11571. var check_clab_amt float64 = 0
  11572. var check_other_amt float64 = 0
  11573. var material_claa_sunmfee float64 = 0
  11574. var material_clab_amt float64 = 0
  11575. var material_other_amt float64 = 0
  11576. var laboratory_claa_sunmfee float64 = 0
  11577. var laboratory_clab_amt float64 = 0
  11578. var laboratory_other_amt float64 = 0
  11579. var treat_claa_sunmfee float64 = 0
  11580. var treat_clab_amt float64 = 0
  11581. var treat_other_amt float64 = 0
  11582. for _, item := range order.HisOrderInfo {
  11583. if item.MedChrgitmType == "01" { //床位费
  11584. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11585. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11586. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11587. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11588. if item.ChrgitmLv == "1" {
  11589. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11590. }
  11591. if item.ChrgitmLv == "2" {
  11592. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11593. }
  11594. if item.ChrgitmLv == "3" {
  11595. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11596. }
  11597. }
  11598. if item.MedChrgitmType == "03" { //检查费
  11599. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11600. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11601. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11602. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11603. if item.ChrgitmLv == "1" {
  11604. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11605. }
  11606. if item.ChrgitmLv == "2" {
  11607. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11608. }
  11609. if item.ChrgitmLv == "3" {
  11610. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11611. }
  11612. }
  11613. if item.MedChrgitmType == "04" { //化验费
  11614. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11615. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11616. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11617. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11618. if item.ChrgitmLv == "1" {
  11619. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11620. }
  11621. if item.ChrgitmLv == "2" {
  11622. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11623. }
  11624. if item.ChrgitmLv == "3" {
  11625. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11626. }
  11627. }
  11628. if item.MedChrgitmType == "05" { //治疗费
  11629. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11630. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11631. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11632. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11633. if item.ChrgitmLv == "1" {
  11634. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11635. }
  11636. if item.ChrgitmLv == "2" {
  11637. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11638. }
  11639. if item.ChrgitmLv == "3" {
  11640. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11641. }
  11642. }
  11643. if item.MedChrgitmType == "06" { //手术费
  11644. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11645. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11646. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11647. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11648. if item.ChrgitmLv == "1" {
  11649. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11650. }
  11651. if item.ChrgitmLv == "2" {
  11652. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11653. }
  11654. if item.ChrgitmLv == "3" {
  11655. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11656. }
  11657. }
  11658. if item.MedChrgitmType == "08" { //材料费
  11659. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11660. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11661. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11662. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11663. if item.ChrgitmLv == "1" {
  11664. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11665. }
  11666. if item.ChrgitmLv == "2" {
  11667. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11668. }
  11669. if item.ChrgitmLv == "3" {
  11670. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11671. }
  11672. }
  11673. if item.MedChrgitmType == "09" { //西药费
  11674. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11675. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11676. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11677. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11678. if item.ChrgitmLv == "1" {
  11679. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11680. }
  11681. if item.ChrgitmLv == "2" {
  11682. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11683. }
  11684. if item.ChrgitmLv == "3" {
  11685. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11686. }
  11687. }
  11688. if item.MedChrgitmType == "11" { //中成费
  11689. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11690. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11691. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11692. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11693. if item.ChrgitmLv == "1" {
  11694. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11695. }
  11696. if item.ChrgitmLv == "2" {
  11697. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11698. }
  11699. if item.ChrgitmLv == "3" {
  11700. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11701. }
  11702. }
  11703. if item.MedChrgitmType == "14" { //其他费
  11704. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11705. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11706. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11707. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11708. if item.ChrgitmLv == "1" {
  11709. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11710. }
  11711. if item.ChrgitmLv == "2" {
  11712. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11713. }
  11714. if item.ChrgitmLv == "3" {
  11715. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11716. }
  11717. }
  11718. }
  11719. var iteminfoStructs []service.IteminfoStruct
  11720. if bedCostTotal != 0 {
  11721. iteminfo.MedChrgitm = "01"
  11722. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11723. iteminfo.Amt = bedCostTotal
  11724. iteminfo.ClaaSumfee = bed_claa_sunmfee
  11725. iteminfo.ClabAmt = bed_clab_amt
  11726. iteminfo.OthAmt = bed_other_amt
  11727. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11728. }
  11729. if checkCostTotal != 0 {
  11730. iteminfo.MedChrgitm = "03"
  11731. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11732. iteminfo.Amt = checkCostTotal
  11733. iteminfo.ClaaSumfee = check_claa_sunmfee
  11734. iteminfo.ClabAmt = check_clab_amt
  11735. iteminfo.OthAmt = check_other_amt
  11736. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11737. }
  11738. if laboratoryCostTotal != 0 {
  11739. iteminfo.MedChrgitm = "04"
  11740. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11741. iteminfo.Amt = laboratoryCostTotal
  11742. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11743. iteminfo.ClabAmt = laboratory_clab_amt
  11744. iteminfo.OthAmt = laboratory_other_amt
  11745. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11746. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11747. }
  11748. if treatCostTotal != 0 {
  11749. iteminfo.MedChrgitm = "05"
  11750. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11751. iteminfo.Amt = treatCostTotal
  11752. iteminfo.ClaaSumfee = treat_claa_sunmfee
  11753. iteminfo.ClabAmt = treat_clab_amt
  11754. iteminfo.OthAmt = treat_other_amt
  11755. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11756. //(struct4101.IteminfoStruct, iteminfo)
  11757. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11758. }
  11759. if operationCostTotal != 0 {
  11760. iteminfo.MedChrgitm = "06"
  11761. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11762. iteminfo.Amt = operationCostTotal
  11763. iteminfo.ClaaSumfee = operation_claa_sunmfee
  11764. iteminfo.ClabAmt = operation_clab_amt
  11765. iteminfo.OthAmt = operation_other_amt
  11766. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11767. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11768. }
  11769. if materialCostTotal != 0 {
  11770. iteminfo.MedChrgitm = "08"
  11771. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11772. iteminfo.Amt = materialCostTotal
  11773. iteminfo.ClaaSumfee = material_claa_sunmfee
  11774. iteminfo.ClabAmt = material_clab_amt
  11775. iteminfo.OthAmt = material_other_amt
  11776. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11778. }
  11779. if westernMedicineCostTotal != 0 {
  11780. iteminfo.MedChrgitm = "09"
  11781. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11782. iteminfo.Amt = westernMedicineCostTotal
  11783. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11784. iteminfo.ClabAmt = westernMedicine_clab_amt
  11785. iteminfo.OthAmt = westernMedicine_other_amt
  11786. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11787. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11788. }
  11789. if chineseTraditionalMedicineCostTotal != 0 {
  11790. iteminfo.MedChrgitm = "11"
  11791. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11792. iteminfo.Amt = westernMedicineCostTotal
  11793. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11794. iteminfo.ClabAmt = westernMedicine_clab_amt
  11795. iteminfo.OthAmt = westernMedicine_other_amt
  11796. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11797. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11798. }
  11799. if otherCostTotal != 0 {
  11800. iteminfo.MedChrgitm = "14"
  11801. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  11802. iteminfo.Amt = otherCostTotal
  11803. iteminfo.ClaaSumfee = other_claa_sunmfee
  11804. iteminfo.ClabAmt = other_clab_amt
  11805. iteminfo.OthAmt = other_other_amt
  11806. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11807. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11808. }
  11809. struct4101.IteminfoStruct = iteminfoStructs
  11810. struct4101.Ntly = "中国"
  11811. struct4101.AdmCaty = "A03.06"
  11812. struct4101.DoctorName = doctor.UserName
  11813. struct4101.DoctorCode = doctor.DoctorNumber
  11814. var res ResultSeventeen
  11815. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11816. struct4101.BillCode = order.Number
  11817. struct4101.BillNo = order.SetlId
  11818. var resOther ResultSeventeenOther
  11819. var pp models.PublicParams
  11820. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11821. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11822. pp.FixmedinsName = miConfig.OrgName
  11823. pp.FixmedinsCode = miConfig.Code
  11824. pp.RequestUrl = miConfig.Url
  11825. pp.Cainfo = miConfig.Cainfo
  11826. pp.SecretKey = miConfig.SecretKey
  11827. pp.AccessKey = miConfig.AccessKey
  11828. pp.OpterName = curRoles.UserName
  11829. client := &http.Client{}
  11830. var req *http.Request
  11831. data := make(map[string]interface{})
  11832. data["struct4101"] = struct4101
  11833. data["pp"] = pp
  11834. bytesData, _ := json.Marshal(data)
  11835. if miConfig.MdtrtareaAdmvs == "320921" {
  11836. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11837. } else {
  11838. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11839. }
  11840. resp, _ := client.Do(req)
  11841. defer resp.Body.Close()
  11842. body, ioErr := ioutil.ReadAll(resp.Body)
  11843. if ioErr != nil {
  11844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11846. return
  11847. }
  11848. var respJSON map[string]interface{}
  11849. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11852. return
  11853. }
  11854. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11855. userJSONBytes, _ := json.Marshal(respJSON)
  11856. fmt.Println("log")
  11857. fmt.Println(string(userJSONBytes))
  11858. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11859. utils.ErrorLog("解析失败:%v", err)
  11860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11861. return
  11862. }
  11863. res.InfRefmsgid = resOther.InfRefmsgid
  11864. res.Output = resOther.Output
  11865. res.ErrMsg = resOther.ErrMsg
  11866. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11867. res.Infcode = infocode
  11868. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11869. var pp models.PublicParams
  11870. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11871. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11872. pp.FixmedinsName = miConfig.OrgName
  11873. pp.FixmedinsCode = miConfig.Code
  11874. pp.RequestUrl = miConfig.Url
  11875. pp.Cainfo = miConfig.Cainfo
  11876. pp.SecretKey = miConfig.SecretKey
  11877. pp.AccessKey = miConfig.AccessKey
  11878. pp.OpterName = curRoles.UserName
  11879. result, _ := service.Jxyb4101(struct4101, pp)
  11880. var dat map[string]interface{}
  11881. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11882. fmt.Println(dat)
  11883. } else {
  11884. fmt.Println(err)
  11885. }
  11886. userJSONBytes, _ := json.Marshal(dat)
  11887. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11888. utils.ErrorLog("解析失败:%v", err)
  11889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11890. return
  11891. }
  11892. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11893. var pp models.PublicParams
  11894. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11895. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11896. pp.FixmedinsName = miConfig.OrgName
  11897. pp.FixmedinsCode = miConfig.Code
  11898. pp.RequestUrl = miConfig.Url
  11899. pp.Cainfo = miConfig.Cainfo
  11900. pp.SecretKey = miConfig.SecretKey
  11901. pp.AccessKey = miConfig.AccessKey
  11902. pp.OpterName = curRoles.UserName
  11903. result, _ := service.Hnyb4101(struct4101, pp)
  11904. var dat map[string]interface{}
  11905. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11906. fmt.Println(dat)
  11907. } else {
  11908. fmt.Println(err)
  11909. }
  11910. userJSONBytes, _ := json.Marshal(dat)
  11911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11912. utils.ErrorLog("解析失败:%v", err)
  11913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11914. return
  11915. }
  11916. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11917. var resOther ResultSeventeenOther
  11918. var pp models.PublicParams
  11919. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11920. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11921. pp.FixmedinsName = miConfig.OrgName
  11922. pp.FixmedinsCode = miConfig.Code
  11923. pp.RequestUrl = miConfig.Url
  11924. pp.Cainfo = miConfig.Cainfo
  11925. pp.SecretKey = miConfig.SecretKey
  11926. pp.AccessKey = miConfig.AccessKey
  11927. pp.OpterName = curRoles.UserName
  11928. client := &http.Client{}
  11929. var req *http.Request
  11930. data := make(map[string]interface{})
  11931. data["struct4101"] = struct4101
  11932. data["pp"] = pp
  11933. bytesData, _ := json.Marshal(data)
  11934. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  11935. resp, _ := client.Do(req)
  11936. defer resp.Body.Close()
  11937. body, ioErr := ioutil.ReadAll(resp.Body)
  11938. if ioErr != nil {
  11939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11941. return
  11942. }
  11943. var respJSON map[string]interface{}
  11944. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11947. return
  11948. }
  11949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11950. userJSONBytes, _ := json.Marshal(respJSON)
  11951. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11952. utils.ErrorLog("解析失败:%v", err)
  11953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11954. return
  11955. }
  11956. res.InfRefmsgid = resOther.InfRefmsgid
  11957. res.Output = resOther.Output
  11958. res.ErrMsg = resOther.ErrMsg
  11959. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11960. res.Infcode = infocode
  11961. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11962. var pp models.PublicParams
  11963. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11964. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11965. pp.FixmedinsName = miConfig.OrgName
  11966. pp.FixmedinsCode = miConfig.Code
  11967. pp.RequestUrl = miConfig.Url
  11968. pp.Cainfo = miConfig.Cainfo
  11969. pp.SecretKey = miConfig.SecretKey
  11970. pp.AccessKey = miConfig.AccessKey
  11971. pp.OpterName = curRoles.UserName
  11972. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  11973. fmt.Println(requestLog)
  11974. fmt.Println(errMsgLog)
  11975. saveLog(result, requestLog, "4101a", "上传清单")
  11976. var dat map[string]interface{}
  11977. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11978. fmt.Println(dat)
  11979. } else {
  11980. fmt.Println(err)
  11981. }
  11982. userJSONBytes, _ := json.Marshal(dat)
  11983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11984. utils.ErrorLog("解析失败:%v", err)
  11985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11986. return
  11987. }
  11988. } else if miConfig.MdtrtareaAdmvs == "441799" {
  11989. var pp models.PublicParams
  11990. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11991. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11992. pp.FixmedinsName = miConfig.OrgName
  11993. pp.FixmedinsCode = miConfig.Code
  11994. pp.RequestUrl = miConfig.Url
  11995. pp.Cainfo = miConfig.Cainfo
  11996. pp.SecretKey = miConfig.SecretKey
  11997. pp.AccessKey = miConfig.AccessKey
  11998. pp.OpterName = curRoles.UserName
  11999. client := &http.Client{}
  12000. var req *http.Request
  12001. data := make(map[string]interface{})
  12002. data["struct4101"] = struct4101
  12003. data["pp"] = pp
  12004. bytesData, _ := json.Marshal(data)
  12005. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  12006. resp, _ := client.Do(req)
  12007. defer resp.Body.Close()
  12008. body, ioErr := ioutil.ReadAll(resp.Body)
  12009. if ioErr != nil {
  12010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12012. return
  12013. }
  12014. var respJSON map[string]interface{}
  12015. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12018. return
  12019. }
  12020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12021. userJSONBytes, _ := json.Marshal(respJSON)
  12022. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12023. utils.ErrorLog("解析失败:%v", err)
  12024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12025. return
  12026. }
  12027. } else {
  12028. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12029. var dat map[string]interface{}
  12030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12031. fmt.Println(dat)
  12032. } else {
  12033. fmt.Println(err)
  12034. }
  12035. userJSONBytes, _ := json.Marshal(dat)
  12036. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12037. utils.ErrorLog("解析失败:%v", err)
  12038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12039. return
  12040. }
  12041. }
  12042. if res.Infcode != 0 {
  12043. errlog := &models.HisOrderError{
  12044. UserOrgId: order.UserOrgId,
  12045. Ctime: time.Now().Unix(),
  12046. Mtime: time.Now().Unix(),
  12047. ErrMsg: res.ErrMsg + "解析失败",
  12048. Status: 1,
  12049. PatientId: order.ID,
  12050. Stage: 10485,
  12051. }
  12052. service.CreateErrMsgLog(errlog)
  12053. continue
  12054. //c.ServeSuccessJSON(map[string]interface{}{
  12055. // "failed_code": -10,
  12056. // "msg": res.ErrMsg,
  12057. //})
  12058. } else {
  12059. //order.FaPiaoNumber = zero
  12060. //order.FaPiaoCode = last_order.FaPiaoCode
  12061. //service.UpdateOrder(order)
  12062. hisFundSettleListResult := &models.HisFundSettleListResult{
  12063. Number: res.Output.SetlListId,
  12064. Status: 1,
  12065. Ctime: time.Now().Unix(),
  12066. Mtime: time.Now().Unix(),
  12067. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12068. IsUpload: 1,
  12069. OrderId: order.ID,
  12070. }
  12071. service.CreateUploadRecord(hisFundSettleListResult)
  12072. continue
  12073. }
  12074. }
  12075. }
  12076. func (c *HisApiController) GetSettleList() {
  12077. order_id, _ := c.GetInt64("order_id")
  12078. admin_user_id, _ := c.GetInt64("admin_user_id")
  12079. order, _ := service.GetHisOrderByIDTwo(order_id)
  12080. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12081. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12082. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12083. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12084. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12085. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12086. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12087. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12088. if order.ID == 0 {
  12089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12090. return
  12091. }
  12092. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12093. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12094. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12095. //fmt.Println(count)
  12096. //var zero string
  12097. //number := count + 1
  12098. //if number >= 1000 {
  12099. // zero = "0000" + strconv.FormatInt(number, 10)
  12100. //} else if number >= 10000 {
  12101. // zero = "000" + strconv.FormatInt(number, 10)
  12102. //} else if number >= 100000 {
  12103. // zero = "00" + strconv.FormatInt(number, 10)
  12104. //} else if number >= 1000000 {
  12105. // zero = "0" + strconv.FormatInt(number, 10)
  12106. //} else {
  12107. // zero = strconv.FormatInt(number, 10)
  12108. //}
  12109. //fmt.Println(zero)
  12110. struct4101 := service.Struct4101{
  12111. PsnNo: order.PsnNo,
  12112. MdtrtId: order.MdtrtId,
  12113. SetlId: order.SetlId,
  12114. PsnName: order.PsnName,
  12115. Gend: order.Gend,
  12116. Brdy: his.Brdy,
  12117. Age: his.Age,
  12118. Naty: order.Naty,
  12119. PatnCertType: "01",
  12120. Certno: order.Certno,
  12121. Prfs: "90",
  12122. ConerName: roles[0].UserName,
  12123. PatnRlts: "99",
  12124. ConerAddr: miConfig.OrgName,
  12125. ConerTel: admin.Mobile,
  12126. HiType: order.Insutype,
  12127. Insuplc: miConfig.InsuplcAdmdvs,
  12128. MaindiagFlag: "1",
  12129. BillCode: order.SetlId,
  12130. BillNo: order.SetlId,
  12131. BizSn: order.Number,
  12132. PsnSelfPay: order.PsnPartAmt,
  12133. PsnOwnPay: order.PsnPartAmt,
  12134. AcctPay: order.AcctPay,
  12135. PsnCashpay: order.PsnCashPay,
  12136. HiPaymtd: "1",
  12137. Hsorg: miConfig.InsuplcAdmdvs,
  12138. HsorgOpter: miConfig.InsuplcAdmdvs,
  12139. MedinsFillPsn: curRoles.UserName,
  12140. MedinsFillDept: miConfig.OrgName,
  12141. IptMedType: "2",
  12142. }
  12143. struct4101.SetlBegnDate = order.SetlTime
  12144. struct4101.SetlEndDate = order.SetlTime
  12145. time_arr := strings.Split(order.SetlTime, " ")
  12146. struct4101.AdmTime = time_arr[0]
  12147. struct4101.AdmEndTime = time_arr[0]
  12148. //
  12149. //var rf []CustomFundPay
  12150. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12151. //
  12152. //var tempFunPays []service.CustomStruct
  12153. //for _, item := range rf {
  12154. // var tempFunPay service.CustomStruct
  12155. // tempFunPay.FundPayamt = item.FundPayamt
  12156. // tempFunPay.FundPayType = item.FundPayType
  12157. // tempFunPays = append(tempFunPays, tempFunPay)
  12158. //}
  12159. //struct4101.CustomStruct = tempFunPays
  12160. var tempDiaginfos []service.DiaginfoStructTwo
  12161. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12162. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12163. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  12164. var config []*models.HisXtDiagnoseConfig
  12165. for _, item := range diagnosis_ids {
  12166. id, _ := strconv.ParseInt(item, 10, 64)
  12167. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12168. config = append(config, &diagnosisConfig)
  12169. }
  12170. if miConfig.Code == "H15049901371" {
  12171. //for _, item := range config {
  12172. // if item.ID == 138 {
  12173. diagnosisConfig, _ := service.FindDiagnoseById(138)
  12174. var tempDiaginfo service.DiaginfoStructTwo
  12175. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  12176. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  12177. tempDiaginfo.DiagType = "1"
  12178. tempDiaginfo.MaindiagFlag = "1"
  12179. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12180. //}
  12181. //}
  12182. for _, item := range config {
  12183. if item.ID != 138 {
  12184. var tempDiaginfo service.DiaginfoStructTwo
  12185. tempDiaginfo.DiagCode = item.CountryCode
  12186. tempDiaginfo.DiagName = item.CountryContentName
  12187. tempDiaginfo.DiagType = "1"
  12188. tempDiaginfo.MaindiagFlag = "0"
  12189. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12190. }
  12191. }
  12192. } else {
  12193. for index, item := range config {
  12194. if index == 0 {
  12195. var tempDiaginfo service.DiaginfoStructTwo
  12196. tempDiaginfo.DiagCode = item.CountryCode
  12197. tempDiaginfo.DiagName = item.CountryContentName
  12198. tempDiaginfo.DiagType = "1"
  12199. tempDiaginfo.MaindiagFlag = "1"
  12200. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12201. } else {
  12202. var tempDiaginfo service.DiaginfoStructTwo
  12203. tempDiaginfo.DiagCode = item.CountryCode
  12204. tempDiaginfo.DiagName = item.CountryContentName
  12205. tempDiaginfo.DiagType = "1"
  12206. tempDiaginfo.MaindiagFlag = "0"
  12207. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12208. }
  12209. }
  12210. }
  12211. struct4101.Diseinfo = tempDiaginfos
  12212. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12213. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12214. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12215. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12216. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12217. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12218. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12219. var iteminfo service.IteminfoStruct
  12220. var bedCostTotal float64 = 0 //床位总费
  12221. var bedCostSelfTotal float64 = 0 //床位自费
  12222. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12223. var operationCostTotal float64 = 0 //手术费
  12224. var operationCostSelfTotal float64 = 0 //手术费
  12225. var operationCostPartSelfTotal float64 = 0 //手术费
  12226. var otherCostTotal float64 = 0 //其他费用
  12227. var otherCostSelfTotal float64 = 0 //其他费用
  12228. var otherCostPartSelfTotal float64 = 0 //其他费用
  12229. var materialCostTotal float64 = 0 //材料费
  12230. var materialCostSelfTotal float64 = 0 //材料费
  12231. var materialCostPartSelfTotal float64 = 0 //材料费
  12232. var westernMedicineCostTotal float64 = 0 //西药费
  12233. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12234. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12235. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12236. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12237. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12238. var checkCostTotal float64 = 0 //检查费
  12239. var checkCostSelfTotal float64 = 0 //检查费
  12240. var checkCostPartSelfTotal float64 = 0 //检查费
  12241. var laboratoryCostTotal float64 = 0 //化验费
  12242. var laboratoryCostSelfTotal float64 = 0 //化验费
  12243. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12244. var treatCostTotal float64 = 0 //治疗费用
  12245. var treatCostSelfTotal float64 = 0 //治疗费用
  12246. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12247. decimal.DivisionPrecision = 2
  12248. var bed_fulamt_ownpay_amt float64 = 0
  12249. var operation_fulamt_ownpay_amt float64 = 0
  12250. var other_fulamt_ownpay_amt float64 = 0
  12251. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12252. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12253. var check_fulamt_ownpay_amt float64 = 0
  12254. var material_fulamt_ownpay_amt float64 = 0
  12255. var laboratory_fulamt_ownpay_amt float64 = 0
  12256. var treat_fulamt_ownpay_amt float64 = 0
  12257. var bed_claa_sunmfee float64 = 0
  12258. var bed_clab_amt float64 = 0
  12259. var bed_other_amt float64 = 0
  12260. var operation_claa_sunmfee float64 = 0
  12261. var operation_clab_amt float64 = 0
  12262. var operation_other_amt float64 = 0
  12263. var other_claa_sunmfee float64 = 0
  12264. var other_clab_amt float64 = 0
  12265. var other_other_amt float64 = 0
  12266. var westernMedicine_claa_sunmfee float64 = 0
  12267. var westernMedicine_clab_amt float64 = 0
  12268. var westernMedicine_other_amt float64 = 0
  12269. var chineseTraditional_claa_sunmfee float64 = 0
  12270. var chineseTraditional_clab_amt float64 = 0
  12271. var chineseTraditional_other_amt float64 = 0
  12272. var check_claa_sunmfee float64 = 0
  12273. var check_clab_amt float64 = 0
  12274. var check_other_amt float64 = 0
  12275. var material_claa_sunmfee float64 = 0
  12276. var material_clab_amt float64 = 0
  12277. var material_other_amt float64 = 0
  12278. var laboratory_claa_sunmfee float64 = 0
  12279. var laboratory_clab_amt float64 = 0
  12280. var laboratory_other_amt float64 = 0
  12281. var treat_claa_sunmfee float64 = 0
  12282. var treat_clab_amt float64 = 0
  12283. var treat_other_amt float64 = 0
  12284. for _, item := range order.HisOrderInfo {
  12285. if item.MedChrgitmType == "01" { //床位费
  12286. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12287. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12288. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12289. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12290. if item.ChrgitmLv == "1" {
  12291. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12292. }
  12293. if item.ChrgitmLv == "2" {
  12294. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12295. }
  12296. if item.ChrgitmLv == "3" {
  12297. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12298. }
  12299. }
  12300. if item.MedChrgitmType == "03" { //检查费
  12301. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12302. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12303. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12304. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12305. if item.ChrgitmLv == "1" {
  12306. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12307. }
  12308. if item.ChrgitmLv == "2" {
  12309. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12310. }
  12311. if item.ChrgitmLv == "3" {
  12312. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12313. }
  12314. }
  12315. if item.MedChrgitmType == "04" { //化验费
  12316. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12317. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12318. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12319. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12320. if item.ChrgitmLv == "1" {
  12321. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12322. }
  12323. if item.ChrgitmLv == "2" {
  12324. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12325. }
  12326. if item.ChrgitmLv == "3" {
  12327. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12328. }
  12329. }
  12330. if item.MedChrgitmType == "05" { //治疗费
  12331. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12332. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12333. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12334. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12335. if item.ChrgitmLv == "1" {
  12336. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12337. }
  12338. if item.ChrgitmLv == "2" {
  12339. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12340. }
  12341. if item.ChrgitmLv == "3" {
  12342. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12343. }
  12344. }
  12345. if item.MedChrgitmType == "06" { //手术费
  12346. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12347. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12348. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12349. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12350. if item.ChrgitmLv == "1" {
  12351. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12352. }
  12353. if item.ChrgitmLv == "2" {
  12354. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12355. }
  12356. if item.ChrgitmLv == "3" {
  12357. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12358. }
  12359. }
  12360. if item.MedChrgitmType == "08" { //材料费
  12361. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12362. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12363. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12364. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12365. if item.ChrgitmLv == "1" {
  12366. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12367. }
  12368. if item.ChrgitmLv == "2" {
  12369. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12370. }
  12371. if item.ChrgitmLv == "3" {
  12372. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12373. }
  12374. }
  12375. if item.MedChrgitmType == "09" { //西药费
  12376. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12377. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12378. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12379. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12380. if item.ChrgitmLv == "1" {
  12381. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12382. }
  12383. if item.ChrgitmLv == "2" {
  12384. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12385. }
  12386. if item.ChrgitmLv == "3" {
  12387. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12388. }
  12389. }
  12390. if item.MedChrgitmType == "11" { //中成费
  12391. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12392. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12393. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12394. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12395. if item.ChrgitmLv == "1" {
  12396. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12397. }
  12398. if item.ChrgitmLv == "2" {
  12399. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12400. }
  12401. if item.ChrgitmLv == "3" {
  12402. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12403. }
  12404. }
  12405. if item.MedChrgitmType == "14" { //其他费
  12406. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12407. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12408. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12409. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12410. if item.ChrgitmLv == "1" {
  12411. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12412. }
  12413. if item.ChrgitmLv == "2" {
  12414. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12415. }
  12416. if item.ChrgitmLv == "3" {
  12417. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12418. }
  12419. }
  12420. }
  12421. var iteminfoStructs []service.IteminfoStruct
  12422. if bedCostTotal != 0 {
  12423. iteminfo.MedChrgitm = "01"
  12424. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12425. iteminfo.Amt = bedCostTotal
  12426. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12427. iteminfo.ClabAmt = bed_clab_amt
  12428. iteminfo.OthAmt = bed_other_amt
  12429. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12430. }
  12431. if checkCostTotal != 0 {
  12432. iteminfo.MedChrgitm = "03"
  12433. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12434. iteminfo.Amt = checkCostTotal
  12435. iteminfo.ClaaSumfee = check_claa_sunmfee
  12436. iteminfo.ClabAmt = check_clab_amt
  12437. iteminfo.OthAmt = check_other_amt
  12438. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12439. }
  12440. if laboratoryCostTotal != 0 {
  12441. iteminfo.MedChrgitm = "04"
  12442. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12443. iteminfo.Amt = laboratoryCostTotal
  12444. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12445. iteminfo.ClabAmt = laboratory_clab_amt
  12446. iteminfo.OthAmt = laboratory_other_amt
  12447. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12448. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12449. }
  12450. if treatCostTotal != 0 {
  12451. iteminfo.MedChrgitm = "05"
  12452. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12453. iteminfo.Amt = treatCostTotal
  12454. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12455. iteminfo.ClabAmt = treat_clab_amt
  12456. iteminfo.OthAmt = treat_other_amt
  12457. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12458. //(struct4101.IteminfoStruct, iteminfo)
  12459. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12460. }
  12461. if operationCostTotal != 0 {
  12462. iteminfo.MedChrgitm = "06"
  12463. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12464. iteminfo.Amt = operationCostTotal
  12465. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12466. iteminfo.ClabAmt = operation_clab_amt
  12467. iteminfo.OthAmt = operation_other_amt
  12468. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12469. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12470. }
  12471. if materialCostTotal != 0 {
  12472. iteminfo.MedChrgitm = "08"
  12473. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12474. iteminfo.Amt = materialCostTotal
  12475. iteminfo.ClaaSumfee = material_claa_sunmfee
  12476. iteminfo.ClabAmt = material_clab_amt
  12477. iteminfo.OthAmt = material_other_amt
  12478. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12479. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12480. }
  12481. if westernMedicineCostTotal != 0 {
  12482. iteminfo.MedChrgitm = "09"
  12483. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12484. iteminfo.Amt = westernMedicineCostTotal
  12485. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12486. iteminfo.ClabAmt = westernMedicine_clab_amt
  12487. iteminfo.OthAmt = westernMedicine_other_amt
  12488. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12489. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12490. }
  12491. if chineseTraditionalMedicineCostTotal != 0 {
  12492. iteminfo.MedChrgitm = "11"
  12493. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12494. iteminfo.Amt = westernMedicineCostTotal
  12495. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12496. iteminfo.ClabAmt = westernMedicine_clab_amt
  12497. iteminfo.OthAmt = westernMedicine_other_amt
  12498. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12499. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12500. }
  12501. if otherCostTotal != 0 {
  12502. iteminfo.MedChrgitm = "14"
  12503. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12504. iteminfo.Amt = otherCostTotal
  12505. iteminfo.ClaaSumfee = other_claa_sunmfee
  12506. iteminfo.ClabAmt = other_clab_amt
  12507. iteminfo.OthAmt = other_other_amt
  12508. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12509. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12510. }
  12511. struct4101.IteminfoStruct = iteminfoStructs
  12512. struct4101.Ntly = "中国"
  12513. struct4101.AdmCaty = "A03.06"
  12514. struct4101.DoctorName = doctor.UserName
  12515. struct4101.DoctorCode = doctor.DoctorNumber
  12516. var res ResultSeventeen
  12517. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12518. struct4101.BillCode = order.Number
  12519. struct4101.BillNo = order.SetlId
  12520. var resOther ResultSeventeenOther
  12521. var pp models.PublicParams
  12522. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12523. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12524. pp.FixmedinsName = miConfig.OrgName
  12525. pp.FixmedinsCode = miConfig.Code
  12526. pp.RequestUrl = miConfig.Url
  12527. pp.Cainfo = miConfig.Cainfo
  12528. pp.SecretKey = miConfig.SecretKey
  12529. pp.AccessKey = miConfig.AccessKey
  12530. pp.OpterName = curRoles.UserName
  12531. client := &http.Client{}
  12532. var req *http.Request
  12533. data := make(map[string]interface{})
  12534. data["struct4101"] = struct4101
  12535. data["pp"] = pp
  12536. bytesData, _ := json.Marshal(data)
  12537. if miConfig.MdtrtareaAdmvs == "320921" {
  12538. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12539. } else {
  12540. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12541. }
  12542. resp, _ := client.Do(req)
  12543. defer resp.Body.Close()
  12544. body, ioErr := ioutil.ReadAll(resp.Body)
  12545. if ioErr != nil {
  12546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12548. return
  12549. }
  12550. var respJSON map[string]interface{}
  12551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12554. return
  12555. }
  12556. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12557. userJSONBytes, _ := json.Marshal(respJSON)
  12558. fmt.Println("log")
  12559. fmt.Println(string(userJSONBytes))
  12560. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12561. utils.ErrorLog("解析失败:%v", err)
  12562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12563. return
  12564. }
  12565. res.InfRefmsgid = resOther.InfRefmsgid
  12566. res.Output = resOther.Output
  12567. res.ErrMsg = resOther.ErrMsg
  12568. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12569. res.Infcode = infocode
  12570. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12571. var pp models.PublicParams
  12572. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12573. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12574. pp.FixmedinsName = miConfig.OrgName
  12575. pp.FixmedinsCode = miConfig.Code
  12576. pp.RequestUrl = miConfig.Url
  12577. pp.Cainfo = miConfig.Cainfo
  12578. pp.SecretKey = miConfig.SecretKey
  12579. pp.AccessKey = miConfig.AccessKey
  12580. pp.OpterName = curRoles.UserName
  12581. result, _ := service.Jxyb4101(struct4101, pp)
  12582. var dat map[string]interface{}
  12583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12584. fmt.Println(dat)
  12585. } else {
  12586. fmt.Println(err)
  12587. }
  12588. userJSONBytes, _ := json.Marshal(dat)
  12589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12590. utils.ErrorLog("解析失败:%v", err)
  12591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12592. return
  12593. }
  12594. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12595. var pp models.PublicParams
  12596. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12597. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12598. pp.FixmedinsName = miConfig.OrgName
  12599. pp.FixmedinsCode = miConfig.Code
  12600. pp.RequestUrl = miConfig.Url
  12601. pp.Cainfo = miConfig.Cainfo
  12602. pp.SecretKey = miConfig.SecretKey
  12603. pp.AccessKey = miConfig.AccessKey
  12604. pp.OpterName = curRoles.UserName
  12605. result, _ := service.Hnyb4101(struct4101, pp)
  12606. var dat map[string]interface{}
  12607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12608. fmt.Println(dat)
  12609. } else {
  12610. fmt.Println(err)
  12611. }
  12612. userJSONBytes, _ := json.Marshal(dat)
  12613. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12614. utils.ErrorLog("解析失败:%v", err)
  12615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12616. return
  12617. }
  12618. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12619. var resOther ResultSeventeenOther
  12620. var pp models.PublicParams
  12621. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12622. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12623. pp.FixmedinsName = miConfig.OrgName
  12624. pp.FixmedinsCode = miConfig.Code
  12625. pp.RequestUrl = miConfig.Url
  12626. pp.Cainfo = miConfig.Cainfo
  12627. pp.SecretKey = miConfig.SecretKey
  12628. pp.AccessKey = miConfig.AccessKey
  12629. pp.OpterName = curRoles.UserName
  12630. client := &http.Client{}
  12631. var req *http.Request
  12632. data := make(map[string]interface{})
  12633. data["struct4101"] = struct4101
  12634. data["pp"] = pp
  12635. bytesData, _ := json.Marshal(data)
  12636. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12637. resp, _ := client.Do(req)
  12638. defer resp.Body.Close()
  12639. body, ioErr := ioutil.ReadAll(resp.Body)
  12640. if ioErr != nil {
  12641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12643. return
  12644. }
  12645. var respJSON map[string]interface{}
  12646. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12649. return
  12650. }
  12651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12652. userJSONBytes, _ := json.Marshal(respJSON)
  12653. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12654. utils.ErrorLog("解析失败:%v", err)
  12655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12656. return
  12657. }
  12658. res.InfRefmsgid = resOther.InfRefmsgid
  12659. res.Output = resOther.Output
  12660. res.ErrMsg = resOther.ErrMsg
  12661. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12662. res.Infcode = infocode
  12663. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12664. var pp models.PublicParams
  12665. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12666. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12667. pp.FixmedinsName = miConfig.OrgName
  12668. pp.FixmedinsCode = miConfig.Code
  12669. pp.RequestUrl = miConfig.Url
  12670. pp.Cainfo = miConfig.Cainfo
  12671. pp.SecretKey = miConfig.SecretKey
  12672. pp.AccessKey = miConfig.AccessKey
  12673. pp.OpterName = curRoles.UserName
  12674. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12675. fmt.Println(requestLog)
  12676. fmt.Println(errMsgLog)
  12677. saveLog(result, requestLog, "4101a", "上传清单")
  12678. var dat map[string]interface{}
  12679. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12680. fmt.Println(dat)
  12681. } else {
  12682. fmt.Println(err)
  12683. }
  12684. userJSONBytes, _ := json.Marshal(dat)
  12685. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12686. utils.ErrorLog("解析失败:%v", err)
  12687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12688. return
  12689. }
  12690. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12691. var pp models.PublicParams
  12692. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12693. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12694. pp.FixmedinsName = miConfig.OrgName
  12695. pp.FixmedinsCode = miConfig.Code
  12696. pp.RequestUrl = miConfig.Url
  12697. pp.Cainfo = miConfig.Cainfo
  12698. pp.SecretKey = miConfig.SecretKey
  12699. pp.AccessKey = miConfig.AccessKey
  12700. pp.OpterName = curRoles.UserName
  12701. client := &http.Client{}
  12702. var req *http.Request
  12703. data := make(map[string]interface{})
  12704. data["struct4101"] = struct4101
  12705. data["pp"] = pp
  12706. bytesData, _ := json.Marshal(data)
  12707. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  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{})["pre"].(map[string]interface{})
  12723. userJSONBytes, _ := json.Marshal(respJSON)
  12724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12725. utils.ErrorLog("解析失败:%v", err)
  12726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12727. return
  12728. }
  12729. } else {
  12730. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12731. var dat map[string]interface{}
  12732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12733. fmt.Println(dat)
  12734. } else {
  12735. fmt.Println(err)
  12736. }
  12737. userJSONBytes, _ := json.Marshal(dat)
  12738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12739. utils.ErrorLog("解析失败:%v", err)
  12740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12741. return
  12742. }
  12743. }
  12744. if res.Infcode != 0 {
  12745. c.ServeSuccessJSON(map[string]interface{}{
  12746. "failed_code": -10,
  12747. "msg": res.ErrMsg,
  12748. })
  12749. return
  12750. } else {
  12751. //order.FaPiaoNumber = zero
  12752. //order.FaPiaoCode = last_order.FaPiaoCode
  12753. //service.UpdateOrder(order)
  12754. hisFundSettleListResult := &models.HisFundSettleListResult{
  12755. Number: res.Output.SetlListId,
  12756. Status: 1,
  12757. Ctime: time.Now().Unix(),
  12758. Mtime: time.Now().Unix(),
  12759. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12760. IsUpload: 1,
  12761. OrderId: order_id,
  12762. }
  12763. service.CreateUploadRecord(hisFundSettleListResult)
  12764. c.ServeSuccessJSON(map[string]interface{}{
  12765. "msg": "上传成功",
  12766. "result": hisFundSettleListResult,
  12767. })
  12768. return
  12769. }
  12770. }
  12771. func (c *HisApiController) GetSettleListHospital() {
  12772. order_id, _ := c.GetInt64("order_id")
  12773. admin_user_id, _ := c.GetInt64("admin_user_id")
  12774. order, _ := service.GetHisOrderByIDTwo(order_id)
  12775. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12776. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  12777. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12778. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12779. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12780. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12781. if order.ID == 0 {
  12782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12783. return
  12784. }
  12785. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12786. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12787. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12788. fmt.Println(count)
  12789. var zero string
  12790. number := count + 1
  12791. if number >= 1000 {
  12792. zero = "0000" + strconv.FormatInt(number, 10)
  12793. } else if number >= 10000 {
  12794. zero = "000" + strconv.FormatInt(number, 10)
  12795. } else if number >= 100000 {
  12796. zero = "00" + strconv.FormatInt(number, 10)
  12797. } else if number >= 1000000 {
  12798. zero = "0" + strconv.FormatInt(number, 10)
  12799. } else {
  12800. zero = strconv.FormatInt(number, 10)
  12801. }
  12802. fmt.Println(zero)
  12803. struct4101 := service.Struct4101{
  12804. PsnNo: order.PsnNo,
  12805. MdtrtId: order.MdtrtId,
  12806. SetlId: order.SetlId,
  12807. PsnName: order.PsnName,
  12808. Gend: order.Gend,
  12809. Brdy: his.Brdy,
  12810. Age: int64(order.Age),
  12811. Naty: order.Naty,
  12812. PatnCertType: "01",
  12813. Certno: order.Certno,
  12814. Prfs: "90",
  12815. ConerName: roles[0].UserName,
  12816. PatnRlts: "99",
  12817. ConerAddr: miConfig.OrgName,
  12818. ConerTel: admin.Mobile,
  12819. HiType: order.Insutype,
  12820. Insuplc: miConfig.InsuplcAdmdvs,
  12821. MaindiagFlag: "1",
  12822. BillCode: order.SetlId,
  12823. BillNo: order.SetlId,
  12824. BizSn: order.Number,
  12825. PsnSelfPay: order.PsnPartAmt,
  12826. PsnOwnPay: order.PsnPartAmt,
  12827. AcctPay: order.AcctPay,
  12828. PsnCashpay: order.PsnCashPay,
  12829. HiPaymtd: "1",
  12830. Hsorg: miConfig.InsuplcAdmdvs,
  12831. HsorgOpter: miConfig.InsuplcAdmdvs,
  12832. MedinsFillPsn: curRoles.UserName,
  12833. MedinsFillDept: depart.Name,
  12834. IptMedType: "2",
  12835. AdmTime: his.InHosptialTime,
  12836. AdmEndTime: his.OutHosptialTime,
  12837. }
  12838. struct4101.SetlBegnDate = order.SetlTime
  12839. struct4101.SetlEndDate = order.SetlTime
  12840. //var rf []CustomFundPay
  12841. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12842. //
  12843. //var tempFunPays []service.CustomStruct
  12844. //for _, item := range rf {
  12845. // var tempFunPay service.CustomStruct
  12846. // tempFunPay.FundPayamt = item.FundPayamt
  12847. // tempFunPay.FundPayType = item.FundPayType
  12848. // tempFunPays = append(tempFunPays, tempFunPay)
  12849. //}
  12850. //struct4101.CustomStruct = tempFunPays
  12851. var tempDiaginfos []service.DiaginfoStructTwo
  12852. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12853. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12854. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  12855. //for _, item := range infos {
  12856. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  12857. //}
  12858. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  12859. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  12860. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12861. fmt.Println(diagnosis_ids_arr)
  12862. if order.UserOrgId == 10210 {
  12863. var diagnosis_ids_arr_two []int64
  12864. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  12865. var config []*models.HisXtDiagnoseConfig
  12866. for _, id := range diagnosis_ids_arr_two {
  12867. //id, _ := strconv.ParseInt(item, 10, 64)
  12868. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12869. if diagnosisConfig.ID > 0 {
  12870. config = append(config, &diagnosisConfig)
  12871. }
  12872. }
  12873. for index, item := range config {
  12874. if item.ID > 0 {
  12875. if index == 0 {
  12876. var tempDiaginfo service.DiaginfoStructTwo
  12877. tempDiaginfo.DiagCode = item.CountryCode
  12878. tempDiaginfo.DiagName = item.CountryContentName
  12879. tempDiaginfo.DiagType = "1"
  12880. tempDiaginfo.MaindiagFlag = "1"
  12881. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12882. } else {
  12883. var tempDiaginfo service.DiaginfoStructTwo
  12884. tempDiaginfo.DiagCode = item.CountryCode
  12885. tempDiaginfo.DiagName = item.CountryContentName
  12886. tempDiaginfo.DiagType = "1"
  12887. tempDiaginfo.MaindiagFlag = "0"
  12888. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12889. }
  12890. }
  12891. }
  12892. struct4101.Diseinfo = tempDiaginfos
  12893. } else {
  12894. var config []*models.HisXtDiagnoseConfig
  12895. for _, item := range diagnosis_ids_arr {
  12896. id, _ := strconv.ParseInt(item, 10, 64)
  12897. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12898. if diagnosisConfig.ID > 0 {
  12899. config = append(config, &diagnosisConfig)
  12900. }
  12901. }
  12902. for index, item := range config {
  12903. if item.ID > 0 {
  12904. if index == 0 {
  12905. var tempDiaginfo service.DiaginfoStructTwo
  12906. tempDiaginfo.DiagCode = item.CountryCode
  12907. tempDiaginfo.DiagName = item.CountryContentName
  12908. tempDiaginfo.DiagType = "1"
  12909. tempDiaginfo.MaindiagFlag = "1"
  12910. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12911. } else {
  12912. var tempDiaginfo service.DiaginfoStructTwo
  12913. tempDiaginfo.DiagCode = item.CountryCode
  12914. tempDiaginfo.DiagName = item.CountryContentName
  12915. tempDiaginfo.DiagType = "1"
  12916. tempDiaginfo.MaindiagFlag = "0"
  12917. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12918. }
  12919. }
  12920. }
  12921. struct4101.Diseinfo = tempDiaginfos
  12922. }
  12923. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12924. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12925. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12926. tempOpspdiseinfo2.OprnOprtCode = ""
  12927. tempOpspdiseinfo2.OprnOprtName = ""
  12928. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12929. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12930. var iteminfo service.IteminfoStruct
  12931. var bedCostTotal float64 = 0 //床位总费
  12932. var bedCostSelfTotal float64 = 0 //床位自费
  12933. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12934. var operationCostTotal float64 = 0 //手术费
  12935. var operationCostSelfTotal float64 = 0 //手术费
  12936. var operationCostPartSelfTotal float64 = 0 //手术费
  12937. var otherCostTotal float64 = 0 //其他费用
  12938. var otherCostSelfTotal float64 = 0 //其他费用
  12939. var otherCostPartSelfTotal float64 = 0 //其他费用
  12940. var materialCostTotal float64 = 0 //材料费
  12941. var materialCostSelfTotal float64 = 0 //材料费
  12942. var materialCostPartSelfTotal float64 = 0 //材料费
  12943. var westernMedicineCostTotal float64 = 0 //西药费
  12944. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12945. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12946. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12947. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12948. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12949. var checkCostTotal float64 = 0 //检查费
  12950. var checkCostSelfTotal float64 = 0 //检查费
  12951. var checkCostPartSelfTotal float64 = 0 //检查费
  12952. var laboratoryCostTotal float64 = 0 //化验费
  12953. var laboratoryCostSelfTotal float64 = 0 //化验费
  12954. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12955. var treatCostTotal float64 = 0 //治疗费用
  12956. var treatCostSelfTotal float64 = 0 //治疗费用
  12957. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12958. decimal.DivisionPrecision = 2
  12959. var bed_fulamt_ownpay_amt float64 = 0
  12960. var operation_fulamt_ownpay_amt float64 = 0
  12961. var other_fulamt_ownpay_amt float64 = 0
  12962. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12963. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12964. var check_fulamt_ownpay_amt float64 = 0
  12965. var material_fulamt_ownpay_amt float64 = 0
  12966. var laboratory_fulamt_ownpay_amt float64 = 0
  12967. var treat_fulamt_ownpay_amt float64 = 0
  12968. var bed_claa_sunmfee float64 = 0
  12969. var bed_clab_amt float64 = 0
  12970. var bed_other_amt float64 = 0
  12971. var operation_claa_sunmfee float64 = 0
  12972. var operation_clab_amt float64 = 0
  12973. var operation_other_amt float64 = 0
  12974. var other_claa_sunmfee float64 = 0
  12975. var other_clab_amt float64 = 0
  12976. var other_other_amt float64 = 0
  12977. var westernMedicine_claa_sunmfee float64 = 0
  12978. var westernMedicine_clab_amt float64 = 0
  12979. var westernMedicine_other_amt float64 = 0
  12980. var chineseTraditional_claa_sunmfee float64 = 0
  12981. var chineseTraditional_clab_amt float64 = 0
  12982. var chineseTraditional_other_amt float64 = 0
  12983. var check_claa_sunmfee float64 = 0
  12984. var check_clab_amt float64 = 0
  12985. var check_other_amt float64 = 0
  12986. var material_claa_sunmfee float64 = 0
  12987. var material_clab_amt float64 = 0
  12988. var material_other_amt float64 = 0
  12989. var laboratory_claa_sunmfee float64 = 0
  12990. var laboratory_clab_amt float64 = 0
  12991. var laboratory_other_amt float64 = 0
  12992. var treat_claa_sunmfee float64 = 0
  12993. var treat_clab_amt float64 = 0
  12994. var treat_other_amt float64 = 0
  12995. for _, item := range order.HisOrderInfo {
  12996. if item.MedChrgitmType == "01" { //床位费
  12997. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12998. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12999. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13000. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13001. if item.ChrgitmLv == "1" {
  13002. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13003. }
  13004. if item.ChrgitmLv == "2" {
  13005. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13006. }
  13007. if item.ChrgitmLv == "3" {
  13008. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13009. }
  13010. }
  13011. if item.MedChrgitmType == "03" { //检查费
  13012. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13013. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13014. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13015. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13016. if item.ChrgitmLv == "1" {
  13017. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13018. }
  13019. if item.ChrgitmLv == "2" {
  13020. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13021. }
  13022. if item.ChrgitmLv == "3" {
  13023. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13024. }
  13025. }
  13026. if item.MedChrgitmType == "04" { //化验费
  13027. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13028. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13029. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13030. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13031. if item.ChrgitmLv == "1" {
  13032. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13033. }
  13034. if item.ChrgitmLv == "2" {
  13035. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13036. }
  13037. if item.ChrgitmLv == "3" {
  13038. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13039. }
  13040. }
  13041. if item.MedChrgitmType == "05" { //治疗费
  13042. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13043. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13044. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13045. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13046. if item.ChrgitmLv == "1" {
  13047. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13048. }
  13049. if item.ChrgitmLv == "2" {
  13050. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13051. }
  13052. if item.ChrgitmLv == "3" {
  13053. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13054. }
  13055. }
  13056. if item.MedChrgitmType == "06" { //手术费
  13057. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13058. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13059. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13060. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13061. if item.ChrgitmLv == "1" {
  13062. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13063. }
  13064. if item.ChrgitmLv == "2" {
  13065. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13066. }
  13067. if item.ChrgitmLv == "3" {
  13068. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13069. }
  13070. }
  13071. if item.MedChrgitmType == "08" { //材料费
  13072. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13073. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13074. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13075. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13076. if item.ChrgitmLv == "1" {
  13077. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13078. }
  13079. if item.ChrgitmLv == "2" {
  13080. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13081. }
  13082. if item.ChrgitmLv == "3" {
  13083. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13084. }
  13085. }
  13086. if item.MedChrgitmType == "09" { //西药费
  13087. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13088. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13089. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13090. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13091. if item.ChrgitmLv == "1" {
  13092. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13093. }
  13094. if item.ChrgitmLv == "2" {
  13095. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13096. }
  13097. if item.ChrgitmLv == "3" {
  13098. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13099. }
  13100. }
  13101. if item.MedChrgitmType == "11" { //中成费
  13102. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13103. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13104. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13105. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13106. if item.ChrgitmLv == "1" {
  13107. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13108. }
  13109. if item.ChrgitmLv == "2" {
  13110. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13111. }
  13112. if item.ChrgitmLv == "3" {
  13113. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13114. }
  13115. }
  13116. if item.MedChrgitmType == "14" { //其他费
  13117. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13118. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13119. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13120. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13121. if item.ChrgitmLv == "1" {
  13122. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13123. }
  13124. if item.ChrgitmLv == "2" {
  13125. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13126. }
  13127. if item.ChrgitmLv == "3" {
  13128. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13129. }
  13130. }
  13131. }
  13132. var iteminfoStructs []service.IteminfoStruct
  13133. if bedCostTotal != 0 {
  13134. iteminfo.MedChrgitm = "01"
  13135. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13136. iteminfo.Amt = bedCostTotal
  13137. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13138. iteminfo.ClabAmt = bed_clab_amt
  13139. iteminfo.OthAmt = bed_other_amt
  13140. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13141. }
  13142. if checkCostTotal != 0 {
  13143. iteminfo.MedChrgitm = "03"
  13144. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13145. iteminfo.Amt = checkCostTotal
  13146. iteminfo.ClaaSumfee = check_claa_sunmfee
  13147. iteminfo.ClabAmt = check_clab_amt
  13148. iteminfo.OthAmt = check_other_amt
  13149. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13150. }
  13151. if laboratoryCostTotal != 0 {
  13152. iteminfo.MedChrgitm = "04"
  13153. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13154. iteminfo.Amt = laboratoryCostTotal
  13155. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13156. iteminfo.ClabAmt = laboratory_clab_amt
  13157. iteminfo.OthAmt = laboratory_other_amt
  13158. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13159. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13160. }
  13161. if treatCostTotal != 0 {
  13162. iteminfo.MedChrgitm = "05"
  13163. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13164. iteminfo.Amt = treatCostTotal
  13165. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13166. iteminfo.ClabAmt = treat_clab_amt
  13167. iteminfo.OthAmt = treat_other_amt
  13168. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13169. //(struct4101.IteminfoStruct, iteminfo)
  13170. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13171. }
  13172. if operationCostTotal != 0 {
  13173. iteminfo.MedChrgitm = "06"
  13174. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13175. iteminfo.Amt = operationCostTotal
  13176. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13177. iteminfo.ClabAmt = operation_clab_amt
  13178. iteminfo.OthAmt = operation_other_amt
  13179. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13180. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13181. }
  13182. if materialCostTotal != 0 {
  13183. iteminfo.MedChrgitm = "08"
  13184. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13185. iteminfo.Amt = materialCostTotal
  13186. iteminfo.ClaaSumfee = material_claa_sunmfee
  13187. iteminfo.ClabAmt = material_clab_amt
  13188. iteminfo.OthAmt = material_other_amt
  13189. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13190. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13191. }
  13192. if westernMedicineCostTotal != 0 {
  13193. iteminfo.MedChrgitm = "09"
  13194. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13195. iteminfo.Amt = westernMedicineCostTotal
  13196. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13197. iteminfo.ClabAmt = westernMedicine_clab_amt
  13198. iteminfo.OthAmt = westernMedicine_other_amt
  13199. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13200. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13201. }
  13202. if chineseTraditionalMedicineCostTotal != 0 {
  13203. iteminfo.MedChrgitm = "11"
  13204. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13205. iteminfo.Amt = westernMedicineCostTotal
  13206. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13207. iteminfo.ClabAmt = westernMedicine_clab_amt
  13208. iteminfo.OthAmt = westernMedicine_other_amt
  13209. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13210. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13211. }
  13212. if otherCostTotal != 0 {
  13213. iteminfo.MedChrgitm = "14"
  13214. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13215. iteminfo.Amt = otherCostTotal
  13216. iteminfo.ClaaSumfee = other_claa_sunmfee
  13217. iteminfo.ClabAmt = other_clab_amt
  13218. iteminfo.OthAmt = other_other_amt
  13219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13220. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13221. }
  13222. struct4101.IteminfoStruct = iteminfoStructs
  13223. struct4101.Ntly = "中国"
  13224. struct4101.AdmCaty = "A03.06"
  13225. var resOther ResultSeventeenOther
  13226. var res ResultSeventeen
  13227. if miConfig.MdtrtareaAdmvs == "150499" {
  13228. var pp models.PublicParams
  13229. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13230. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13231. pp.FixmedinsName = miConfig.OrgName
  13232. pp.FixmedinsCode = miConfig.Code
  13233. pp.RequestUrl = miConfig.Url
  13234. pp.Cainfo = miConfig.Cainfo
  13235. pp.SecretKey = miConfig.SecretKey
  13236. pp.AccessKey = miConfig.AccessKey
  13237. pp.OpterName = curRoles.UserName
  13238. client := &http.Client{}
  13239. var req *http.Request
  13240. data := make(map[string]interface{})
  13241. data["struct4101"] = struct4101
  13242. data["pp"] = pp
  13243. bytesData, _ := json.Marshal(data)
  13244. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13245. resp, _ := client.Do(req)
  13246. defer resp.Body.Close()
  13247. body, ioErr := ioutil.ReadAll(resp.Body)
  13248. if ioErr != nil {
  13249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13251. return
  13252. }
  13253. var respJSON map[string]interface{}
  13254. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13257. return
  13258. }
  13259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13260. userJSONBytes, _ := json.Marshal(respJSON)
  13261. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13262. utils.ErrorLog("解析失败:%v", err)
  13263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13264. return
  13265. }
  13266. res.InfRefmsgid = resOther.InfRefmsgid
  13267. res.Output = resOther.Output
  13268. res.ErrMsg = resOther.ErrMsg
  13269. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13270. res.Infcode = infocode
  13271. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13272. var pp models.PublicParams
  13273. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13274. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13275. pp.FixmedinsName = miConfig.OrgName
  13276. pp.FixmedinsCode = miConfig.Code
  13277. pp.RequestUrl = miConfig.Url
  13278. pp.Cainfo = miConfig.Cainfo
  13279. pp.SecretKey = miConfig.SecretKey
  13280. pp.AccessKey = miConfig.AccessKey
  13281. pp.OpterName = curRoles.UserName
  13282. result, _ := service.Jxyb4101(struct4101, pp)
  13283. var dat map[string]interface{}
  13284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13285. fmt.Println(dat)
  13286. } else {
  13287. fmt.Println(err)
  13288. }
  13289. userJSONBytes, _ := json.Marshal(dat)
  13290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13291. utils.ErrorLog("解析失败:%v", err)
  13292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13293. return
  13294. }
  13295. } else {
  13296. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13297. var dat map[string]interface{}
  13298. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13299. fmt.Println(dat)
  13300. } else {
  13301. fmt.Println(err)
  13302. }
  13303. userJSONBytes, _ := json.Marshal(dat)
  13304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13305. utils.ErrorLog("解析失败:%v", err)
  13306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13307. return
  13308. }
  13309. }
  13310. if res.Infcode != 0 {
  13311. c.ServeSuccessJSON(map[string]interface{}{
  13312. "failed_code": -10,
  13313. "msg": res.ErrMsg,
  13314. })
  13315. return
  13316. } else {
  13317. if miConfig.MdtrtareaAdmvs != "150499" {
  13318. order.FaPiaoNumber = zero
  13319. order.FaPiaoCode = last_order.FaPiaoCode
  13320. service.UpdateOrder(order)
  13321. }
  13322. hisFundSettleListResult := &models.HisFundSettleListResult{
  13323. Number: res.Output.SetlListId,
  13324. Status: 1,
  13325. Ctime: time.Now().Unix(),
  13326. Mtime: time.Now().Unix(),
  13327. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13328. IsUpload: 1,
  13329. OrderId: order_id,
  13330. }
  13331. service.CreateUploadRecord(hisFundSettleListResult)
  13332. c.ServeSuccessJSON(map[string]interface{}{
  13333. "msg": "上传成功",
  13334. "result": hisFundSettleListResult,
  13335. })
  13336. return
  13337. }
  13338. }
  13339. //func (c *HisApiController) GetBatchSettleList() {
  13340. // orders, _ := service.GetAllHisOrder(10106)
  13341. // for _, item := range orders {
  13342. // order_id := item.ID
  13343. // order, _ := service.GetHisOrderByIDTwo(order_id)
  13344. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13345. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13346. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13347. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  13348. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13349. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13350. //
  13351. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13352. //
  13353. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13354. //
  13355. // if order.ID == 0 {
  13356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13357. // return
  13358. // }
  13359. // if his.BalanceAccountsType == 2 {
  13360. // continue
  13361. // }
  13362. // struct4101 := service.Struct4101{
  13363. // PsnNo: order.PsnNo,
  13364. // MdtrtId: order.MdtrtId,
  13365. // SetlId: order.SetlId,
  13366. // PsnName: order.PsnName,
  13367. // Gend: order.Gend,
  13368. // Brdy: his.Brdy,
  13369. // Age: his.Age,
  13370. // Naty: order.Naty,
  13371. // PatnCertType: "01",
  13372. // Certno: order.Certno,
  13373. // Prfs: "90",
  13374. // ConerName: roles[0].UserName,
  13375. // PatnRlts: "99",
  13376. // ConerAddr: miConfig.OrgName,
  13377. // ConerTel: admin.Mobile,
  13378. // HiType: order.Insutype,
  13379. // Insuplc: his.InsuplcAdmdvs,
  13380. // MaindiagFlag: "1",
  13381. // BillCode: order.SetlId,
  13382. // BillNo: order.SetlId,
  13383. // BizSn: order.Number,
  13384. // PsnSelfPay: order.PsnPartAmt,
  13385. // PsnOwnPay: order.PsnPartAmt,
  13386. // AcctPay: order.AcctPay,
  13387. // PsnCashpay: order.PsnCashPay,
  13388. // HiPaymtd: "1",
  13389. // Hsorg: his.InsuplcAdmdvs,
  13390. // HsorgOpter: his.InsuplcAdmdvs,
  13391. // MedinsFillPsn: curRoles.UserName,
  13392. // MedinsFillDept: depart.Name,
  13393. // IptMedType: "2",
  13394. // }
  13395. // struct4101.SetlBegnDate = order.SetlTime
  13396. // struct4101.SetlEndDate = order.SetlTime
  13397. // //if order.SettleType == 1 {
  13398. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  13399. // // dateStr := t.Format("2006-01-02")
  13400. // // struct4101.SetlBegnDate = dateStr
  13401. // // struct4101.SetlEndDate = dateStr
  13402. // //} else {
  13403. // // t := time.Unix(int64(order.SettleStartTime), 0)
  13404. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  13405. // // dateStartStr := t.Format("2006-01-02")
  13406. // // dateEndStr := t2.Format("2006-01-02")
  13407. // // struct4101.SetlBegnDate = dateStartStr
  13408. // // struct4101.SetlEndDate = dateEndStr
  13409. // //}
  13410. //
  13411. // var rf []CustomFundPay
  13412. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  13413. //
  13414. // var tempFunPays []service.CustomStruct
  13415. // var tempFunPay610100 service.CustomStruct
  13416. //
  13417. // for _, item := range rf {
  13418. // if item.FundPayType == "610100" {
  13419. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  13420. // tempFunPay610100.FundPayType = item.FundPayType
  13421. // } else {
  13422. // var tempFunPay service.CustomStruct
  13423. // tempFunPay.FundPayamt = item.FundPayamt
  13424. // tempFunPay.FundPayType = item.FundPayType
  13425. // tempFunPays = append(tempFunPays, tempFunPay)
  13426. // }
  13427. // }
  13428. // tempFunPays = append(tempFunPays, tempFunPay610100)
  13429. // struct4101.CustomStruct = tempFunPays
  13430. //
  13431. // var tempDiaginfos []service.DiaginfoStructTwo
  13432. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13433. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13434. //
  13435. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13436. // var config []*models.HisXtDiagnoseConfig
  13437. // for _, item := range diagnosis_ids {
  13438. // id, _ := strconv.ParseInt(item, 10, 64)
  13439. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  13440. // config = append(config, &diagnosisConfig)
  13441. // }
  13442. //
  13443. // for index, item := range config {
  13444. // if index == 0 {
  13445. // var tempDiaginfo service.DiaginfoStructTwo
  13446. // tempDiaginfo.DiagCode = item.CountryCode
  13447. // tempDiaginfo.DiagName = item.CountryContentName
  13448. // tempDiaginfo.DiagType = "1"
  13449. // tempDiaginfo.MaindiagFlag = "1"
  13450. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13451. // } else {
  13452. //
  13453. // var tempDiaginfo service.DiaginfoStructTwo
  13454. // tempDiaginfo.DiagCode = item.CountryCode
  13455. // tempDiaginfo.DiagName = item.CountryContentName
  13456. // tempDiaginfo.DiagType = "2"
  13457. // tempDiaginfo.MaindiagFlag = "0"
  13458. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13459. // }
  13460. // }
  13461. // struct4101.Diseinfo = tempDiaginfos
  13462. //
  13463. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  13464. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13465. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13466. // tempOpspdiseinfo2.OprnOprtCode = ""
  13467. // tempOpspdiseinfo2.OprnOprtName = ""
  13468. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13469. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13470. //
  13471. // var iteminfo service.IteminfoStruct
  13472. //
  13473. // var bedCostTotal float64 = 0 //床位总费
  13474. // var bedCostSelfTotal float64 = 0 //床位自费
  13475. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13476. //
  13477. // var examineCostTotal float64 = 0 //诊查总费
  13478. // var examineCostSelfTotal float64 = 0 //诊查自费
  13479. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  13480. //
  13481. // var nursingCostTotal float64 = 0 //护理总费
  13482. // var nursingCostSelfTotal float64 = 0 //护理自费
  13483. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  13484. //
  13485. // var chineseMedicineCostTotal float64 = 0 //中成药
  13486. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  13487. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  13488. //
  13489. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  13490. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  13491. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  13492. //
  13493. // var registerCostTotal float64 = 0 //一般诊疗费
  13494. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  13495. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  13496. //
  13497. // var operationCostTotal float64 = 0 //手术费
  13498. // var operationCostSelfTotal float64 = 0 //手术费
  13499. // var operationCostPartSelfTotal float64 = 0 //手术费
  13500. //
  13501. // var otherCostTotal float64 = 0 //其他费用
  13502. // var otherCostSelfTotal float64 = 0 //其他费用
  13503. // var otherCostPartSelfTotal float64 = 0 //其他费用
  13504. //
  13505. // var materialCostTotal float64 = 0 //材料费
  13506. // var materialCostSelfTotal float64 = 0 //材料费
  13507. // var materialCostPartSelfTotal float64 = 0 //材料费
  13508. //
  13509. // var westernMedicineCostTotal float64 = 0 //西药费
  13510. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  13511. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13512. //
  13513. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13514. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13515. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13516. //
  13517. // var checkCostTotal float64 = 0 //检查费
  13518. // var checkCostSelfTotal float64 = 0 //检查费
  13519. // var checkCostPartSelfTotal float64 = 0 //检查费
  13520. //
  13521. // var laboratoryCostTotal float64 = 0 //化验费
  13522. // var laboratoryCostSelfTotal float64 = 0 //化验费
  13523. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13524. //
  13525. // var treatCostTotal float64 = 0 //治疗费用
  13526. // var treatCostSelfTotal float64 = 0 //治疗费用
  13527. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  13528. //
  13529. // decimal.DivisionPrecision = 2
  13530. //
  13531. // var bed_fulamt_ownpay_amt float64 = 0
  13532. //
  13533. // var examine_fulamt_ownpay_amt float64 = 0
  13534. //
  13535. // var nursing_fulamt_ownpay_amt float64 = 0
  13536. //
  13537. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  13538. //
  13539. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  13540. //
  13541. // var register_fulamt_ownpay_amt float64 = 0
  13542. //
  13543. // var operation_fulamt_ownpay_amt float64 = 0
  13544. // var other_fulamt_ownpay_amt float64 = 0
  13545. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  13546. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13547. // var check_fulamt_ownpay_amt float64 = 0
  13548. // var material_fulamt_ownpay_amt float64 = 0
  13549. // var laboratory_fulamt_ownpay_amt float64 = 0
  13550. // var treat_fulamt_ownpay_amt float64 = 0
  13551. //
  13552. // var bed_claa_sunmfee float64 = 0
  13553. // var bed_clab_amt float64 = 0
  13554. // var bed_other_amt float64 = 0
  13555. //
  13556. // var examine_claa_sunmfee float64 = 0
  13557. // var examine_clab_amt float64 = 0
  13558. // var examine_other_amt float64 = 0
  13559. //
  13560. // var nursing_claa_sunmfee float64 = 0
  13561. // var nursing_clab_amt float64 = 0
  13562. // var nursing_other_amt float64 = 0
  13563. //
  13564. // var chinese_medicine_claa_sunmfee float64 = 0
  13565. // var chinese_medicine_clab_amt float64 = 0
  13566. // var chinese_medicine_other_amt float64 = 0
  13567. //
  13568. // var commonly_treatment_claa_sunmfee float64 = 0
  13569. // var commonly_treatment_clab_amt float64 = 0
  13570. // var commonly_treatment_other_amt float64 = 0
  13571. //
  13572. // var operation_claa_sunmfee float64 = 0
  13573. // var operation_clab_amt float64 = 0
  13574. // var operation_other_amt float64 = 0
  13575. //
  13576. // var other_claa_sunmfee float64 = 0
  13577. // var other_clab_amt float64 = 0
  13578. // var other_other_amt float64 = 0
  13579. //
  13580. // var westernMedicine_claa_sunmfee float64 = 0
  13581. // var westernMedicine_clab_amt float64 = 0
  13582. // var westernMedicine_other_amt float64 = 0
  13583. //
  13584. // var chineseTraditional_claa_sunmfee float64 = 0
  13585. // var chineseTraditional_clab_amt float64 = 0
  13586. // var chineseTraditional_other_amt float64 = 0
  13587. //
  13588. // var check_claa_sunmfee float64 = 0
  13589. // var check_clab_amt float64 = 0
  13590. // var check_other_amt float64 = 0
  13591. //
  13592. // var material_claa_sunmfee float64 = 0
  13593. // var material_clab_amt float64 = 0
  13594. // var material_other_amt float64 = 0
  13595. //
  13596. // var laboratory_claa_sunmfee float64 = 0
  13597. // var laboratory_clab_amt float64 = 0
  13598. // var laboratory_other_amt float64 = 0
  13599. //
  13600. // var treat_claa_sunmfee float64 = 0
  13601. // var treat_clab_amt float64 = 0
  13602. // var treat_other_amt float64 = 0
  13603. //
  13604. // var register_claa_sunmfee float64 = 0
  13605. // var register_clab_amt float64 = 0
  13606. // var register_other_amt float64 = 0
  13607. //
  13608. // for _, item := range order.HisOrderInfo {
  13609. // if item.MedChrgitmType == "01" { //床位费
  13610. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13611. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13612. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13613. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13614. // if item.ChrgitmLv == "1" {
  13615. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13616. // }
  13617. // if item.ChrgitmLv == "2" {
  13618. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13619. //
  13620. // }
  13621. // if item.ChrgitmLv == "3" {
  13622. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13623. // }
  13624. //
  13625. // }
  13626. //
  13627. // if item.MedChrgitmType == "02" { //诊查
  13628. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13629. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13630. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13631. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13632. // if item.ChrgitmLv == "1" {
  13633. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13634. // }
  13635. // if item.ChrgitmLv == "2" {
  13636. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13637. //
  13638. // }
  13639. // if item.ChrgitmLv == "3" {
  13640. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13641. // }
  13642. //
  13643. // }
  13644. //
  13645. // if item.MedChrgitmType == "03" { //检查费
  13646. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13647. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13648. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13649. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13650. // if item.ChrgitmLv == "1" {
  13651. //
  13652. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13653. //
  13654. // }
  13655. // if item.ChrgitmLv == "2" {
  13656. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13657. //
  13658. // }
  13659. // if item.ChrgitmLv == "3" {
  13660. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13661. // }
  13662. // }
  13663. //
  13664. // if item.MedChrgitmType == "04" { //化验费
  13665. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13666. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13667. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13668. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13669. // if item.ChrgitmLv == "1" {
  13670. //
  13671. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13672. //
  13673. // }
  13674. // if item.ChrgitmLv == "2" {
  13675. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13676. //
  13677. // }
  13678. // if item.ChrgitmLv == "3" {
  13679. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13680. // }
  13681. // }
  13682. //
  13683. // if item.MedChrgitmType == "05" { //治疗费
  13684. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13685. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13686. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13687. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13688. // if item.ChrgitmLv == "1" {
  13689. //
  13690. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13691. //
  13692. // }
  13693. // if item.ChrgitmLv == "2" {
  13694. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13695. //
  13696. // }
  13697. // if item.ChrgitmLv == "3" {
  13698. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13699. // }
  13700. // }
  13701. //
  13702. // if item.MedChrgitmType == "06" { //手术费
  13703. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13704. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13705. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13706. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13707. //
  13708. // if item.ChrgitmLv == "1" {
  13709. //
  13710. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13711. //
  13712. // }
  13713. // if item.ChrgitmLv == "2" {
  13714. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13715. //
  13716. // }
  13717. // if item.ChrgitmLv == "3" {
  13718. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13719. // }
  13720. // }
  13721. //
  13722. // if item.MedChrgitmType == "07" { //手术费
  13723. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13724. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13725. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13726. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13727. //
  13728. // if item.ChrgitmLv == "1" {
  13729. //
  13730. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13731. //
  13732. // }
  13733. // if item.ChrgitmLv == "2" {
  13734. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13735. //
  13736. // }
  13737. // if item.ChrgitmLv == "3" {
  13738. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13739. // }
  13740. // }
  13741. //
  13742. // if item.MedChrgitmType == "08" { //材料费
  13743. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13744. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13745. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13746. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13747. // if item.ChrgitmLv == "1" {
  13748. //
  13749. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13750. //
  13751. // }
  13752. // if item.ChrgitmLv == "2" {
  13753. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13754. //
  13755. // }
  13756. // if item.ChrgitmLv == "3" {
  13757. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13758. // }
  13759. // }
  13760. // if item.MedChrgitmType == "09" { //西药费
  13761. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13762. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13763. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13764. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13765. // if item.ChrgitmLv == "1" {
  13766. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13767. // }
  13768. // if item.ChrgitmLv == "2" {
  13769. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13770. // }
  13771. // if item.ChrgitmLv == "3" {
  13772. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13773. // }
  13774. // }
  13775. // if item.MedChrgitmType == "10" { //中药饮片
  13776. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13777. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13778. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13779. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13780. // if item.ChrgitmLv == "1" {
  13781. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13782. // }
  13783. // if item.ChrgitmLv == "2" {
  13784. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13785. // }
  13786. // if item.ChrgitmLv == "3" {
  13787. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13788. // }
  13789. // }
  13790. //
  13791. // if item.MedChrgitmType == "11" { //中成费
  13792. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13793. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13794. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13795. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13796. // if item.ChrgitmLv == "1" {
  13797. //
  13798. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13799. //
  13800. // }
  13801. // if item.ChrgitmLv == "2" {
  13802. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13803. //
  13804. // }
  13805. // if item.ChrgitmLv == "3" {
  13806. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13807. // }
  13808. // }
  13809. //
  13810. // if item.MedChrgitmType == "12" { //中成费
  13811. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13812. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13813. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13814. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13815. // if item.ChrgitmLv == "1" {
  13816. //
  13817. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13818. //
  13819. // }
  13820. // if item.ChrgitmLv == "2" {
  13821. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13822. //
  13823. // }
  13824. // if item.ChrgitmLv == "3" {
  13825. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13826. // }
  13827. // }
  13828. //
  13829. // if item.MedChrgitmType == "13" { //中成费
  13830. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13831. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13832. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13833. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13834. // if item.ChrgitmLv == "1" {
  13835. //
  13836. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13837. //
  13838. // }
  13839. // if item.ChrgitmLv == "2" {
  13840. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13841. //
  13842. // }
  13843. // if item.ChrgitmLv == "3" {
  13844. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13845. // }
  13846. // }
  13847. //
  13848. // if item.MedChrgitmType == "14" { //其他费
  13849. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13850. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13851. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13852. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13853. // if item.ChrgitmLv == "1" {
  13854. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13855. //
  13856. // }
  13857. // if item.ChrgitmLv == "2" {
  13858. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13859. //
  13860. // }
  13861. // if item.ChrgitmLv == "3" {
  13862. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13863. // }
  13864. // }
  13865. //
  13866. // }
  13867. //
  13868. // var iteminfoStructs []service.IteminfoStruct
  13869. //
  13870. // if bedCostTotal != 0 {
  13871. // iteminfo.MedChrgitm = "01"
  13872. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13873. // iteminfo.Amt = bedCostTotal
  13874. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  13875. // iteminfo.ClabAmt = bed_clab_amt
  13876. // iteminfo.OthAmt = bed_other_amt
  13877. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13878. // }
  13879. //
  13880. // if examineCostTotal != 0 {
  13881. // iteminfo.MedChrgitm = "02"
  13882. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  13883. // iteminfo.Amt = examineCostTotal
  13884. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  13885. // iteminfo.ClabAmt = examine_clab_amt
  13886. // iteminfo.OthAmt = examine_other_amt
  13887. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13888. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13889. // }
  13890. //
  13891. // if checkCostTotal != 0 {
  13892. // iteminfo.MedChrgitm = "03"
  13893. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13894. // iteminfo.Amt = checkCostTotal
  13895. // iteminfo.ClaaSumfee = check_claa_sunmfee
  13896. // iteminfo.ClabAmt = check_clab_amt
  13897. // iteminfo.OthAmt = check_other_amt
  13898. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13899. //
  13900. // }
  13901. //
  13902. // if laboratoryCostTotal != 0 {
  13903. // iteminfo.MedChrgitm = "04"
  13904. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13905. // iteminfo.Amt = laboratoryCostTotal
  13906. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13907. // iteminfo.ClabAmt = laboratory_clab_amt
  13908. // iteminfo.OthAmt = laboratory_other_amt
  13909. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13910. //
  13911. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13912. //
  13913. // }
  13914. //
  13915. // if treatCostTotal != 0 {
  13916. // iteminfo.MedChrgitm = "05"
  13917. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13918. // iteminfo.Amt = treatCostTotal
  13919. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  13920. // iteminfo.ClabAmt = treat_clab_amt
  13921. // iteminfo.OthAmt = treat_other_amt
  13922. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13923. // //(struct4101.IteminfoStruct, iteminfo)
  13924. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13925. // }
  13926. //
  13927. // if operationCostTotal != 0 {
  13928. // iteminfo.MedChrgitm = "06"
  13929. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13930. // iteminfo.Amt = operationCostTotal
  13931. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  13932. // iteminfo.ClabAmt = operation_clab_amt
  13933. // iteminfo.OthAmt = operation_other_amt
  13934. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13935. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13936. // }
  13937. //
  13938. // if nursingCostTotal != 0 {
  13939. // iteminfo.MedChrgitm = "07"
  13940. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  13941. // iteminfo.Amt = nursingCostTotal
  13942. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  13943. // iteminfo.ClabAmt = nursing_clab_amt
  13944. // iteminfo.OthAmt = nursing_other_amt
  13945. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13946. // }
  13947. //
  13948. // if materialCostTotal != 0 {
  13949. // iteminfo.MedChrgitm = "08"
  13950. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13951. // iteminfo.Amt = materialCostTotal
  13952. // iteminfo.ClaaSumfee = material_claa_sunmfee
  13953. // iteminfo.ClabAmt = material_clab_amt
  13954. // iteminfo.OthAmt = material_other_amt
  13955. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13956. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13957. // }
  13958. //
  13959. // if westernMedicineCostTotal != 0 {
  13960. // iteminfo.MedChrgitm = "09"
  13961. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13962. // iteminfo.Amt = westernMedicineCostTotal
  13963. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13964. // iteminfo.ClabAmt = westernMedicine_clab_amt
  13965. // iteminfo.OthAmt = westernMedicine_other_amt
  13966. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13967. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13968. //
  13969. // }
  13970. //
  13971. // if chineseMedicineCostTotal != 0 {
  13972. // iteminfo.MedChrgitm = "10"
  13973. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  13974. // iteminfo.Amt = chineseMedicineCostTotal
  13975. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  13976. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  13977. // iteminfo.OthAmt = chinese_medicine_other_amt
  13978. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13979. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13980. //
  13981. // }
  13982. //
  13983. // if chineseTraditionalMedicineCostTotal != 0 {
  13984. // iteminfo.MedChrgitm = "11"
  13985. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13986. // iteminfo.Amt = westernMedicineCostTotal
  13987. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13988. // iteminfo.ClabAmt = westernMedicine_clab_amt
  13989. // iteminfo.OthAmt = westernMedicine_other_amt
  13990. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13991. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13992. //
  13993. // }
  13994. //
  13995. // if commonlyTreatmentCostTotal != 0 {
  13996. // iteminfo.MedChrgitm = "12"
  13997. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  13998. // iteminfo.Amt = commonlyTreatmentCostTotal
  13999. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  14000. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  14001. // iteminfo.OthAmt = commonly_treatment_other_amt
  14002. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14003. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14004. //
  14005. // }
  14006. //
  14007. // if registerCostTotal != 0 {
  14008. // iteminfo.MedChrgitm = "13"
  14009. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  14010. // iteminfo.Amt = registerCostTotal
  14011. // iteminfo.ClaaSumfee = register_claa_sunmfee
  14012. // iteminfo.ClabAmt = register_clab_amt
  14013. // iteminfo.OthAmt = register_other_amt
  14014. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14015. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14016. //
  14017. // }
  14018. //
  14019. // if otherCostTotal != 0 {
  14020. // iteminfo.MedChrgitm = "14"
  14021. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14022. // iteminfo.Amt = otherCostTotal
  14023. // iteminfo.ClaaSumfee = other_claa_sunmfee
  14024. // iteminfo.ClabAmt = other_clab_amt
  14025. // iteminfo.OthAmt = other_other_amt
  14026. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14027. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14028. //
  14029. // }
  14030. // struct4101.IteminfoStruct = iteminfoStructs
  14031. // time_arr := strings.Split(order.SetlTime, " ")
  14032. // struct4101.AdmTime = time_arr[0]
  14033. // struct4101.AdmEndTime = time_arr[0]
  14034. //
  14035. // struct4101.DoctorName = doctor.UserName
  14036. // struct4101.DoctorCode = doctor.DoctorNumber
  14037. //
  14038. // struct4101.Ntly = "中国"
  14039. // struct4101.AdmCaty = "A03.06"
  14040. // var res ResultSeventeen
  14041. // if miConfig.MdtrtareaAdmvs == "421300" {
  14042. // data := make(map[string]interface{})
  14043. // data["struct4101"] = struct4101
  14044. // data["secret_key"] = miConfig.SecretKey
  14045. // data["org_name"] = miConfig.OrgName
  14046. // data["opera"] = curRoles.UserName
  14047. // data["code"] = miConfig.Code
  14048. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14049. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14050. //
  14051. // client := &http.Client{}
  14052. // bytesData, _ := json.Marshal(data)
  14053. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14054. // resp, _ := client.Do(req)
  14055. // defer resp.Body.Close()
  14056. // body, ioErr := ioutil.ReadAll(resp.Body)
  14057. // if ioErr != nil {
  14058. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14060. // return
  14061. // }
  14062. // var respJSON map[string]interface{}
  14063. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14064. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14066. // return
  14067. // }
  14068. //
  14069. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14070. // userJSONBytes, _ := json.Marshal(respJSON)
  14071. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14072. // utils.ErrorLog("解析失败:%v", err)
  14073. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14074. // adminUser := c.GetAdminUserInfo()
  14075. // errlog := &models.HisOrderError{
  14076. // UserOrgId: adminUser.CurrentOrgId,
  14077. // Ctime: time.Now().Unix(),
  14078. // Mtime: time.Now().Unix(),
  14079. // ErrMsg: res.ErrMsg + "解析失败",
  14080. // Status: 1,
  14081. // PatientId: order_id,
  14082. // Stage: 10088,
  14083. // }
  14084. // service.CreateErrMsgLog(errlog)
  14085. // continue
  14086. // }
  14087. //
  14088. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  14089. // data := make(map[string]interface{})
  14090. // data["struct4101"] = struct4101
  14091. // data["secret_key"] = miConfig.SecretKey
  14092. // data["org_name"] = miConfig.OrgName
  14093. // data["opera"] = curRoles.UserName
  14094. // data["code"] = miConfig.Code
  14095. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14096. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14097. //
  14098. // client := &http.Client{}
  14099. // bytesData, _ := json.Marshal(data)
  14100. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14101. // resp, _ := client.Do(req)
  14102. // defer resp.Body.Close()
  14103. // body, ioErr := ioutil.ReadAll(resp.Body)
  14104. // if ioErr != nil {
  14105. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14107. // return
  14108. // }
  14109. // var respJSON map[string]interface{}
  14110. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14111. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14113. // return
  14114. // }
  14115. //
  14116. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14117. // userJSONBytes, _ := json.Marshal(respJSON)
  14118. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14119. // utils.ErrorLog("解析失败:%v", err)
  14120. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14121. // adminUser := c.GetAdminUserInfo()
  14122. // errlog := &models.HisOrderError{
  14123. // UserOrgId: adminUser.CurrentOrgId,
  14124. // Ctime: time.Now().Unix(),
  14125. // Mtime: time.Now().Unix(),
  14126. // ErrMsg: res.ErrMsg + "解析失败",
  14127. // Status: 1,
  14128. // PatientId: order_id,
  14129. // Stage: 10088,
  14130. // }
  14131. // service.CreateErrMsgLog(errlog)
  14132. // continue
  14133. // }
  14134. //
  14135. // } else {
  14136. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  14137. // fmt.Println(result)
  14138. //
  14139. // var dat map[string]interface{}
  14140. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14141. // fmt.Println(dat)
  14142. // } else {
  14143. // fmt.Println(err)
  14144. // }
  14145. // userJSONBytes, _ := json.Marshal(dat)
  14146. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14147. // utils.ErrorLog("解析失败:%v", err)
  14148. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14149. // adminUser := c.GetAdminUserInfo()
  14150. // errlog := &models.HisOrderError{
  14151. // UserOrgId: adminUser.CurrentOrgId,
  14152. // Ctime: time.Now().Unix(),
  14153. // Mtime: time.Now().Unix(),
  14154. // ErrMsg: res.ErrMsg + "解析失败",
  14155. // Status: 1,
  14156. // PatientId: order_id,
  14157. // Stage: 10106,
  14158. // }
  14159. // service.CreateErrMsgLog(errlog)
  14160. // continue
  14161. // }
  14162. // }
  14163. //
  14164. // if res.Infcode != 0 {
  14165. // adminUser := c.GetAdminUserInfo()
  14166. // errlog := &models.HisOrderError{
  14167. // UserOrgId: adminUser.CurrentOrgId,
  14168. // Ctime: time.Now().Unix(),
  14169. // Mtime: time.Now().Unix(),
  14170. // ErrMsg: res.ErrMsg,
  14171. // Status: 1,
  14172. // PatientId: order_id,
  14173. // Stage: 10106,
  14174. // }
  14175. // service.CreateErrMsgLog(errlog)
  14176. // continue
  14177. // } else {
  14178. // hisFundSettleListResult := &models.HisFundSettleListResult{
  14179. // Number: res.Output.SetlListId,
  14180. // Status: 1,
  14181. // Ctime: time.Now().Unix(),
  14182. // Mtime: time.Now().Unix(),
  14183. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14184. // IsUpload: 1,
  14185. // OrderId: order_id,
  14186. // }
  14187. // service.CreateUploadRecord(hisFundSettleListResult)
  14188. // continue
  14189. // }
  14190. // }
  14191. //}
  14192. func (c *HisApiController) GetOrgInfo() {
  14193. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  14194. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  14195. }
  14196. func (c *HisApiController) GetHisPatientInfo() {
  14197. medical_insurance_card := c.GetString("medical_insurance_card")
  14198. id_card_type, _ := c.GetInt64("id_card_type")
  14199. id_card := c.GetString("id_card")
  14200. adminInfo := c.GetAdminUserInfo()
  14201. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14202. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14203. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  14204. IdCardNo := ""
  14205. if id_card_type == 1 {
  14206. IdCardNo = medical_insurance_card
  14207. } else if id_card_type == 2 {
  14208. IdCardNo = id_card
  14209. }
  14210. if config.IsOpen == 1 {
  14211. 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
  14212. resp, requestErr := http.Get(api)
  14213. if requestErr != nil {
  14214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14215. return
  14216. }
  14217. defer resp.Body.Close()
  14218. body, ioErr := ioutil.ReadAll(resp.Body)
  14219. if ioErr != nil {
  14220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14222. return
  14223. }
  14224. var respJSON map[string]interface{}
  14225. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14228. return
  14229. }
  14230. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14231. userJSONBytes, _ := json.Marshal(userJSON)
  14232. var res ResultTwo
  14233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14234. utils.ErrorLog("解析失败:%v", err)
  14235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14236. return
  14237. }
  14238. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14239. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14240. infoStr := string(Iinfos)
  14241. idetinfoStr := string(Idetinfos)
  14242. if res.Infcode == 0 {
  14243. his := models.VMHisPatient{
  14244. Status: 1,
  14245. Ctime: time.Now().Unix(),
  14246. Mtime: time.Now().Unix(),
  14247. PsnNo: res.Output.Baseinfo.PsnNo,
  14248. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14249. Certno: res.Output.Baseinfo.Certno,
  14250. PsnName: res.Output.Baseinfo.PsnName,
  14251. Gend: res.Output.Baseinfo.Gend,
  14252. Naty: res.Output.Baseinfo.Naty,
  14253. Iinfo: infoStr,
  14254. Idetinfo: idetinfoStr,
  14255. UserOrgId: adminInfo.CurrentOrgId,
  14256. IsReturn: 1,
  14257. IdCardType: id_card_type,
  14258. }
  14259. c.ServeSuccessJSON(map[string]interface{}{
  14260. "info": his,
  14261. })
  14262. } else {
  14263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14264. return
  14265. }
  14266. }
  14267. }
  14268. //func GetBasBaseInfo() (jsonStr string, err error) {
  14269. //
  14270. // handle := syscall.NewLazyDLL("SSCard.dll")
  14271. // add := handle.NewProc("ReadCardBas")
  14272. // str := make([]byte, 1024)
  14273. // str1 := make([]byte, 1024)
  14274. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14275. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  14276. //
  14277. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  14278. //
  14279. // fmt.Println("> Add(4,5)的结果为:", ret)
  14280. // handle.Release()
  14281. //
  14282. // return "", nil
  14283. //
  14284. //}
  14285. //func GetQRBaseInfo() (jsonStr string, err error) {
  14286. // handle := syscall.LoadDLL("SSCard.dll")
  14287. // ReadCardBas := handle.FindProc("GetQRBase")
  14288. //
  14289. // str := make([]byte, 256)
  14290. // str1 := make([]byte, 256)
  14291. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14292. //
  14293. // fmt.Println(string(str))
  14294. // fmt.Println(r)
  14295. // return string(str), nil
  14296. //}
  14297. //func CardInit() int {
  14298. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  14299. // add := DllTestDef.MustFindProc("Init")
  14300. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14301. // if err != nil {
  14302. // fmt.Println("SSCard的运算结果为:", ret)
  14303. // }
  14304. // result := int(ret)
  14305. // return result
  14306. //}
  14307. //func CardInit() int {
  14308. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14309. // if err != nil {
  14310. // fmt.Println("SSCard的运算结果为:", ret)
  14311. // }
  14312. // fmt.Println(err)
  14313. // result := int(ret)
  14314. // return result
  14315. //}
  14316. func IntPtr(n int) uintptr {
  14317. return uintptr(n)
  14318. }
  14319. func StrPtr(s string) uintptr {
  14320. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  14321. }
  14322. type Result2001 struct {
  14323. Cainfo interface{} `json:"cainfo"`
  14324. ErrMsg string `json:"err_msg"`
  14325. InfRefmsgid string `json:"inf_refmsgid"`
  14326. Infcode int64 `json:"infcode"`
  14327. Output struct {
  14328. Trtinfo struct {
  14329. PsnNo string `json:"psn_no"`
  14330. TrtChkType string `json:"trt_chk_type"`
  14331. FundPayType string `json:"fund_pay_type"`
  14332. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14333. Begndate string `json:"begndate"`
  14334. Enddate string `json:"enddate"`
  14335. TrtChkRslt string `json:"trt_chk_rslt"`
  14336. } `json:"trtinfo"`
  14337. } `json:"output"`
  14338. RefmsgTime string `json:"refmsg_time"`
  14339. RespondTime string `json:"respond_time"`
  14340. Signtype interface{} `json:"signtype"`
  14341. WarnMsg interface{} `json:"warn_msg"`
  14342. }
  14343. type Result2001Org10265 struct {
  14344. Cainfo interface{} `json:"cainfo"`
  14345. ErrMsg string `json:"err_msg"`
  14346. InfRefmsgid string `json:"inf_refmsgid"`
  14347. Infcode string `json:"infcode"`
  14348. Output struct {
  14349. Trtinfo struct {
  14350. PsnNo string `json:"psn_no"`
  14351. TrtChkType string `json:"trt_chk_type"`
  14352. FundPayType string `json:"fund_pay_type"`
  14353. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14354. Begndate string `json:"begndate"`
  14355. Enddate string `json:"enddate"`
  14356. TrtChkRslt string `json:"trt_chk_rslt"`
  14357. } `json:"trtinfo"`
  14358. } `json:"output"`
  14359. RefmsgTime string `json:"refmsg_time"`
  14360. RespondTime string `json:"respond_time"`
  14361. Signtype interface{} `json:"signtype"`
  14362. WarnMsg interface{} `json:"warn_msg"`
  14363. }
  14364. type ResultTwo struct {
  14365. ErrMsg string `json:"err_msg"`
  14366. InfRefmsgid string `json:"inf_refmsgid"`
  14367. Infcode int64 `json:"infcode"`
  14368. Output struct {
  14369. Baseinfo struct {
  14370. //Brdy string `json:"brdy"`
  14371. Certno string `json:"certno"`
  14372. Gend string `json:"gend"`
  14373. Naty string `json:"naty"`
  14374. PsnCertType string `json:"psn_cert_type"`
  14375. PsnName string `json:"psn_name"`
  14376. PsnNo string `json:"psn_no"`
  14377. } `json:"baseinfo"`
  14378. Idetinfo []interface{} `json:"idetinfo"`
  14379. Iinfo []struct {
  14380. Balc float64 `json:"balc"`
  14381. CvlservFlag string `json:"cvlserv_flag"`
  14382. EmpName string `json:"emp_name"`
  14383. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14384. Insutype string `json:"insutype"`
  14385. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14386. //PausInsuDate string `json:"paus_insu_date"`
  14387. //PsnInsuDate string `json:"psn_insu_date"`
  14388. PsnInsuStas string `json:"psn_insu_stas"`
  14389. PsnType string `json:"psn_type"`
  14390. } `json:"insuinfo"`
  14391. } `json:"output"`
  14392. RefmsgTime string `json:"refmsg_time"`
  14393. RespondTime string `json:"respond_time"`
  14394. Signtype interface{} `json:"signtype"`
  14395. WarnInfo interface{} `json:"warn_info"`
  14396. }
  14397. type ResultTwo10265 struct {
  14398. ErrMsg string `json:"err_msg"`
  14399. InfRefmsgid string `json:"inf_refmsgid"`
  14400. Infcode string `json:"infcode"`
  14401. Output struct {
  14402. Baseinfo struct {
  14403. //Brdy string `json:"brdy"`
  14404. Certno string `json:"certno"`
  14405. Gend string `json:"gend"`
  14406. Naty string `json:"naty"`
  14407. PsnCertType string `json:"psn_cert_type"`
  14408. PsnName string `json:"psn_name"`
  14409. PsnNo string `json:"psn_no"`
  14410. } `json:"baseinfo"`
  14411. Idetinfo []interface{} `json:"idetinfo"`
  14412. Iinfo []struct {
  14413. Balc float64 `json:"balc"`
  14414. CvlservFlag string `json:"cvlserv_flag"`
  14415. EmpName string `json:"emp_name"`
  14416. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14417. Insutype string `json:"insutype"`
  14418. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14419. PsnInsuStas string `json:"psn_insu_stas"`
  14420. PsnType string `json:"psn_type"`
  14421. } `json:"insuinfo"`
  14422. } `json:"output"`
  14423. RefmsgTime string `json:"refmsg_time"`
  14424. RespondTime string `json:"respond_time"`
  14425. Signtype interface{} `json:"signtype"`
  14426. WarnInfo interface{} `json:"warn_info"`
  14427. }
  14428. type ResultThree struct {
  14429. Cainfo interface{} `json:"cainfo"`
  14430. ErrMsg string `json:"err_msg"`
  14431. InfRefmsgid string `json:"inf_refmsgid"`
  14432. Infcode int64 `json:"infcode"`
  14433. Output struct {
  14434. Data struct {
  14435. IptOtpNo string `json:"ipt_otp_no"`
  14436. MdtrtID string `json:"mdtrt_id"`
  14437. PsnNo string `json:"psn_no"`
  14438. } `json:"data"`
  14439. } `json:"output"`
  14440. RefmsgTime string `json:"refmsg_time"`
  14441. RespondTime string `json:"respond_time"`
  14442. Signtype interface{} `json:"signtype"`
  14443. WarnMsg interface{} `json:"warn_msg"`
  14444. }
  14445. type ResultThree10265 struct {
  14446. Cainfo interface{} `json:"cainfo"`
  14447. ErrMsg string `json:"err_msg"`
  14448. InfRefmsgid string `json:"inf_refmsgid"`
  14449. Infcode string `json:"infcode"`
  14450. Output struct {
  14451. Data struct {
  14452. IptOtpNo string `json:"ipt_otp_no"`
  14453. MdtrtID string `json:"mdtrt_id"`
  14454. PsnNo string `json:"psn_no"`
  14455. } `json:"data"`
  14456. } `json:"output"`
  14457. RefmsgTime string `json:"refmsg_time"`
  14458. RespondTime string `json:"respond_time"`
  14459. Signtype interface{} `json:"signtype"`
  14460. WarnMsg interface{} `json:"warn_msg"`
  14461. }
  14462. type ResultFour struct {
  14463. Cainfo string `json:"cainfo"`
  14464. ErrMsg string `json:"err_msg"`
  14465. InfRefmsgid string `json:"inf_refmsgid"`
  14466. Infcode int64 `json:"infcode"`
  14467. Output struct {
  14468. Result []struct {
  14469. BasMednFlag string `json:"bas_medn_flag"`
  14470. ChldMedcFlag string `json:"chld_medc_flag"`
  14471. ChrgitmLv string `json:"chrgitm_lv"`
  14472. Cnt float64 `json:"cnt"`
  14473. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14474. DrtReimFlag string `json:"drt_reim_flag"`
  14475. FeedetlSn string `json:"feedetl_sn"`
  14476. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14477. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14478. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14479. ListSpItemFlag string `json:"list_sp_item_flag"`
  14480. LmtUsedFlag string `json:"lmt_used_flag"`
  14481. MedChrgitmType string `json:"med_chrgitm_type"`
  14482. Memo string `json:"memo"`
  14483. OverlmtAmt float64 `json:"overlmt_amt"`
  14484. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14485. Pric float64 `json:"pric"`
  14486. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14487. SelfpayProp float64 `json:"selfpay_prop"`
  14488. } `json:"result"`
  14489. } `json:"output"`
  14490. RefmsgTime string `json:"refmsg_time"`
  14491. RespondTime string `json:"respond_time"`
  14492. Signtype string `json:"signtype"`
  14493. WarnMsg string `json:"warn_msg"`
  14494. }
  14495. type ResultFour10265 struct {
  14496. Cainfo string `json:"cainfo"`
  14497. ErrMsg string `json:"err_msg"`
  14498. InfRefmsgid string `json:"inf_refmsgid"`
  14499. Infcode string `json:"infcode"`
  14500. Output struct {
  14501. Result []struct {
  14502. BasMednFlag string `json:"bas_medn_flag"`
  14503. ChldMedcFlag string `json:"chld_medc_flag"`
  14504. ChrgitmLv string `json:"chrgitm_lv"`
  14505. Cnt float64 `json:"cnt"`
  14506. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14507. DrtReimFlag string `json:"drt_reim_flag"`
  14508. FeedetlSn string `json:"feedetl_sn"`
  14509. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14510. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14511. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14512. ListSpItemFlag string `json:"list_sp_item_flag"`
  14513. LmtUsedFlag string `json:"lmt_used_flag"`
  14514. MedChrgitmType string `json:"med_chrgitm_type"`
  14515. Memo string `json:"memo"`
  14516. OverlmtAmt float64 `json:"overlmt_amt"`
  14517. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14518. Pric float64 `json:"pric"`
  14519. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14520. SelfpayProp float64 `json:"selfpay_prop"`
  14521. } `json:"result"`
  14522. } `json:"output"`
  14523. RefmsgTime string `json:"refmsg_time"`
  14524. RespondTime string `json:"respond_time"`
  14525. Signtype string `json:"signtype"`
  14526. WarnMsg string `json:"warn_msg"`
  14527. }
  14528. type ResultMemo struct {
  14529. InsuAdmdvs string `json:"insuAdmdvs"`
  14530. }
  14531. // [{"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}]
  14532. type ResultIDInfo struct {
  14533. Begntime string `json:"begntime"`
  14534. Endtime string `json:"endtime"`
  14535. Memo string `json:"memo"`
  14536. }
  14537. type ResultFive struct {
  14538. Balc float64 `json:"balc"`
  14539. CvlservFlag string `json:"cvlserv_flag"`
  14540. EmpName string `json:"emp_name"`
  14541. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14542. Insutype string `json:"insutype"`
  14543. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14544. PausInsuDate string `json:"paus_insu_date"`
  14545. PsnInsuDate string `json:"psn_insu_date"`
  14546. PsnInsuStas string `json:"psn_insu_stas"`
  14547. PsnType string `json:"psn_type"`
  14548. }
  14549. type ResultSix struct {
  14550. Cainfo interface{} `json:"cainfo"`
  14551. ErrMsg string `json:"err_msg"`
  14552. InfRefmsgid string `json:"inf_refmsgid"`
  14553. Infcode int64 `json:"infcode"`
  14554. Output struct {
  14555. } `json:"output"`
  14556. RefmsgTime string `json:"refmsg_time"`
  14557. RespondTime string `json:"respond_time"`
  14558. Signtype interface{} `json:"signtype"`
  14559. WarnMsg interface{} `json:"warn_msg"`
  14560. }
  14561. type Result2406 struct {
  14562. Cainfo interface{} `json:"cainfo"`
  14563. ErrMsg string `json:"err_msg"`
  14564. InfRefmsgid string `json:"inf_refmsgid"`
  14565. Infcode int64 `json:"infcode"`
  14566. Output struct {
  14567. Result struct {
  14568. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  14569. } `json:"result"`
  14570. } `json:"output"`
  14571. RefmsgTime string `json:"refmsg_time"`
  14572. RespondTime string `json:"respond_time"`
  14573. Signtype interface{} `json:"signtype"`
  14574. WarnMsg interface{} `json:"warn_msg"`
  14575. }
  14576. type GZResultSix struct {
  14577. Cainfo interface{} `json:"cainfo"`
  14578. ErrMsg string `json:"err_msg"`
  14579. InfRefmsgid string `json:"inf_refmsgid"`
  14580. Infcode int64 `json:"infcode"`
  14581. Output string `json:"output"`
  14582. RefmsgTime string `json:"refmsg_time"`
  14583. RespondTime string `json:"respond_time"`
  14584. Signtype interface{} `json:"signtype"`
  14585. WarnMsg interface{} `json:"warn_msg"`
  14586. }
  14587. type ResultSix10265 struct {
  14588. Cainfo interface{} `json:"cainfo"`
  14589. ErrMsg string `json:"err_msg"`
  14590. InfRefmsgid string `json:"inf_refmsgid"`
  14591. Infcode string `json:"infcode"`
  14592. Output struct {
  14593. } `json:"output"`
  14594. RefmsgTime string `json:"refmsg_time"`
  14595. RespondTime string `json:"respond_time"`
  14596. Signtype interface{} `json:"signtype"`
  14597. WarnMsg interface{} `json:"warn_msg"`
  14598. }
  14599. type ResultSeven struct {
  14600. Cainfo string `json:"cainfo"`
  14601. ErrMsg string `json:"err_msg"`
  14602. InfRefmsgid string `json:"inf_refmsgid"`
  14603. Infcode int64 `json:"infcode"`
  14604. Output struct {
  14605. Setlinfo struct {
  14606. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14607. AcctPay float64 `json:"acct_pay"`
  14608. ActPayDedc float64 `json:"act_pay_dedc"`
  14609. Age float64 `json:"age"`
  14610. Balc float64 `json:"balc"`
  14611. Certno string `json:"certno"`
  14612. ClrOptins string `json:"clr_optins"`
  14613. ClrType string `json:"clr_type"`
  14614. ClrWay string `json:"clr_way"`
  14615. CvlservFlag string `json:"cvlserv_flag"`
  14616. CvlservPay float64 `json:"cvlserv_pay"`
  14617. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14618. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14619. Gend string `json:"gend"`
  14620. HifesPay float64 `json:"hifes_pay"`
  14621. HifmiPay float64 `json:"hifmi_pay"`
  14622. HifpPay float64 `json:"hifp_pay"`
  14623. HospPartAmt float64 `json:"hosp_part_amt"`
  14624. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14625. Insutype string `json:"insutype"`
  14626. MafPay float64 `json:"maf_pay"`
  14627. MdtrtCertType string `json:"mdtrt_cert_type"`
  14628. HifobPay float64 `json:"hifob_pay"`
  14629. MdtrtID string `json:"mdtrt_id"`
  14630. MedType string `json:"med_type"`
  14631. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14632. MedinsSetlID string `json:"medins_setl_id"`
  14633. Naty string `json:"naty"`
  14634. OthPay float64 `json:"oth_pay"`
  14635. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14636. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  14637. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14638. PsnCashPay float64 `json:"psn_cash_pay"`
  14639. PsnCertType string `json:"psn_cert_type"`
  14640. PsnName string `json:"psn_name"`
  14641. PsnNo string `json:"psn_no"`
  14642. PsnPartAmt float64 `json:"psn_part_amt"`
  14643. PsnType string `json:"psn_type"`
  14644. SetlID string `json:"setl_id"`
  14645. SetlTime string `json:"setl_time"`
  14646. } `json:"setlinfo"`
  14647. Setldetail interface{} `json:"setldetail"`
  14648. } `json:"output"`
  14649. RefmsgTime string `json:"refmsg_time"`
  14650. RespondTime string `json:"respond_time"`
  14651. Signtype interface{} `json:"signtype"`
  14652. WarnMsg interface{} `json:"warn_msg"`
  14653. }
  14654. type ResultSevenAH struct {
  14655. Cainfo string `json:"cainfo"`
  14656. ErrMsg string `json:"err_msg"`
  14657. InfRefmsgid string `json:"inf_refmsgid"`
  14658. Infcode int64 `json:"infcode"`
  14659. Output struct {
  14660. Setlinfo struct {
  14661. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14662. AcctPay float64 `json:"acct_pay"`
  14663. ActPayDedc float64 `json:"act_pay_dedc"`
  14664. Age float64 `json:"age"`
  14665. Balc float64 `json:"balc"`
  14666. Certno string `json:"certno"`
  14667. ClrOptins string `json:"clr_optins"`
  14668. ClrType string `json:"clr_type"`
  14669. ClrWay string `json:"clr_way"`
  14670. CvlservFlag string `json:"cvlserv_flag"`
  14671. CvlservPay float64 `json:"cvlserv_pay"`
  14672. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14673. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14674. Gend string `json:"gend"`
  14675. HifesPay float64 `json:"hifes_pay"`
  14676. HifmiPay float64 `json:"hifmi_pay"`
  14677. HifpPay float64 `json:"hifp_pay"`
  14678. HospPartAmt float64 `json:"hosp_part_amt"`
  14679. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14680. Insutype string `json:"insutype"`
  14681. MafPay float64 `json:"maf_pay"`
  14682. MdtrtCertType string `json:"mdtrt_cert_type"`
  14683. HifobPay float64 `json:"hifob_pay"`
  14684. MdtrtID string `json:"mdtrt_id"`
  14685. MedType string `json:"med_type"`
  14686. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14687. MedinsSetlID string `json:"medins_setl_id"`
  14688. Naty string `json:"naty"`
  14689. OthPay float64 `json:"oth_pay"`
  14690. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14691. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  14692. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14693. PsnCashPay float64 `json:"psn_cash_pay"`
  14694. PsnCertType string `json:"psn_cert_type"`
  14695. PsnName string `json:"psn_name"`
  14696. PsnNo string `json:"psn_no"`
  14697. PsnPartAmt float64 `json:"psn_part_amt"`
  14698. PsnType string `json:"psn_type"`
  14699. SetlID string `json:"setl_id"`
  14700. SetlTime int64 `json:"setl_time"`
  14701. } `json:"setlinfo"`
  14702. Setldetail interface{} `json:"setldetail"`
  14703. } `json:"output"`
  14704. RefmsgTime string `json:"refmsg_time"`
  14705. RespondTime string `json:"respond_time"`
  14706. Signtype interface{} `json:"signtype"`
  14707. WarnMsg interface{} `json:"warn_msg"`
  14708. }
  14709. type ResultSeven10265 struct {
  14710. Cainfo string `json:"cainfo"`
  14711. ErrMsg string `json:"err_msg"`
  14712. InfRefmsgid string `json:"inf_refmsgid"`
  14713. Infcode string `json:"infcode"`
  14714. Output struct {
  14715. Setlinfo struct {
  14716. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14717. AcctPay float64 `json:"acct_pay"`
  14718. ActPayDedc float64 `json:"act_pay_dedc"`
  14719. Age float64 `json:"age"`
  14720. Balc float64 `json:"balc"`
  14721. Certno string `json:"certno"`
  14722. ClrOptins string `json:"clr_optins"`
  14723. ClrType string `json:"clr_type"`
  14724. ClrWay string `json:"clr_way"`
  14725. CvlservFlag string `json:"cvlserv_flag"`
  14726. CvlservPay float64 `json:"cvlserv_pay"`
  14727. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14728. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14729. Gend string `json:"gend"`
  14730. HifesPay float64 `json:"hifes_pay"`
  14731. HifmiPay float64 `json:"hifmi_pay"`
  14732. HifpPay float64 `json:"hifp_pay"`
  14733. HospPartAmt float64 `json:"hosp_part_amt"`
  14734. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14735. Insutype string `json:"insutype"`
  14736. MafPay float64 `json:"maf_pay"`
  14737. MdtrtCertType string `json:"mdtrt_cert_type"`
  14738. HifobPay float64 `json:"hifob_pay"`
  14739. MdtrtID string `json:"mdtrt_id"`
  14740. MedType string `json:"med_type"`
  14741. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14742. MedinsSetlID string `json:"medins_setl_id"`
  14743. Naty string `json:"naty"`
  14744. OthPay float64 `json:"oth_pay"`
  14745. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14746. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  14747. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14748. PsnCashPay float64 `json:"psn_cash_pay"`
  14749. PsnCertType string `json:"psn_cert_type"`
  14750. PsnName string `json:"psn_name"`
  14751. PsnNo string `json:"psn_no"`
  14752. PsnPartAmt float64 `json:"psn_part_amt"`
  14753. PsnType string `json:"psn_type"`
  14754. SetlID string `json:"setl_id"`
  14755. SetlTime string `json:"setl_time"`
  14756. } `json:"setlinfo"`
  14757. Setldetail interface{} `json:"setldetail"`
  14758. } `json:"output"`
  14759. RefmsgTime string `json:"refmsg_time"`
  14760. RespondTime string `json:"respond_time"`
  14761. Signtype interface{} `json:"signtype"`
  14762. WarnMsg interface{} `json:"warn_msg"`
  14763. }
  14764. type ResultSeven10265Two struct {
  14765. Cainfo string `json:"cainfo"`
  14766. ErrMsg string `json:"err_msg"`
  14767. InfRefmsgid string `json:"inf_refmsgid"`
  14768. Infcode string `json:"infcode"`
  14769. Output struct {
  14770. Setlinfo struct {
  14771. AcctMulaidPay string `json:"acct_mulaid_pay"`
  14772. AcctPay float64 `json:"acct_pay"`
  14773. ActPayDedc float64 `json:"act_pay_dedc"`
  14774. Age float64 `json:"age"`
  14775. Balc float64 `json:"balc"`
  14776. Certno string `json:"certno"`
  14777. ClrOptins string `json:"clr_optins"`
  14778. ClrType string `json:"clr_type"`
  14779. ClrWay string `json:"clr_way"`
  14780. CvlservFlag string `json:"cvlserv_flag"`
  14781. CvlservPay float64 `json:"cvlserv_pay"`
  14782. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14783. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14784. Gend string `json:"gend"`
  14785. HifesPay float64 `json:"hifes_pay"`
  14786. HifmiPay float64 `json:"hifmi_pay"`
  14787. HifpPay float64 `json:"hifp_pay"`
  14788. HospPartAmt string `json:"hosp_part_amt"`
  14789. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14790. Insutype string `json:"insutype"`
  14791. MafPay float64 `json:"maf_pay"`
  14792. MdtrtCertType string `json:"mdtrt_cert_type"`
  14793. HifobPay float64 `json:"hifob_pay"`
  14794. MdtrtID string `json:"mdtrt_id"`
  14795. MedType string `json:"med_type"`
  14796. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14797. MedinsSetlID string `json:"medins_setl_id"`
  14798. Naty string `json:"naty"`
  14799. OthPay float64 `json:"oth_pay"`
  14800. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14801. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  14802. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14803. PsnCashPay float64 `json:"psn_cash_pay"`
  14804. PsnCertType string `json:"psn_cert_type"`
  14805. PsnName string `json:"psn_name"`
  14806. PsnNo string `json:"psn_no"`
  14807. PsnPartAmt float64 `json:"psn_part_amt"`
  14808. PsnType string `json:"psn_type"`
  14809. SetlID string `json:"setl_id"`
  14810. SetlTime string `json:"setl_time"`
  14811. } `json:"setlinfo"`
  14812. Setldetail interface{} `json:"setldetail"`
  14813. } `json:"output"`
  14814. RefmsgTime string `json:"refmsg_time"`
  14815. RespondTime string `json:"respond_time"`
  14816. Signtype interface{} `json:"signtype"`
  14817. WarnMsg interface{} `json:"warn_msg"`
  14818. }
  14819. type GZResultSeven10265Two struct {
  14820. Cainfo string `json:"cainfo"`
  14821. ErrMsg string `json:"err_msg"`
  14822. InfRefmsgid string `json:"inf_refmsgid"`
  14823. Infcode int64 `json:"infcode"`
  14824. Output struct {
  14825. Setlinfo struct {
  14826. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14827. AcctPay float64 `json:"acct_pay"`
  14828. ActPayDedc float64 `json:"act_pay_dedc"`
  14829. Age float64 `json:"age"`
  14830. Balc float64 `json:"balc"`
  14831. Certno string `json:"certno"`
  14832. ClrOptins string `json:"clr_optins"`
  14833. ClrType string `json:"clr_type"`
  14834. ClrWay string `json:"clr_way"`
  14835. CvlservFlag string `json:"cvlserv_flag"`
  14836. CvlservPay float64 `json:"cvlserv_pay"`
  14837. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14838. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14839. Gend string `json:"gend"`
  14840. HifesPay float64 `json:"hifes_pay"`
  14841. HifmiPay float64 `json:"hifmi_pay"`
  14842. HifpPay float64 `json:"hifp_pay"`
  14843. HospPartAmt float64 `json:"hosp_part_amt"`
  14844. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14845. Insutype string `json:"insutype"`
  14846. MafPay float64 `json:"maf_pay"`
  14847. MdtrtCertType string `json:"mdtrt_cert_type"`
  14848. HifobPay float64 `json:"hifob_pay"`
  14849. MdtrtID string `json:"mdtrt_id"`
  14850. MedType string `json:"med_type"`
  14851. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14852. MedinsSetlID string `json:"medins_setl_id"`
  14853. Naty string `json:"naty"`
  14854. OthPay float64 `json:"oth_pay"`
  14855. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14856. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  14857. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14858. PsnCashPay float64 `json:"psn_cash_pay"`
  14859. PsnCertType string `json:"psn_cert_type"`
  14860. PsnName string `json:"psn_name"`
  14861. PsnNo string `json:"psn_no"`
  14862. PsnPartAmt float64 `json:"psn_part_amt"`
  14863. PsnType string `json:"psn_type"`
  14864. SetlID string `json:"setl_id"`
  14865. SetlTime string `json:"setl_time"`
  14866. } `json:"setlinfo"`
  14867. Setldetail interface{} `json:"setldetail"`
  14868. } `json:"output"`
  14869. RefmsgTime string `json:"refmsg_time"`
  14870. RespondTime string `json:"respond_time"`
  14871. Signtype interface{} `json:"signtype"`
  14872. WarnMsg interface{} `json:"warn_msg"`
  14873. }
  14874. type ResultEight struct {
  14875. Cainfo string `json:"cainfo"`
  14876. ErrMsg string `json:"err_msg"`
  14877. InfRefmsgid string `json:"inf_refmsgid"`
  14878. Infcode int64 `json:"infcode"`
  14879. Output struct {
  14880. Stmtinfo struct {
  14881. SetlOptins string `json:"setl_optins"`
  14882. StmtRslt string `json:"stmt_rslt"`
  14883. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  14884. } `json:"stmtinfo"`
  14885. } `json:"output"`
  14886. RefmsgTime string `json:"refmsg_time"`
  14887. RespondTime string `json:"respond_time"`
  14888. Signtype interface{} `json:"signtype"`
  14889. WarnMsg interface{} `json:"warn_msg"`
  14890. }
  14891. type ResultEightFor10188 struct {
  14892. Cainfo string `json:"cainfo"`
  14893. ErrMsg string `json:"err_msg"`
  14894. InfRefmsgid string `json:"inf_refmsgid"`
  14895. Infcode string `json:"infcode"`
  14896. Output struct {
  14897. Stmtinfo struct {
  14898. SetlOptins string `json:"setl_optins"`
  14899. StmtRslt string `json:"stmt_rslt"`
  14900. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  14901. } `json:"stmtinfo"`
  14902. } `json:"output"`
  14903. RefmsgTime string `json:"refmsg_time"`
  14904. RespondTime string `json:"respond_time"`
  14905. Signtype interface{} `json:"signtype"`
  14906. WarnMsg interface{} `json:"warn_msg"`
  14907. }
  14908. type ResultNine struct {
  14909. Cainfo string `json:"cainfo"`
  14910. ErrMsg string `json:"err_msg"`
  14911. InfRefmsgid string `json:"inf_refmsgid"`
  14912. Infcode int64 `json:"infcode"`
  14913. Output struct {
  14914. FileQuryNo string `json:"file_qury_no"`
  14915. } `json:"output"`
  14916. RefmsgTime string `json:"refmsg_time"`
  14917. RespondTime string `json:"respond_time"`
  14918. Signtype interface{} `json:"signtype"`
  14919. WarnMsg interface{} `json:"warn_msg"`
  14920. }
  14921. type ResultTen struct {
  14922. Cainfo string `json:"cainfo"`
  14923. ErrMsg string `json:"err_msg"`
  14924. InfRefmsgid string `json:"inf_refmsgid"`
  14925. Infcode int64 `json:"infcode"`
  14926. Output struct {
  14927. Fileinfo struct {
  14928. DldEndtime string `json:"dld_endtime"`
  14929. FileQuryNo string `json:"file_qury_no"`
  14930. Filename string `json:"filename"`
  14931. } `json:"fileinfo"`
  14932. } `json:"output"`
  14933. RefmsgTime string `json:"refmsg_time"`
  14934. RespondTime string `json:"respond_time"`
  14935. Signtype interface{} `json:"signtype"`
  14936. WarnMsg interface{} `json:"warn_msg"`
  14937. }
  14938. type Result5262 struct {
  14939. ErrMsg string `json:"err_msg"`
  14940. InfRefmsgid string `json:"inf_refmsgid"`
  14941. Infcode int64 `json:"infcode"`
  14942. Output struct {
  14943. PageInfo struct {
  14944. Size int `json:"size"`
  14945. RecordCounts int `json:"record_counts"`
  14946. } `json:"page_info"`
  14947. Idetinfo []interface{} `json:"idetinfo"`
  14948. Result []struct {
  14949. SetlID string `json:"setl_id"`
  14950. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  14951. MdtrtID string `json:"mdtrt_id"`
  14952. InitSetlID string `json:"init_setl_id,omitempty"`
  14953. PsnNo string `json:"psn_no"`
  14954. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  14955. PsnName string `json:"psn_name"`
  14956. PsnCertType string `json:"psn_cert_type"`
  14957. Certno string `json:"certno"`
  14958. Gend string `json:"gend,omitempty"`
  14959. Naty string `json:"naty,omitempty"`
  14960. Brdy string `json:"brdy,omitempty"`
  14961. Age float64 `json:"age,omitempty"`
  14962. Insutype string `json:"insutype,omitempty"`
  14963. PsnType string `json:"psn_type"`
  14964. CvlservFlag string `json:"cvlserv_flag"`
  14965. CvlservLv string `json:"cvlserv_lv,omitempty"`
  14966. SpPsnType string `json:"sp_psn_type,omitempty"`
  14967. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  14968. ClctGrde string `json:"clct_grde,omitempty"`
  14969. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  14970. NwbFlag string `json:"nwb_flag,omitempty"`
  14971. InsuAdmdvs string `json:"insu_admdvs"`
  14972. EmpNo string `json:"emp_no,omitempty"`
  14973. EmpName string `json:"emp_name,omitempty"`
  14974. EmpType string `json:"emp_type,omitempty"`
  14975. EconType string `json:"econ_type,omitempty"`
  14976. AfilIndu string `json:"afil_indu,omitempty"`
  14977. AfilRlts string `json:"afil_rlts,omitempty"`
  14978. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  14979. PayLoc string `json:"pay_loc,omitempty"`
  14980. FixmedinsCode string `json:"fixmedins_code"`
  14981. FixmedinsName string `json:"fixmedins_name"`
  14982. HospLv string `json:"hosp_lv,omitempty"`
  14983. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  14984. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  14985. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  14986. Begndate string `json:"begndate"`
  14987. Enddate string `json:"enddate"`
  14988. SetlTime string `json:"setl_time"`
  14989. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  14990. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  14991. MedType string `json:"med_type"`
  14992. SetlType string `json:"setl_type,omitempty"`
  14993. ClrType string `json:"clr_type,omitempty"`
  14994. ClrWay string `json:"clr_way,omitempty"`
  14995. PsnSetlway string `json:"psn_setlway,omitempty"`
  14996. ClrOptins string `json:"clr_optins,omitempty"`
  14997. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  14998. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  14999. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15000. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15001. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15002. DedcStd float64 `json:"dedc_std,omitempty"`
  15003. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15004. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15005. HifpPay float64 `json:"hifp_pay,omitempty"`
  15006. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15007. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15008. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15009. HifesPay float64 `json:"hifes_pay,omitempty"`
  15010. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15011. HifobPay float64 `json:"hifob_pay,omitempty"`
  15012. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15013. MafPay float64 `json:"maf_pay,omitempty"`
  15014. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15015. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15016. PsnPay float64 `json:"psn_pay,omitempty"`
  15017. AcctPay float64 `json:"acct_pay,omitempty"`
  15018. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15019. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15020. Balc float64 `json:"balc,omitempty"`
  15021. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15022. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15023. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15024. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15025. Year string `json:"year,omitempty"`
  15026. DiseNo string `json:"dise_no,omitempty"`
  15027. DiseName string `json:"dise_name,omitempty"`
  15028. Invono string `json:"invono,omitempty"`
  15029. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15030. ValiFlag string `json:"vali_flag,omitempty"`
  15031. Memo string `json:"memo,omitempty"`
  15032. Rid string `json:"rid"`
  15033. UpdtTime string `json:"updt_time,omitempty"`
  15034. CrterID string `json:"crter_id,omitempty"`
  15035. CrterName string `json:"crter_name,omitempty"`
  15036. CrteTime string `json:"crte_time,omitempty"`
  15037. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  15038. OpterID string `json:"opter_id,omitempty"`
  15039. OpterName string `json:"opter_name,omitempty"`
  15040. OptTime string `json:"opt_time,omitempty"`
  15041. OptinsNo string `json:"optins_no,omitempty"`
  15042. PoolareaNo string `json:"poolarea_no,omitempty"`
  15043. } `json:"result"`
  15044. } `json:"output"`
  15045. RefmsgTime string `json:"refmsg_time"`
  15046. RespondTime string `json:"respond_time"`
  15047. Signtype interface{} `json:"signtype"`
  15048. WarnInfo interface{} `json:"warn_info"`
  15049. }
  15050. type Result5267 struct {
  15051. ErrMsg string `json:"err_msg"`
  15052. InfRefmsgid string `json:"inf_refmsgid"`
  15053. Infcode int64 `json:"infcode"`
  15054. Output struct {
  15055. PageInfo struct {
  15056. Size int `json:"size"`
  15057. RecordCounts int `json:"record_counts"`
  15058. } `json:"pageinfo"`
  15059. Result []struct {
  15060. SetlID string `json:"setl_id"`
  15061. ClrOptins string `json:"clr_optins"`
  15062. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15063. MdtrtID string `json:"mdtrt_id"`
  15064. InitSetlID string `json:"init_setl_id,omitempty"`
  15065. PsnNo string `json:"psn_no"`
  15066. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15067. PsnName string `json:"psn_name"`
  15068. PsnCertType string `json:"psn_cert_type"`
  15069. Certno string `json:"certno"`
  15070. Gend string `json:"gend,omitempty"`
  15071. Naty string `json:"naty,omitempty"`
  15072. Brdy string `json:"brdy,omitempty"`
  15073. Age float64 `json:"age,omitempty"`
  15074. Insutype string `json:"insutype,omitempty"`
  15075. PsnType string `json:"psn_type"`
  15076. CvlservFlag string `json:"cvlserv_flag"`
  15077. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15078. SpPsnType string `json:"sp_psn_type,omitempty"`
  15079. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15080. ClctGrde string `json:"clct_grde,omitempty"`
  15081. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15082. NwbFlag string `json:"nwb_flag,omitempty"`
  15083. InsuAdmdvs string `json:"insu_admdvs"`
  15084. EmpNo string `json:"emp_no,omitempty"`
  15085. EmpName string `json:"emp_name,omitempty"`
  15086. EmpType string `json:"emp_type,omitempty"`
  15087. EconType string `json:"econ_type,omitempty"`
  15088. AfilIndu string `json:"afil_indu,omitempty"`
  15089. AfilRlts string `json:"afil_rlts,omitempty"`
  15090. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15091. PayLoc string `json:"pay_loc,omitempty"`
  15092. FixmedinsCode string `json:"fixmedins_code"`
  15093. FixmedinsName string `json:"fixmedins_name"`
  15094. HospLv string `json:"hosp_lv,omitempty"`
  15095. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15096. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15097. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15098. Begndate string `json:"begndate,omitempty"`
  15099. Enddate string `json:"enddate,omitempty"`
  15100. SetlTime string `json:"setl_time,omitempty"`
  15101. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15102. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15103. MedType string `json:"med_type"`
  15104. SetlType string `json:"setl_type,omitempty"`
  15105. ClrType string `json:"clr_type,omitempty"`
  15106. ClrWay string `json:"clr_way,omitempty"`
  15107. PsnSetlway string `json:"psn_setlway,omitempty"`
  15108. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15109. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15110. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15111. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15112. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15113. DedcStd float64 `json:"dedc_std,omitempty"`
  15114. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15115. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15116. HifpPay float64 `json:"hifp_pay,omitempty"`
  15117. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15118. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15119. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15120. HifesPay float64 `json:"hifes_pay,omitempty"`
  15121. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15122. HifobPay float64 `json:"hifob_pay,omitempty"`
  15123. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15124. MafPay float64 `json:"maf_pay,omitempty"`
  15125. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15126. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15127. PsnPay float64 `json:"psn_pay,omitempty"`
  15128. AcctPay float64 `json:"acct_pay,omitempty"`
  15129. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15130. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15131. Balc float64 `json:"balc,omitempty"`
  15132. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15133. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15134. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15135. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15136. Year string `json:"year,omitempty"`
  15137. DiseNo string `json:"dise_no,omitempty"`
  15138. DiseName string `json:"dise_name,omitempty"`
  15139. Invono string `json:"invono,omitempty"`
  15140. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15141. Memo string `json:"memo,omitempty"`
  15142. UpdtTime string `json:"updt_time,omitempty"`
  15143. OpterID string `json:"opter_id,omitempty"`
  15144. OpterName string `json:"opter_name,omitempty"`
  15145. OptTime string `json:"opt_time,omitempty"`
  15146. OptinsNo string `json:"optins_no,omitempty"`
  15147. PoolareaNo string `json:"poolarea_no,omitempty"`
  15148. } `json:"result"`
  15149. } `json:"output"`
  15150. RefmsgTime string `json:"refmsg_time"`
  15151. RespondTime string `json:"respond_time"`
  15152. Signtype interface{} `json:"signtype"`
  15153. WarnInfo interface{} `json:"warn_info"`
  15154. }
  15155. // type Autogenerated struct {
  15156. // Output struct {
  15157. // Setlinfo struct {
  15158. // SetlTime string `json:"setl_time"`
  15159. // CvlservPay float64 `json:"cvlserv_pay"`
  15160. // Year string `json:"year"`
  15161. // MedType string `json:"med_type"`
  15162. // PsnPay float64 `json:"psn_pay"`
  15163. // OpterID string `json:"opter_id"`
  15164. // Begndate string `json:"begndate"`
  15165. // FlxempeFlag string `json:"flxempe_flag"`
  15166. // HifmiPay float64 `json:"hifmi_pay"`
  15167. // PsnNo string `json:"psn_no"`
  15168. // ActPayDedc float64 `json:"act_pay_dedc"`
  15169. // MedinsSetlID interface{} `json:"medins_setl_id"`
  15170. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15171. // ClrWay string `json:"clr_way"`
  15172. // OthPay float64 `json:"oth_pay"`
  15173. // Gend string `json:"gend"`
  15174. // MdtrtID string `json:"mdtrt_id"`
  15175. // AcctPay float64 `json:"acct_pay"`
  15176. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  15177. // Insutype string `json:"insutype"`
  15178. // Invono interface{} `json:"invono"`
  15179. // Enddate string `json:"enddate"`
  15180. // CashPayamt float64 `json:"cash_payamt"`
  15181. // PsnType string `json:"psn_type"`
  15182. // FixmedinsName string `json:"fixmedins_name"`
  15183. // HifpPay float64 `json:"hifp_pay"`
  15184. // NewFlag interface{} `json:"new_flag"`
  15185. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15186. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  15187. // PayLoc string `json:"pay_loc"`
  15188. // ClrType string `json:"clr_type"`
  15189. // RefdSetlFlag string `json:"refd_setl_flag"`
  15190. // CvlservFlag string `json:"cvlserv_flag"`
  15191. // EmpName string `json:"emp_name"`
  15192. // Brdy string `json:"brdy"`
  15193. // Naty string `json:"naty"`
  15194. // Certno string `json:"certno"`
  15195. // DiseCode string `json:"dise_code"`
  15196. // FixmedinsCode string `json:"fixmedins_code"`
  15197. // DedcHospLv string `json:"dedc_hosp_lv"`
  15198. // OpterName string `json:"opter_name"`
  15199. // Balc float64 `json:"balc"`
  15200. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15201. // PsnCertType string `json:"psn_cert_type"`
  15202. // HifobPay float64 `json:"hifob_pay"`
  15203. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  15204. // HifesPay float64 `json:"hifes_pay"`
  15205. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15206. // OptTime string `json:"opt_time"`
  15207. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15208. // SetlID string `json:"setl_id"`
  15209. // MafPay float64 `json:"maf_pay"`
  15210. // PsnName string `json:"psn_name"`
  15211. // InsuOptins interface{} `json:"insu_optins"`
  15212. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15213. // ClrOptins string `json:"clr_optins"`
  15214. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15215. // DiseName string `json:"dise_name"`
  15216. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15217. // Age float64 `json:"age"`
  15218. // DtrtCertType string `json:"dtrt_cert_type"`
  15219. // HospLv string `json:"hosp_lv"`
  15220. // } `json:"setlinfo"`
  15221. // Setldetail []struct {
  15222. // FundPayType string `json:"fund_pay_type"`
  15223. // FundPayamt float64 `json:"fund_payamt"`
  15224. // SetlProcInfo interface{} `json:"setl_proc_info"`
  15225. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  15226. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  15227. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  15228. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15229. // } `json:"setldetail"`
  15230. // } `json:"output"`
  15231. // Infcode int `json:"infcode"`
  15232. // WarnMsg interface{} `json:"warn_msg"`
  15233. // Cainfo interface{} `json:"cainfo"`
  15234. // ErrMsg interface{} `json:"err_msg"`
  15235. // RefmsgTime string `json:"refmsg_time"`
  15236. // Signtype interface{} `json:"signtype"`
  15237. // RespondTime string `json:"respond_time"`
  15238. // InfRefmsgid string `json:"inf_refmsgid"`
  15239. // }
  15240. type Result002 struct {
  15241. Cainfo interface{} `json:"cainfo"`
  15242. ErrMsg string `json:"err_msg"`
  15243. InfRefmsgid string `json:"inf_refmsgid"`
  15244. Infcode int64 `json:"infcode"`
  15245. Output struct {
  15246. RxFile string `json:"rx_file"`
  15247. SignDigest string `json:"sign_digest"`
  15248. SignCertSn string `json:"sign_cert_sn"`
  15249. SignCertDn string `json:"sign_cert_dn"`
  15250. } `json:"output"`
  15251. RefmsgTime string `json:"refmsg_time"`
  15252. RespondTime string `json:"respond_time"`
  15253. Signtype interface{} `json:"signtype"`
  15254. WarnMsg interface{} `json:"warn_msg"`
  15255. }
  15256. type Result003 struct {
  15257. Cainfo interface{} `json:"cainfo"`
  15258. ErrMsg string `json:"err_msg"`
  15259. InfRefmsgid string `json:"inf_refmsgid"`
  15260. Infcode int64 `json:"infcode"`
  15261. Output struct {
  15262. HiRxno string `json:"hi_rxno"`
  15263. RxStasCodg string `json:"rx_stas_codg"`
  15264. RxStasName string `json:"rx_stas_name"`
  15265. } `json:"output"`
  15266. RefmsgTime string `json:"refmsg_time"`
  15267. RespondTime string `json:"respond_time"`
  15268. Signtype interface{} `json:"signtype"`
  15269. WarnMsg interface{} `json:"warn_msg"`
  15270. }
  15271. type ResultEleven struct {
  15272. Cainfo string `json:"cainfo"`
  15273. ErrMsg string `json:"err_msg"`
  15274. InfRefmsgid string `json:"inf_refmsgid"`
  15275. Infcode int64 `json:"infcode"`
  15276. Output struct {
  15277. Setlinfo struct {
  15278. SetlTime string `json:"setl_time"`
  15279. CvlservPay float64 `json:"cvlserv_pay"`
  15280. Year string `json:"year"`
  15281. MedType string `json:"med_type"`
  15282. PsnPay float64 `json:"psn_pay"`
  15283. OpterID string `json:"opter_id"`
  15284. Begndate string `json:"begndate"`
  15285. FlxempeFlag string `json:"flxempe_flag"`
  15286. HifmiPay float64 `json:"hifmi_pay"`
  15287. PsnNo string `json:"psn_no"`
  15288. ActPayDedc float64 `json:"act_pay_dedc"`
  15289. MedinsSetlID interface{} `json:"medins_setl_id"`
  15290. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15291. ClrWay string `json:"clr_way"`
  15292. OthPay float64 `json:"oth_pay"`
  15293. Gend string `json:"gend"`
  15294. MdtrtID string `json:"mdtrt_id"`
  15295. AcctPay float64 `json:"acct_pay"`
  15296. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15297. Insutype string `json:"insutype"`
  15298. Invono interface{} `json:"invono"`
  15299. Enddate string `json:"enddate"`
  15300. CashPayamt float64 `json:"cash_payamt"`
  15301. PsnType string `json:"psn_type"`
  15302. FixmedinsName string `json:"fixmedins_name"`
  15303. HifpPay float64 `json:"hifp_pay"`
  15304. NewFlag interface{} `json:"new_flag"`
  15305. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15306. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15307. PayLoc string `json:"pay_loc"`
  15308. ClrType string `json:"clr_type"`
  15309. RefdSetlFlag string `json:"refd_setl_flag"`
  15310. CvlservFlag string `json:"cvlserv_flag"`
  15311. EmpName string `json:"emp_name"`
  15312. Brdy string `json:"brdy"`
  15313. Naty string `json:"naty"`
  15314. Certno string `json:"certno"`
  15315. DiseCode string `json:"dise_code"`
  15316. FixmedinsCode string `json:"fixmedins_code"`
  15317. DedcHospLv string `json:"dedc_hosp_lv"`
  15318. OpterName string `json:"opter_name"`
  15319. Balc float64 `json:"balc"`
  15320. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15321. PsnCertType string `json:"psn_cert_type"`
  15322. HifobPay float64 `json:"hifob_pay"`
  15323. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15324. HifesPay float64 `json:"hifes_pay"`
  15325. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15326. OptTime string `json:"opt_time"`
  15327. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15328. SetlID string `json:"setl_id"`
  15329. MafPay float64 `json:"maf_pay"`
  15330. PsnName string `json:"psn_name"`
  15331. InsuOptins interface{} `json:"insu_optins"`
  15332. PrefFundPay interface{} `json:"pref_fund_pay"`
  15333. ClrOptins string `json:"clr_optins"`
  15334. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15335. DiseName string `json:"dise_name"`
  15336. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15337. Age float64 `json:"age"`
  15338. DtrtCertType string `json:"dtrt_cert_type"`
  15339. HospLv string `json:"hosp_lv"`
  15340. PsnCashPay float64 `json:"psn_cash_pay"`
  15341. } `json:"setlinfo"`
  15342. } `json:"output"`
  15343. RefmsgTime string `json:"refmsg_time"`
  15344. RespondTime string `json:"respond_time"`
  15345. Signtype interface{} `json:"signtype"`
  15346. WarnMsg interface{} `json:"warn_msg"`
  15347. }
  15348. type ResultElevenah struct {
  15349. Cainfo string `json:"cainfo"`
  15350. ErrMsg string `json:"err_msg"`
  15351. InfRefmsgid string `json:"inf_refmsgid"`
  15352. Infcode int64 `json:"infcode"`
  15353. Output struct {
  15354. Setlinfo struct {
  15355. SetlTime int64 `json:"setl_time"`
  15356. CvlservPay float64 `json:"cvlserv_pay"`
  15357. Year string `json:"year"`
  15358. MedType string `json:"med_type"`
  15359. PsnPay float64 `json:"psn_pay"`
  15360. OpterID string `json:"opter_id"`
  15361. Begndate int64 `json:"begndate"`
  15362. FlxempeFlag string `json:"flxempe_flag"`
  15363. HifmiPay float64 `json:"hifmi_pay"`
  15364. PsnNo string `json:"psn_no"`
  15365. ActPayDedc float64 `json:"act_pay_dedc"`
  15366. MedinsSetlID interface{} `json:"medins_setl_id"`
  15367. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15368. ClrWay string `json:"clr_way"`
  15369. OthPay float64 `json:"oth_pay"`
  15370. Gend string `json:"gend"`
  15371. MdtrtID string `json:"mdtrt_id"`
  15372. AcctPay float64 `json:"acct_pay"`
  15373. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15374. Insutype string `json:"insutype"`
  15375. Invono interface{} `json:"invono"`
  15376. Enddate int64 `json:"enddate"`
  15377. CashPayamt float64 `json:"cash_payamt"`
  15378. PsnType string `json:"psn_type"`
  15379. FixmedinsName string `json:"fixmedins_name"`
  15380. HifpPay float64 `json:"hifp_pay"`
  15381. NewFlag interface{} `json:"new_flag"`
  15382. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15383. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15384. PayLoc string `json:"pay_loc"`
  15385. ClrType string `json:"clr_type"`
  15386. RefdSetlFlag string `json:"refd_setl_flag"`
  15387. CvlservFlag string `json:"cvlserv_flag"`
  15388. EmpName string `json:"emp_name"`
  15389. Brdy int64 `json:"brdy"`
  15390. Naty string `json:"naty"`
  15391. Certno string `json:"certno"`
  15392. DiseCode string `json:"dise_code"`
  15393. FixmedinsCode string `json:"fixmedins_code"`
  15394. DedcHospLv string `json:"dedc_hosp_lv"`
  15395. OpterName string `json:"opter_name"`
  15396. Balc float64 `json:"balc"`
  15397. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15398. PsnCertType string `json:"psn_cert_type"`
  15399. HifobPay float64 `json:"hifob_pay"`
  15400. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15401. HifesPay float64 `json:"hifes_pay"`
  15402. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15403. OptTime int64 `json:"opt_time"`
  15404. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15405. SetlID string `json:"setl_id"`
  15406. MafPay float64 `json:"maf_pay"`
  15407. PsnName string `json:"psn_name"`
  15408. InsuOptins interface{} `json:"insu_optins"`
  15409. PrefFundPay interface{} `json:"pref_fund_pay"`
  15410. ClrOptins string `json:"clr_optins"`
  15411. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15412. DiseName string `json:"dise_name"`
  15413. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15414. Age float64 `json:"age"`
  15415. DtrtCertType string `json:"dtrt_cert_type"`
  15416. HospLv string `json:"hosp_lv"`
  15417. PsnCashPay float64 `json:"psn_cash_pay"`
  15418. } `json:"setlinfo"`
  15419. } `json:"output"`
  15420. RefmsgTime string `json:"refmsg_time"`
  15421. RespondTime string `json:"respond_time"`
  15422. Signtype interface{} `json:"signtype"`
  15423. WarnMsg interface{} `json:"warn_msg"`
  15424. }
  15425. type ResultEleven10265 struct {
  15426. Cainfo string `json:"cainfo"`
  15427. ErrMsg string `json:"err_msg"`
  15428. InfRefmsgid string `json:"inf_refmsgid"`
  15429. Infcode string `json:"infcode"`
  15430. Output struct {
  15431. Setlinfo struct {
  15432. SetlTime string `json:"setl_time"`
  15433. CvlservPay float64 `json:"cvlserv_pay"`
  15434. Year string `json:"year"`
  15435. MedType string `json:"med_type"`
  15436. PsnPay float64 `json:"psn_pay"`
  15437. OpterID string `json:"opter_id"`
  15438. Begndate string `json:"begndate"`
  15439. FlxempeFlag string `json:"flxempe_flag"`
  15440. HifmiPay float64 `json:"hifmi_pay"`
  15441. PsnNo string `json:"psn_no"`
  15442. ActPayDedc float64 `json:"act_pay_dedc"`
  15443. MedinsSetlID interface{} `json:"medins_setl_id"`
  15444. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15445. ClrWay string `json:"clr_way"`
  15446. OthPay float64 `json:"oth_pay"`
  15447. Gend string `json:"gend"`
  15448. MdtrtID string `json:"mdtrt_id"`
  15449. AcctPay float64 `json:"acct_pay"`
  15450. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15451. Insutype string `json:"insutype"`
  15452. Invono interface{} `json:"invono"`
  15453. Enddate string `json:"enddate"`
  15454. CashPayamt float64 `json:"cash_payamt"`
  15455. PsnType string `json:"psn_type"`
  15456. FixmedinsName string `json:"fixmedins_name"`
  15457. HifpPay float64 `json:"hifp_pay"`
  15458. NewFlag interface{} `json:"new_flag"`
  15459. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15460. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15461. PayLoc string `json:"pay_loc"`
  15462. ClrType string `json:"clr_type"`
  15463. RefdSetlFlag string `json:"refd_setl_flag"`
  15464. CvlservFlag string `json:"cvlserv_flag"`
  15465. EmpName string `json:"emp_name"`
  15466. Brdy string `json:"brdy"`
  15467. Naty string `json:"naty"`
  15468. Certno string `json:"certno"`
  15469. DiseCode string `json:"dise_code"`
  15470. FixmedinsCode string `json:"fixmedins_code"`
  15471. DedcHospLv string `json:"dedc_hosp_lv"`
  15472. OpterName string `json:"opter_name"`
  15473. Balc float64 `json:"balc"`
  15474. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15475. PsnCertType string `json:"psn_cert_type"`
  15476. HifobPay float64 `json:"hifob_pay"`
  15477. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15478. HifesPay float64 `json:"hifes_pay"`
  15479. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15480. OptTime string `json:"opt_time"`
  15481. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15482. SetlID string `json:"setl_id"`
  15483. MafPay float64 `json:"maf_pay"`
  15484. PsnName string `json:"psn_name"`
  15485. InsuOptins interface{} `json:"insu_optins"`
  15486. PrefFundPay interface{} `json:"pref_fund_pay"`
  15487. ClrOptins string `json:"clr_optins"`
  15488. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15489. DiseName string `json:"dise_name"`
  15490. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15491. Age float64 `json:"age"`
  15492. DtrtCertType string `json:"dtrt_cert_type"`
  15493. HospLv string `json:"hosp_lv"`
  15494. PsnCashPay float64 `json:"psn_cash_pay"`
  15495. } `json:"setlinfo"`
  15496. } `json:"output"`
  15497. RefmsgTime string `json:"refmsg_time"`
  15498. RespondTime string `json:"respond_time"`
  15499. Signtype interface{} `json:"signtype"`
  15500. WarnMsg interface{} `json:"warn_msg"`
  15501. }
  15502. type ResultTwelve struct {
  15503. Cainfo string `json:"cainfo"`
  15504. ErrMsg string `json:"err_msg"`
  15505. InfRefmsgid string `json:"inf_refmsgid"`
  15506. Infcode int64 `json:"infcode"`
  15507. Output struct {
  15508. MdtrtId string `json:"mdtrt_id"`
  15509. ChrgBchno string `json:"chrg_bchno"`
  15510. PsnNo string `json:"psn_no"`
  15511. } `json:"output"`
  15512. RefmsgTime string `json:"refmsg_time"`
  15513. RespondTime string `json:"respond_time"`
  15514. Signtype interface{} `json:"signtype"`
  15515. WarnMsg interface{} `json:"warn_msg"`
  15516. }
  15517. type ResultThirteen struct {
  15518. ErrMsg string `json:"err_msg"`
  15519. InfRefmsgid string `json:"inf_refmsgid"`
  15520. Infcode int64 `json:"infcode"`
  15521. Output struct {
  15522. Result struct {
  15523. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15524. } `json:"result"`
  15525. } `json:"output"`
  15526. RefmsgTime string `json:"refmsg_time"`
  15527. RespondTime string `json:"respond_time"`
  15528. Signtype interface{} `json:"signtype"`
  15529. WarnInfo interface{} `json:"warn_info"`
  15530. }
  15531. type ResultThirteen10265 struct {
  15532. ErrMsg string `json:"err_msg"`
  15533. InfRefmsgid string `json:"inf_refmsgid"`
  15534. Infcode string `json:"infcode"`
  15535. Output struct {
  15536. Result struct {
  15537. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15538. } `json:"result"`
  15539. } `json:"output"`
  15540. RefmsgTime string `json:"refmsg_time"`
  15541. RespondTime string `json:"respond_time"`
  15542. Signtype interface{} `json:"signtype"`
  15543. WarnInfo interface{} `json:"warn_info"`
  15544. }
  15545. type ResultFourteen struct {
  15546. ErrMsg string `json:"err_msg"`
  15547. InfRefmsgid string `json:"inf_refmsgid"`
  15548. Infcode int64 `json:"infcode"`
  15549. Output struct {
  15550. } `json:"output"`
  15551. RefmsgTime string `json:"refmsg_time"`
  15552. RespondTime string `json:"respond_time"`
  15553. Signtype interface{} `json:"signtype"`
  15554. WarnInfo interface{} `json:"warn_info"`
  15555. }
  15556. type ResultCFYLJG001 struct {
  15557. ErrMsg string `json:"err_msg"`
  15558. InfRefmsgid string `json:"inf_refmsgid"`
  15559. Infcode int64 `json:"infcode"`
  15560. Output struct {
  15561. RxTraceCode string `json:"rx_trace_code"`
  15562. HiRxno string `json:"hi_rxno"`
  15563. } `json:"output"`
  15564. RefmsgTime string `json:"refmsg_time"`
  15565. RespondTime string `json:"respond_time"`
  15566. Signtype interface{} `json:"signtype"`
  15567. WarnInfo interface{} `json:"warn_info"`
  15568. }
  15569. type ResultCFYLJG007 struct {
  15570. ErrMsg string `json:"err_msg"`
  15571. InfRefmsgid string `json:"inf_refmsgid"`
  15572. Infcode int64 `json:"infcode"`
  15573. Output struct {
  15574. } `json:"output"`
  15575. RefmsgTime string `json:"refmsg_time"`
  15576. RespondTime string `json:"respond_time"`
  15577. Signtype interface{} `json:"signtype"`
  15578. WarnInfo interface{} `json:"warn_info"`
  15579. }
  15580. type ResultCFYLJG002 struct {
  15581. ErrMsg string `json:"err_msg"`
  15582. InfRefmsgid string `json:"inf_refmsgid"`
  15583. Infcode int64 `json:"infcode"`
  15584. Output struct {
  15585. RxFile string `json:"rx_file"`
  15586. SignDigest string `json:"sign_digest"`
  15587. SignCertSn string `json:"sign_cert_sn"`
  15588. SignCertDn string `json:"sign_cert_dn"`
  15589. } `json:"output"`
  15590. RefmsgTime string `json:"refmsg_time"`
  15591. RespondTime string `json:"respond_time"`
  15592. Signtype interface{} `json:"signtype"`
  15593. WarnInfo interface{} `json:"warn_info"`
  15594. }
  15595. type ResultCFYLJG003 struct {
  15596. ErrMsg string `json:"err_msg"`
  15597. InfRefmsgid string `json:"inf_refmsgid"`
  15598. Infcode int64 `json:"infcode"`
  15599. Output struct {
  15600. HiRxno string `json:"hi_rxno"`
  15601. RxStasCodg string `json:"rx_stas_codg"`
  15602. RxStasName string `json:"rx_stas_name"`
  15603. } `json:"output"`
  15604. RefmsgTime string `json:"refmsg_time"`
  15605. RespondTime string `json:"respond_time"`
  15606. Signtype interface{} `json:"signtype"`
  15607. WarnInfo interface{} `json:"warn_info"`
  15608. }
  15609. type ResultCFYLJG004 struct {
  15610. ErrMsg string `json:"err_msg"`
  15611. InfRefmsgid string `json:"inf_refmsgid"`
  15612. Infcode int64 `json:"infcode"`
  15613. Output struct {
  15614. HiRxno string `json:"hi_rxno"`
  15615. RxStasCodg string `json:"rx_stas_codg"`
  15616. RxStasName string `json:"rx_stas_name"`
  15617. } `json:"output"`
  15618. RefmsgTime string `json:"refmsg_time"`
  15619. RespondTime string `json:"respond_time"`
  15620. Signtype interface{} `json:"signtype"`
  15621. WarnInfo interface{} `json:"warn_info"`
  15622. }
  15623. type ResultCFYLJG008 struct {
  15624. ErrMsg string `json:"err_msg"`
  15625. InfRefmsgid string `json:"inf_refmsgid"`
  15626. Infcode int64 `json:"infcode"`
  15627. Output struct {
  15628. PoolareaNo string `json:"poolareaNo"`
  15629. AdmdvsName string `json:"admdvsName"`
  15630. Count string `json:"count"`
  15631. } `json:"output"`
  15632. RefmsgTime string `json:"refmsg_time"`
  15633. RespondTime string `json:"respond_time"`
  15634. Signtype interface{} `json:"signtype"`
  15635. WarnInfo interface{} `json:"warn_info"`
  15636. }
  15637. type ResultCFYLJG005 struct {
  15638. ErrMsg string `json:"err_msg"`
  15639. InfRefmsgid string `json:"inf_refmsgid"`
  15640. Infcode int64 `json:"infcode"`
  15641. Output struct {
  15642. HiRxNo string `json:"hi_rxno"`
  15643. FixMedinsCode string `json:"fixmedins_code"`
  15644. FixMedinsName string `json:"fixmedins_name"`
  15645. RxStasCodg string `json:"rx_stas_codg"`
  15646. RxStasName string `json:"rx_stas_name"`
  15647. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  15648. RxUserdStasName string `json:"rx_userd_stas_name"`
  15649. PrscTime string `json:"prsc_time"`
  15650. RxDrugCnt float64 `json:"rx_drug_cnt"`
  15651. RxUsedWayCodg string `json:"rx_used_way_codg"`
  15652. RxUsedWayName string `json:"rx_used_way_name"`
  15653. RxFrquCodg string `json:"rx_frqu_codg"`
  15654. RxFrquName string `json:"rx_frqu_name"`
  15655. RxDosunt string `json:"rx_dosunt"`
  15656. RxDoscnt float64 `json:"rx_doscnt"`
  15657. RxDrordDscr string `json:"rx_drord_dscr"`
  15658. ValiDays int64 `json:"vali_days"`
  15659. ValiEndTime string `json:"vali_end_time"`
  15660. ReptFlag string `json:"rept_flag"`
  15661. MaxReptCnt int64 `json:"max_rept_cnt"`
  15662. ReptdCnt int64 `json:"reptd_cnt"`
  15663. MinInrvDays int64 `json:"min_inrv_days"`
  15664. RxTypeCode string `json:"rx_type_code"`
  15665. RxTypeName string `json:"rx_type_name"`
  15666. LongRxFlag string `json:"long_rx_flag"`
  15667. RxDetlList []struct {
  15668. MedListCodg string `json:"med_list_codg"`
  15669. MedinsListCodg string `json:"medins_list_codg"`
  15670. HospPrepFlag string `json:"hosp_prep_flag"`
  15671. RxItemTypeCode string `json:"rx_item_type_code"`
  15672. RxItemTypeName string `json:"rx_item_type_name"`
  15673. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  15674. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  15675. TcmHerbFoote string `json:"tcmherb_foote"`
  15676. MednTypeCode string `json:"medn_type_code"`
  15677. MednTypeName string `json:"medn_type_name"`
  15678. MainMedcFlag string `json:"main_medc_flag"`
  15679. UrgtFlag string `json:"urgt_flag"`
  15680. BasMednFlag string `json:"bas_medn_flag"`
  15681. ImpDrugFlag string `json:"imp_drug_flag"`
  15682. ProdBarc string `json:"prod_barc"`
  15683. DrugProdname string `json:"drug_prodname"`
  15684. GennameCodg string `json:"genname_codg"`
  15685. DrugGenname string `json:"drug_genname"`
  15686. DrugDosform string `json:"drug_dosform"`
  15687. DrugSpec string `json:"drug_spec"`
  15688. PrdrName string `json:"prdr_name"`
  15689. MedcWayCodg string `json:"medc_way_codg"`
  15690. MedcWayDscr string `json:"medc_way_dscr"`
  15691. MedcBegntime string `json:"medc_begntime"`
  15692. MedcEndtime string `json:"medc_endtime"`
  15693. MedcDays float64 `json:"medc_days"`
  15694. DrugPric float64 `json:"drug_pric"`
  15695. DrugSumamt float64 `json:"drug_sumamt"`
  15696. DrugCnt float64 `json:"drug_cnt"`
  15697. DrugDosunt string `json:"drug_dosunt"`
  15698. SinDoscnt float64 `json:"sin_doscnt"`
  15699. SinDosunt string `json:"sin_dosunt"`
  15700. UsedFrquCodg string `json:"used_frqu_codg"`
  15701. UsedFrquName string `json:"used_frqu_name"`
  15702. DrugTotlcnt float64 `json:"drug_totlcnt"`
  15703. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  15704. DiseCodg string `json:"dise_codg"`
  15705. HospApprFlag string `json:"hosp_appr_flag"`
  15706. } `json:"rx_detl_list"`
  15707. RxOtpinfo struct {
  15708. MedType string `json:"med_type"`
  15709. IptOtpNo string `json:"ipt_otp_no"`
  15710. OtpIptFlag string `json:"otp_ipt_flag"`
  15711. PatnName string `json:"patn_name"`
  15712. PatnAge float64 `json:"patn_age"`
  15713. PatnHgt float64 `json:"patn_hgt"`
  15714. PatnWt float64 `json:"patn_wt"`
  15715. Gend string `json:"gend"`
  15716. GesoVal float64 `json:"geso_val"`
  15717. NwbFlag string `json:"nwb_flag"`
  15718. NwbAge string `json:"nwb_age"`
  15719. SuckPrdFlag string `json:"suck_prd_flag"`
  15720. AlgsHis string `json:"algs_his"`
  15721. Insutype string `json:"insutype"`
  15722. PrscDeptName string `json:"prsc_dept_name"`
  15723. PrscDrName string `json:"prsc_dr_name"`
  15724. PharName string `json:"phar_name"`
  15725. PharChkTime string `json:"phar_chk_time"`
  15726. MdtrtTime string `json:"mdtrt_time"`
  15727. DiseCodg string `json:"dise_codg"`
  15728. DiseName string `json:"dise_name"`
  15729. SpDiseFlag string `json:"sp_dise_flag"`
  15730. MaindiagCode string `json:"maindiag_code"`
  15731. MaindiagName string `json:"maindiag_name"`
  15732. DiseCondDscr string `json:"dise_cond_dscr"`
  15733. FstdiagFlag string `json:"fstdiag_flag"`
  15734. } `json:"rx_otpinfo"`
  15735. RxDiseList []struct {
  15736. DiagType string `json:"diag_type"`
  15737. MaindiagFlag string `json:"maindiag_flag"`
  15738. DiagSrtNo string `json:"diag_srt_no"`
  15739. DiagCode string `json:"diag_code"`
  15740. DiagName string `json:"diag_name"`
  15741. DiagDept string `json:"diag_dept"`
  15742. DiagDrNo string `json:"diag_dr_no"`
  15743. DiagDrName string `json:"diag_dr_name"`
  15744. DiagTime string `json:"diag_time"`
  15745. TcmDiseCode string `json:"tcm_dise_code"`
  15746. TcmDiseName string `json:"tcm_dise_name"`
  15747. TcmSympCode string `json:"tcmsymp_code"`
  15748. TcmSymp string `json:"tcmsymp"`
  15749. } `json:"rx_dise_list"`
  15750. } `json:"output"`
  15751. RefmsgTime string `json:"refmsg_time"`
  15752. RespondTime string `json:"respond_time"`
  15753. Signtype interface{} `json:"signtype"`
  15754. WarnInfo interface{} `json:"warn_info"`
  15755. }
  15756. type ResultCFYLJG006 struct {
  15757. ErrMsg string `json:"err_msg"`
  15758. InfRefmsgid string `json:"inf_refmsgid"`
  15759. Infcode int64 `json:"infcode"`
  15760. Output struct {
  15761. HiRxNo string `json:"hi_rxno"`
  15762. PharCode string `json:"phar_code"`
  15763. PharName string `json:"phar_name"`
  15764. RxChkOpnn string `json:"rx_chk_opnn"`
  15765. RxChkTime string `json:"rx_chk_time"`
  15766. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  15767. RxChkStasName string `json:"rx_chk_stas_name"`
  15768. RxStasCodg string `json:"rx_stas_codg"`
  15769. RxStasName string `json:"rx_stas_name"`
  15770. } `json:"output"`
  15771. RefmsgTime string `json:"refmsg_time"`
  15772. RespondTime string `json:"respond_time"`
  15773. Signtype interface{} `json:"signtype"`
  15774. WarnInfo interface{} `json:"warn_info"`
  15775. }
  15776. type ResultFourteen10265 struct {
  15777. ErrMsg string `json:"err_msg"`
  15778. InfRefmsgid string `json:"inf_refmsgid"`
  15779. Infcode string `json:"infcode"`
  15780. Output struct {
  15781. } `json:"output"`
  15782. RefmsgTime string `json:"refmsg_time"`
  15783. RespondTime string `json:"respond_time"`
  15784. Signtype interface{} `json:"signtype"`
  15785. WarnInfo interface{} `json:"warn_info"`
  15786. }
  15787. type ResultSixteen struct {
  15788. Cainfo string `json:"cainfo"`
  15789. ErrMsg string `json:"err_msg"`
  15790. InfRefmsgid string `json:"inf_refmsgid"`
  15791. Infcode int64 `json:"infcode"`
  15792. Output struct {
  15793. Setlinfo struct {
  15794. MdtrtID string `json:"mdtrt_id"`
  15795. SetlID string `json:"setl_id"`
  15796. ClrOptins string `json:"clr_optins"`
  15797. SetlTime string `json:"setl_time"`
  15798. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15799. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15800. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15801. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15802. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15803. ActPayDedc float64 `json:"act_pay_dedc"`
  15804. HifpPay float64 `json:"hifp_pay"`
  15805. PoolPropSe float64 `json:"pool_prop_selfpay"`
  15806. Lfpay float64 `json:"selfpay"`
  15807. CvlservPay float64 `json:"cvlserv_pay"`
  15808. HifesPay float64 `json:"hifes_pay"`
  15809. HifmiPay float64 `json:"hifmi_pay"`
  15810. HifobPay float64 `json:"hifob_pay"`
  15811. MafPay float64 `json:"maf_pay"`
  15812. OthPay float64 `json:"oth_pay"`
  15813. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15814. PsnPartAmt float64 `json:"psn_part_amt"`
  15815. AcctPay float64 `json:"acct_pay"`
  15816. Balc float64 `json:"balc"`
  15817. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15818. HospPartAmt float64 `json:"hosp_part_amt"`
  15819. MedinsSetlID string `json:"medins_setl_id"`
  15820. PdnCashPay string `json:"pdn_cash_pay"`
  15821. } `json:"setlinfo"`
  15822. } `json:"output"`
  15823. RefmsgTime string `json:"refmsg_time"`
  15824. RespondTime string `json:"respond_time"`
  15825. Signtype interface{} `json:"signtype"`
  15826. WarnMsg interface{} `json:"warn_msg"`
  15827. }
  15828. type ResultSixteen10265 struct {
  15829. Cainfo string `json:"cainfo"`
  15830. ErrMsg string `json:"err_msg"`
  15831. InfRefmsgid string `json:"inf_refmsgid"`
  15832. Infcode string `json:"infcode"`
  15833. Output struct {
  15834. Setlinfo struct {
  15835. MdtrtID string `json:"mdtrt_id"`
  15836. SetlID string `json:"setl_id"`
  15837. ClrOptins string `json:"clr_optins"`
  15838. SetlTime string `json:"setl_time"`
  15839. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15840. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15841. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15842. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15843. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15844. ActPayDedc float64 `json:"act_pay_dedc"`
  15845. HifpPay float64 `json:"hifp_pay"`
  15846. PoolPropSe float64 `json:"pool_prop_selfpay"`
  15847. Lfpay float64 `json:"selfpay"`
  15848. CvlservPay float64 `json:"cvlserv_pay"`
  15849. HifesPay float64 `json:"hifes_pay"`
  15850. HifmiPay float64 `json:"hifmi_pay"`
  15851. HifobPay float64 `json:"hifob_pay"`
  15852. MafPay float64 `json:"maf_pay"`
  15853. OthPay float64 `json:"oth_pay"`
  15854. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15855. PsnPartAmt float64 `json:"psn_part_amt"`
  15856. AcctPay float64 `json:"acct_pay"`
  15857. Balc float64 `json:"balc"`
  15858. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15859. HospPartAmt float64 `json:"hosp_part_amt"`
  15860. MedinsSetlID string `json:"medins_setl_id"`
  15861. PdnCashPay string `json:"pdn_cash_pay"`
  15862. } `json:"setlinfo"`
  15863. } `json:"output"`
  15864. RefmsgTime string `json:"refmsg_time"`
  15865. RespondTime string `json:"respond_time"`
  15866. Signtype interface{} `json:"signtype"`
  15867. WarnMsg interface{} `json:"warn_msg"`
  15868. }
  15869. type ResultSixteen10265Two struct {
  15870. Cainfo string `json:"cainfo"`
  15871. ErrMsg string `json:"err_msg"`
  15872. InfRefmsgid string `json:"inf_refmsgid"`
  15873. Infcode string `json:"infcode"`
  15874. Output struct {
  15875. Setlinfo interface{} `json:"setlinfo"`
  15876. } `json:"output"`
  15877. RefmsgTime string `json:"refmsg_time"`
  15878. RespondTime string `json:"respond_time"`
  15879. Signtype interface{} `json:"signtype"`
  15880. WarnMsg interface{} `json:"warn_msg"`
  15881. }
  15882. type ResultgzSixteen10265Two struct {
  15883. Cainfo string `json:"cainfo"`
  15884. ErrMsg string `json:"err_msg"`
  15885. InfRefmsgid string `json:"inf_refmsgid"`
  15886. Infcode int64 `json:"infcode"`
  15887. Output struct {
  15888. Setlinfo interface{} `json:"setlinfo"`
  15889. } `json:"output"`
  15890. RefmsgTime string `json:"refmsg_time"`
  15891. RespondTime string `json:"respond_time"`
  15892. Signtype interface{} `json:"signtype"`
  15893. WarnMsg interface{} `json:"warn_msg"`
  15894. }
  15895. type ResultSeventeen struct {
  15896. ErrMsg string `json:"err_msg"`
  15897. InfRefmsgid string `json:"inf_refmsgid"`
  15898. Infcode int64 `json:"infcode"`
  15899. Output struct {
  15900. SetlListId string `json:"setl_list_id"`
  15901. } `json:"output"`
  15902. RefmsgTime string `json:"refmsg_time"`
  15903. RespondTime string `json:"respond_time"`
  15904. Signtype string `json:"signtype"`
  15905. WarnInfo string `json:"warn_info"`
  15906. }
  15907. type ResultSeventeenOther struct {
  15908. ErrMsg string `json:"err_msg"`
  15909. InfRefmsgid string `json:"inf_refmsgid"`
  15910. Infcode string `json:"infcode"`
  15911. Output struct {
  15912. SetlListId string `json:"setl_list_id"`
  15913. } `json:"output"`
  15914. RefmsgTime string `json:"refmsg_time"`
  15915. RespondTime string `json:"respond_time"`
  15916. Signtype string `json:"signtype"`
  15917. WarnInfo string `json:"warn_info"`
  15918. }
  15919. type Result90991 struct {
  15920. ErrMsg string `json:"err_msg"`
  15921. InfRefmsgid string `json:"inf_refmsgid"`
  15922. Infcode int64 `json:"infcode"`
  15923. Output struct {
  15924. Result struct {
  15925. PsnNo string `json:"psn_no"`
  15926. CardStat string `json:"card_stat"`
  15927. Certno string `json:"certno"`
  15928. PsnName string `json:"psn_name"`
  15929. CheckStat string `json:"check_stat"`
  15930. SscnoCheckStat string `json:"sscno_check_stat"`
  15931. } `json:"result"`
  15932. } `json:"output"`
  15933. RefmsgTime string `json:"refmsg_time"`
  15934. RespondTime string `json:"respond_time"`
  15935. Signtype interface{} `json:"signtype"`
  15936. WarnInfo interface{} `json:"warn_info"`
  15937. }
  15938. type Result90100 struct {
  15939. ErrMsg string `json:"err_msg"`
  15940. InfRefmsgid string `json:"inf_refmsgid"`
  15941. Infcode int64 `json:"infcode"`
  15942. Output struct {
  15943. PoolareaNo string `json:"poolarea_no"`
  15944. PoolareaNoName string `json:"poolarea_no_name"`
  15945. Insutype string `json:"insutype"`
  15946. InsutypeName string `json:"insutype_name"`
  15947. ClctType string `json:"clct_type"`
  15948. ClctTypeName string `json:"clct_type_name"`
  15949. ClctFlag string `json:"clct_flag"`
  15950. ClctFlagName string `json:"clct_flag_name"`
  15951. AccrymBegn string `json:"accrym_begn"`
  15952. AccrymEnd string `json:"accrym_end"`
  15953. ClctTime string `json:"clct_time"`
  15954. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  15955. } `json:"output"`
  15956. RefmsgTime string `json:"refmsg_time"`
  15957. RespondTime string `json:"respond_time"`
  15958. Signtype interface{} `json:"signtype"`
  15959. WarnInfo interface{} `json:"warn_info"`
  15960. }
  15961. type Custom struct {
  15962. DetItemFeeSumamt string
  15963. Cut string
  15964. FeedetlSn string
  15965. Price string
  15966. MedListCodg string
  15967. Type int64
  15968. AdviceId int64
  15969. ProjectId int64
  15970. ItemId int64
  15971. }
  15972. type Result5301 struct {
  15973. ErrMsg string `json:"err_msg"`
  15974. InfRefmsgid string `json:"inf_refmsgid"`
  15975. Infcode int64 `json:"infcode"`
  15976. Output struct {
  15977. Result []struct {
  15978. OpspDiseCode string `json:"opsp_dise_code"`
  15979. OpspDiseName string `json:"opsp_dise_name"`
  15980. Begndate string `json:"begndate"`
  15981. Enddate string `json:"enddate"`
  15982. } `json:"feedetail"`
  15983. } `json:"output"`
  15984. RefmsgTime string `json:"refmsg_time"`
  15985. RespondTime string `json:"respond_time"`
  15986. Signtype interface{} `json:"signtype"`
  15987. WarnInfo interface{} `json:"warn_info"`
  15988. }
  15989. type Result5301For10265 struct {
  15990. ErrMsg string `json:"err_msg"`
  15991. InfRefmsgid string `json:"inf_refmsgid"`
  15992. Infcode string `json:"infcode"`
  15993. Output struct {
  15994. Result []struct {
  15995. OpspDiseCode string `json:"opsp_dise_code"`
  15996. OpspDiseName string `json:"opsp_dise_name"`
  15997. Begndate string `json:"begndate"`
  15998. Enddate string `json:"enddate"`
  15999. } `json:"feedetail"`
  16000. } `json:"output"`
  16001. RefmsgTime string `json:"refmsg_time"`
  16002. RespondTime string `json:"respond_time"`
  16003. Signtype interface{} `json:"signtype"`
  16004. WarnInfo interface{} `json:"warn_info"`
  16005. }
  16006. //获取个人信息----挂号-----上传就诊信息
  16007. func (c *HisApiController) GetRegisterInfo() {
  16008. id, _ := c.GetInt64("id")
  16009. record_time := c.GetString("record_time")
  16010. settlementValue, _ := c.GetInt64("settlement_value")
  16011. medical_insurance_card := c.GetString("medical_insurance_card")
  16012. name := c.GetString("name")
  16013. id_card_type, _ := c.GetInt64("id_card_type")
  16014. certificates, _ := c.GetInt64("certificates")
  16015. medical_care, _ := c.GetInt64("medical_care")
  16016. birthday := c.GetString("birthday")
  16017. id_card := c.GetString("id_card")
  16018. register_type, _ := c.GetInt64("register")
  16019. doctor, _ := c.GetInt64("doctor")
  16020. department, _ := c.GetInt64("department")
  16021. gender, _ := c.GetInt64("sex")
  16022. registration_fee, _ := c.GetFloat("registration_fee")
  16023. medical_expenses, _ := c.GetFloat("medical_expenses")
  16024. social_type, _ := c.GetInt64("social_type")
  16025. admin_user_id, _ := c.GetInt64("admin_user_id")
  16026. insuplc_admdvs := c.GetString("insuplc_admdvs")
  16027. mdtrt_type := c.GetString("mdtrt_type")
  16028. if id_card_type == 5 {
  16029. id_card_type = 4
  16030. }
  16031. timeLayout := "2006-01-02"
  16032. loc, _ := time.LoadLocation("Local")
  16033. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  16034. birthUnix := birthdays.Unix()
  16035. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16036. if err != nil {
  16037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16038. return
  16039. }
  16040. recordDateTime := theTime.Unix()
  16041. adminInfo := c.GetAdminUserInfo()
  16042. var patient service.Patients
  16043. if id == 0 {
  16044. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  16045. } else {
  16046. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  16047. }
  16048. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16049. if patientPrescription.ID == 0 {
  16050. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16051. }
  16052. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16053. if patient.ID == 0 {
  16054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16055. return
  16056. }
  16057. if len(patient.IdCardNo) == 0 {
  16058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  16059. return
  16060. }
  16061. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16062. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  16063. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  16064. //就诊结算未完成,不能进行二次挂号
  16065. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  16066. //if len(his) >= 1 {
  16067. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  16068. // if len(his) >= 1 && order.ID == 0 {
  16069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  16070. // return
  16071. // }
  16072. //}
  16073. //var register_log string
  16074. if config.IsOpen == 1 {
  16075. var res ResultTwo
  16076. var res10265 ResultTwo10265
  16077. var PsnNo string
  16078. var PsnCertType string
  16079. var Certno string
  16080. var PsnName string
  16081. var Gend string
  16082. var Naty string
  16083. var Brdy string
  16084. var Age float64
  16085. var infoStr string
  16086. var idetinfoStr string
  16087. var infocode int64
  16088. var verify_number string
  16089. fmt.Println(verify_number)
  16090. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" {
  16091. psn_info, _ := service.GetPsnByPatientId(id)
  16092. PsnNo = psn_info.PsnNo
  16093. PsnCertType = psn_info.PsnCertType
  16094. Certno = psn_info.Certno
  16095. PsnName = psn_info.PsnName
  16096. Gend = psn_info.Gend
  16097. Naty = psn_info.Naty
  16098. Brdy = psn_info.Brdy
  16099. Age = psn_info.Age
  16100. infoStr = psn_info.Insuinfo
  16101. idetinfoStr = psn_info.Idetinfo
  16102. infocode = 0
  16103. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16104. psn_info, _ := service.GetPsnByPatientId(id)
  16105. PsnNo = psn_info.PsnNo
  16106. PsnCertType = psn_info.PsnCertType
  16107. Certno = psn_info.Certno
  16108. PsnName = psn_info.PsnName
  16109. Gend = psn_info.Gend
  16110. Naty = psn_info.Naty
  16111. Brdy = psn_info.Brdy
  16112. Age = psn_info.Age
  16113. infoStr = psn_info.Insuinfo
  16114. idetinfoStr = psn_info.Idetinfo
  16115. infocode = 0
  16116. verify_number = psn_info.VerifyNumber
  16117. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16118. if id_card_type == 2 {
  16119. //请求内网数据
  16120. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  16121. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16122. "&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
  16123. resp, requestErr := http.Get(api)
  16124. if requestErr != nil {
  16125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16126. return
  16127. }
  16128. body, ioErr := ioutil.ReadAll(resp.Body)
  16129. if ioErr != nil {
  16130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16132. return
  16133. }
  16134. var respJSON map[string]interface{}
  16135. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16138. return
  16139. }
  16140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16141. result_byte, _ := json.Marshal(respJSON)
  16142. result := string(result_byte)
  16143. var dat map[string]interface{}
  16144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16145. fmt.Println(dat)
  16146. } else {
  16147. fmt.Println(err)
  16148. }
  16149. userJSONBytes, _ := json.Marshal(dat)
  16150. var res ResultTwo
  16151. var resTwo10265 ResultTwo10265
  16152. if miConfig.Code == "H15049901371" {
  16153. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  16154. utils.ErrorLog("解析失败:%v", err)
  16155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16156. return
  16157. }
  16158. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  16159. res.Infcode = Infcode
  16160. res.ErrMsg = resTwo10265.ErrMsg
  16161. res.Output = resTwo10265.Output
  16162. res.InfRefmsgid = resTwo10265.InfRefmsgid
  16163. res.RespondTime = resTwo10265.RespondTime
  16164. res.WarnInfo = resTwo10265.WarnInfo
  16165. } else {
  16166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16167. utils.ErrorLog("解析失败:%v", err)
  16168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16169. return
  16170. }
  16171. }
  16172. //var insutypes []string
  16173. //var insutype string
  16174. //var is390 int = 0
  16175. //var is310 int = 0
  16176. //for _, item := range res.Output.Iinfo {
  16177. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16178. // insutypes = append(insutypes, item.Insutype)
  16179. // }
  16180. //}
  16181. //if len(insutypes) == 1 {
  16182. // insutype = insutypes[0]
  16183. //} else {
  16184. // for _, i := range insutypes {
  16185. // if i == "390" {
  16186. // is390 = 1
  16187. // }
  16188. //
  16189. // if i == "310" {
  16190. // is310 = 1
  16191. // }
  16192. // }
  16193. //}
  16194. //if is390 == 1 {
  16195. // insutype = "390"
  16196. //}
  16197. //if is310 == 1 {
  16198. // insutype = "310"
  16199. //}
  16200. //if len(insutypes) == 0 {
  16201. // insutype = "310"
  16202. //}
  16203. PsnNo = res.Output.Baseinfo.PsnNo
  16204. PsnCertType = res.Output.Baseinfo.PsnCertType
  16205. Certno = res.Output.Baseinfo.Certno
  16206. PsnName = res.Output.Baseinfo.PsnName
  16207. Gend = res.Output.Baseinfo.Gend
  16208. Naty = res.Output.Baseinfo.Naty
  16209. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16210. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16211. infoStr = string(Iinfos)
  16212. idetinfoStr = string(Idetinfos)
  16213. infocode = res.Infcode
  16214. //infocode = 0
  16215. //verify_number = psn_info.VerifyNumber
  16216. } else {
  16217. psn_info, _ := service.GetPsnByPatientId(id)
  16218. PsnNo = psn_info.PsnNo
  16219. PsnCertType = psn_info.PsnCertType
  16220. Certno = psn_info.Certno
  16221. PsnName = psn_info.PsnName
  16222. Gend = psn_info.Gend
  16223. Naty = psn_info.Naty
  16224. Brdy = psn_info.Brdy
  16225. Age = psn_info.Age
  16226. infoStr = psn_info.Insuinfo
  16227. idetinfoStr = psn_info.Idetinfo
  16228. infocode = 0
  16229. verify_number = psn_info.VerifyNumber
  16230. }
  16231. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16232. if id_card_type == 1 {
  16233. psn_info, _ := service.GetPsnByPatientId(id)
  16234. PsnNo = psn_info.PsnNo
  16235. PsnCertType = psn_info.PsnCertType
  16236. Certno = psn_info.Certno
  16237. PsnName = psn_info.PsnName
  16238. Gend = psn_info.Gend
  16239. Naty = psn_info.Naty
  16240. Brdy = psn_info.Brdy
  16241. Age = psn_info.Age
  16242. infoStr = psn_info.Insuinfo
  16243. idetinfoStr = psn_info.Idetinfo
  16244. infocode = 0
  16245. verify_number = psn_info.VerifyNumber
  16246. } else if id_card_type == 2 {
  16247. 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)
  16248. fmt.Println(errMsgLog)
  16249. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16250. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16251. utils.ErrorLog("解析失败:%v", err)
  16252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16253. return
  16254. }
  16255. PsnNo = res.Output.Baseinfo.PsnNo
  16256. PsnCertType = res.Output.Baseinfo.PsnCertType
  16257. Certno = res.Output.Baseinfo.Certno
  16258. PsnName = res.Output.Baseinfo.PsnName
  16259. Gend = res.Output.Baseinfo.Gend
  16260. Naty = res.Output.Baseinfo.Naty
  16261. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16262. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16263. infoStr = string(Iinfos)
  16264. idetinfoStr = string(Idetinfos)
  16265. infocode = res.Infcode
  16266. }
  16267. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16268. if id_card_type == 1 {
  16269. psn_info, _ := service.GetPsnByPatientId(id)
  16270. PsnNo = psn_info.PsnNo
  16271. PsnCertType = psn_info.PsnCertType
  16272. Certno = psn_info.Certno
  16273. PsnName = psn_info.PsnName
  16274. Gend = psn_info.Gend
  16275. Naty = psn_info.Naty
  16276. Brdy = psn_info.Brdy
  16277. Age = psn_info.Age
  16278. infoStr = psn_info.Insuinfo
  16279. idetinfoStr = psn_info.Idetinfo
  16280. infocode = 0
  16281. verify_number = psn_info.VerifyNumber
  16282. } else if id_card_type == 2 {
  16283. 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, "")
  16284. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16286. utils.ErrorLog("解析失败:%v", err)
  16287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16288. return
  16289. }
  16290. PsnNo = res.Output.Baseinfo.PsnNo
  16291. PsnCertType = res.Output.Baseinfo.PsnCertType
  16292. Certno = res.Output.Baseinfo.Certno
  16293. PsnName = res.Output.Baseinfo.PsnName
  16294. Gend = res.Output.Baseinfo.Gend
  16295. Naty = res.Output.Baseinfo.Naty
  16296. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16297. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16298. infoStr = string(Iinfos)
  16299. idetinfoStr = string(Idetinfos)
  16300. infocode = res.Infcode
  16301. } else {
  16302. psn_info, _ := service.GetPsnByPatientId(id)
  16303. PsnNo = psn_info.PsnNo
  16304. PsnCertType = psn_info.PsnCertType
  16305. Certno = psn_info.Certno
  16306. PsnName = psn_info.PsnName
  16307. Gend = psn_info.Gend
  16308. Naty = psn_info.Naty
  16309. Brdy = psn_info.Brdy
  16310. Age = psn_info.Age
  16311. infoStr = psn_info.Insuinfo
  16312. idetinfoStr = psn_info.Idetinfo
  16313. infocode = 0
  16314. verify_number = psn_info.VerifyNumber
  16315. }
  16316. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16317. psn_info, _ := service.GetPsnByPatientId(id)
  16318. PsnNo = psn_info.PsnNo
  16319. PsnCertType = psn_info.PsnCertType
  16320. Certno = psn_info.Certno
  16321. PsnName = psn_info.PsnName
  16322. Gend = psn_info.Gend
  16323. Naty = psn_info.Naty
  16324. Brdy = psn_info.Brdy
  16325. Age = psn_info.Age
  16326. infoStr = psn_info.Insuinfo
  16327. idetinfoStr = psn_info.Idetinfo
  16328. infocode = 0
  16329. verify_number = psn_info.VerifyNumber
  16330. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16331. if id_card_type == 1 {
  16332. psn_info, _ := service.GetPsnByPatientId(id)
  16333. PsnNo = psn_info.PsnNo
  16334. PsnCertType = psn_info.PsnCertType
  16335. Certno = psn_info.Certno
  16336. PsnName = psn_info.PsnName
  16337. Gend = psn_info.Gend
  16338. Naty = psn_info.Naty
  16339. Brdy = psn_info.Brdy
  16340. Age = psn_info.Age
  16341. infoStr = psn_info.Insuinfo
  16342. idetinfoStr = psn_info.Idetinfo
  16343. infocode = 0
  16344. verify_number = psn_info.VerifyNumber
  16345. } else if id_card_type == 2 {
  16346. 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)
  16347. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16348. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16349. utils.ErrorLog("解析失败:%v", err)
  16350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16351. return
  16352. }
  16353. PsnNo = res.Output.Baseinfo.PsnNo
  16354. PsnCertType = res.Output.Baseinfo.PsnCertType
  16355. Certno = res.Output.Baseinfo.Certno
  16356. PsnName = res.Output.Baseinfo.PsnName
  16357. Gend = res.Output.Baseinfo.Gend
  16358. Naty = res.Output.Baseinfo.Naty
  16359. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16360. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16361. infoStr = string(Iinfos)
  16362. idetinfoStr = string(Idetinfos)
  16363. infocode = res.Infcode
  16364. } else if id_card_type == 4 {
  16365. psn_info, _ := service.GetPsnByPatientId(id)
  16366. PsnNo = psn_info.PsnNo
  16367. PsnCertType = psn_info.PsnCertType
  16368. Certno = psn_info.Certno
  16369. PsnName = psn_info.PsnName
  16370. Gend = psn_info.Gend
  16371. Naty = psn_info.Naty
  16372. Brdy = psn_info.Brdy
  16373. Age = psn_info.Age
  16374. infoStr = psn_info.Insuinfo
  16375. idetinfoStr = psn_info.Idetinfo
  16376. infocode = 0
  16377. verify_number = psn_info.VerifyNumber
  16378. }
  16379. } else if miConfig.MdtrtareaAdmvs == "131023" {
  16380. var result string
  16381. var requestLog string
  16382. 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), "")
  16383. if id_card_type == 4 {
  16384. psn_info, _ := service.GetPsnByPatientId(id)
  16385. PsnNo = psn_info.PsnNo
  16386. PsnCertType = psn_info.PsnCertType
  16387. Certno = psn_info.Certno
  16388. PsnName = psn_info.PsnName
  16389. Gend = psn_info.Gend
  16390. Naty = psn_info.Naty
  16391. Brdy = psn_info.Brdy
  16392. Age = psn_info.Age
  16393. infoStr = psn_info.Insuinfo
  16394. idetinfoStr = psn_info.Idetinfo
  16395. infocode = 0
  16396. verify_number = psn_info.VerifyNumber
  16397. } else {
  16398. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16399. if miConfig.Code == "H15049901371" {
  16400. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16401. utils.ErrorLog("解析失败:%v", err)
  16402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16403. return
  16404. }
  16405. res.ErrMsg = res10265.ErrMsg
  16406. res.Output = res10265.Output
  16407. res.InfRefmsgid = res10265.InfRefmsgid
  16408. } else {
  16409. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16410. utils.ErrorLog("解析失败:%v", err)
  16411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16412. return
  16413. }
  16414. }
  16415. PsnNo = res.Output.Baseinfo.PsnNo
  16416. PsnCertType = res.Output.Baseinfo.PsnCertType
  16417. Certno = res.Output.Baseinfo.Certno
  16418. PsnName = res.Output.Baseinfo.PsnName
  16419. Gend = res.Output.Baseinfo.Gend
  16420. Naty = res.Output.Baseinfo.Naty
  16421. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16422. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16423. infoStr = string(Iinfos)
  16424. idetinfoStr = string(Idetinfos)
  16425. if miConfig.Code == "H15049901371" {
  16426. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16427. } else {
  16428. infocode = res.Infcode
  16429. }
  16430. }
  16431. } else if miConfig.MdtrtareaAdmvs == "441799" {
  16432. psn_info, _ := service.GetPsnByPatientId(id)
  16433. PsnNo = psn_info.PsnNo
  16434. PsnCertType = psn_info.PsnCertType
  16435. Certno = psn_info.Certno
  16436. PsnName = psn_info.PsnName
  16437. Gend = psn_info.Gend
  16438. Naty = psn_info.Naty
  16439. Brdy = psn_info.Brdy
  16440. Age = psn_info.Age
  16441. infoStr = psn_info.Insuinfo
  16442. idetinfoStr = psn_info.Idetinfo
  16443. infocode = 0
  16444. verify_number = psn_info.VerifyNumber
  16445. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16446. psn_info, _ := service.GetPsnByPatientId(id)
  16447. PsnNo = psn_info.PsnNo
  16448. PsnCertType = psn_info.PsnCertType
  16449. Certno = psn_info.Certno
  16450. PsnName = psn_info.PsnName
  16451. Gend = psn_info.Gend
  16452. Naty = psn_info.Naty
  16453. Brdy = psn_info.Brdy
  16454. Age = psn_info.Age
  16455. infoStr = psn_info.Insuinfo
  16456. idetinfoStr = psn_info.Idetinfo
  16457. infocode = 0
  16458. verify_number = psn_info.VerifyNumber
  16459. } else {
  16460. var result string
  16461. var requestLog string
  16462. //if miConfig.UserOrgId == 10138 {
  16463. if id_card_type != 4 || id_card_type != 1 {
  16464. var insa string
  16465. if len(patient.InsuplcAdmdvs) > 0 {
  16466. insa = patient.InsuplcAdmdvs
  16467. } else {
  16468. insa = miConfig.InsuplcAdmdvs
  16469. }
  16470. //psn_info, _ := service.GetPsnByPatientId(id)
  16471. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  16472. 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)
  16473. }
  16474. //}
  16475. //else {
  16476. // var insa string
  16477. // if len(patient.InsuplcAdmdvs) > 0 {
  16478. // insa = patient.InsuplcAdmdvs
  16479. // } else {
  16480. // insa = miConfig.InsuplcAdmdvs
  16481. // }
  16482. // 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)
  16483. //}
  16484. if id_card_type == 4 || id_card_type == 1 {
  16485. psn_info, _ := service.GetPsnByPatientId(id)
  16486. PsnNo = psn_info.PsnNo
  16487. PsnCertType = psn_info.PsnCertType
  16488. Certno = psn_info.Certno
  16489. PsnName = psn_info.PsnName
  16490. Gend = psn_info.Gend
  16491. Naty = psn_info.Naty
  16492. Brdy = psn_info.Brdy
  16493. Age = psn_info.Age
  16494. infoStr = psn_info.Insuinfo
  16495. idetinfoStr = psn_info.Idetinfo
  16496. infocode = 0
  16497. verify_number = psn_info.VerifyNumber
  16498. } else {
  16499. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16500. if miConfig.Code == "H15049901371" {
  16501. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16502. utils.ErrorLog("解析失败:%v", err)
  16503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16504. return
  16505. }
  16506. res.ErrMsg = res10265.ErrMsg
  16507. res.Output = res10265.Output
  16508. res.InfRefmsgid = res10265.InfRefmsgid
  16509. } else {
  16510. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16511. utils.ErrorLog("解析失败:%v", err)
  16512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16513. return
  16514. }
  16515. }
  16516. PsnNo = res.Output.Baseinfo.PsnNo
  16517. PsnCertType = res.Output.Baseinfo.PsnCertType
  16518. Certno = res.Output.Baseinfo.Certno
  16519. PsnName = res.Output.Baseinfo.PsnName
  16520. Gend = res.Output.Baseinfo.Gend
  16521. Naty = res.Output.Baseinfo.Naty
  16522. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16523. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16524. infoStr = string(Iinfos)
  16525. idetinfoStr = string(Idetinfos)
  16526. if miConfig.Code == "H15049901371" {
  16527. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16528. } else {
  16529. infocode = res.Infcode
  16530. }
  16531. }
  16532. }
  16533. if infocode == 0 {
  16534. his := models.VMHisPatient{
  16535. Name: name,
  16536. Gender: gender,
  16537. Birthday: birthUnix,
  16538. MedicalTreatmentType: medical_care,
  16539. IdType: certificates,
  16540. IdCardNo: id_card,
  16541. BalanceAccountsType: settlementValue,
  16542. SocialType: social_type,
  16543. MedicalInsuranceNumber: medical_insurance_card,
  16544. RegisterType: register_type,
  16545. RegisterCost: registration_fee,
  16546. TreatmentCost: medical_expenses,
  16547. Status: 1,
  16548. Ctime: time.Now().Unix(),
  16549. Mtime: time.Now().Unix(),
  16550. PsnNo: PsnNo,
  16551. PsnCertType: PsnCertType,
  16552. Certno: Certno,
  16553. PsnName: PsnName,
  16554. Gend: Gend,
  16555. Naty: Naty,
  16556. Brdy: Brdy,
  16557. Age: Age,
  16558. Iinfo: infoStr,
  16559. Idetinfo: idetinfoStr,
  16560. PatientId: patient.ID,
  16561. RecordDate: theTime.Unix(),
  16562. UserOrgId: adminInfo.CurrentOrgId,
  16563. AdminUserId: admin_user_id,
  16564. IsReturn: 1,
  16565. IdCardType: id_card_type,
  16566. Doctor: doctor,
  16567. Departments: department,
  16568. MdtrtGrpType: mdtrt_type,
  16569. }
  16570. timestamp := time.Now().Unix()
  16571. tempTime := time.Unix(timestamp, 0)
  16572. timeFormat := tempTime.Format("20060102150405")
  16573. chrgBchno := rand.Intn(100000) + 10000
  16574. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  16575. his.Number = ipt_otp_no
  16576. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  16577. department, _ := service.GetDepartMentDetail(department)
  16578. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  16579. IdCardNo := ""
  16580. if id_card_type == 1 {
  16581. // IdCardNo = medical_insurance_card
  16582. IdCardNo = patient.IdCardNo
  16583. } else {
  16584. IdCardNo = patient.IdCardNo
  16585. }
  16586. var rf []*ResultFive
  16587. json.Unmarshal([]byte(his.Iinfo), &rf)
  16588. var insutypes []*ResultFive
  16589. var insutype string
  16590. var insuplc_admdvs_temp string
  16591. var is390 int = 0
  16592. var is310 int = 0
  16593. for _, item := range rf {
  16594. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16595. insutypes = append(insutypes, item)
  16596. }
  16597. }
  16598. if len(insutypes) == 1 {
  16599. insutype = insutypes[0].Insutype
  16600. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16601. if insutype == "390" {
  16602. is390 = 1
  16603. }
  16604. if insutype == "310" {
  16605. is310 = 1
  16606. }
  16607. } else {
  16608. for _, i := range insutypes {
  16609. if i.Insutype == "390" {
  16610. is390 = 1
  16611. }
  16612. if i.Insutype == "310" {
  16613. is310 = 1
  16614. }
  16615. }
  16616. }
  16617. if is390 == 1 {
  16618. insutype = "390"
  16619. }
  16620. if is310 == 1 {
  16621. insutype = "310"
  16622. }
  16623. fmt.Println(social_type)
  16624. if social_type > 0 {
  16625. insutype = strconv.FormatInt(social_type, 10)
  16626. }
  16627. var infocode int64
  16628. var resThree ResultThree
  16629. var resThree10265 ResultThree10265
  16630. if len(insuplc_admdvs) == 0 {
  16631. psn_info, _ := service.GetPsnByPatientId(id)
  16632. //if len(psn_info.InsuplcAdmdvs) > 0 {
  16633. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16634. //}
  16635. } else {
  16636. insuplc_admdvs_temp = insuplc_admdvs
  16637. }
  16638. if miConfig.MdtrtareaAdmvs == "421300" {
  16639. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16640. psn_info, _ := service.GetPsnByPatientId(id)
  16641. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16642. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16643. "&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
  16644. resp, requestErr := http.Get(api)
  16645. if requestErr != nil {
  16646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16647. return
  16648. }
  16649. body, ioErr := ioutil.ReadAll(resp.Body)
  16650. if ioErr != nil {
  16651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16653. return
  16654. }
  16655. var respJSON map[string]interface{}
  16656. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16659. return
  16660. }
  16661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16662. result, _ := json.Marshal(respJSON)
  16663. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16664. utils.ErrorLog("解析失败:%v", err)
  16665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16666. return
  16667. }
  16668. infocode = resThree.Infcode
  16669. } else if miConfig.MdtrtareaAdmvs == "420200" {
  16670. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16671. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  16672. // insuplc_admdvs_temp =
  16673. //}
  16674. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  16675. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  16676. //}
  16677. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16678. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16679. "&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
  16680. resp, requestErr := http.Get(api)
  16681. if requestErr != nil {
  16682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16683. return
  16684. }
  16685. body, ioErr := ioutil.ReadAll(resp.Body)
  16686. if ioErr != nil {
  16687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16689. return
  16690. }
  16691. var respJSON map[string]interface{}
  16692. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16695. return
  16696. }
  16697. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16698. result, _ := json.Marshal(respJSON)
  16699. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16700. utils.ErrorLog("解析失败:%v", err)
  16701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16702. return
  16703. }
  16704. infocode = resThree.Infcode
  16705. } else if miConfig.MdtrtareaAdmvs == "421182" {
  16706. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16707. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  16708. // insuplc_admdvs_temp =
  16709. //}
  16710. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  16711. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  16712. //}
  16713. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16714. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16715. "&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
  16716. resp, requestErr := http.Get(api)
  16717. if requestErr != nil {
  16718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16719. return
  16720. }
  16721. body, ioErr := ioutil.ReadAll(resp.Body)
  16722. if ioErr != nil {
  16723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16725. return
  16726. }
  16727. var respJSON map[string]interface{}
  16728. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16731. return
  16732. }
  16733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16734. result, _ := json.Marshal(respJSON)
  16735. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16736. utils.ErrorLog("解析失败:%v", err)
  16737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16738. return
  16739. }
  16740. infocode = resThree.Infcode
  16741. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16742. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16743. psn_info, _ := service.GetPsnByPatientId(id)
  16744. var verify_number string
  16745. if id_card_type == 4 {
  16746. verify_number = psn_info.VerifyNumber
  16747. } else if id_card_type == 1 {
  16748. bas := strings.Split(psn_info.CardInfo, "|")
  16749. cardNumber := bas[2]
  16750. verify_number = cardNumber
  16751. }
  16752. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16753. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16754. "&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
  16755. resp, requestErr := http.Get(api)
  16756. if requestErr != nil {
  16757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16758. return
  16759. }
  16760. body, ioErr := ioutil.ReadAll(resp.Body)
  16761. if ioErr != nil {
  16762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16764. return
  16765. }
  16766. var respJSON map[string]interface{}
  16767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16770. return
  16771. }
  16772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16773. result, _ := json.Marshal(respJSON)
  16774. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16775. // utils.ErrorLog("解析失败:%v", err)
  16776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16777. // return
  16778. //}
  16779. //infocode = resThree.Infcode
  16780. //result, _ := json.Marshal(respJSON)
  16781. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16782. utils.ErrorLog("解析失败:%v", err)
  16783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16784. return
  16785. }
  16786. resThree.ErrMsg = resThree10265.ErrMsg
  16787. resThree.Output = resThree10265.Output
  16788. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16789. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16790. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16791. psn_info, _ := service.GetPsnByPatientId(id)
  16792. his.PsnNo = psn_info.PsnNo
  16793. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  16794. var cert_no string
  16795. if id_card_type == 3 {
  16796. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  16797. cert_no = IdCardNo
  16798. } else if id_card_type == 4 {
  16799. cert_no = IdCardNo
  16800. psn_info.VerifyNumber = psn_info.VerifyNumber
  16801. } else {
  16802. bas := strings.Split(psn_info.CardInfo, "|")
  16803. cert_no = bas[2]
  16804. }
  16805. var hisPrescription []*models.HisPrescription
  16806. for _, item := range rf {
  16807. if item.Insutype == insutype {
  16808. //insuplc_admdvs = item.InsuplcAdmdvs
  16809. his.InsuplcAdmdvs = insuplc_admdvs
  16810. }
  16811. }
  16812. his.Insutype = insutype
  16813. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  16814. fmt.Println(res3101)
  16815. fmt.Println(res3101.Infcode)
  16816. if res3101.Infcode == "0" {
  16817. fmt.Println("33333333")
  16818. if len(res3101.Output.Result) > 0 {
  16819. fmt.Println("222222")
  16820. for _, item := range res3101.Output.Result {
  16821. if len(res3101.ErrMsg) == 0 {
  16822. res3101.ErrMsg = item.VolaCont
  16823. } else {
  16824. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  16825. }
  16826. }
  16827. c.ServeSuccessJSON(map[string]interface{}{
  16828. "failed_code": -10,
  16829. "msg": res3101.ErrMsg,
  16830. })
  16831. return
  16832. } else {
  16833. fmt.Println("11111")
  16834. var api string
  16835. if miConfig.MdtrtareaAdmvs == "320921" {
  16836. ipt_otp_no = timeFormat
  16837. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  16838. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16839. "&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
  16840. } else {
  16841. ipt_otp_no = timeFormat
  16842. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  16843. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16844. "&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
  16845. }
  16846. resp, requestErr := http.Get(api)
  16847. if requestErr != nil {
  16848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16849. return
  16850. }
  16851. body, ioErr := ioutil.ReadAll(resp.Body)
  16852. if ioErr != nil {
  16853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16855. return
  16856. }
  16857. var respJSON map[string]interface{}
  16858. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16861. return
  16862. }
  16863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16864. result, _ := json.Marshal(respJSON)
  16865. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16866. utils.ErrorLog("解析失败:%v", err)
  16867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16868. return
  16869. }
  16870. resThree.ErrMsg = resThree10265.ErrMsg
  16871. resThree.Output = resThree10265.Output
  16872. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16873. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16874. }
  16875. } else if res3101.Infcode != "0" {
  16876. c.ServeSuccessJSON(map[string]interface{}{
  16877. "failed_code": -10,
  16878. "msg": res3101.ErrMsg,
  16879. })
  16880. return
  16881. }
  16882. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16883. psn_info, _ := service.GetPsnByPatientId(id)
  16884. var cert_no string
  16885. if id_card_type == 1 {
  16886. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  16887. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16888. } else if id_card_type == 4 {
  16889. cert_no = psn_info.VerifyNumber
  16890. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16891. } else {
  16892. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16893. cert_no = psn_info.VerifyNumber
  16894. }
  16895. 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)
  16896. saveLog(result, requestLog, "2201", "挂号")
  16897. if miConfig.Code == "H15049901371" {
  16898. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16899. utils.ErrorLog("解析失败:%v", err)
  16900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16901. return
  16902. }
  16903. resThree.ErrMsg = resThree10265.ErrMsg
  16904. resThree.Output = resThree10265.Output
  16905. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16906. } else {
  16907. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16908. utils.ErrorLog("解析失败:%v", err)
  16909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16910. return
  16911. }
  16912. }
  16913. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16914. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  16915. psn_info, _ := service.GetPsnByPatientId(id)
  16916. var result string
  16917. var requestLog string
  16918. if id_card_type == 1 {
  16919. bas := strings.Split(psn_info.CardInfo, "|")
  16920. basNumber := bas[2]
  16921. card_sn := bas[3]
  16922. 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)
  16923. saveLog(result, requestLog, "2201A", "挂号")
  16924. } else if id_card_type == 2 {
  16925. 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, "", "", "", "", "", "")
  16926. saveLog(result, requestLog, "2201A", "挂号")
  16927. } else {
  16928. 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)
  16929. saveLog(result, requestLog, "2201A", "挂号")
  16930. }
  16931. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16932. utils.ErrorLog("解析失败:%v", err)
  16933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16934. return
  16935. }
  16936. infocode = resThree.Infcode
  16937. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16938. psn_info, _ := service.GetPsnByPatientId(id)
  16939. his.PsnNo = psn_info.PsnNo
  16940. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  16941. var cert_no string
  16942. if id_card_type == 1 {
  16943. bas := strings.Split(psn_info.CardInfo, "|")
  16944. cert_no = bas[2]
  16945. } else if id_card_type == 4 {
  16946. cert_no = IdCardNo
  16947. psn_info.VerifyNumber = psn_info.VerifyNumber
  16948. } else {
  16949. cert_no = IdCardNo
  16950. psn_info.VerifyNumber = cert_no
  16951. }
  16952. for _, item := range rf {
  16953. if item.Insutype == insutype {
  16954. his.InsuplcAdmdvs = insuplc_admdvs
  16955. }
  16956. }
  16957. his.Insutype = insutype
  16958. var api string
  16959. ipt_otp_no = timeFormat
  16960. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  16961. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16962. "&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
  16963. resp, requestErr := http.Get(api)
  16964. if requestErr != nil {
  16965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16966. return
  16967. }
  16968. body, ioErr := ioutil.ReadAll(resp.Body)
  16969. if ioErr != nil {
  16970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16972. return
  16973. }
  16974. var respJSON map[string]interface{}
  16975. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16978. return
  16979. }
  16980. status := respJSON["data"].(map[string]interface{})["status"].(string)
  16981. if status == "0" {
  16982. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  16983. c.ServeSuccessJSON(map[string]interface{}{
  16984. "failed_code": -10,
  16985. "msg": err_msg,
  16986. })
  16987. return
  16988. }
  16989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16990. result, _ := json.Marshal(respJSON)
  16991. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16992. utils.ErrorLog("解析失败:%v", err)
  16993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16994. return
  16995. }
  16996. infocode = resThree.Infcode
  16997. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16998. psn_info, _ := service.GetPsnByPatientId(id)
  16999. var result string
  17000. var requestLog string
  17001. if id_card_type == 1 {
  17002. bas := strings.Split(psn_info.CardInfo, "|")
  17003. basNumber := bas[2]
  17004. card_sn := bas[3]
  17005. 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)
  17006. saveLog(result, requestLog, "2201A", "挂号")
  17007. } else if id_card_type == 2 {
  17008. 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, "", "")
  17009. saveLog(result, requestLog, "2201A", "挂号")
  17010. } else {
  17011. 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, "", "")
  17012. saveLog(result, requestLog, "2201A", "挂号")
  17013. }
  17014. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17015. utils.ErrorLog("解析失败:%v", err)
  17016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17017. return
  17018. }
  17019. infocode = resThree.Infcode
  17020. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17021. psn_info, _ := service.GetPsnByPatientId(id)
  17022. 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)
  17023. saveLog(result, requestLog, "2201A", "挂号")
  17024. if miConfig.Code == "H15049901371" {
  17025. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17026. utils.ErrorLog("解析失败:%v", err)
  17027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17028. return
  17029. }
  17030. resThree.ErrMsg = resThree10265.ErrMsg
  17031. resThree.Output = resThree10265.Output
  17032. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17033. } else {
  17034. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17035. utils.ErrorLog("解析失败:%v", err)
  17036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17037. return
  17038. }
  17039. }
  17040. if miConfig.Code == "H15049901371" {
  17041. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17042. } else {
  17043. infocode = resThree.Infcode
  17044. }
  17045. } else {
  17046. psn_info, _ := service.GetPsnByPatientId(id)
  17047. if id_card_type == 4 || id_card_type == 1 {
  17048. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17049. }
  17050. var rf []*ResultFive
  17051. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  17052. var insutypes []*ResultFive
  17053. var insutype string
  17054. var is390 int = 0
  17055. var is310 int = 0
  17056. for _, item := range rf {
  17057. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17058. insutypes = append(insutypes, item)
  17059. }
  17060. }
  17061. if len(insutypes) == 1 {
  17062. insutype = insutypes[0].Insutype
  17063. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17064. } else {
  17065. for _, i := range insutypes {
  17066. if i.Insutype == "390" {
  17067. is390 = 1
  17068. }
  17069. if i.Insutype == "310" {
  17070. is310 = 1
  17071. }
  17072. }
  17073. }
  17074. if is390 == 1 {
  17075. insutype = "390"
  17076. }
  17077. if is310 == 1 {
  17078. insutype = "310"
  17079. }
  17080. fmt.Println(len(insutypes))
  17081. if len(insutypes) == 0 {
  17082. for index, item := range rf {
  17083. if index == 0 {
  17084. insutype = item.Insutype
  17085. insuplc_admdvs = item.InsuplcAdmdvs
  17086. }
  17087. }
  17088. fmt.Println(insutype)
  17089. fmt.Println(insuplc_admdvs)
  17090. }
  17091. if social_type > 0 {
  17092. insutype = strconv.FormatInt(social_type, 10)
  17093. }
  17094. fmt.Println("--------")
  17095. fmt.Println(psn_info)
  17096. fmt.Println(psn_info.PsnNo)
  17097. if miConfig.MdtrtareaAdmvs == "441202" {
  17098. var hisPrescription []*models.HisPrescription
  17099. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17100. if res3101.Infcode == 0 {
  17101. fmt.Println("33333333")
  17102. if len(res3101.Output.Result) > 0 {
  17103. fmt.Println("222222")
  17104. for _, item := range res3101.Output.Result {
  17105. if len(res3101.ErrMsg) == 0 {
  17106. res3101.ErrMsg = item.VolaCont
  17107. } else {
  17108. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17109. }
  17110. }
  17111. c.ServeSuccessJSON(map[string]interface{}{
  17112. "failed_code": -10,
  17113. "msg": res3101.ErrMsg,
  17114. })
  17115. return
  17116. } else {
  17117. hour := time.Now().Format("15")
  17118. min := time.Now().Format("04")
  17119. sec := time.Now().Format("05")
  17120. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17121. fmt.Println(record_time_two)
  17122. 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)
  17123. saveLog(result, requestLog, "2201A", "挂号")
  17124. if miConfig.Code == "H15049901371" {
  17125. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17126. utils.ErrorLog("解析失败:%v", err)
  17127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17128. return
  17129. }
  17130. resThree.ErrMsg = resThree10265.ErrMsg
  17131. resThree.Output = resThree10265.Output
  17132. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17133. } else {
  17134. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17135. utils.ErrorLog("解析失败:%v", err)
  17136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17137. return
  17138. }
  17139. }
  17140. if miConfig.Code == "H15049901371" {
  17141. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17142. } else {
  17143. infocode = resThree.Infcode
  17144. }
  17145. }
  17146. } else if res3101.Infcode != 0 {
  17147. c.ServeSuccessJSON(map[string]interface{}{
  17148. "failed_code": -10,
  17149. "msg": res3101.ErrMsg,
  17150. })
  17151. return
  17152. }
  17153. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17154. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17155. psn_info, _ := service.GetPsnByPatientId(id)
  17156. var verify_number string
  17157. if id_card_type == 4 {
  17158. verify_number = psn_info.VerifyNumber
  17159. } else if id_card_type == 1 {
  17160. bas := strings.Split(psn_info.CardInfo, "|")
  17161. cardNumber := bas[2]
  17162. verify_number = cardNumber
  17163. } else {
  17164. verify_number = psn_info.Certno
  17165. }
  17166. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17167. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17168. "&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
  17169. resp, requestErr := http.Get(api)
  17170. if requestErr != nil {
  17171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17172. return
  17173. }
  17174. body, ioErr := ioutil.ReadAll(resp.Body)
  17175. if ioErr != nil {
  17176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17178. return
  17179. }
  17180. var respJSON map[string]interface{}
  17181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17184. return
  17185. }
  17186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17187. result, _ := json.Marshal(respJSON)
  17188. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17189. utils.ErrorLog("解析失败:%v", err)
  17190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17191. return
  17192. }
  17193. infocode = resThree.Infcode
  17194. } else {
  17195. hour := time.Now().Format("15")
  17196. min := time.Now().Format("04")
  17197. sec := time.Now().Format("05")
  17198. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17199. if id_card_type == 1 {
  17200. for _, item := range rf {
  17201. if item.Insutype == strconv.FormatInt(social_type, 10) {
  17202. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  17203. insuplc_admdvs_temp = item.InsuplcAdmdvs
  17204. } else if strconv.FormatInt(social_type, 10) == "390" {
  17205. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17206. } else {
  17207. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17208. }
  17209. }
  17210. }
  17211. }
  17212. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  17213. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17214. }
  17215. if id_card_type == 1 {
  17216. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  17217. bas := strings.Split(psn_info.CardInfo, "|")
  17218. basNumber := bas[1]
  17219. IdCardNo = basNumber
  17220. }
  17221. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  17222. IdCardNo = psn_info.VerifyNumber
  17223. }
  17224. 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)
  17225. saveLog(result, requestLog, "2201A", "挂号")
  17226. if miConfig.Code == "H15049901371" {
  17227. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17228. utils.ErrorLog("解析失败:%v", err)
  17229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17230. return
  17231. }
  17232. resThree.ErrMsg = resThree10265.ErrMsg
  17233. resThree.Output = resThree10265.Output
  17234. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17235. } else {
  17236. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17237. utils.ErrorLog("解析失败:%v", err)
  17238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17239. return
  17240. }
  17241. }
  17242. if miConfig.Code == "H15049901371" {
  17243. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17244. } else {
  17245. infocode = resThree.Infcode
  17246. }
  17247. }
  17248. }
  17249. if infocode != 0 {
  17250. adminUser := c.GetAdminUserInfo()
  17251. errlog := &models.HisOrderError{
  17252. UserOrgId: adminUser.CurrentOrgId,
  17253. Ctime: time.Now().Unix(),
  17254. Mtime: time.Now().Unix(),
  17255. ErrMsg: resThree.ErrMsg,
  17256. Status: 1,
  17257. PatientId: id,
  17258. RecordTime: recordDateTime,
  17259. Stage: 2,
  17260. }
  17261. service.CreateErrMsgLog(errlog)
  17262. c.ServeSuccessJSON(map[string]interface{}{
  17263. "failed_code": -10,
  17264. "msg": resThree.ErrMsg,
  17265. })
  17266. return
  17267. }
  17268. his.Number = resThree.Output.Data.MdtrtID
  17269. his.PsnNo = resThree.Output.Data.PsnNo
  17270. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  17271. his.IdCardNo = patient.IdCardNo
  17272. his.PhoneNumber = patient.Phone
  17273. his.UserOrgId = adminInfo.CurrentOrgId
  17274. his.Insutype = insutype
  17275. his.Ctime = time.Now().Unix()
  17276. his.Mtime = time.Now().Unix()
  17277. his.InsuplcAdmdvs = insuplc_admdvs_temp
  17278. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  17279. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17280. }
  17281. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  17282. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17283. }
  17284. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  17285. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17286. }
  17287. his.Status = 1
  17288. his.MdtrtGrpType = mdtrt_type
  17289. service.UpdateHisPatientStatus(&his)
  17290. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  17291. c.ServeSuccessJSON(map[string]interface{}{
  17292. "his_info": his,
  17293. })
  17294. } else {
  17295. adminUser := c.GetAdminUserInfo()
  17296. errlog := &models.HisOrderError{
  17297. UserOrgId: adminUser.CurrentOrgId,
  17298. Ctime: time.Now().Unix(),
  17299. Mtime: time.Now().Unix(),
  17300. ErrMsg: res.ErrMsg,
  17301. Status: 1,
  17302. PatientId: id,
  17303. RecordTime: recordDateTime,
  17304. Stage: 1,
  17305. }
  17306. service.CreateErrMsgLog(errlog)
  17307. c.ServeSuccessJSON(map[string]interface{}{
  17308. "failed_code": -10,
  17309. "msg": res.ErrMsg,
  17310. })
  17311. return
  17312. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  17313. }
  17314. }
  17315. }
  17316. func (c *HisApiController) GetUploadInfo() {
  17317. id, _ := c.GetInt64("id")
  17318. record_time := c.GetString("record_time")
  17319. his_patient_id, _ := c.GetInt64("his_patient_id")
  17320. order_id, _ := c.GetInt64("order_id")
  17321. pay_way, _ := c.GetInt64("pay_way")
  17322. pay_ways := c.GetString("pay_ways")
  17323. oth_desc := c.GetString("oth_desc")
  17324. pay_price, _ := c.GetFloat("pay_price")
  17325. pay_card_no := c.GetString("pay_card_no")
  17326. discount_price, _ := c.GetFloat("discount_price")
  17327. preferential_price, _ := c.GetFloat("preferential_price")
  17328. reality_price, _ := c.GetFloat("reality_price")
  17329. found_price, _ := c.GetFloat("found_price")
  17330. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  17331. private_price, _ := c.GetFloat("private_price")
  17332. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  17333. admin_user_id, _ := c.GetInt64("admin_user_id")
  17334. fapiao_code := c.GetString("fapiao_code")
  17335. fapiao_number := c.GetString("fapiao_number")
  17336. diagnosis_id := c.GetString("diagnosis")
  17337. sick_type, _ := c.GetInt64("sick_type")
  17338. reg_type, _ := c.GetInt64("p_type")
  17339. begin_time := c.GetString("begin_time")
  17340. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  17341. cash_pay := c.GetString("cash_pay")
  17342. band_card_pay := c.GetString("band_card_pay")
  17343. wechat_pay := c.GetString("wechat_pay")
  17344. ali_pay := c.GetString("ali_pay")
  17345. jifen_pay := c.GetString("jifen_pay")
  17346. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  17347. fmt.Println(acct_used_flag)
  17348. id_str := c.GetString("ids")
  17349. ids_arr := strings.Split(id_str, ",")
  17350. timeLayout := "2006-01-02"
  17351. loc, _ := time.LoadLocation("Local")
  17352. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17353. if err != nil {
  17354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17355. return
  17356. }
  17357. recordDateTime := theTime.Unix()
  17358. adminUser := c.GetAdminUserInfo()
  17359. var tempOrder models.HisOrder
  17360. tempOrder, _ = service.GetHisOrderByID(order_id)
  17361. var prescriptions []*models.HisPrescription
  17362. var start_time int64
  17363. var end_time int64
  17364. //押金模块
  17365. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  17366. tmp_decimal := c.GetString("tmp_decimal")
  17367. var decimal float64 //本次使用的押金
  17368. var errmsg error
  17369. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  17370. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  17371. return
  17372. }
  17373. if len(tmp_decimal) > 0 {
  17374. if tmp_decimal[0] == 45 {
  17375. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  17376. return
  17377. }
  17378. }
  17379. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  17380. fmt.Println(errs)
  17381. decimal = tt
  17382. //if adminUser.CurrentOrgId == 10106{
  17383. // if len(fapiao_code) == 0{
  17384. // fapiao_code = "144072080589"
  17385. // }
  17386. // if len(fapiao_number) == 0{
  17387. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  17388. // if order.ID == 0{
  17389. // fapiao_number = "00001520"
  17390. // }else{
  17391. // //fapiao_code = "00001520"
  17392. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  17393. // var zero string
  17394. // if fpNumber >= 1000{
  17395. // zero = "0000" + strconv.Itoa(fpNumber)
  17396. // }else if fpNumber >= 10000{
  17397. // zero = "000" + strconv.Itoa(fpNumber)
  17398. // } else if fpNumber >= 100000{
  17399. // zero = "00" + strconv.Itoa(fpNumber)
  17400. // } else if fpNumber >= 1000000{
  17401. // zero = "0" + strconv.Itoa(fpNumber)
  17402. // }else {
  17403. // zero = strconv.Itoa(fpNumber)
  17404. // }
  17405. // fapiao_number = zero
  17406. // }
  17407. // }
  17408. //}
  17409. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17410. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17411. var patientPrescription models.HisPrescriptionInfo
  17412. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17413. if patientPrescription.ID == 0 {
  17414. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  17415. }
  17416. //if patientPrescription.Do
  17417. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17418. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  17419. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  17420. diagnosis_ids := strings.Split(diagnosis_id, ",")
  17421. var config []*models.HisXtDiagnoseConfig
  17422. for _, item := range diagnosis_ids {
  17423. id, _ := strconv.ParseInt(item, 10, 64)
  17424. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17425. config = append(config, &diagnosisConfig)
  17426. }
  17427. sickConfig, _ := service.FindSickById(sick_type)
  17428. //if tempOrder.ID == 0 {
  17429. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  17430. //}
  17431. if tempOrder.ID == 0 {
  17432. var result string
  17433. var requestLog string
  17434. var res2 ResultSix
  17435. var res3 GZResultSix
  17436. var ressix10265 ResultSix10265
  17437. if miConfig.MdtrtareaAdmvs == "421300" {
  17438. data := make(map[string]interface{})
  17439. client := &http.Client{}
  17440. data["psn_no"] = his.PsnNo
  17441. data["mdtrt_id"] = his.Number
  17442. data["opter"] = roles.UserName
  17443. data["org_name"] = miConfig.OrgName
  17444. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17445. data["doctor_id"] = doctor_info.DoctorNumber
  17446. data["doctor_name"] = doctor_info.UserName
  17447. data["department"] = department.Name
  17448. data["fixmedins_code"] = miConfig.Code
  17449. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17450. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17451. data["secret_key"] = miConfig.SecretKey
  17452. data["sick_code"] = sickConfig.CountryCode
  17453. data["sick_name"] = sickConfig.ClassName
  17454. data["dept"] = strconv.FormatInt(department.ID, 10)
  17455. data["config"] = config
  17456. data["begin_time"] = begin_time
  17457. bytesData, _ := json.Marshal(data)
  17458. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17459. resp, _ := client.Do(req)
  17460. defer resp.Body.Close()
  17461. body, ioErr := ioutil.ReadAll(resp.Body)
  17462. if ioErr != nil {
  17463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17465. return
  17466. }
  17467. var respJSON map[string]interface{}
  17468. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17471. return
  17472. }
  17473. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17474. userJSONBytes, _ := json.Marshal(respJSON)
  17475. fmt.Println("log")
  17476. fmt.Println(string(userJSONBytes))
  17477. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17478. utils.ErrorLog("解析失败:%v", err)
  17479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17480. return
  17481. }
  17482. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17483. data := make(map[string]interface{})
  17484. client := &http.Client{}
  17485. data["psn_no"] = his.PsnNo
  17486. data["mdtrt_id"] = his.Number
  17487. data["opter"] = roles.UserName
  17488. data["org_name"] = miConfig.OrgName
  17489. if reg_type == 11 && his.Insutype == "390" {
  17490. data["med_type"] = "110104"
  17491. } else {
  17492. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17493. }
  17494. data["doctor_id"] = doctor_info.DoctorNumber
  17495. data["doctor_name"] = doctor_info.UserName
  17496. data["department"] = department.Name
  17497. data["fixmedins_code"] = miConfig.Code
  17498. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17499. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17500. data["secret_key"] = miConfig.SecretKey
  17501. data["sick_code"] = sickConfig.CountryCode
  17502. data["sick_name"] = sickConfig.ClassName
  17503. data["dept"] = strconv.FormatInt(department.ID, 10)
  17504. data["config"] = config
  17505. data["begin_time"] = begin_time
  17506. bytesData, _ := json.Marshal(data)
  17507. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17508. resp, _ := client.Do(req)
  17509. defer resp.Body.Close()
  17510. body, ioErr := ioutil.ReadAll(resp.Body)
  17511. if ioErr != nil {
  17512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17514. return
  17515. }
  17516. var respJSON map[string]interface{}
  17517. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17520. return
  17521. }
  17522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17523. userJSONBytes, _ := json.Marshal(respJSON)
  17524. fmt.Println("log")
  17525. fmt.Println(string(userJSONBytes))
  17526. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17527. utils.ErrorLog("解析失败:%v", err)
  17528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17529. return
  17530. }
  17531. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17532. data := make(map[string]interface{})
  17533. client := &http.Client{}
  17534. data["psn_no"] = his.PsnNo
  17535. data["mdtrt_id"] = his.Number
  17536. data["opter"] = roles.UserName
  17537. data["org_name"] = miConfig.OrgName
  17538. if reg_type == 11 && his.Insutype == "390" {
  17539. data["med_type"] = "110104"
  17540. } else {
  17541. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17542. }
  17543. data["doctor_id"] = doctor_info.DoctorNumber
  17544. data["doctor_name"] = doctor_info.UserName
  17545. data["department"] = department.Name
  17546. data["fixmedins_code"] = miConfig.Code
  17547. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17548. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17549. data["secret_key"] = miConfig.SecretKey
  17550. data["sick_code"] = sickConfig.CountryCode
  17551. data["sick_name"] = sickConfig.ClassName
  17552. data["dept"] = strconv.FormatInt(department.ID, 10)
  17553. data["config"] = config
  17554. data["begin_time"] = begin_time
  17555. bytesData, _ := json.Marshal(data)
  17556. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  17557. resp, _ := client.Do(req)
  17558. defer resp.Body.Close()
  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(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. userJSONBytes, _ := json.Marshal(respJSON)
  17573. fmt.Println("log")
  17574. fmt.Println(string(userJSONBytes))
  17575. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17576. utils.ErrorLog("解析失败:%v", err)
  17577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17578. return
  17579. }
  17580. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17581. data := make(map[string]interface{})
  17582. client := &http.Client{}
  17583. data["psn_no"] = his.PsnNo
  17584. data["mdtrt_id"] = his.Number
  17585. data["doctor"] = roles.UserName
  17586. data["department"] = department.Name
  17587. data["org_name"] = miConfig.OrgName
  17588. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17589. data["doctor_id"] = doctor_info.DoctorNumber
  17590. data["new_doctor_name"] = doctor_info.UserName
  17591. data["fixmedins_code"] = miConfig.Code
  17592. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17593. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17594. data["secret_key"] = miConfig.SecretKey
  17595. data["sick_code"] = sickConfig.CountryCode
  17596. data["sick_name"] = sickConfig.ClassName
  17597. data["url"] = miConfig.Url
  17598. data["ak"] = miConfig.AccessKey
  17599. data["begin_time"] = begin_time
  17600. data["cainfo"] = miConfig.Cainfo
  17601. data["dept"] = strconv.FormatInt(department.ID, 10)
  17602. data["config"] = config
  17603. bytesData, _ := json.Marshal(data)
  17604. var req *http.Request
  17605. if miConfig.MdtrtareaAdmvs == "320921" {
  17606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  17607. //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 +
  17608. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  17609. } else {
  17610. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  17611. }
  17612. resp, _ := client.Do(req)
  17613. defer resp.Body.Close()
  17614. body, ioErr := ioutil.ReadAll(resp.Body)
  17615. if ioErr != nil {
  17616. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17618. return
  17619. }
  17620. var respJSON map[string]interface{}
  17621. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17624. return
  17625. }
  17626. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17627. userJSONBytes, _ := json.Marshal(respJSON)
  17628. fmt.Println("log")
  17629. fmt.Println(string(userJSONBytes))
  17630. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  17631. utils.ErrorLog("解析失败:%v", err)
  17632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17633. return
  17634. }
  17635. res2.InfRefmsgid = ressix10265.InfRefmsgid
  17636. res2.Output = ressix10265.Output
  17637. res2.ErrMsg = ressix10265.ErrMsg
  17638. res2.Cainfo = ressix10265.Cainfo
  17639. res2.WarnMsg = ressix10265.WarnMsg
  17640. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  17641. res2.Infcode = infocode
  17642. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17643. data := make(map[string]interface{})
  17644. client := &http.Client{}
  17645. data["psn_no"] = his.PsnNo
  17646. data["mdtrt_id"] = his.Number
  17647. data["doctor"] = roles.UserName
  17648. data["department"] = department.Name
  17649. data["org_name"] = miConfig.OrgName
  17650. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17651. data["doctor_id"] = doctor_info.DoctorNumber
  17652. data["new_doctor_name"] = doctor_info.UserName
  17653. data["fixmedins_code"] = miConfig.Code
  17654. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17655. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17656. data["secret_key"] = miConfig.SecretKey
  17657. data["sick_code"] = sickConfig.CountryCode
  17658. data["sick_name"] = sickConfig.ClassName
  17659. data["url"] = miConfig.Url
  17660. data["ak"] = miConfig.AccessKey
  17661. data["begin_time"] = begin_time
  17662. data["cainfo"] = miConfig.Cainfo
  17663. data["dept"] = strconv.FormatInt(department.ID, 10)
  17664. data["config"] = config
  17665. bytesData, _ := json.Marshal(data)
  17666. var req *http.Request
  17667. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  17668. resp, _ := client.Do(req)
  17669. defer resp.Body.Close()
  17670. body, ioErr := ioutil.ReadAll(resp.Body)
  17671. if ioErr != nil {
  17672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17674. return
  17675. }
  17676. var respJSON map[string]interface{}
  17677. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17680. return
  17681. }
  17682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17683. userJSONBytes, _ := json.Marshal(respJSON)
  17684. fmt.Println("log")
  17685. fmt.Println(string(userJSONBytes))
  17686. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  17687. utils.ErrorLog("解析失败:%v", err)
  17688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17689. return
  17690. }
  17691. res2.InfRefmsgid = ressix10265.InfRefmsgid
  17692. res2.Output = ressix10265.Output
  17693. res2.ErrMsg = ressix10265.ErrMsg
  17694. res2.Cainfo = ressix10265.Cainfo
  17695. res2.WarnMsg = ressix10265.WarnMsg
  17696. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  17697. res2.Infcode = infocode
  17698. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17699. 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)
  17700. saveLog(result, requestLog, "2203", "上传就诊信息")
  17701. var respJSON2 map[string]interface{}
  17702. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  17703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17705. return
  17706. }
  17707. userJSONBytes2, _ := json.Marshal(respJSON2)
  17708. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17709. utils.ErrorLog("解析失败:%v", err)
  17710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17711. return
  17712. }
  17713. 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)
  17714. fmt.Println(result2)
  17715. fmt.Println(src_request)
  17716. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17717. data := make(map[string]interface{})
  17718. client := &http.Client{}
  17719. data["psn_no"] = his.PsnNo
  17720. data["mdtrt_id"] = his.Number
  17721. data["doctor"] = roles.UserName
  17722. data["department"] = department.Name
  17723. data["org_name"] = miConfig.OrgName
  17724. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17725. data["doctor_id"] = doctor_info.DoctorNumber
  17726. data["new_doctor_name"] = doctor_info.UserName
  17727. data["fixmedins_code"] = miConfig.Code
  17728. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17729. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17730. data["secret_key"] = miConfig.SecretKey
  17731. data["sick_code"] = sickConfig.CountryCode
  17732. data["sick_name"] = sickConfig.ClassName
  17733. data["url"] = miConfig.Url
  17734. data["ak"] = miConfig.AccessKey
  17735. data["begin_time"] = begin_time
  17736. data["cainfo"] = miConfig.Cainfo
  17737. data["dept"] = strconv.FormatInt(department.ID, 10)
  17738. data["config"] = config
  17739. bytesData, _ := json.Marshal(data)
  17740. var req *http.Request
  17741. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  17742. resp, _ := client.Do(req)
  17743. defer resp.Body.Close()
  17744. body, ioErr := ioutil.ReadAll(resp.Body)
  17745. if ioErr != nil {
  17746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17748. return
  17749. }
  17750. var respJSON map[string]interface{}
  17751. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17754. return
  17755. }
  17756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17757. userJSONBytes, _ := json.Marshal(respJSON)
  17758. fmt.Println("log")
  17759. fmt.Println(string(userJSONBytes))
  17760. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17761. utils.ErrorLog("解析失败:%v", err)
  17762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17763. return
  17764. }
  17765. } else {
  17766. if miConfig.MdtrtareaAdmvs == "440781" { //
  17767. 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)
  17768. } else {
  17769. if miConfig.Code == "H15049901371" {
  17770. //赤峰地区国家医保医疗类别
  17771. //职工透析:医疗类别选特殊情况门诊990502
  17772. //居民定额血透门慢: 医疗类别选门诊慢病140104
  17773. var med_type string
  17774. if his.Insutype == "390" {
  17775. if reg_type == 14 {
  17776. med_type = "9933"
  17777. } else if reg_type == 11 {
  17778. med_type = "11"
  17779. }
  17780. } else if his.Insutype == "310" {
  17781. if reg_type == 14 {
  17782. med_type = "990502"
  17783. } else if reg_type == 11 {
  17784. med_type = "11"
  17785. }
  17786. }
  17787. 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)
  17788. } else {
  17789. 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)
  17790. }
  17791. }
  17792. saveLog(result, requestLog, "2203", "上传就诊信息")
  17793. var respJSON2 map[string]interface{}
  17794. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  17795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17797. return
  17798. }
  17799. userJSONBytes2, _ := json.Marshal(respJSON2)
  17800. if miConfig.Code == "H15049901371" {
  17801. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  17802. utils.ErrorLog("解析失败:%v", err)
  17803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17804. return
  17805. }
  17806. res2.InfRefmsgid = ressix10265.InfRefmsgid
  17807. res2.Output = ressix10265.Output
  17808. res2.ErrMsg = ressix10265.ErrMsg
  17809. res2.Cainfo = ressix10265.Cainfo
  17810. res2.WarnMsg = ressix10265.WarnMsg
  17811. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  17812. res2.Infcode = infocode
  17813. } else {
  17814. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  17815. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  17816. utils.ErrorLog("解析失败:%v", err)
  17817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17818. return
  17819. }
  17820. res2.Infcode = res3.Infcode
  17821. } else {
  17822. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17823. utils.ErrorLog("解析失败:%v", err)
  17824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17825. return
  17826. }
  17827. }
  17828. }
  17829. }
  17830. if res2.Infcode != 0 {
  17831. adminUser := c.GetAdminUserInfo()
  17832. errlog := &models.HisOrderError{
  17833. UserOrgId: adminUser.CurrentOrgId,
  17834. Ctime: time.Now().Unix(),
  17835. Mtime: time.Now().Unix(),
  17836. ErrMsg: res2.ErrMsg,
  17837. Status: 1,
  17838. PatientId: id,
  17839. RecordTime: recordDateTime,
  17840. Stage: 3,
  17841. }
  17842. service.CreateErrMsgLog(errlog)
  17843. c.ServeSuccessJSON(map[string]interface{}{
  17844. "failed_code": -10,
  17845. "msg": res2.ErrMsg,
  17846. })
  17847. return
  17848. } else {
  17849. his.Diagnosis = diagnosis_id
  17850. his.SickType = sickConfig.ID
  17851. //var p_type int64
  17852. //if reg_type == 1111 || reg_type == 1112 {
  17853. // p_type = 11
  17854. //
  17855. //}
  17856. his.PType = fmt.Sprintf("%d", reg_type)
  17857. service.UpdateHisPatientThree(&his)
  17858. data := make(map[string]interface{})
  17859. if settle_accounts_type == 1 { //日结
  17860. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  17861. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  17862. } else {
  17863. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  17864. }
  17865. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  17866. data["pre"] = prescriptions
  17867. } else { //月结
  17868. start_time_str := c.GetString("start_time")
  17869. end_time_str := c.GetString("end_time")
  17870. timeLayout := "2006-01-02"
  17871. loc, _ := time.LoadLocation("Local")
  17872. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  17873. if err != nil {
  17874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17875. return
  17876. }
  17877. recordStartTime := theStartTime.Unix()
  17878. start_time = recordStartTime
  17879. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  17880. if err != nil {
  17881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17882. return
  17883. }
  17884. recordEndTime := theEndTime.Unix()
  17885. end_time = recordEndTime
  17886. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  17887. data["pre"] = prescriptions
  17888. }
  17889. timestamp := time.Now().Unix()
  17890. tempTime := time.Unix(timestamp, 0)
  17891. timeFormat := tempTime.Format("20060102150405")
  17892. chrgBchno := rand.Intn(100000) + 10000
  17893. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17894. strconv.FormatInt(his.PatientId, 10)
  17895. client := &http.Client{}
  17896. data["psn_no"] = his.PsnNo
  17897. data["mdtrt_id"] = his.Number
  17898. data["chrg_bchno"] = chrg_bchno
  17899. data["org_name"] = miConfig.OrgName
  17900. data["doctor"] = doctor_info.UserName
  17901. data["doctor_id"] = doctor_info.DoctorNumber
  17902. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  17903. data["fixmedins_code"] = miConfig.Code
  17904. data["dept_code"] = department.Number
  17905. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17906. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17907. data["secret_key"] = miConfig.SecretKey
  17908. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  17909. data["url"] = miConfig.Url
  17910. data["ak"] = miConfig.AccessKey
  17911. data["new_doctor_name"] = patientPrescription.Doctor
  17912. data["diag_code"] = sickConfig.CountryCode
  17913. data["cainfo"] = miConfig.Cainfo
  17914. data["opter"] = roles.UserName
  17915. var ids []int64
  17916. for _, item := range prescriptions {
  17917. ids = append(ids, item.ID)
  17918. }
  17919. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17920. if config.IsOpen == 1 { //对接了医保,走医保流程
  17921. var res ResultFour
  17922. var resFour10265 ResultFour10265
  17923. if miConfig.MdtrtareaAdmvs == "421300" {
  17924. bytesData, _ := json.Marshal(data)
  17925. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  17926. resp, _ := client.Do(req)
  17927. defer resp.Body.Close()
  17928. body, ioErr := ioutil.ReadAll(resp.Body)
  17929. if ioErr != nil {
  17930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17932. return
  17933. }
  17934. var respJSON map[string]interface{}
  17935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17938. return
  17939. }
  17940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17941. userJSONBytes, _ := json.Marshal(respJSON)
  17942. fmt.Println("log")
  17943. fmt.Println(string(userJSONBytes))
  17944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17945. utils.ErrorLog("解析失败:%v", err)
  17946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17947. return
  17948. }
  17949. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17950. bytesData, _ := json.Marshal(data)
  17951. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  17952. resp, _ := client.Do(req)
  17953. defer resp.Body.Close()
  17954. body, ioErr := ioutil.ReadAll(resp.Body)
  17955. if ioErr != nil {
  17956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17958. return
  17959. }
  17960. var respJSON map[string]interface{}
  17961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17964. return
  17965. }
  17966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17967. userJSONBytes, _ := json.Marshal(respJSON)
  17968. fmt.Println("log")
  17969. fmt.Println(string(userJSONBytes))
  17970. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17971. utils.ErrorLog("解析失败:%v", err)
  17972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17973. return
  17974. }
  17975. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17976. bytesData, _ := json.Marshal(data)
  17977. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  17978. resp, _ := client.Do(req)
  17979. defer resp.Body.Close()
  17980. body, ioErr := ioutil.ReadAll(resp.Body)
  17981. if ioErr != nil {
  17982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17984. return
  17985. }
  17986. var respJSON map[string]interface{}
  17987. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17990. return
  17991. }
  17992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17993. userJSONBytes, _ := json.Marshal(respJSON)
  17994. fmt.Println("log")
  17995. fmt.Println(string(userJSONBytes))
  17996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17997. utils.ErrorLog("解析失败:%v", err)
  17998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17999. return
  18000. }
  18001. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18002. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  18003. if result3101.Infcode == "0" {
  18004. if len(result3101.Output.Result) > 0 {
  18005. var errMsgs []string
  18006. for _, item := range result3101.Output.Result {
  18007. errMsgs = append(errMsgs, item.VolaCont)
  18008. }
  18009. c.ServeSuccessJSON(map[string]interface{}{
  18010. "failed_code": -10,
  18011. "msg": errMsgs,
  18012. })
  18013. return
  18014. }
  18015. }
  18016. bytesData, _ := json.Marshal(data)
  18017. var req *http.Request
  18018. if miConfig.MdtrtareaAdmvs == "320921" {
  18019. data["diag_code"] = sickConfig.CountryCode
  18020. fmt.Println(data)
  18021. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18022. } else {
  18023. data["diag_code"] = sickConfig.CountryCode
  18024. fmt.Println(data)
  18025. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18026. }
  18027. resp, _ := client.Do(req)
  18028. defer resp.Body.Close()
  18029. body, ioErr := ioutil.ReadAll(resp.Body)
  18030. if ioErr != nil {
  18031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18033. return
  18034. }
  18035. var respJSON map[string]interface{}
  18036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18039. return
  18040. }
  18041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18042. userJSONBytes, _ := json.Marshal(respJSON)
  18043. fmt.Println("log")
  18044. fmt.Println(string(userJSONBytes))
  18045. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18046. utils.ErrorLog("解析失败:%v", err)
  18047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18048. return
  18049. }
  18050. res.InfRefmsgid = resFour10265.InfRefmsgid
  18051. res.Output = resFour10265.Output
  18052. res.ErrMsg = resFour10265.ErrMsg
  18053. res.Cainfo = resFour10265.Cainfo
  18054. res.WarnMsg = resFour10265.WarnMsg
  18055. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18056. res.Infcode = infocode
  18057. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18058. var pagesize int = 2
  18059. var start int = 1
  18060. var stop int
  18061. var pagecount int
  18062. var curpage int
  18063. var isSuccess bool = true
  18064. data["doctor_id"] = doctor_info.DoctorNumber
  18065. //总页数,向上取整,注意除之前要先转换类型为float64
  18066. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  18067. for curpage = 1; curpage <= pagecount; curpage++ {
  18068. if curpage == 1 {
  18069. start = 1
  18070. } else {
  18071. start = (curpage-1)*pagesize + 1
  18072. }
  18073. stop = curpage * pagesize
  18074. if stop > len(prescriptions) {
  18075. stop = len(prescriptions)
  18076. }
  18077. //var requestLog string
  18078. data["pre"] = prescriptions[start-1 : stop]
  18079. fmt.Println(data["pre"])
  18080. bytesData, _ := json.Marshal(data)
  18081. var req *http.Request
  18082. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  18083. resp, _ := client.Do(req)
  18084. defer resp.Body.Close()
  18085. body, ioErr := ioutil.ReadAll(resp.Body)
  18086. if ioErr != nil {
  18087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18089. return
  18090. }
  18091. var respJSON map[string]interface{}
  18092. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18095. return
  18096. }
  18097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18098. userJSONBytes, _ := json.Marshal(respJSON)
  18099. fmt.Println("log")
  18100. fmt.Println(string(userJSONBytes))
  18101. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18102. utils.ErrorLog("解析失败:%v", err)
  18103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18104. return
  18105. }
  18106. res.InfRefmsgid = resFour10265.InfRefmsgid
  18107. res.Output = resFour10265.Output
  18108. res.ErrMsg = resFour10265.ErrMsg
  18109. res.Cainfo = resFour10265.Cainfo
  18110. res.WarnMsg = resFour10265.WarnMsg
  18111. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18112. res.Infcode = infocode
  18113. if infocode == 0 {
  18114. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  18115. } else {
  18116. isSuccess = false
  18117. errlog := &models.HisOrderError{
  18118. UserOrgId: adminUser.CurrentOrgId,
  18119. Ctime: time.Now().Unix(),
  18120. Mtime: time.Now().Unix(),
  18121. Number: chrg_bchno,
  18122. ErrMsg: "",
  18123. Status: 1,
  18124. PatientId: id,
  18125. RecordTime: recordDateTime,
  18126. Stage: 4,
  18127. }
  18128. service.CreateErrMsgLog(errlog)
  18129. c.ServeSuccessJSON(map[string]interface{}{
  18130. "failed_code": -10,
  18131. "msg": res.ErrMsg,
  18132. })
  18133. return
  18134. }
  18135. }
  18136. if isSuccess {
  18137. res.Infcode = 0
  18138. }
  18139. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18140. 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)
  18141. var dat map[string]interface{}
  18142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18143. fmt.Println(dat)
  18144. } else {
  18145. fmt.Println(err)
  18146. }
  18147. saveLog(result, request_log, "2204", "上传费用明细")
  18148. userJSONBytes, _ := json.Marshal(dat)
  18149. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18150. utils.ErrorLog("解析失败:%v", err)
  18151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18152. return
  18153. }
  18154. res.InfRefmsgid = resFour10265.InfRefmsgid
  18155. res.Output = resFour10265.Output
  18156. res.ErrMsg = resFour10265.ErrMsg
  18157. res.Cainfo = resFour10265.Cainfo
  18158. res.WarnMsg = resFour10265.WarnMsg
  18159. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18160. res.Infcode = infocode
  18161. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18162. bytesData, _ := json.Marshal(data)
  18163. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  18164. resp, _ := client.Do(req)
  18165. defer resp.Body.Close()
  18166. body, ioErr := ioutil.ReadAll(resp.Body)
  18167. if ioErr != nil {
  18168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18170. return
  18171. }
  18172. var respJSON map[string]interface{}
  18173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18176. return
  18177. }
  18178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18179. userJSONBytes, _ := json.Marshal(respJSON)
  18180. fmt.Println("log")
  18181. fmt.Println(string(userJSONBytes))
  18182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18183. utils.ErrorLog("解析失败:%v", err)
  18184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18185. return
  18186. }
  18187. } else {
  18188. if miConfig.Code == "H15049901371" {
  18189. 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)
  18190. var dat map[string]interface{}
  18191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18192. fmt.Println(dat)
  18193. } else {
  18194. fmt.Println(err)
  18195. }
  18196. saveLog(result, request_log, "2204", "上传费用明细")
  18197. userJSONBytes, _ := json.Marshal(dat)
  18198. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18199. utils.ErrorLog("解析失败:%v", err)
  18200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18201. return
  18202. }
  18203. res.InfRefmsgid = resFour10265.InfRefmsgid
  18204. res.Output = resFour10265.Output
  18205. res.ErrMsg = resFour10265.ErrMsg
  18206. res.Cainfo = resFour10265.Cainfo
  18207. res.WarnMsg = resFour10265.WarnMsg
  18208. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18209. res.Infcode = infocode
  18210. } else {
  18211. 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)
  18212. var dat map[string]interface{}
  18213. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18214. fmt.Println(dat)
  18215. } else {
  18216. fmt.Println(err)
  18217. }
  18218. saveLog(result, request_log, "2204", "上传费用明细")
  18219. userJSONBytes, _ := json.Marshal(dat)
  18220. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18221. utils.ErrorLog("解析失败:%v", err)
  18222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18223. return
  18224. }
  18225. }
  18226. }
  18227. if res.Infcode == 0 {
  18228. order := &models.HisOrder{
  18229. UserOrgId: adminUser.CurrentOrgId,
  18230. HisPatientId: his.ID,
  18231. PatientId: his.PatientId,
  18232. SettleAccountsDate: recordDateTime,
  18233. MdtrtId: his.Number,
  18234. PsnNo: his.PsnNo,
  18235. MedType: strconv.FormatInt(reg_type, 10),
  18236. Ctime: time.Now().Unix(),
  18237. Mtime: time.Now().Unix(),
  18238. Status: 1,
  18239. Number: chrg_bchno,
  18240. Infcode: res.Infcode,
  18241. WarnMsg: res.WarnMsg,
  18242. Cainfo: res.Cainfo,
  18243. ErrMsg: res.ErrMsg,
  18244. RespondTime: res.RefmsgTime,
  18245. InfRefmsgid: res.InfRefmsgid,
  18246. OrderStatus: 1,
  18247. PayWay: pay_way,
  18248. PayWays: pay_ways,
  18249. OthDesc: oth_desc,
  18250. PayPrice: pay_price,
  18251. PayCardNo: pay_card_no,
  18252. DiscountPrice: discount_price,
  18253. PreferentialPrice: preferential_price,
  18254. RealityPrice: reality_price,
  18255. FoundPrice: found_price,
  18256. MedicalInsurancePrice: medical_insurance_price,
  18257. PrivatePrice: private_price,
  18258. IsMedicineInsurance: 1,
  18259. SettleType: settle_accounts_type,
  18260. SettleStartTime: start_time,
  18261. SettleEndTime: end_time,
  18262. Creator: roles.AdminUserId,
  18263. Modify: roles.AdminUserId,
  18264. FaPiaoNumber: fapiao_number,
  18265. FaPiaoCode: fapiao_code,
  18266. PType: 2,
  18267. Diagnosis: diagnosis_id,
  18268. CashPay: cash_pay,
  18269. WechatPay: wechat_pay,
  18270. AliPay: ali_pay,
  18271. JifenPay: jifen_pay,
  18272. BandCardPay: band_card_pay,
  18273. }
  18274. err = service.CreateOrder(order)
  18275. if err != nil {
  18276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  18277. return
  18278. }
  18279. for _, item := range res.Output.Result {
  18280. temp := strings.Split(item.FeedetlSn, "-")
  18281. var advice_id int64 = 0
  18282. var project_id int64 = 0
  18283. var types int64 = 0
  18284. id, _ := strconv.ParseInt(temp[2], 10, 64)
  18285. types, _ = strconv.ParseInt(temp[1], 10, 64)
  18286. if temp[1] == "1" {
  18287. advice_id = id
  18288. project_id = 0
  18289. } else if temp[1] == "2" {
  18290. advice_id = 0
  18291. project_id = id
  18292. }
  18293. if item.MedChrgitmType == "9" {
  18294. item.MedChrgitmType = "09"
  18295. }
  18296. info := &models.HisOrderInfo{
  18297. OrderNumber: order.Number,
  18298. FeedetlSn: item.FeedetlSn,
  18299. UploadDate: time.Now().Unix(),
  18300. AdviceId: advice_id,
  18301. DetItemFeeSumamt: item.DetItemFeeSumamt,
  18302. Cnt: item.Cnt,
  18303. Pric: float64(item.Pric),
  18304. PatientId: his.PatientId,
  18305. PricUplmtAmt: item.PricUplmtAmt,
  18306. SelfpayProp: item.SelfpayProp,
  18307. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  18308. OverlmtAmt: item.OverlmtAmt,
  18309. PreselfpayAmt: item.PreselfpayAmt,
  18310. BasMednFlag: item.BasMednFlag,
  18311. MedChrgitmType: item.MedChrgitmType,
  18312. HiNegoDrugFlag: item.HiNegoDrugFlag,
  18313. Status: 1,
  18314. Memo: item.Memo,
  18315. Mtime: time.Now().Unix(),
  18316. InscpScpAmt: item.InscpScpAmt,
  18317. DrtReimFlag: item.DrtReimFlag,
  18318. Ctime: time.Now().Unix(),
  18319. ListSpItemFlag: item.ListSpItemFlag,
  18320. ChldMedcFlag: item.ChldMedcFlag,
  18321. LmtUsedFlag: item.LmtUsedFlag,
  18322. ChrgitmLv: item.ChrgitmLv,
  18323. UserOrgId: adminUser.CurrentOrgId,
  18324. HisPatientId: his.ID,
  18325. OrderId: order.ID,
  18326. ProjectId: project_id,
  18327. Type: types,
  18328. }
  18329. service.CreateOrderInfo(info)
  18330. }
  18331. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  18332. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  18333. var total float64
  18334. for _, item := range prescriptions {
  18335. if item.Type == 1 { //药品
  18336. for _, subItem := range item.HisDoctorAdviceInfo {
  18337. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18338. total_one := price * subItem.PrescribingNumber
  18339. total = total + total_one
  18340. }
  18341. }
  18342. if item.Type == 2 { //项目
  18343. for _, subItem := range item.HisPrescriptionProject {
  18344. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  18345. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18346. total_one := price * cnt
  18347. total = total + total_one
  18348. }
  18349. }
  18350. }
  18351. allTotal := fmt.Sprintf("%.2f", total)
  18352. //if adminUser.CurrentOrgId == 9919 {
  18353. //
  18354. // allTotal = fmt.Sprintf("%.2f", total)
  18355. //
  18356. //} else {
  18357. //
  18358. // allTotal = fmt.Sprintf("%.2f", total)
  18359. //
  18360. //}
  18361. if res.Infcode == 0 {
  18362. var rf []*ResultFive
  18363. json.Unmarshal([]byte(his.Iinfo), &rf)
  18364. chrg_bchno := chrg_bchno
  18365. cert_no := his.Certno
  18366. var insutypes []string
  18367. var insutype string
  18368. var is390 int = 0
  18369. var is310 int = 0
  18370. for _, item := range rf {
  18371. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18372. insutypes = append(insutypes, item.Insutype)
  18373. }
  18374. }
  18375. if len(insutypes) == 1 {
  18376. insutype = insutypes[0]
  18377. } else {
  18378. for _, i := range insutypes {
  18379. if i == "390" {
  18380. is390 = 1
  18381. }
  18382. if i == "310" {
  18383. is310 = 1
  18384. }
  18385. }
  18386. }
  18387. if is390 == 1 {
  18388. insutype = "390"
  18389. }
  18390. if is310 == 1 {
  18391. insutype = "310"
  18392. }
  18393. if len(insutypes) == 0 {
  18394. insutype = "310"
  18395. }
  18396. if len(insutypes) == 2 {
  18397. insutype = strconv.FormatInt(his.SocialType, 10)
  18398. }
  18399. insutype = strconv.FormatInt(his.SocialType, 10)
  18400. //insutype = "390"
  18401. if his.IdCardType == 1 {
  18402. // cert_no = his.MedicalInsuranceNumber
  18403. cert_no = his.Certno
  18404. } else {
  18405. cert_no = his.Certno
  18406. }
  18407. var res ResultSeven
  18408. var resSeven10265 ResultSeven10265
  18409. var gzresSeven10265Two GZResultSeven10265Two
  18410. var src_resquest string
  18411. var result2 string
  18412. if miConfig.MdtrtareaAdmvs == "421300" {
  18413. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18414. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18415. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18416. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18417. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18418. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18419. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18420. resp, requestErr := http.Get(api)
  18421. if requestErr != nil {
  18422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18423. return
  18424. }
  18425. body, ioErr := ioutil.ReadAll(resp.Body)
  18426. if ioErr != nil {
  18427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18429. return
  18430. }
  18431. var respJSON map[string]interface{}
  18432. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18435. return
  18436. }
  18437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18438. result, _ := json.Marshal(respJSON)
  18439. if miConfig.Code == "H15049901371" {
  18440. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18441. utils.ErrorLog("解析失败:%v", err)
  18442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18443. return
  18444. }
  18445. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18446. res.Output = resSeven10265.Output
  18447. res.ErrMsg = resSeven10265.ErrMsg
  18448. res.Cainfo = resSeven10265.Cainfo
  18449. res.WarnMsg = resSeven10265.WarnMsg
  18450. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18451. res.Infcode = infocode
  18452. } else {
  18453. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18454. utils.ErrorLog("解析失败:%v", err)
  18455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18456. return
  18457. }
  18458. }
  18459. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18460. if reg_type == 11 && his.Insutype == "390" {
  18461. reg_type = 110104
  18462. }
  18463. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18464. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18465. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18466. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18467. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18468. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18469. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18470. resp, requestErr := http.Get(api)
  18471. if requestErr != nil {
  18472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18473. return
  18474. }
  18475. body, ioErr := ioutil.ReadAll(resp.Body)
  18476. if ioErr != nil {
  18477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18479. return
  18480. }
  18481. var respJSON map[string]interface{}
  18482. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18485. return
  18486. }
  18487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18488. result, _ := json.Marshal(respJSON)
  18489. if miConfig.Code == "H15049901371" {
  18490. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18491. utils.ErrorLog("解析失败:%v", err)
  18492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18493. return
  18494. }
  18495. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18496. res.Output = resSeven10265.Output
  18497. res.ErrMsg = resSeven10265.ErrMsg
  18498. res.Cainfo = resSeven10265.Cainfo
  18499. res.WarnMsg = resSeven10265.WarnMsg
  18500. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18501. res.Infcode = infocode
  18502. } else {
  18503. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18504. utils.ErrorLog("解析失败:%v", err)
  18505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18506. return
  18507. }
  18508. }
  18509. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18510. if reg_type == 11 && his.Insutype == "390" {
  18511. reg_type = 110104
  18512. }
  18513. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18514. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18515. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18516. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18517. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18518. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18519. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18520. resp, requestErr := http.Get(api)
  18521. if requestErr != nil {
  18522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18523. return
  18524. }
  18525. body, ioErr := ioutil.ReadAll(resp.Body)
  18526. if ioErr != nil {
  18527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18529. return
  18530. }
  18531. var respJSON map[string]interface{}
  18532. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18535. return
  18536. }
  18537. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18538. result, _ := json.Marshal(respJSON)
  18539. if miConfig.Code == "H15049901371" {
  18540. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18541. utils.ErrorLog("解析失败:%v", err)
  18542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18543. return
  18544. }
  18545. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18546. res.Output = resSeven10265.Output
  18547. res.ErrMsg = resSeven10265.ErrMsg
  18548. res.Cainfo = resSeven10265.Cainfo
  18549. res.WarnMsg = resSeven10265.WarnMsg
  18550. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18551. res.Infcode = infocode
  18552. } else {
  18553. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18554. utils.ErrorLog("解析失败:%v", err)
  18555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18556. return
  18557. }
  18558. }
  18559. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18560. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  18561. if result3101.Infcode == "0" {
  18562. if len(result3101.Output.Result) > 0 {
  18563. var errMsgs []string
  18564. for _, item := range result3101.Output.Result {
  18565. errMsgs = append(errMsgs, item.VolaCont)
  18566. }
  18567. c.ServeSuccessJSON(map[string]interface{}{
  18568. "failed_code": -10,
  18569. "msg": errMsgs,
  18570. })
  18571. return
  18572. } else {
  18573. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18574. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18575. bas := strings.Split(psn_info.CardInfo, "|")
  18576. if his.IdCardType == 1 {
  18577. cert_no = bas[2]
  18578. } else if his.IdCardType == 3 {
  18579. cert_no = his.Certno
  18580. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  18581. } else if his.IdCardType == 4 {
  18582. cert_no = his.Certno
  18583. psn_info.VerifyNumber = psn_info.VerifyNumber
  18584. }
  18585. var api string
  18586. if miConfig.MdtrtareaAdmvs == "320921" {
  18587. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18588. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18589. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18590. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18591. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18592. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18593. "&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
  18594. } else {
  18595. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18596. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18597. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18598. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18599. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18600. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18601. "&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
  18602. }
  18603. resp, requestErr := http.Get(api)
  18604. if requestErr != nil {
  18605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18606. return
  18607. }
  18608. body, ioErr := ioutil.ReadAll(resp.Body)
  18609. if ioErr != nil {
  18610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18612. return
  18613. }
  18614. var respJSON map[string]interface{}
  18615. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18618. return
  18619. }
  18620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18621. result, _ := json.Marshal(respJSON)
  18622. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18623. utils.ErrorLog("解析失败:%v", err)
  18624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18625. return
  18626. }
  18627. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18628. res.Output = resSeven10265.Output
  18629. res.ErrMsg = resSeven10265.ErrMsg
  18630. res.Cainfo = resSeven10265.Cainfo
  18631. res.WarnMsg = resSeven10265.WarnMsg
  18632. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18633. res.Infcode = infocode
  18634. }
  18635. }
  18636. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18637. psn_info, _ := service.GetPsnByPatientId(id)
  18638. var verify_number string
  18639. if psn_info.IdCardType == 4 {
  18640. verify_number = psn_info.VerifyNumber
  18641. } else if psn_info.IdCardType == 1 {
  18642. bas := strings.Split(psn_info.CardInfo, "|")
  18643. cardNumber := bas[2]
  18644. verify_number = cardNumber
  18645. } else {
  18646. psn_info.IdCardType = 2
  18647. verify_number = psn_info.Certno
  18648. }
  18649. var api string
  18650. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18651. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18652. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18653. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18654. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18655. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18656. "&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
  18657. resp, requestErr := http.Get(api)
  18658. if requestErr != nil {
  18659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18660. return
  18661. }
  18662. body, ioErr := ioutil.ReadAll(resp.Body)
  18663. if ioErr != nil {
  18664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18666. return
  18667. }
  18668. var respJSON map[string]interface{}
  18669. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18672. return
  18673. }
  18674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18675. result, _ := json.Marshal(respJSON)
  18676. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18677. utils.ErrorLog("解析失败:%v", err)
  18678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18679. return
  18680. }
  18681. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18682. res.Output = resSeven10265.Output
  18683. res.ErrMsg = resSeven10265.ErrMsg
  18684. res.Cainfo = resSeven10265.Cainfo
  18685. res.WarnMsg = resSeven10265.WarnMsg
  18686. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18687. res.Infcode = infocode
  18688. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18689. var cert_no string
  18690. if his.IdCardType == 4 {
  18691. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18692. cert_no = psn_info.VerifyNumber
  18693. 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)
  18694. } else if his.IdCardType == 1 {
  18695. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18696. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  18697. 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)
  18698. }
  18699. //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)
  18700. var dat map[string]interface{}
  18701. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  18702. fmt.Println(dat)
  18703. } else {
  18704. fmt.Println(err)
  18705. }
  18706. saveLog(result2, src_resquest, "2207", "结算")
  18707. userJSONBytes, _ := json.Marshal(dat)
  18708. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  18709. utils.ErrorLog("解析失败:%v", err)
  18710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18711. return
  18712. }
  18713. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18714. res.Output = resSeven10265.Output
  18715. res.ErrMsg = resSeven10265.ErrMsg
  18716. res.Cainfo = resSeven10265.Cainfo
  18717. res.WarnMsg = resSeven10265.WarnMsg
  18718. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18719. res.Infcode = infocode
  18720. } else if miConfig.MdtrtareaAdmvs == "450721" {
  18721. res2 := c.GetoleInfo()
  18722. if res2.Infcode == 0 {
  18723. var result string
  18724. var request_log string
  18725. var result_log string
  18726. if res2.Output.MdtrtCertType == "02" {
  18727. 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)
  18728. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  18729. } else if res2.Output.MdtrtCertType == "01" {
  18730. 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)
  18731. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  18732. } else {
  18733. 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)
  18734. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  18735. }
  18736. var dat map[string]interface{}
  18737. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18738. fmt.Println(dat)
  18739. } else {
  18740. fmt.Println(err)
  18741. }
  18742. userJSONBytes, _ := json.Marshal(dat)
  18743. var res5 ResultTwo
  18744. //var resTwo10265 ResultTwo10265
  18745. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  18746. utils.ErrorLog("解析失败:%v", err)
  18747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18748. return
  18749. }
  18750. if res5.Infcode == -1 {
  18751. c.ServeSuccessJSON(map[string]interface{}{
  18752. "failed_code": -10,
  18753. "msg": res5.ErrMsg,
  18754. })
  18755. return
  18756. }
  18757. var insutypes []string
  18758. var insutype string
  18759. var is390 int = 0
  18760. var is310 int = 0
  18761. for _, item := range res5.Output.Iinfo {
  18762. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18763. insutypes = append(insutypes, item.Insutype)
  18764. }
  18765. }
  18766. if len(insutypes) == 1 {
  18767. insutype = insutypes[0]
  18768. } else {
  18769. for _, i := range insutypes {
  18770. if i == "390" {
  18771. is390 = 1
  18772. }
  18773. if i == "310" {
  18774. is310 = 1
  18775. }
  18776. }
  18777. }
  18778. if is390 == 1 {
  18779. insutype = "390"
  18780. }
  18781. if is310 == 1 {
  18782. insutype = "310"
  18783. }
  18784. if len(insutypes) == 0 {
  18785. insutype = "310"
  18786. }
  18787. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  18788. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  18789. infoStr := string(Iinfos)
  18790. idetinfoStr := string(Idetinfos)
  18791. psn := &models.HisPsn{
  18792. PsnNo: res5.Output.Baseinfo.PsnNo,
  18793. PatientId: id,
  18794. Certno: res5.Output.Baseinfo.Certno,
  18795. Gend: res5.Output.Baseinfo.Gend,
  18796. Naty: res5.Output.Baseinfo.Naty,
  18797. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  18798. PsnName: res5.Output.Baseinfo.PsnName,
  18799. Idetinfo: idetinfoStr,
  18800. Insuinfo: infoStr,
  18801. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  18802. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18803. VerifyNumber: res2.Output.EcToken,
  18804. }
  18805. if res2.Output.MdtrtCertType == "01" {
  18806. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18807. psn.VerifyNumber = res2.Output.EcToken
  18808. } else if res2.Output.MdtrtCertType == "02" {
  18809. psn.VerifyNumber = res2.Output.CardNo
  18810. } else {
  18811. psn.VerifyNumber = res2.Output.MdtrtCertNo
  18812. }
  18813. service.CreateHisPsn(psn)
  18814. if res2.Output.MdtrtCertType == "01" {
  18815. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18816. token := res2.Output.EcToken
  18817. 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)
  18818. } else if res2.Output.MdtrtCertType == "02" {
  18819. 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)
  18820. } else {
  18821. 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)
  18822. }
  18823. var dat2 map[string]interface{}
  18824. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  18825. fmt.Println(dat2)
  18826. } else {
  18827. fmt.Println(err)
  18828. }
  18829. userJSONBytes3, _ := json.Marshal(dat2)
  18830. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  18831. utils.ErrorLog("解析失败:%v", err)
  18832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18833. return
  18834. }
  18835. saveLog(result2, src_resquest, "2207", "结算")
  18836. } else {
  18837. c.ServeSuccessJSON(map[string]interface{}{
  18838. "failed_code": -10,
  18839. "msg": res2.ErrMsg,
  18840. })
  18841. return
  18842. }
  18843. } else {
  18844. if miConfig.Code == "H15049901371" {
  18845. //赤峰地区国家医保医疗类别
  18846. //职工透析:医疗类别选特殊情况门诊990502
  18847. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18848. var med_type string
  18849. if his.Insutype == "390" {
  18850. if reg_type == 14 {
  18851. med_type = "9933"
  18852. } else if reg_type == 11 {
  18853. med_type = "11"
  18854. }
  18855. } else if his.Insutype == "310" {
  18856. if reg_type == 14 {
  18857. med_type = "990502"
  18858. } else if reg_type == 11 {
  18859. med_type = "11"
  18860. }
  18861. }
  18862. 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)
  18863. } else {
  18864. if his.IdCardType == 4 {
  18865. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18866. var token string
  18867. token = psn_info.VerifyNumber
  18868. 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)
  18869. } else {
  18870. if his.IdCardType == 1 {
  18871. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18872. bas := strings.Split(psn_info.CardInfo, "|")
  18873. basNumber := bas[2]
  18874. cert_no = basNumber
  18875. }
  18876. 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)
  18877. }
  18878. }
  18879. //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)
  18880. var dat map[string]interface{}
  18881. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  18882. fmt.Println(dat)
  18883. } else {
  18884. fmt.Println(err)
  18885. }
  18886. saveLog(result2, src_resquest, "2207", "结算")
  18887. userJSONBytes, _ := json.Marshal(dat)
  18888. if miConfig.Code == "H15049901371" {
  18889. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  18890. utils.ErrorLog("解析失败:%v", err)
  18891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18892. return
  18893. }
  18894. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18895. res.Output = resSeven10265.Output
  18896. res.ErrMsg = resSeven10265.ErrMsg
  18897. res.Cainfo = resSeven10265.Cainfo
  18898. res.WarnMsg = resSeven10265.WarnMsg
  18899. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18900. res.Infcode = infocode
  18901. } else {
  18902. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18903. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  18904. utils.ErrorLog("解析失败:%v", err)
  18905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18906. return
  18907. }
  18908. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  18909. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  18910. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  18911. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  18912. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  18913. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  18914. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  18915. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  18916. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  18917. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18918. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18919. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18920. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18921. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  18922. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  18923. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  18924. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  18925. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  18926. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  18927. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  18928. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  18929. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  18930. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  18931. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  18932. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  18933. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  18934. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  18935. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  18936. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  18937. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  18938. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  18939. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  18940. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  18941. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  18942. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  18943. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  18944. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  18945. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  18946. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18947. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  18948. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  18949. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  18950. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  18951. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  18952. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  18953. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  18954. res.ErrMsg = gzresSeven10265Two.ErrMsg
  18955. res.Cainfo = gzresSeven10265Two.Cainfo
  18956. res.WarnMsg = gzresSeven10265Two.WarnMsg
  18957. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  18958. //res.Infcode = infocode
  18959. } else {
  18960. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18961. utils.ErrorLog("解析失败:%v", err)
  18962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18963. return
  18964. }
  18965. }
  18966. }
  18967. }
  18968. if res.Infcode == -1 {
  18969. errlog := &models.HisOrderError{
  18970. UserOrgId: adminUser.CurrentOrgId,
  18971. Ctime: time.Now().Unix(),
  18972. Mtime: time.Now().Unix(),
  18973. Number: chrg_bchno,
  18974. ErrMsg: res.ErrMsg,
  18975. Status: 1,
  18976. PatientId: id,
  18977. RecordTime: recordDateTime,
  18978. Stage: 6,
  18979. }
  18980. service.CreateErrMsgLog(errlog)
  18981. c.ServeSuccessJSON(map[string]interface{}{
  18982. "failed_code": -10,
  18983. "msg": res.ErrMsg,
  18984. })
  18985. return
  18986. } else {
  18987. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  18988. order.OrderStatus = 2
  18989. order.Status = 1
  18990. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  18991. order.SetlId = res.Output.Setlinfo.SetlID
  18992. order.PsnNo = res.Output.Setlinfo.PsnNo
  18993. order.PsnName = res.Output.Setlinfo.PsnName
  18994. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  18995. order.Certno = res.Output.Setlinfo.Certno
  18996. order.Gend = res.Output.Setlinfo.Gend
  18997. order.Naty = res.Output.Setlinfo.Naty
  18998. order.Age = res.Output.Setlinfo.Age
  18999. order.Insutype = res.Output.Setlinfo.Insutype
  19000. order.PsnType = res.Output.Setlinfo.PsnType
  19001. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  19002. order.SetlTime = res.Output.Setlinfo.SetlTime
  19003. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  19004. if res.Output.Setlinfo.MedType == "140101" {
  19005. order.MedType = "14"
  19006. } else {
  19007. if res.Output.Setlinfo.MedType == "110104" {
  19008. order.MedType = "11"
  19009. } else {
  19010. order.MedType = res.Output.Setlinfo.MedType
  19011. }
  19012. }
  19013. if reg_type == 1112 {
  19014. order.MedType = "1112"
  19015. }
  19016. if reg_type == 1111 {
  19017. order.MedType = "1111"
  19018. }
  19019. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  19020. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  19021. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  19022. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  19023. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  19024. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  19025. order.HifpPay = res.Output.Setlinfo.HifpPay
  19026. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  19027. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  19028. order.HifesPay = res.Output.Setlinfo.HifesPay
  19029. order.HifobPay = res.Output.Setlinfo.HifobPay
  19030. order.MafPay = res.Output.Setlinfo.MafPay
  19031. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  19032. order.OthPay = res.Output.Setlinfo.OthPay
  19033. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  19034. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  19035. order.AcctPay = res.Output.Setlinfo.AcctPay
  19036. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  19037. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  19038. order.Balc = res.Output.Setlinfo.Balc
  19039. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  19040. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  19041. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  19042. order.ClrType = res.Output.Setlinfo.ClrType
  19043. order.ClrWay = res.Output.Setlinfo.ClrWay
  19044. order.Creator = order.Creator
  19045. order.Modify = roles.AdminUserId
  19046. order.RequestLog = src_resquest
  19047. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  19048. //detailStr := string(setlDetail)
  19049. //order.SetlDetail = detailStr
  19050. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  19051. err = service.UpDateOrder(order)
  19052. if err == nil {
  19053. //判断是否使用了押金
  19054. if dec_way == "true" {
  19055. tmpstring := strconv.FormatInt(order.ID, 10)
  19056. order.Decimal = decimal
  19057. service.UpDateOrder(order)
  19058. //扣押金
  19059. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  19060. if errmsg != nil {
  19061. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  19062. return
  19063. }
  19064. }
  19065. c.ServeSuccessJSON(map[string]interface{}{
  19066. "msg": "结算成功",
  19067. })
  19068. } else {
  19069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  19070. return
  19071. }
  19072. }
  19073. } else {
  19074. adminUser := c.GetAdminUserInfo()
  19075. errlog := &models.HisOrderError{
  19076. UserOrgId: adminUser.CurrentOrgId,
  19077. Ctime: time.Now().Unix(),
  19078. Mtime: time.Now().Unix(),
  19079. ErrMsg: res.ErrMsg,
  19080. Status: 1,
  19081. PatientId: id,
  19082. RecordTime: recordDateTime,
  19083. Stage: 4,
  19084. }
  19085. service.CreateErrMsgLog(errlog)
  19086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  19087. return
  19088. }
  19089. } else {
  19090. adminUser := c.GetAdminUserInfo()
  19091. errlog := &models.HisOrderError{
  19092. UserOrgId: adminUser.CurrentOrgId,
  19093. Ctime: time.Now().Unix(),
  19094. Mtime: time.Now().Unix(),
  19095. ErrMsg: res.ErrMsg,
  19096. Status: 1,
  19097. PatientId: id,
  19098. RecordTime: recordDateTime,
  19099. Stage: 4,
  19100. }
  19101. service.CreateErrMsgLog(errlog)
  19102. c.ServeSuccessJSON(map[string]interface{}{
  19103. "failed_code": -10,
  19104. "msg": res.ErrMsg,
  19105. })
  19106. return
  19107. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  19108. //return
  19109. }
  19110. }
  19111. }
  19112. } else if tempOrder.ID > 0 {
  19113. if tempOrder.IsPre == 1 {
  19114. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  19115. var rf []*ResultFive
  19116. json.Unmarshal([]byte(his.Iinfo), &rf)
  19117. chrg_bchno := tempOrder.Number
  19118. cert_no := his.Certno
  19119. var insutypes []string
  19120. var insutype string
  19121. var is390 int = 0
  19122. var is310 int = 0
  19123. for _, item := range rf {
  19124. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19125. insutypes = append(insutypes, item.Insutype)
  19126. }
  19127. }
  19128. if len(insutypes) == 1 {
  19129. insutype = insutypes[0]
  19130. } else {
  19131. for _, i := range insutypes {
  19132. if i == "390" {
  19133. is390 = 1
  19134. }
  19135. if i == "310" {
  19136. is310 = 1
  19137. }
  19138. }
  19139. }
  19140. if is390 == 1 {
  19141. insutype = "390"
  19142. }
  19143. if is310 == 1 {
  19144. insutype = "310"
  19145. }
  19146. if len(insutypes) == 0 {
  19147. insutype = "310"
  19148. }
  19149. if len(insutypes) == 2 {
  19150. insutype = strconv.FormatInt(his.SocialType, 10)
  19151. }
  19152. //insutype = "390"
  19153. if his.IdCardType == 1 {
  19154. // cert_no = his.MedicalInsuranceNumber
  19155. cert_no = his.Certno
  19156. } else {
  19157. cert_no = his.Certno
  19158. }
  19159. var res ResultSeven
  19160. var ahres ResultSevenAH
  19161. var resSeven10265 ResultSeven10265
  19162. var gzresSeven10265Two GZResultSeven10265Two
  19163. var src_resquest string
  19164. var result2 string
  19165. if miConfig.MdtrtareaAdmvs == "450721" {
  19166. res2 := c.GetoleInfo()
  19167. if res2.Infcode == 0 {
  19168. var result string
  19169. var request_log string
  19170. var result_log string
  19171. if res2.Output.MdtrtCertType == "02" {
  19172. 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)
  19173. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19174. } else if res2.Output.MdtrtCertType == "01" {
  19175. 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)
  19176. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19177. } else {
  19178. 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)
  19179. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19180. }
  19181. var dat map[string]interface{}
  19182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19183. fmt.Println(dat)
  19184. } else {
  19185. fmt.Println(err)
  19186. }
  19187. userJSONBytes, _ := json.Marshal(dat)
  19188. var res5 ResultTwo
  19189. //var resTwo10265 ResultTwo10265
  19190. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19191. utils.ErrorLog("解析失败:%v", err)
  19192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19193. return
  19194. }
  19195. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  19196. if res5.Infcode == -1 {
  19197. c.ServeSuccessJSON(map[string]interface{}{
  19198. "failed_code": -10,
  19199. "msg": res5.ErrMsg,
  19200. })
  19201. return
  19202. }
  19203. var insutypes []string
  19204. var insutype string
  19205. var is390 int = 0
  19206. var is310 int = 0
  19207. for _, item := range res5.Output.Iinfo {
  19208. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19209. insutypes = append(insutypes, item.Insutype)
  19210. }
  19211. }
  19212. if len(insutypes) == 1 {
  19213. insutype = insutypes[0]
  19214. } else {
  19215. for _, i := range insutypes {
  19216. if i == "390" {
  19217. is390 = 1
  19218. }
  19219. if i == "310" {
  19220. is310 = 1
  19221. }
  19222. }
  19223. }
  19224. if is390 == 1 {
  19225. insutype = "390"
  19226. }
  19227. if is310 == 1 {
  19228. insutype = "310"
  19229. }
  19230. if len(insutypes) == 0 {
  19231. insutype = "310"
  19232. }
  19233. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19234. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19235. infoStr := string(Iinfos)
  19236. idetinfoStr := string(Idetinfos)
  19237. psn := &models.HisPsn{
  19238. PsnNo: res5.Output.Baseinfo.PsnNo,
  19239. PatientId: id,
  19240. Certno: res5.Output.Baseinfo.Certno,
  19241. Gend: res5.Output.Baseinfo.Gend,
  19242. Naty: res5.Output.Baseinfo.Naty,
  19243. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19244. PsnName: res5.Output.Baseinfo.PsnName,
  19245. Idetinfo: idetinfoStr,
  19246. Insuinfo: infoStr,
  19247. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19248. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19249. VerifyNumber: res2.Output.EcToken,
  19250. }
  19251. service.CreateHisPsn(psn)
  19252. if res2.Output.MdtrtCertType == "01" {
  19253. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19254. token := res2.Output.EcToken
  19255. 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)
  19256. } else if res2.Output.MdtrtCertType == "02" {
  19257. 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)
  19258. } else {
  19259. 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)
  19260. }
  19261. var dat2 map[string]interface{}
  19262. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19263. fmt.Println(dat2)
  19264. } else {
  19265. fmt.Println(err)
  19266. }
  19267. userJSONBytes3, _ := json.Marshal(dat2)
  19268. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19269. utils.ErrorLog("解析失败:%v", err)
  19270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19271. return
  19272. }
  19273. saveLog(result2, src_resquest, "2207", "结算")
  19274. } else {
  19275. c.ServeSuccessJSON(map[string]interface{}{
  19276. "failed_code": -10,
  19277. "msg": res2.ErrMsg,
  19278. })
  19279. return
  19280. }
  19281. } else if miConfig.MdtrtareaAdmvs == "421300" {
  19282. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19283. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19284. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19285. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19286. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19287. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19288. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19289. resp, requestErr := http.Get(api)
  19290. if requestErr != nil {
  19291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19292. return
  19293. }
  19294. body, ioErr := ioutil.ReadAll(resp.Body)
  19295. if ioErr != nil {
  19296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19298. return
  19299. }
  19300. var respJSON map[string]interface{}
  19301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19304. return
  19305. }
  19306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19307. result, _ := json.Marshal(respJSON)
  19308. fmt.Println("log")
  19309. fmt.Println(string(result))
  19310. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19311. utils.ErrorLog("解析失败:%v", err)
  19312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19313. return
  19314. }
  19315. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19316. if reg_type == 11 && his.Insutype == "390" {
  19317. reg_type = 110104
  19318. }
  19319. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19320. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19321. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19322. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19323. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19324. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19325. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19326. resp, requestErr := http.Get(api)
  19327. if requestErr != nil {
  19328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19329. return
  19330. }
  19331. body, ioErr := ioutil.ReadAll(resp.Body)
  19332. if ioErr != nil {
  19333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19335. return
  19336. }
  19337. var respJSON map[string]interface{}
  19338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19341. return
  19342. }
  19343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19344. result, _ := json.Marshal(respJSON)
  19345. fmt.Println("log")
  19346. fmt.Println(string(result))
  19347. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19348. utils.ErrorLog("解析失败:%v", err)
  19349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19350. return
  19351. }
  19352. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19353. if reg_type == 11 && his.Insutype == "390" {
  19354. reg_type = 110104
  19355. }
  19356. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19357. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19358. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19359. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19360. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19361. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19362. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19363. resp, requestErr := http.Get(api)
  19364. if requestErr != nil {
  19365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19366. return
  19367. }
  19368. body, ioErr := ioutil.ReadAll(resp.Body)
  19369. if ioErr != nil {
  19370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19372. return
  19373. }
  19374. var respJSON map[string]interface{}
  19375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19378. return
  19379. }
  19380. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19381. result, _ := json.Marshal(respJSON)
  19382. fmt.Println("log")
  19383. fmt.Println(string(result))
  19384. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19385. utils.ErrorLog("解析失败:%v", err)
  19386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19387. return
  19388. }
  19389. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19390. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  19391. if result3101.Infcode == "0" {
  19392. if len(result3101.Output.Result) > 0 {
  19393. var errMsgs []string
  19394. for _, item := range result3101.Output.Result {
  19395. errMsgs = append(errMsgs, item.VolaCont)
  19396. }
  19397. c.ServeSuccessJSON(map[string]interface{}{
  19398. "failed_code": -10,
  19399. "msg": errMsgs,
  19400. })
  19401. return
  19402. } else {
  19403. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19404. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19405. bas := strings.Split(psn_info.CardInfo, "|")
  19406. if his.IdCardType == 1 {
  19407. cert_no = bas[2]
  19408. } else if his.IdCardType == 3 {
  19409. cert_no = his.Certno
  19410. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19411. } else if his.IdCardType == 4 {
  19412. cert_no = his.Certno
  19413. psn_info.VerifyNumber = psn_info.VerifyNumber
  19414. }
  19415. //江苏地区国家医保医疗类别
  19416. //职工透析:医疗类别选特殊情况门诊9933
  19417. //居民血透门慢: 医疗类别选门诊慢病1402
  19418. //var med_type string
  19419. //if his.Insutype == "310" {
  19420. // if reg_type == 14 {
  19421. // med_type = "9933"
  19422. // } else if reg_type == 11 {
  19423. // med_type = "11"
  19424. //
  19425. // }
  19426. //} else if his.Insutype == "390" {
  19427. // if reg_type == 14 {
  19428. // med_type = "1402"
  19429. // } else if reg_type == 11 {
  19430. // med_type = "11"
  19431. // }
  19432. //}
  19433. var api string
  19434. if miConfig.MdtrtareaAdmvs == "320921" {
  19435. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19436. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19437. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19438. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19439. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19440. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19441. "&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
  19442. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19443. } else {
  19444. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19445. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19446. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19447. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19448. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19449. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19450. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19451. "&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
  19452. }
  19453. resp, requestErr := http.Get(api)
  19454. if requestErr != nil {
  19455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19456. return
  19457. }
  19458. body, ioErr := ioutil.ReadAll(resp.Body)
  19459. if ioErr != nil {
  19460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19462. return
  19463. }
  19464. var respJSON map[string]interface{}
  19465. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19468. return
  19469. }
  19470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19471. result, _ := json.Marshal(respJSON)
  19472. fmt.Println("log")
  19473. fmt.Println(string(result))
  19474. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19475. utils.ErrorLog("解析失败:%v", err)
  19476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19477. return
  19478. }
  19479. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19480. res.Output = resSeven10265.Output
  19481. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19482. res.ErrMsg = resSeven10265.ErrMsg
  19483. res.Cainfo = resSeven10265.Cainfo
  19484. res.WarnMsg = resSeven10265.WarnMsg
  19485. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19486. res.Infcode = infocode
  19487. }
  19488. }
  19489. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19490. psn_info, _ := service.GetPsnByPatientId(id)
  19491. var verify_number string
  19492. if psn_info.IdCardType == 4 {
  19493. verify_number = psn_info.VerifyNumber
  19494. } else if psn_info.IdCardType == 1 {
  19495. bas := strings.Split(psn_info.CardInfo, "|")
  19496. cardNumber := bas[2]
  19497. verify_number = cardNumber
  19498. } else {
  19499. verify_number = psn_info.Certno
  19500. psn_info.IdCardType = 2
  19501. }
  19502. var api string
  19503. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19504. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19505. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19506. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19507. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  19508. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19509. "&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
  19510. resp, requestErr := http.Get(api)
  19511. if requestErr != nil {
  19512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19513. return
  19514. }
  19515. body, ioErr := ioutil.ReadAll(resp.Body)
  19516. if ioErr != nil {
  19517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19519. return
  19520. }
  19521. var respJSON map[string]interface{}
  19522. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19525. return
  19526. }
  19527. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19528. result, _ := json.Marshal(respJSON)
  19529. fmt.Println("log")
  19530. fmt.Println(string(result))
  19531. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19532. utils.ErrorLog("解析失败:%v", err)
  19533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19534. return
  19535. }
  19536. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19537. res.Output = resSeven10265.Output
  19538. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19539. res.ErrMsg = resSeven10265.ErrMsg
  19540. res.Cainfo = resSeven10265.Cainfo
  19541. res.WarnMsg = resSeven10265.WarnMsg
  19542. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19543. res.Infcode = infocode
  19544. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19545. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19546. var cert_no string
  19547. if his.IdCardType == 1 {
  19548. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19549. } else {
  19550. cert_no = psn_info.VerifyNumber
  19551. }
  19552. 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)
  19553. var dat map[string]interface{}
  19554. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19555. fmt.Println(dat)
  19556. } else {
  19557. fmt.Println(err)
  19558. }
  19559. saveLog(result2, src_resquest, "2207", "结算")
  19560. userJSONBytes, _ := json.Marshal(dat)
  19561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19562. utils.ErrorLog("解析失败:%v", err)
  19563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19564. return
  19565. }
  19566. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19567. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19568. var cert_no string
  19569. var card_sn string
  19570. if his.IdCardType == 1 {
  19571. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19572. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19573. bas := strings.Split(psn_info.CardInfo, "|")
  19574. card_sn = bas[3]
  19575. } else if his.IdCardType == 2 {
  19576. cert_no = his.IdCardNo
  19577. } else {
  19578. cert_no = psn_info.VerifyNumber
  19579. }
  19580. var rf []*ResultFive
  19581. json.Unmarshal([]byte(his.Iinfo), &rf)
  19582. var psn_type string
  19583. for _, item := range rf {
  19584. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  19585. psn_type = item.PsnType
  19586. }
  19587. }
  19588. 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)
  19589. var dat map[string]interface{}
  19590. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19591. fmt.Println(dat)
  19592. } else {
  19593. fmt.Println(err)
  19594. }
  19595. saveLog(result2, src_resquest, "2207", "结算")
  19596. userJSONBytes, _ := json.Marshal(dat)
  19597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19598. utils.ErrorLog("解析失败:%v", err)
  19599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19600. return
  19601. }
  19602. } else if miConfig.MdtrtareaAdmvs == "341203" {
  19603. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19604. if his.IdCardType == 1 {
  19605. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19606. bas := strings.Split(psn_info.CardInfo, "|")
  19607. cert_no = bas[2]
  19608. } else if his.IdCardType == 3 {
  19609. cert_no = his.Certno
  19610. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19611. } else if his.IdCardType == 4 {
  19612. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19613. cert_no = his.Certno
  19614. psn_info.VerifyNumber = psn_info.VerifyNumber
  19615. } else {
  19616. cert_no = his.Certno
  19617. psn_info.VerifyNumber = his.Certno
  19618. }
  19619. var api string
  19620. var med_type string
  19621. if his.Insutype == "390" {
  19622. if reg_type == 992102 {
  19623. med_type = "992102"
  19624. }
  19625. if reg_type == 140104 {
  19626. med_type = "140104"
  19627. }
  19628. if reg_type == 14 {
  19629. med_type = "14"
  19630. }
  19631. } else if his.Insutype == "310" {
  19632. if reg_type == 992102 {
  19633. med_type = "992102"
  19634. }
  19635. if reg_type == 14 {
  19636. med_type = "14"
  19637. }
  19638. }
  19639. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19640. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19641. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19642. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19643. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19644. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19645. "&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
  19646. resp, requestErr := http.Get(api)
  19647. if requestErr != nil {
  19648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19649. return
  19650. }
  19651. body, ioErr := ioutil.ReadAll(resp.Body)
  19652. if ioErr != nil {
  19653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19655. return
  19656. }
  19657. var respJSON map[string]interface{}
  19658. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19661. return
  19662. }
  19663. status := respJSON["data"].(map[string]interface{})["status"].(string)
  19664. if status == "0" {
  19665. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  19666. c.ServeSuccessJSON(map[string]interface{}{
  19667. "failed_code": -10,
  19668. "msg": err_msg,
  19669. })
  19670. return
  19671. }
  19672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19673. result, _ := json.Marshal(respJSON)
  19674. fmt.Println("log")
  19675. fmt.Println(string(result))
  19676. if err := json.Unmarshal(result, &ahres); err != nil {
  19677. utils.ErrorLog("解析失败:%v", err)
  19678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19679. return
  19680. }
  19681. res.InfRefmsgid = ahres.InfRefmsgid
  19682. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  19683. // 创建对应的Time类型
  19684. t := time.UnixMilli(timestamp)
  19685. // 格式化成指定的日期字符串
  19686. str := t.Format("2006-01-02 15:04:05")
  19687. res.Output.Setlinfo.SetlTime = str
  19688. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  19689. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  19690. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  19691. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  19692. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  19693. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  19694. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19695. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  19696. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  19697. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  19698. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  19699. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  19700. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  19701. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  19702. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  19703. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  19704. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  19705. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  19706. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  19707. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19708. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  19709. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  19710. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  19711. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  19712. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  19713. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  19714. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  19715. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  19716. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  19717. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  19718. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  19719. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  19720. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  19721. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  19722. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  19723. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  19724. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  19725. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  19726. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  19727. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  19728. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  19729. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  19730. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  19731. res.Output.Setldetail = ahres.Output.Setldetail
  19732. res.ErrMsg = ahres.ErrMsg
  19733. res.Cainfo = ahres.Cainfo
  19734. res.WarnMsg = ahres.WarnMsg
  19735. res.Infcode = ahres.Infcode
  19736. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19737. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19738. var cert_no string
  19739. if his.IdCardType == 1 {
  19740. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19741. } else if his.IdCardType == 2 {
  19742. cert_no = his.IdCardNo
  19743. } else {
  19744. cert_no = psn_info.VerifyNumber
  19745. }
  19746. 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, "")
  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, &res); err != nil {
  19756. utils.ErrorLog("解析失败:%v", err)
  19757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19758. return
  19759. }
  19760. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19761. psn_info, _ := service.GetPsnByPatientId(id)
  19762. var verify_number string
  19763. if psn_info.IdCardType == 4 {
  19764. verify_number = psn_info.VerifyNumber
  19765. } else if psn_info.IdCardType == 1 {
  19766. bas := strings.Split(psn_info.CardInfo, "|")
  19767. cardNumber := bas[2]
  19768. verify_number = cardNumber
  19769. } else {
  19770. verify_number = psn_info.Certno
  19771. psn_info.IdCardType = 2
  19772. }
  19773. var api string
  19774. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19775. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19776. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19777. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19778. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  19779. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19780. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  19781. resp, requestErr := http.Get(api)
  19782. if requestErr != nil {
  19783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19784. return
  19785. }
  19786. body, ioErr := ioutil.ReadAll(resp.Body)
  19787. if ioErr != nil {
  19788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19790. return
  19791. }
  19792. var respJSON map[string]interface{}
  19793. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19796. return
  19797. }
  19798. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19799. result, _ := json.Marshal(respJSON)
  19800. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19801. utils.ErrorLog("解析失败:%v", err)
  19802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19803. return
  19804. }
  19805. } else {
  19806. var src_resquest string
  19807. if miConfig.Code == "H15049901371" {
  19808. //赤峰地区国家医保医疗类别
  19809. //职工透析:医疗类别选特殊情况门诊990502
  19810. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19811. var med_type string
  19812. if his.Insutype == "390" {
  19813. if reg_type == 14 {
  19814. med_type = "9933"
  19815. } else if reg_type == 11 {
  19816. med_type = "11"
  19817. }
  19818. } else if his.Insutype == "310" {
  19819. if reg_type == 14 {
  19820. med_type = "990502"
  19821. } else if reg_type == 11 {
  19822. med_type = "11"
  19823. }
  19824. }
  19825. 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)
  19826. } else {
  19827. if his.IdCardType == 4 {
  19828. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19829. token := psn_info.VerifyNumber
  19830. 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)
  19831. } else {
  19832. 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)
  19833. }
  19834. }
  19835. var dat map[string]interface{}
  19836. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19837. fmt.Println(dat)
  19838. } else {
  19839. fmt.Println(err)
  19840. }
  19841. saveLog(result2, src_resquest, "2207", "结算")
  19842. userJSONBytes, _ := json.Marshal(dat)
  19843. if miConfig.Code == "H15049901371" {
  19844. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19845. utils.ErrorLog("解析失败:%v", err)
  19846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19847. return
  19848. }
  19849. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19850. res.Output = resSeven10265.Output
  19851. res.ErrMsg = resSeven10265.ErrMsg
  19852. res.Cainfo = resSeven10265.Cainfo
  19853. res.WarnMsg = resSeven10265.WarnMsg
  19854. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19855. res.Infcode = infocode
  19856. } else {
  19857. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19858. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  19859. utils.ErrorLog("解析失败:%v", err)
  19860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19861. return
  19862. }
  19863. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  19864. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  19865. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  19866. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19867. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  19868. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  19869. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  19870. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19871. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  19872. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19873. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19874. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19875. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19876. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19877. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  19878. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  19879. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  19880. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  19881. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  19882. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  19883. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19884. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  19885. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  19886. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19887. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19888. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19889. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19890. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19891. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19892. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19893. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19894. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19895. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19896. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19897. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19898. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  19899. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  19900. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  19901. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19902. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  19903. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  19904. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  19905. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  19906. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  19907. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  19908. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  19909. res.ErrMsg = gzresSeven10265Two.ErrMsg
  19910. res.Cainfo = gzresSeven10265Two.Cainfo
  19911. res.WarnMsg = gzresSeven10265Two.WarnMsg
  19912. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  19913. //res.Infcode = infocode
  19914. } else {
  19915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19916. utils.ErrorLog("解析失败:%v", err)
  19917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19918. return
  19919. }
  19920. }
  19921. }
  19922. }
  19923. if res.Infcode != 0 {
  19924. errlog := &models.HisOrderError{
  19925. UserOrgId: adminUser.CurrentOrgId,
  19926. Ctime: time.Now().Unix(),
  19927. Mtime: time.Now().Unix(),
  19928. Number: chrg_bchno,
  19929. ErrMsg: res.ErrMsg,
  19930. Status: 1,
  19931. PatientId: id,
  19932. RecordTime: recordDateTime,
  19933. Stage: 6,
  19934. }
  19935. service.CreateErrMsgLog(errlog)
  19936. c.ServeSuccessJSON(map[string]interface{}{
  19937. "failed_code": -10,
  19938. "msg": res.ErrMsg,
  19939. })
  19940. return
  19941. } else {
  19942. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  19943. order.OrderStatus = 2
  19944. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  19945. order.SetlId = res.Output.Setlinfo.SetlID
  19946. order.PsnNo = res.Output.Setlinfo.PsnNo
  19947. order.PsnName = res.Output.Setlinfo.PsnName
  19948. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  19949. order.Certno = res.Output.Setlinfo.Certno
  19950. order.Gend = res.Output.Setlinfo.Gend
  19951. order.Naty = res.Output.Setlinfo.Naty
  19952. order.Age = res.Output.Setlinfo.Age
  19953. order.Insutype = res.Output.Setlinfo.Insutype
  19954. order.PsnType = res.Output.Setlinfo.PsnType
  19955. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  19956. order.SetlTime = res.Output.Setlinfo.SetlTime
  19957. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  19958. order.PayWays = pay_ways
  19959. order.AcctUsedFlag = acct_used_flag
  19960. order.WechatPay = wechat_pay
  19961. order.AliPay = ali_pay
  19962. order.JifenPay = jifen_pay
  19963. order.BandCardPay = band_card_pay
  19964. order.CashPay = cash_pay
  19965. order.OthDesc = oth_desc
  19966. //order.MedType = res.Output.Setlinfo.MedType
  19967. if reg_type == 1112 {
  19968. order.MedType = "1112"
  19969. }
  19970. if reg_type == 1111 {
  19971. order.MedType = "1111"
  19972. }
  19973. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  19974. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  19975. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  19976. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  19977. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  19978. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  19979. order.HifpPay = res.Output.Setlinfo.HifpPay
  19980. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  19981. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  19982. order.HifesPay = res.Output.Setlinfo.HifesPay
  19983. order.HifobPay = res.Output.Setlinfo.HifobPay
  19984. order.MafPay = res.Output.Setlinfo.MafPay
  19985. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  19986. order.OthPay = res.Output.Setlinfo.OthPay
  19987. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  19988. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  19989. order.AcctPay = res.Output.Setlinfo.AcctPay
  19990. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  19991. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  19992. order.Balc = res.Output.Setlinfo.Balc
  19993. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  19994. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  19995. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  19996. order.ClrWay = res.Output.Setlinfo.ClrWay
  19997. order.Creator = order.Creator
  19998. order.ClrType = res.Output.Setlinfo.ClrType
  19999. order.Modify = roles.AdminUserId
  20000. order.RequestLog = src_resquest
  20001. order.Diagnosis = diagnosis_id
  20002. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20003. detailStr := string(setlDetail)
  20004. order.SetlDetail = detailStr
  20005. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20006. err = service.UpDateOrder(order)
  20007. if err == nil {
  20008. //判断是否使用了押金
  20009. if dec_way == "true" {
  20010. tmpstring := strconv.FormatInt(order.ID, 10)
  20011. //扣押金
  20012. order.Decimal = decimal
  20013. service.UpDateOrder(order)
  20014. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20015. if errmsg != nil {
  20016. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20017. return
  20018. }
  20019. }
  20020. c.ServeSuccessJSON(map[string]interface{}{
  20021. "msg": "结算成功",
  20022. })
  20023. } else {
  20024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20025. return
  20026. }
  20027. }
  20028. }
  20029. }
  20030. }
  20031. // 上传明细-预结算-
  20032. func (c *HisApiController) GetPreUploadInfo() {
  20033. id, _ := c.GetInt64("id")
  20034. record_time := c.GetString("record_time")
  20035. his_patient_id, _ := c.GetInt64("his_patient_id")
  20036. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  20037. admin_user_id, _ := c.GetInt64("admin_user_id")
  20038. diagnosis_id := c.GetString("diagnosis")
  20039. sick_type, _ := c.GetInt64("sick_type")
  20040. reg_type, _ := c.GetInt64("p_type")
  20041. begin_time := c.GetString("begin_time")
  20042. acct_used_flag := c.GetString("acct_used_flag")
  20043. id_str := c.GetString("ids")
  20044. ids_arr := strings.Split(id_str, ",")
  20045. timeLayout := "2006-01-02"
  20046. loc, _ := time.LoadLocation("Local")
  20047. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  20048. if err != nil {
  20049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20050. return
  20051. }
  20052. recordDateTime := theTime.Unix()
  20053. adminUser := c.GetAdminUserInfo()
  20054. diagnosis_ids := strings.Split(diagnosis_id, ",")
  20055. var config []*models.HisXtDiagnoseConfig
  20056. for _, item := range diagnosis_ids {
  20057. id, _ := strconv.ParseInt(item, 10, 64)
  20058. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20059. config = append(config, &diagnosisConfig)
  20060. }
  20061. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  20062. sickConfig, _ := service.FindSickById(sick_type)
  20063. var prescriptions []*models.HisPrescription
  20064. var start_time int64
  20065. var end_time int64
  20066. var isSuccess bool = true
  20067. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20068. fmt.Println(his_patient_id)
  20069. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  20070. timestamp := time.Now().Unix()
  20071. tempTime := time.Unix(timestamp, 0)
  20072. timeFormat := tempTime.Format("20060102150405")
  20073. chrgBchno := rand.Intn(100000) + 10000
  20074. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  20075. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20076. var patientPrescription models.HisPrescriptionInfo
  20077. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  20078. if patientPrescription.ID == 0 {
  20079. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  20080. }
  20081. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20082. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  20083. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  20084. strconv.FormatInt(his.PatientId, 10)
  20085. var res2406 Result2406
  20086. //安徽单病种处理
  20087. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  20088. data := make(map[string]interface{})
  20089. client := &http.Client{}
  20090. data["psn_no"] = his.PsnNo
  20091. data["mdtrt_id"] = his.Number
  20092. data["operator"] = roles.UserName
  20093. data["cert_no"] = his.IdCardNo
  20094. data["org_name"] = miConfig.OrgName
  20095. data["psn_name"] = his.Name
  20096. data["ipt_otp_no"] = his.IptOtpNo
  20097. data["ipt_psn_sp_flag_type"] = "0901"
  20098. data["ipt_psn_sp_flag"] = "1"
  20099. data["fixmedins_code"] = miConfig.Code
  20100. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20101. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20102. data["url"] = miConfig.Url
  20103. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  20104. bytesData, _ := json.Marshal(data)
  20105. var req *http.Request
  20106. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  20107. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  20108. resp, _ := client.Do(req)
  20109. defer resp.Body.Close()
  20110. body, ioErr := ioutil.ReadAll(resp.Body)
  20111. if ioErr != nil {
  20112. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20114. return
  20115. }
  20116. var respJSON map[string]interface{}
  20117. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20120. return
  20121. }
  20122. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20123. if status == "0" {
  20124. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20125. c.ServeSuccessJSON(map[string]interface{}{
  20126. "failed_code": -10,
  20127. "msg": err_msg,
  20128. })
  20129. return
  20130. }
  20131. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20132. userJSONBytes, _ := json.Marshal(respJSON)
  20133. fmt.Println("log")
  20134. fmt.Println(string(userJSONBytes))
  20135. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  20136. utils.ErrorLog("解析失败:%v", err)
  20137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20138. return
  20139. }
  20140. }
  20141. if res2406.Infcode != 0 {
  20142. adminUser := c.GetAdminUserInfo()
  20143. errlog := &models.HisOrderError{
  20144. UserOrgId: adminUser.CurrentOrgId,
  20145. Ctime: time.Now().Unix(),
  20146. Mtime: time.Now().Unix(),
  20147. ErrMsg: res2406.ErrMsg,
  20148. Status: 1,
  20149. PatientId: id,
  20150. RecordTime: recordDateTime,
  20151. Stage: 3,
  20152. }
  20153. service.CreateErrMsgLog(errlog)
  20154. c.ServeSuccessJSON(map[string]interface{}{
  20155. "failed_code": -10,
  20156. "msg": res2406.ErrMsg,
  20157. })
  20158. return
  20159. }
  20160. var res2 ResultSix
  20161. var res3 GZResultSix
  20162. var resSix10265 ResultSix10265
  20163. //var time_stamp string
  20164. if miConfig.MdtrtareaAdmvs == "421300" {
  20165. data := make(map[string]interface{})
  20166. client := &http.Client{}
  20167. data["psn_no"] = his.PsnNo
  20168. data["mdtrt_id"] = his.Number
  20169. data["department"] = department.Name
  20170. data["org_name"] = miConfig.OrgName
  20171. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20172. data["doctor_id"] = doctor_info.DoctorNumber
  20173. data["doctor_name"] = roles.UserName
  20174. data["fixmedins_code"] = miConfig.Code
  20175. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20176. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20177. data["secret_key"] = miConfig.SecretKey
  20178. data["sick_code"] = sickConfig.CountryCode
  20179. data["sick_name"] = sickConfig.ClassName
  20180. data["begin_time"] = begin_time
  20181. data["dept"] = strconv.FormatInt(department.ID, 10)
  20182. data["config"] = config
  20183. data["opter"] = roles.UserName
  20184. fmt.Println(data)
  20185. bytesData, _ := json.Marshal(data)
  20186. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20187. resp, _ := client.Do(req)
  20188. defer resp.Body.Close()
  20189. body, ioErr := ioutil.ReadAll(resp.Body)
  20190. if ioErr != nil {
  20191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20193. return
  20194. }
  20195. var respJSON map[string]interface{}
  20196. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20199. return
  20200. }
  20201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20202. userJSONBytes, _ := json.Marshal(respJSON)
  20203. fmt.Println("log")
  20204. fmt.Println(string(userJSONBytes))
  20205. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20206. utils.ErrorLog("解析失败:%v", err)
  20207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20208. return
  20209. }
  20210. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20211. data := make(map[string]interface{})
  20212. client := &http.Client{}
  20213. data["psn_no"] = his.PsnNo
  20214. data["mdtrt_id"] = his.Number
  20215. data["department"] = department.Name
  20216. data["org_name"] = miConfig.OrgName
  20217. if reg_type == 11 && his.Insutype == "390" {
  20218. data["med_type"] = "110104"
  20219. } else {
  20220. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20221. }
  20222. data["doctor_id"] = doctor_info.DoctorNumber
  20223. data["doctor_name"] = roles.UserName
  20224. data["fixmedins_code"] = miConfig.Code
  20225. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20226. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20227. data["secret_key"] = miConfig.SecretKey
  20228. data["sick_code"] = sickConfig.CountryCode
  20229. data["sick_name"] = sickConfig.ClassName
  20230. data["begin_time"] = begin_time
  20231. data["dept"] = strconv.FormatInt(department.ID, 10)
  20232. data["config"] = config
  20233. data["opter"] = roles.UserName
  20234. fmt.Println(data)
  20235. bytesData, _ := json.Marshal(data)
  20236. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20237. resp, _ := client.Do(req)
  20238. defer resp.Body.Close()
  20239. body, ioErr := ioutil.ReadAll(resp.Body)
  20240. if ioErr != nil {
  20241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20243. return
  20244. }
  20245. var respJSON map[string]interface{}
  20246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20249. return
  20250. }
  20251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20252. userJSONBytes, _ := json.Marshal(respJSON)
  20253. fmt.Println("log")
  20254. fmt.Println(string(userJSONBytes))
  20255. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20256. utils.ErrorLog("解析失败:%v", err)
  20257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20258. return
  20259. }
  20260. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20261. data := make(map[string]interface{})
  20262. client := &http.Client{}
  20263. data["psn_no"] = his.PsnNo
  20264. data["mdtrt_id"] = his.Number
  20265. data["department"] = department.Name
  20266. data["org_name"] = miConfig.OrgName
  20267. if reg_type == 11 && his.Insutype == "390" {
  20268. data["med_type"] = "110104"
  20269. } else {
  20270. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20271. }
  20272. data["doctor_id"] = doctor_info.DoctorNumber
  20273. data["doctor_name"] = roles.UserName
  20274. data["fixmedins_code"] = miConfig.Code
  20275. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20276. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20277. data["secret_key"] = miConfig.SecretKey
  20278. data["sick_code"] = sickConfig.CountryCode
  20279. data["sick_name"] = sickConfig.ClassName
  20280. data["begin_time"] = begin_time
  20281. data["dept"] = strconv.FormatInt(department.ID, 10)
  20282. data["config"] = config
  20283. data["opter"] = roles.UserName
  20284. fmt.Println(data)
  20285. bytesData, _ := json.Marshal(data)
  20286. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  20287. resp, _ := client.Do(req)
  20288. defer resp.Body.Close()
  20289. body, ioErr := ioutil.ReadAll(resp.Body)
  20290. if ioErr != nil {
  20291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20293. return
  20294. }
  20295. var respJSON map[string]interface{}
  20296. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20299. return
  20300. }
  20301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20302. userJSONBytes, _ := json.Marshal(respJSON)
  20303. fmt.Println("log")
  20304. fmt.Println(string(userJSONBytes))
  20305. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20306. utils.ErrorLog("解析失败:%v", err)
  20307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20308. return
  20309. }
  20310. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20311. data := make(map[string]interface{})
  20312. client := &http.Client{}
  20313. data["psn_no"] = his.PsnNo
  20314. data["mdtrt_id"] = his.Number
  20315. data["doctor"] = roles.UserName
  20316. data["department"] = department.Name
  20317. data["org_name"] = miConfig.OrgName
  20318. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20319. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20320. data["fixmedins_code"] = miConfig.Code
  20321. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20322. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20323. data["secret_key"] = miConfig.SecretKey
  20324. data["sick_code"] = sickConfig.CountryCode
  20325. data["sick_name"] = sickConfig.ClassName
  20326. data["begin_time"] = begin_time
  20327. data["dept"] = strconv.FormatInt(department.ID, 10)
  20328. data["config"] = config
  20329. data["url"] = miConfig.Url
  20330. data["ak"] = miConfig.AccessKey
  20331. data["cainfo"] = miConfig.Cainfo
  20332. bytesData, _ := json.Marshal(data)
  20333. var req *http.Request
  20334. if miConfig.MdtrtareaAdmvs == "320921" {
  20335. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20336. } else {
  20337. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20338. }
  20339. resp, _ := client.Do(req)
  20340. defer resp.Body.Close()
  20341. body, ioErr := ioutil.ReadAll(resp.Body)
  20342. if ioErr != nil {
  20343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20345. return
  20346. }
  20347. var respJSON map[string]interface{}
  20348. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20351. return
  20352. }
  20353. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20354. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20355. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20357. userJSONBytes, _ := json.Marshal(respJSON)
  20358. fmt.Println("log")
  20359. fmt.Println(string(userJSONBytes))
  20360. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20361. utils.ErrorLog("解析失败:%v", err)
  20362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20363. return
  20364. }
  20365. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20366. res2.Output = resSix10265.Output
  20367. res2.ErrMsg = resSix10265.ErrMsg
  20368. res2.Cainfo = resSix10265.Cainfo
  20369. res2.WarnMsg = resSix10265.WarnMsg
  20370. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20371. res2.Infcode = infocode
  20372. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20373. data := make(map[string]interface{})
  20374. client := &http.Client{}
  20375. data["psn_no"] = his.PsnNo
  20376. data["mdtrt_id"] = his.Number
  20377. data["doctor"] = roles.UserName
  20378. data["department"] = department.Name
  20379. data["org_name"] = miConfig.OrgName
  20380. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20381. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20382. data["fixmedins_code"] = miConfig.Code
  20383. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20384. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20385. data["secret_key"] = miConfig.SecretKey
  20386. data["sick_code"] = sickConfig.CountryCode
  20387. data["sick_name"] = sickConfig.ClassName
  20388. data["begin_time"] = begin_time
  20389. data["dept"] = strconv.FormatInt(department.ID, 10)
  20390. data["config"] = config
  20391. //data["url"] = miConfig.Url
  20392. //data["ak"] = miConfig.AccessKey
  20393. data["cainfo"] = miConfig.Cainfo
  20394. fmt.Println(data)
  20395. bytesData, _ := json.Marshal(data)
  20396. var req *http.Request
  20397. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  20398. resp, _ := client.Do(req)
  20399. defer resp.Body.Close()
  20400. body, ioErr := ioutil.ReadAll(resp.Body)
  20401. if ioErr != nil {
  20402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20404. return
  20405. }
  20406. var respJSON map[string]interface{}
  20407. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20410. return
  20411. }
  20412. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20413. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20414. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20416. userJSONBytes, _ := json.Marshal(respJSON)
  20417. fmt.Println("log")
  20418. fmt.Println(string(userJSONBytes))
  20419. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20420. utils.ErrorLog("解析失败:%v", err)
  20421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20422. return
  20423. }
  20424. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20425. res2.Output = resSix10265.Output
  20426. res2.ErrMsg = resSix10265.ErrMsg
  20427. res2.Cainfo = resSix10265.Cainfo
  20428. res2.WarnMsg = resSix10265.WarnMsg
  20429. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20430. res2.Infcode = infocode
  20431. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20432. 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)
  20433. saveLog(result, requestLog, "2203", "上传就诊信息")
  20434. var respJSON2 map[string]interface{}
  20435. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20438. return
  20439. }
  20440. userJSONBytes2, _ := json.Marshal(respJSON2)
  20441. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20442. utils.ErrorLog("解析失败:%v", err)
  20443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20444. return
  20445. }
  20446. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20447. var result string
  20448. var requestLog string
  20449. 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, "")
  20450. saveLog(result, requestLog, "2203", "上传就诊信息")
  20451. var respJSON2 map[string]interface{}
  20452. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20455. return
  20456. }
  20457. userJSONBytes2, _ := json.Marshal(respJSON2)
  20458. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20459. utils.ErrorLog("解析失败:%v", err)
  20460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20461. return
  20462. }
  20463. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20464. data := make(map[string]interface{})
  20465. client := &http.Client{}
  20466. data["psn_no"] = his.PsnNo
  20467. data["mdtrt_id"] = his.Number
  20468. data["operator"] = roles.UserName
  20469. data["department"] = department.Name
  20470. data["org_name"] = miConfig.OrgName
  20471. var med_type string
  20472. if his.Insutype == "390" {
  20473. if reg_type == 992102 {
  20474. med_type = "992102"
  20475. data["sick_code"] = "ZDZ940"
  20476. data["sick_name"] = "慢性肾衰竭"
  20477. }
  20478. if reg_type == 140104 {
  20479. med_type = "140104"
  20480. data["sick_code"] = sickConfig.CountryCode
  20481. data["sick_name"] = sickConfig.ClassName
  20482. }
  20483. if reg_type == 14 {
  20484. med_type = "140104"
  20485. data["sick_code"] = sickConfig.CountryCode
  20486. data["sick_name"] = sickConfig.ClassName
  20487. }
  20488. } else if his.Insutype == "310" {
  20489. if reg_type == 992102 {
  20490. med_type = "992102"
  20491. data["sick_code"] = "ZDZ940"
  20492. data["sick_name"] = "慢性肾衰竭"
  20493. }
  20494. if reg_type == 140104 {
  20495. med_type = "140104"
  20496. data["sick_code"] = sickConfig.CountryCode
  20497. data["sick_name"] = sickConfig.ClassName
  20498. }
  20499. if reg_type == 14 {
  20500. med_type = "14"
  20501. data["sick_code"] = sickConfig.CountryCode
  20502. data["sick_name"] = sickConfig.ClassName
  20503. }
  20504. }
  20505. data["med_type"] = med_type
  20506. data["doctor_number"] = doctor_info.DoctorNumber
  20507. data["doctor_name"] = doctor_info.UserName
  20508. data["fixmedins_code"] = miConfig.Code
  20509. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20510. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20511. data["secret_key"] = miConfig.SecretKey
  20512. data["begin_time"] = begin_time
  20513. data["dept"] = strconv.FormatInt(department.ID, 10)
  20514. data["config"] = config
  20515. data["url"] = miConfig.Url
  20516. data["ak"] = miConfig.AccessKey
  20517. data["cainfo"] = miConfig.Cainfo
  20518. bytesData, _ := json.Marshal(data)
  20519. var req *http.Request
  20520. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  20521. resp, _ := client.Do(req)
  20522. defer resp.Body.Close()
  20523. body, ioErr := ioutil.ReadAll(resp.Body)
  20524. if ioErr != nil {
  20525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20527. return
  20528. }
  20529. var respJSON map[string]interface{}
  20530. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20533. return
  20534. }
  20535. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20536. if status == "0" {
  20537. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20538. c.ServeSuccessJSON(map[string]interface{}{
  20539. "failed_code": -10,
  20540. "msg": err_msg,
  20541. })
  20542. return
  20543. }
  20544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20545. userJSONBytes, _ := json.Marshal(respJSON)
  20546. fmt.Println("log")
  20547. fmt.Println(string(userJSONBytes))
  20548. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20549. utils.ErrorLog("解析失败:%v", err)
  20550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20551. return
  20552. }
  20553. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20554. var result string
  20555. var requestLog string
  20556. 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, "")
  20557. saveLog(result, requestLog, "2203", "上传就诊信息")
  20558. var respJSON2 map[string]interface{}
  20559. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20562. return
  20563. }
  20564. userJSONBytes2, _ := json.Marshal(respJSON2)
  20565. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20566. utils.ErrorLog("解析失败:%v", err)
  20567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20568. return
  20569. }
  20570. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20571. data := make(map[string]interface{})
  20572. client := &http.Client{}
  20573. data["psn_no"] = his.PsnNo
  20574. data["mdtrt_id"] = his.Number
  20575. data["doctor"] = roles.UserName
  20576. data["department"] = department.Name
  20577. data["org_name"] = miConfig.OrgName
  20578. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20579. data["doctor_id"] = doctor_info.DoctorNumber
  20580. data["fixmedins_code"] = miConfig.Code
  20581. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20582. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20583. data["secret_key"] = miConfig.SecretKey
  20584. data["sick_code"] = sickConfig.CountryCode
  20585. data["sick_name"] = sickConfig.ClassName
  20586. data["begin_time"] = begin_time
  20587. data["new_doctor_name"] = doctor_info.UserName
  20588. data["dept"] = strconv.FormatInt(department.ID, 10)
  20589. data["config"] = config
  20590. bytesData, _ := json.Marshal(data)
  20591. var req *http.Request
  20592. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  20593. resp, _ := client.Do(req)
  20594. defer resp.Body.Close()
  20595. body, ioErr := ioutil.ReadAll(resp.Body)
  20596. if ioErr != nil {
  20597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20599. return
  20600. }
  20601. var respJSON map[string]interface{}
  20602. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20605. return
  20606. }
  20607. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20608. userJSONBytes, _ := json.Marshal(respJSON)
  20609. fmt.Println("log")
  20610. fmt.Println(string(userJSONBytes))
  20611. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20612. utils.ErrorLog("解析失败:%v", err)
  20613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20614. return
  20615. }
  20616. } else {
  20617. var result string
  20618. var requestLog string
  20619. if miConfig.MdtrtareaAdmvs == "440781" { //
  20620. 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)
  20621. } else {
  20622. if miConfig.Code == "H15049901371" {
  20623. //赤峰地区国家医保医疗类别
  20624. //职工透析:医疗类别选特殊情况门诊990502
  20625. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20626. var med_type string
  20627. if his.Insutype == "390" {
  20628. if reg_type == 14 {
  20629. med_type = "9933"
  20630. } else if reg_type == 11 {
  20631. med_type = "11"
  20632. }
  20633. } else if his.Insutype == "310" {
  20634. if reg_type == 14 {
  20635. med_type = "990502"
  20636. } else if reg_type == 11 {
  20637. med_type = "11"
  20638. }
  20639. }
  20640. 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)
  20641. } else {
  20642. 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)
  20643. }
  20644. saveLog(result, requestLog, "2203", "上传就诊信息")
  20645. var respJSON2 map[string]interface{}
  20646. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20649. return
  20650. }
  20651. userJSONBytes2, _ := json.Marshal(respJSON2)
  20652. if miConfig.Code == "H15049901371" {
  20653. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  20654. utils.ErrorLog("解析失败:%v", err)
  20655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20656. return
  20657. }
  20658. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20659. res2.Output = resSix10265.Output
  20660. res2.ErrMsg = resSix10265.ErrMsg
  20661. res2.Cainfo = resSix10265.Cainfo
  20662. res2.WarnMsg = resSix10265.WarnMsg
  20663. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20664. res2.Infcode = infocode
  20665. } else {
  20666. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20667. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  20668. utils.ErrorLog("解析失败:%v", err)
  20669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20670. return
  20671. }
  20672. res2.Infcode = res3.Infcode
  20673. } else {
  20674. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20675. utils.ErrorLog("解析失败:%v", err)
  20676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20677. return
  20678. }
  20679. }
  20680. }
  20681. }
  20682. }
  20683. if res2.Infcode == -1 {
  20684. adminUser := c.GetAdminUserInfo()
  20685. errlog := &models.HisOrderError{
  20686. UserOrgId: adminUser.CurrentOrgId,
  20687. Ctime: time.Now().Unix(),
  20688. Mtime: time.Now().Unix(),
  20689. ErrMsg: res2.ErrMsg,
  20690. Status: 1,
  20691. PatientId: id,
  20692. RecordTime: recordDateTime,
  20693. Stage: 3,
  20694. }
  20695. service.CreateErrMsgLog(errlog)
  20696. c.ServeSuccessJSON(map[string]interface{}{
  20697. "failed_code": -10,
  20698. "msg": res2.ErrMsg,
  20699. })
  20700. return
  20701. }
  20702. if res2.Infcode != 0 {
  20703. adminUser := c.GetAdminUserInfo()
  20704. errlog := &models.HisOrderError{
  20705. UserOrgId: adminUser.CurrentOrgId,
  20706. Ctime: time.Now().Unix(),
  20707. Mtime: time.Now().Unix(),
  20708. ErrMsg: res2.ErrMsg,
  20709. Status: 1,
  20710. PatientId: id,
  20711. RecordTime: recordDateTime,
  20712. Stage: 3,
  20713. }
  20714. service.CreateErrMsgLog(errlog)
  20715. c.ServeSuccessJSON(map[string]interface{}{
  20716. "failed_code": -10,
  20717. "msg": res2.ErrMsg,
  20718. })
  20719. return
  20720. } else {
  20721. his.Diagnosis = diagnosis_id
  20722. his.SickType = sickConfig.ID
  20723. his.PType = fmt.Sprintf("%d", reg_type)
  20724. service.UpdateHisPatientThree(&his)
  20725. data := make(map[string]interface{})
  20726. if settle_accounts_type == 1 { //日结
  20727. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  20728. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  20729. } else {
  20730. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  20731. }
  20732. data["pre"] = prescriptions
  20733. } else { //月结
  20734. start_time_str := c.GetString("start_time")
  20735. end_time_str := c.GetString("end_time")
  20736. timeLayout := "2006-01-02"
  20737. loc, _ := time.LoadLocation("Local")
  20738. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  20739. if err != nil {
  20740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20741. return
  20742. }
  20743. recordStartTime := theStartTime.Unix()
  20744. start_time = recordStartTime
  20745. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  20746. if err != nil {
  20747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20748. return
  20749. }
  20750. recordEndTime := theEndTime.Unix()
  20751. end_time = recordEndTime
  20752. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  20753. data["pre"] = prescriptions
  20754. }
  20755. client := &http.Client{}
  20756. data["psn_no"] = his.PsnNo
  20757. data["mdtrt_id"] = his.Number
  20758. data["chrg_bchno"] = chrg_bchno
  20759. data["org_name"] = miConfig.OrgName
  20760. data["doctor"] = doctor_info.UserName
  20761. data["doctor_id"] = doctor_info.DoctorNumber
  20762. data["dept"] = department.Name
  20763. data["fixmedins_code"] = miConfig.Code
  20764. data["opter"] = roles.UserName
  20765. data["dept_code"] = department.Number
  20766. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20767. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20768. data["secret_key"] = miConfig.SecretKey
  20769. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  20770. data["url"] = miConfig.Url
  20771. data["ak"] = miConfig.AccessKey
  20772. data["new_doctor_name"] = patientPrescription.Doctor
  20773. if his.Insutype == "390" {
  20774. if reg_type == 992102 {
  20775. data["diag_code"] = "ZDZ940"
  20776. }
  20777. if reg_type == 140104 {
  20778. data["diag_code"] = sickConfig.CountryCode
  20779. }
  20780. if reg_type == 14 {
  20781. data["diag_code"] = sickConfig.CountryCode
  20782. }
  20783. } else if his.Insutype == "310" {
  20784. if reg_type == 992102 {
  20785. data["diag_code"] = "ZDZ940"
  20786. }
  20787. if reg_type == 14 {
  20788. data["diag_code"] = sickConfig.CountryCode
  20789. }
  20790. }
  20791. data["cainfo"] = miConfig.Cainfo
  20792. data["opter"] = roles.UserName
  20793. var ids []int64
  20794. for _, item := range prescriptions {
  20795. ids = append(ids, item.ID)
  20796. }
  20797. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  20798. if config.IsOpen == 1 { //对接了医保,走医保流程
  20799. var res ResultFour
  20800. var resFour10265 ResultFour10265
  20801. if miConfig.MdtrtareaAdmvs == "421300" {
  20802. bytesData, _ := json.Marshal(data)
  20803. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  20804. resp, _ := client.Do(req)
  20805. defer resp.Body.Close()
  20806. body, ioErr := ioutil.ReadAll(resp.Body)
  20807. if ioErr != nil {
  20808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20810. return
  20811. }
  20812. var respJSON map[string]interface{}
  20813. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20816. return
  20817. }
  20818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20819. userJSONBytes, _ := json.Marshal(respJSON)
  20820. fmt.Println("log")
  20821. fmt.Println(string(userJSONBytes))
  20822. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20823. utils.ErrorLog("解析失败:%v", err)
  20824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20825. return
  20826. }
  20827. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20828. bytesData, _ := json.Marshal(data)
  20829. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  20830. resp, _ := client.Do(req)
  20831. defer resp.Body.Close()
  20832. body, ioErr := ioutil.ReadAll(resp.Body)
  20833. if ioErr != nil {
  20834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20836. return
  20837. }
  20838. var respJSON map[string]interface{}
  20839. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20842. return
  20843. }
  20844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20845. userJSONBytes, _ := json.Marshal(respJSON)
  20846. fmt.Println("log")
  20847. fmt.Println(string(userJSONBytes))
  20848. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20849. utils.ErrorLog("解析失败:%v", err)
  20850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20851. return
  20852. }
  20853. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20854. bytesData, _ := json.Marshal(data)
  20855. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  20856. resp, _ := client.Do(req)
  20857. defer resp.Body.Close()
  20858. body, ioErr := ioutil.ReadAll(resp.Body)
  20859. if ioErr != nil {
  20860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20862. return
  20863. }
  20864. var respJSON map[string]interface{}
  20865. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20868. return
  20869. }
  20870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20871. userJSONBytes, _ := json.Marshal(respJSON)
  20872. fmt.Println("log")
  20873. fmt.Println(string(userJSONBytes))
  20874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20875. utils.ErrorLog("解析失败:%v", err)
  20876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20877. return
  20878. }
  20879. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20880. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  20881. if result3101.Infcode == "0" {
  20882. if len(result3101.Output.Result) > 0 {
  20883. var errMsgs []string
  20884. for _, item := range result3101.Output.Result {
  20885. errMsgs = append(errMsgs, item.VolaCont)
  20886. }
  20887. c.ServeSuccessJSON(map[string]interface{}{
  20888. "failed_code": -10,
  20889. "msg": errMsgs,
  20890. })
  20891. return
  20892. } else {
  20893. if miConfig.MdtrtareaAdmvs == "320921" {
  20894. data["doctor_id"] = "D320923012139"
  20895. } else {
  20896. data["doctor_id"] = "D371621008686"
  20897. }
  20898. bytesData, _ := json.Marshal(data)
  20899. var req *http.Request
  20900. if miConfig.MdtrtareaAdmvs == "320921" {
  20901. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20902. } else {
  20903. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20904. }
  20905. resp, _ := client.Do(req)
  20906. defer resp.Body.Close()
  20907. body, ioErr := ioutil.ReadAll(resp.Body)
  20908. if ioErr != nil {
  20909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20911. return
  20912. }
  20913. var respJSON map[string]interface{}
  20914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20917. return
  20918. }
  20919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20920. userJSONBytes, _ := json.Marshal(respJSON)
  20921. fmt.Println("log")
  20922. fmt.Println(string(userJSONBytes))
  20923. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20924. utils.ErrorLog("解析失败:%v", err)
  20925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20926. return
  20927. }
  20928. res.InfRefmsgid = resFour10265.InfRefmsgid
  20929. res.Output = resFour10265.Output
  20930. res.ErrMsg = resFour10265.ErrMsg
  20931. res.Cainfo = resFour10265.Cainfo
  20932. res.WarnMsg = resFour10265.WarnMsg
  20933. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20934. res.Infcode = infocode
  20935. }
  20936. }
  20937. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20938. var pagesize int = 5
  20939. var start int = 1
  20940. var stop int
  20941. var pagecount int
  20942. var curpage int
  20943. data["doctor_id"] = doctor_info.DoctorNumber
  20944. var res2 ResultFour
  20945. //var result res.
  20946. //总页数,向上取整,注意除之前要先转换类型为float64
  20947. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  20948. for curpage = 1; curpage <= pagecount; curpage++ {
  20949. if curpage == 1 {
  20950. start = 1
  20951. } else {
  20952. start = (curpage-1)*pagesize + 1
  20953. }
  20954. stop = curpage * pagesize
  20955. if stop > len(prescriptions) {
  20956. stop = len(prescriptions)
  20957. }
  20958. //var requestLog string
  20959. data["pre"] = prescriptions[start-1 : stop]
  20960. fmt.Println(data["pre"])
  20961. bytesData, _ := json.Marshal(data)
  20962. var req *http.Request
  20963. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  20964. resp, _ := client.Do(req)
  20965. defer resp.Body.Close()
  20966. body, ioErr := ioutil.ReadAll(resp.Body)
  20967. if ioErr != nil {
  20968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20970. return
  20971. }
  20972. var respJSON map[string]interface{}
  20973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20976. return
  20977. }
  20978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20979. userJSONBytes, _ := json.Marshal(respJSON)
  20980. fmt.Println("log")
  20981. fmt.Println(string(userJSONBytes))
  20982. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20983. utils.ErrorLog("解析失败:%v", err)
  20984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20985. return
  20986. }
  20987. res.InfRefmsgid = resFour10265.InfRefmsgid
  20988. res.Output = resFour10265.Output
  20989. res.ErrMsg = resFour10265.ErrMsg
  20990. res.Cainfo = resFour10265.Cainfo
  20991. res.WarnMsg = resFour10265.WarnMsg
  20992. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20993. res.Infcode = infocode
  20994. if infocode == 0 {
  20995. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  20996. } else {
  20997. isSuccess = false
  20998. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  20999. res.Infcode = -1
  21000. res.ErrMsg = resFour10265.ErrMsg
  21001. errlog := &models.HisOrderError{
  21002. UserOrgId: adminUser.CurrentOrgId,
  21003. Ctime: time.Now().Unix(),
  21004. Mtime: time.Now().Unix(),
  21005. Number: chrg_bchno,
  21006. ErrMsg: "",
  21007. Status: 1,
  21008. PatientId: id,
  21009. RecordTime: recordDateTime,
  21010. Stage: 4,
  21011. }
  21012. service.CreateErrMsgLog(errlog)
  21013. }
  21014. }
  21015. if isSuccess {
  21016. res.Infcode = 0
  21017. res.Output.Result = res2.Output.Result
  21018. } else {
  21019. order := &models.HisOrder{
  21020. UserOrgId: adminUser.CurrentOrgId,
  21021. HisPatientId: his.ID,
  21022. PatientId: his.PatientId,
  21023. SettleAccountsDate: recordDateTime,
  21024. Ctime: time.Now().Unix(),
  21025. Mtime: time.Now().Unix(),
  21026. MdtrtId: his.Number,
  21027. PsnNo: his.PsnNo,
  21028. MedType: strconv.FormatInt(reg_type, 10),
  21029. Status: 1,
  21030. Number: chrg_bchno,
  21031. Infcode: res.Infcode,
  21032. WarnMsg: res.WarnMsg,
  21033. Cainfo: res.Cainfo,
  21034. ErrMsg: res.ErrMsg,
  21035. RespondTime: res.RefmsgTime,
  21036. InfRefmsgid: res.InfRefmsgid,
  21037. OrderStatus: 1,
  21038. IsMedicineInsurance: 1,
  21039. SettleType: settle_accounts_type,
  21040. SettleStartTime: start_time,
  21041. SettleEndTime: end_time,
  21042. Creator: roles.AdminUserId,
  21043. Modify: roles.AdminUserId,
  21044. PType: 2,
  21045. Diagnosis: diagnosis_id,
  21046. }
  21047. err = service.CreateOrder(order)
  21048. if err != nil {
  21049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21050. return
  21051. }
  21052. c.ServeSuccessJSON(map[string]interface{}{
  21053. "failed_code": -10,
  21054. "msg": res2.ErrMsg,
  21055. })
  21056. return
  21057. }
  21058. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21059. 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)
  21060. var dat map[string]interface{}
  21061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21062. fmt.Println(dat)
  21063. } else {
  21064. fmt.Println(err)
  21065. }
  21066. saveLog(result, request_log, "2204", "上传费用明细")
  21067. userJSONBytes, _ := json.Marshal(dat)
  21068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21069. utils.ErrorLog("解析失败:%v", err)
  21070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21071. return
  21072. }
  21073. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21074. 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, "", "")
  21075. var dat map[string]interface{}
  21076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21077. fmt.Println(dat)
  21078. } else {
  21079. fmt.Println(err)
  21080. }
  21081. saveLog(result, request_log, "2204", "上传费用明细")
  21082. userJSONBytes, _ := json.Marshal(dat)
  21083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21084. utils.ErrorLog("解析失败:%v", err)
  21085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21086. return
  21087. }
  21088. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21089. bytesData, _ := json.Marshal(data)
  21090. var req *http.Request
  21091. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  21092. resp, _ := client.Do(req)
  21093. defer resp.Body.Close()
  21094. body, ioErr := ioutil.ReadAll(resp.Body)
  21095. if ioErr != nil {
  21096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21098. return
  21099. }
  21100. var respJSON map[string]interface{}
  21101. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21104. return
  21105. }
  21106. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21107. if status == "0" {
  21108. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21109. c.ServeSuccessJSON(map[string]interface{}{
  21110. "failed_code": -10,
  21111. "msg": err_msg,
  21112. })
  21113. return
  21114. }
  21115. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21116. userJSONBytes, _ := json.Marshal(respJSON)
  21117. fmt.Println("log")
  21118. fmt.Println(string(userJSONBytes))
  21119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21120. utils.ErrorLog("解析失败:%v", err)
  21121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21122. return
  21123. }
  21124. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21125. 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, "", "")
  21126. var dat map[string]interface{}
  21127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21128. fmt.Println(dat)
  21129. } else {
  21130. fmt.Println(err)
  21131. }
  21132. saveLog(result, request_log, "2204", "上传费用明细")
  21133. userJSONBytes, _ := json.Marshal(dat)
  21134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21135. utils.ErrorLog("解析失败:%v", err)
  21136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21137. return
  21138. }
  21139. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21140. bytesData, _ := json.Marshal(data)
  21141. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  21142. resp, _ := client.Do(req)
  21143. defer resp.Body.Close()
  21144. body, ioErr := ioutil.ReadAll(resp.Body)
  21145. if ioErr != nil {
  21146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21148. return
  21149. }
  21150. var respJSON map[string]interface{}
  21151. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21154. return
  21155. }
  21156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21157. userJSONBytes, _ := json.Marshal(respJSON)
  21158. fmt.Println("log")
  21159. fmt.Println(string(userJSONBytes))
  21160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21161. utils.ErrorLog("解析失败:%v", err)
  21162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21163. return
  21164. }
  21165. } else {
  21166. if miConfig.MdtrtareaAdmvs == "441202" {
  21167. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  21168. if result3101.Infcode == 0 {
  21169. if len(result3101.Output.Result) > 0 {
  21170. var errMsgs []string
  21171. for _, item := range result3101.Output.Result {
  21172. errMsgs = append(errMsgs, item.VolaCont)
  21173. }
  21174. c.ServeSuccessJSON(map[string]interface{}{
  21175. "failed_code": -10,
  21176. "msg": errMsgs,
  21177. })
  21178. return
  21179. } else {
  21180. 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)
  21181. var dat map[string]interface{}
  21182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21183. fmt.Println(dat)
  21184. } else {
  21185. fmt.Println(err)
  21186. }
  21187. saveLog(result, request_log, "2204", "上传费用明细")
  21188. userJSONBytes, _ := json.Marshal(dat)
  21189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21190. utils.ErrorLog("解析失败:%v", err)
  21191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21192. return
  21193. }
  21194. }
  21195. } else {
  21196. c.ServeSuccessJSON(map[string]interface{}{
  21197. "failed_code": -10,
  21198. "msg": result3101.ErrMsg,
  21199. })
  21200. return
  21201. }
  21202. } else {
  21203. if miConfig.Code == "H15049901371" {
  21204. 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)
  21205. var dat map[string]interface{}
  21206. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21207. fmt.Println(dat)
  21208. } else {
  21209. fmt.Println(err)
  21210. }
  21211. saveLog(result, request_log, "2204", "上传费用明细")
  21212. userJSONBytes, _ := json.Marshal(dat)
  21213. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21214. utils.ErrorLog("解析失败:%v", err)
  21215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21216. return
  21217. }
  21218. res.InfRefmsgid = resFour10265.InfRefmsgid
  21219. res.Output = resFour10265.Output
  21220. res.ErrMsg = resFour10265.ErrMsg
  21221. res.Cainfo = resFour10265.Cainfo
  21222. res.WarnMsg = resFour10265.WarnMsg
  21223. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21224. res.Infcode = infocode
  21225. } else {
  21226. 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)
  21227. var dat map[string]interface{}
  21228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21229. fmt.Println(dat)
  21230. } else {
  21231. fmt.Println(err)
  21232. }
  21233. saveLog(result, request_log, "2204", "上传费用明细")
  21234. userJSONBytes, _ := json.Marshal(dat)
  21235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21236. utils.ErrorLog("解析失败:%v", err)
  21237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21238. return
  21239. }
  21240. }
  21241. }
  21242. }
  21243. var total_two float64
  21244. if res.Infcode == 0 {
  21245. order := &models.HisOrder{
  21246. UserOrgId: adminUser.CurrentOrgId,
  21247. HisPatientId: his.ID,
  21248. PatientId: his.PatientId,
  21249. SettleAccountsDate: recordDateTime,
  21250. Ctime: time.Now().Unix(),
  21251. Mtime: time.Now().Unix(),
  21252. MdtrtId: his.Number,
  21253. PsnNo: his.PsnNo,
  21254. MedType: strconv.FormatInt(reg_type, 10),
  21255. Status: 1,
  21256. Number: chrg_bchno,
  21257. Infcode: res.Infcode,
  21258. WarnMsg: res.WarnMsg,
  21259. Cainfo: res.Cainfo,
  21260. ErrMsg: res.ErrMsg,
  21261. RespondTime: res.RefmsgTime,
  21262. InfRefmsgid: res.InfRefmsgid,
  21263. OrderStatus: 1,
  21264. IsMedicineInsurance: 1,
  21265. SettleType: settle_accounts_type,
  21266. SettleStartTime: start_time,
  21267. SettleEndTime: end_time,
  21268. Creator: roles.AdminUserId,
  21269. Modify: roles.AdminUserId,
  21270. PType: 2,
  21271. Diagnosis: diagnosis_id,
  21272. }
  21273. err = service.CreateOrder(order)
  21274. if err != nil {
  21275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21276. return
  21277. }
  21278. for _, item := range res.Output.Result {
  21279. temp := strings.Split(item.FeedetlSn, "-")
  21280. var advice_id int64 = 0
  21281. var project_id int64 = 0
  21282. var types int64 = 0
  21283. id, _ := strconv.ParseInt(temp[2], 10, 64)
  21284. types, _ = strconv.ParseInt(temp[1], 10, 64)
  21285. if temp[1] == "1" {
  21286. advice_id = id
  21287. project_id = 0
  21288. } else if temp[1] == "2" {
  21289. advice_id = 0
  21290. project_id = id
  21291. }
  21292. total_two = total_two + item.DetItemFeeSumamt
  21293. info := &models.HisOrderInfo{
  21294. OrderNumber: order.Number,
  21295. FeedetlSn: item.FeedetlSn,
  21296. UploadDate: time.Now().Unix(),
  21297. AdviceId: advice_id,
  21298. DetItemFeeSumamt: item.DetItemFeeSumamt,
  21299. Cnt: item.Cnt,
  21300. Pric: float64(item.Pric),
  21301. PatientId: his.PatientId,
  21302. PricUplmtAmt: item.PricUplmtAmt,
  21303. SelfpayProp: item.SelfpayProp,
  21304. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  21305. OverlmtAmt: item.OverlmtAmt,
  21306. PreselfpayAmt: item.PreselfpayAmt,
  21307. BasMednFlag: item.BasMednFlag,
  21308. MedChrgitmType: item.MedChrgitmType,
  21309. HiNegoDrugFlag: item.HiNegoDrugFlag,
  21310. Status: 1,
  21311. Memo: item.Memo,
  21312. Mtime: time.Now().Unix(),
  21313. InscpScpAmt: item.InscpScpAmt,
  21314. DrtReimFlag: item.DrtReimFlag,
  21315. Ctime: time.Now().Unix(),
  21316. ListSpItemFlag: item.ListSpItemFlag,
  21317. ChldMedcFlag: item.ChldMedcFlag,
  21318. LmtUsedFlag: item.LmtUsedFlag,
  21319. ChrgitmLv: item.ChrgitmLv,
  21320. UserOrgId: adminUser.CurrentOrgId,
  21321. HisPatientId: his.ID,
  21322. OrderId: order.ID,
  21323. ProjectId: project_id,
  21324. Type: types,
  21325. }
  21326. service.CreateOrderInfo(info)
  21327. }
  21328. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  21329. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  21330. var total float64
  21331. for _, item := range prescriptions {
  21332. if item.Type == 1 { //药品
  21333. for _, subItem := range item.HisDoctorAdviceInfo {
  21334. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21335. total_one := price * subItem.PrescribingNumber
  21336. fmt.Println("subItem")
  21337. fmt.Println(subItem.Price)
  21338. fmt.Println("price")
  21339. fmt.Println(price)
  21340. fmt.Println("total_one")
  21341. fmt.Println(total_one)
  21342. total = total + total_one
  21343. fmt.Println(total)
  21344. }
  21345. }
  21346. if item.Type == 2 { //项目
  21347. for _, subItem := range item.HisPrescriptionProject {
  21348. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  21349. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21350. total_one := price * cnt
  21351. total = total + total_one
  21352. }
  21353. }
  21354. }
  21355. allTotal := fmt.Sprintf("%.2f", total)
  21356. if res.Infcode == 0 {
  21357. var rf []*ResultFive
  21358. json.Unmarshal([]byte(his.Iinfo), &rf)
  21359. chrg_bchno := chrg_bchno
  21360. cert_no := his.Certno
  21361. var insutypes []string
  21362. var insutype string
  21363. var is390 int = 0
  21364. var is310 int = 0
  21365. for _, item := range rf {
  21366. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21367. insutypes = append(insutypes, item.Insutype)
  21368. }
  21369. }
  21370. if len(insutypes) == 1 {
  21371. insutype = insutypes[0]
  21372. } else {
  21373. for _, i := range insutypes {
  21374. if i == "390" {
  21375. is390 = 1
  21376. }
  21377. if i == "310" {
  21378. is310 = 1
  21379. }
  21380. }
  21381. }
  21382. if is390 == 1 {
  21383. insutype = "390"
  21384. }
  21385. if is310 == 1 {
  21386. insutype = "310"
  21387. }
  21388. if len(insutypes) == 0 {
  21389. insutype = "390"
  21390. }
  21391. if len(insutypes) == 2 {
  21392. insutype = strconv.FormatInt(his.SocialType, 10)
  21393. }
  21394. //insutype = "390"
  21395. if his.IdCardType == 1 {
  21396. cert_no = his.MedicalInsuranceNumber
  21397. } else {
  21398. cert_no = his.Certno
  21399. }
  21400. var res ResultSeven
  21401. var ahres ResultSevenAH
  21402. var resSeven10265 ResultSeven10265
  21403. var resSeven10265Two ResultSeven10265Two
  21404. var gzresSeven10265Two GZResultSeven10265Two
  21405. if miConfig.MdtrtareaAdmvs == "421300" {
  21406. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  21407. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21408. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21409. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21410. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21411. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21412. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21413. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21414. resp, requestErr := http.Get(api)
  21415. if requestErr != nil {
  21416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21417. return
  21418. }
  21419. body, ioErr := ioutil.ReadAll(resp.Body)
  21420. if ioErr != nil {
  21421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21423. return
  21424. }
  21425. var respJSON map[string]interface{}
  21426. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21429. return
  21430. }
  21431. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21432. result, _ := json.Marshal(respJSON)
  21433. fmt.Println("log")
  21434. fmt.Println(string(result))
  21435. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21436. utils.ErrorLog("解析失败:%v", err)
  21437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21438. return
  21439. }
  21440. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21441. if reg_type == 11 && his.Insutype == "390" {
  21442. reg_type = 110104
  21443. }
  21444. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21445. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21446. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21447. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21448. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21449. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21450. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21451. resp, requestErr := http.Get(api)
  21452. if requestErr != nil {
  21453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21454. return
  21455. }
  21456. body, ioErr := ioutil.ReadAll(resp.Body)
  21457. if ioErr != nil {
  21458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21460. return
  21461. }
  21462. var respJSON map[string]interface{}
  21463. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21466. return
  21467. }
  21468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21469. result, _ := json.Marshal(respJSON)
  21470. fmt.Println("log")
  21471. fmt.Println(string(result))
  21472. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21473. utils.ErrorLog("解析失败:%v", err)
  21474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21475. return
  21476. }
  21477. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21478. if reg_type == 11 && his.Insutype == "390" {
  21479. reg_type = 110104
  21480. }
  21481. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21482. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21483. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21484. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21485. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21486. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21487. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21488. resp, requestErr := http.Get(api)
  21489. if requestErr != nil {
  21490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21491. return
  21492. }
  21493. body, ioErr := ioutil.ReadAll(resp.Body)
  21494. if ioErr != nil {
  21495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21497. return
  21498. }
  21499. var respJSON map[string]interface{}
  21500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21503. return
  21504. }
  21505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21506. result, _ := json.Marshal(respJSON)
  21507. fmt.Println("log")
  21508. fmt.Println(string(result))
  21509. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21510. utils.ErrorLog("解析失败:%v", err)
  21511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21512. return
  21513. }
  21514. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21515. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  21516. if result3101.Infcode == "0" {
  21517. if len(result3101.Output.Result) > 0 {
  21518. var errMsgs []string
  21519. for _, item := range result3101.Output.Result {
  21520. errMsgs = append(errMsgs, item.VolaCont)
  21521. }
  21522. c.ServeSuccessJSON(map[string]interface{}{
  21523. "failed_code": -10,
  21524. "msg": errMsgs,
  21525. })
  21526. return
  21527. } else {
  21528. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21529. if his.IdCardType != 4 {
  21530. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21531. bas := strings.Split(psn_info.CardInfo, "|")
  21532. if his.IdCardType == 1 {
  21533. cert_no = bas[2]
  21534. } else {
  21535. cert_no = bas[1]
  21536. }
  21537. } else {
  21538. cert_no = his.Certno
  21539. }
  21540. //江苏地区国家医保医疗类别
  21541. //职工透析:医疗类别选特殊情况门诊9933
  21542. //居民血透门慢: 医疗类别选门诊慢病1402
  21543. //var med_type string
  21544. //if his.Insutype == "310" {
  21545. // if reg_type == 14 {
  21546. // med_type = "9933"
  21547. // } else if reg_type == 11 {
  21548. // med_type = "11"
  21549. //
  21550. // }
  21551. //} else if his.Insutype == "390" {
  21552. // if reg_type == 14 {
  21553. // med_type = "1402"
  21554. // } else if reg_type == 11 {
  21555. // med_type = "11"
  21556. // }
  21557. //}
  21558. var api string
  21559. if miConfig.MdtrtareaAdmvs == "320921" {
  21560. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21561. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21562. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21563. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21564. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21565. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21566. "&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
  21567. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21568. } else {
  21569. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21570. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21571. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21572. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21573. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21574. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21575. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21576. "&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
  21577. }
  21578. resp, requestErr := http.Get(api)
  21579. if requestErr != nil {
  21580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21581. return
  21582. }
  21583. body, ioErr := ioutil.ReadAll(resp.Body)
  21584. if ioErr != nil {
  21585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21587. return
  21588. }
  21589. var respJSON map[string]interface{}
  21590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21593. return
  21594. }
  21595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21596. result, _ := json.Marshal(respJSON)
  21597. fmt.Println("log")
  21598. fmt.Println(string(result))
  21599. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  21600. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21601. utils.ErrorLog("解析失败:%v", err)
  21602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21603. return
  21604. }
  21605. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21606. res.Output = resSeven10265.Output
  21607. res.ErrMsg = resSeven10265.ErrMsg
  21608. res.Cainfo = resSeven10265.Cainfo
  21609. res.WarnMsg = resSeven10265.WarnMsg
  21610. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21611. res.Infcode = infocode
  21612. } else {
  21613. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  21614. utils.ErrorLog("解析失败:%v", err)
  21615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21616. return
  21617. }
  21618. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  21619. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  21620. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  21621. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  21622. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  21623. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  21624. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  21625. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  21626. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  21627. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  21628. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  21629. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  21630. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  21631. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  21632. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  21633. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  21634. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  21635. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  21636. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  21637. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  21638. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  21639. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21640. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  21641. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  21642. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  21643. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  21644. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  21645. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  21646. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  21647. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  21648. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  21649. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  21650. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  21651. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  21652. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  21653. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21654. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  21655. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  21656. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  21657. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  21658. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  21659. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  21660. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  21661. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  21662. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  21663. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  21664. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  21665. res.ErrMsg = resSeven10265Two.ErrMsg
  21666. res.Cainfo = resSeven10265Two.Cainfo
  21667. res.WarnMsg = resSeven10265Two.WarnMsg
  21668. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21669. res.Infcode = infocode
  21670. }
  21671. }
  21672. }
  21673. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21674. psn_info, _ := service.GetPsnByPatientId(id)
  21675. var verify_number string
  21676. if psn_info.IdCardType == 4 {
  21677. verify_number = psn_info.VerifyNumber
  21678. } else if psn_info.IdCardType == 1 {
  21679. bas := strings.Split(psn_info.CardInfo, "|")
  21680. cardNumber := bas[2]
  21681. verify_number = cardNumber
  21682. } else {
  21683. psn_info.IdCardType = 2
  21684. verify_number = psn_info.Certno
  21685. }
  21686. var api string
  21687. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21688. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21689. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21690. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21691. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21692. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21693. "&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
  21694. resp, requestErr := http.Get(api)
  21695. if requestErr != nil {
  21696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21697. return
  21698. }
  21699. body, ioErr := ioutil.ReadAll(resp.Body)
  21700. if ioErr != nil {
  21701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21703. return
  21704. }
  21705. var respJSON map[string]interface{}
  21706. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21709. return
  21710. }
  21711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21712. result, _ := json.Marshal(respJSON)
  21713. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21714. utils.ErrorLog("解析失败:%v", err)
  21715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21716. return
  21717. }
  21718. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21719. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  21720. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  21721. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  21722. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  21723. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  21724. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  21725. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  21726. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  21727. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  21728. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  21729. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  21730. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  21731. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  21732. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  21733. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  21734. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  21735. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  21736. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  21737. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  21738. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21739. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  21740. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  21741. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  21742. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  21743. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  21744. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  21745. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  21746. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  21747. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  21748. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  21749. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  21750. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  21751. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  21752. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21753. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  21754. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  21755. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  21756. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  21757. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  21758. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  21759. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  21760. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  21761. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  21762. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  21763. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  21764. res.ErrMsg = resSeven10265.ErrMsg
  21765. res.Cainfo = resSeven10265.Cainfo
  21766. res.WarnMsg = resSeven10265.WarnMsg
  21767. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21768. res.Infcode = infocode
  21769. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21770. acct_used_flag := "1"
  21771. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  21772. var result string
  21773. var request_log string
  21774. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  21775. 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)
  21776. } else {
  21777. 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)
  21778. }
  21779. var dat map[string]interface{}
  21780. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21781. fmt.Println(dat)
  21782. } else {
  21783. fmt.Println(err)
  21784. }
  21785. saveLog(result, request_log, "2206", "预结算")
  21786. userJSONBytes, _ := json.Marshal(dat)
  21787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21788. utils.ErrorLog("解析失败:%v", err)
  21789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21790. return
  21791. }
  21792. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21793. var result string
  21794. var request_log string
  21795. if his.IdCardType == 2 {
  21796. 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, "")
  21797. } else if his.IdCardType == 1 {
  21798. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21799. bas := strings.Split(psn_info.CardInfo, "|")
  21800. basNumber := bas[2]
  21801. card_sn := bas[3]
  21802. var rf []*ResultFive
  21803. json.Unmarshal([]byte(his.Iinfo), &rf)
  21804. var psn_type string
  21805. for _, item := range rf {
  21806. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  21807. psn_type = item.PsnType
  21808. }
  21809. }
  21810. 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)
  21811. } else {
  21812. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21813. 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, "")
  21814. }
  21815. var dat map[string]interface{}
  21816. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21817. fmt.Println(dat)
  21818. } else {
  21819. fmt.Println(err)
  21820. }
  21821. saveLog(result, request_log, "2206", "预结算")
  21822. userJSONBytes, _ := json.Marshal(dat)
  21823. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21824. utils.ErrorLog("解析失败:%v", err)
  21825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21826. return
  21827. }
  21828. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21829. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21830. if his.IdCardType == 4 {
  21831. psn_info.VerifyNumber = psn_info.VerifyNumber
  21832. cert_no = psn_info.Certno
  21833. } else if his.IdCardType == 2 {
  21834. cert_no = psn_info.Certno
  21835. psn_info.VerifyNumber = psn_info.Certno
  21836. } else {
  21837. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21838. bas := strings.Split(psn_info.CardInfo, "|")
  21839. if his.IdCardType == 1 {
  21840. cert_no = bas[2]
  21841. } else {
  21842. cert_no = bas[1]
  21843. }
  21844. }
  21845. var api string
  21846. var med_type string
  21847. if his.Insutype == "390" {
  21848. if reg_type == 992102 {
  21849. med_type = "992102"
  21850. }
  21851. if reg_type == 140104 {
  21852. med_type = "140104"
  21853. }
  21854. if reg_type == 14 {
  21855. med_type = "140104"
  21856. }
  21857. } else if his.Insutype == "310" {
  21858. if reg_type == 992102 {
  21859. med_type = "992102"
  21860. }
  21861. if reg_type == 14 {
  21862. med_type = "14"
  21863. }
  21864. }
  21865. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21866. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21867. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21868. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21869. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21870. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21871. "&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
  21872. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21873. resp, requestErr := http.Get(api)
  21874. if requestErr != nil {
  21875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21876. return
  21877. }
  21878. body, ioErr := ioutil.ReadAll(resp.Body)
  21879. if ioErr != nil {
  21880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21882. return
  21883. }
  21884. var respJSON map[string]interface{}
  21885. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21888. return
  21889. }
  21890. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21891. if status == "0" {
  21892. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21893. c.ServeSuccessJSON(map[string]interface{}{
  21894. "failed_code": -10,
  21895. "msg": err_msg,
  21896. })
  21897. return
  21898. }
  21899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21900. result, _ := json.Marshal(respJSON)
  21901. fmt.Println("log")
  21902. fmt.Println(string(result))
  21903. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  21904. utils.ErrorLog("解析失败:%v", err)
  21905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21906. return
  21907. }
  21908. res.InfRefmsgid = ahres.InfRefmsgid
  21909. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  21910. // 创建对应的Time类型
  21911. t := time.UnixMilli(timestamp)
  21912. // 格式化成指定的日期字符串
  21913. str := t.Format("2006-01-02 15:04:05")
  21914. res.Output.Setlinfo.SetlTime = str
  21915. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  21916. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  21917. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21918. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  21919. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  21920. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  21921. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21922. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  21923. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  21924. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  21925. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  21926. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  21927. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21928. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  21929. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  21930. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  21931. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  21932. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  21933. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  21934. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21935. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  21936. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  21937. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  21938. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  21939. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  21940. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  21941. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  21942. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  21943. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  21944. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  21945. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  21946. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  21947. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  21948. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  21949. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  21950. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  21951. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  21952. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  21953. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  21954. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  21955. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  21956. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  21957. //res.Output.Setldetail = ahres.Output.Setldetail
  21958. res.ErrMsg = ahres.ErrMsg
  21959. res.Cainfo = ahres.Cainfo
  21960. res.WarnMsg = ahres.WarnMsg
  21961. res.Infcode = ahres.Infcode
  21962. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21963. var result string
  21964. var request_log string
  21965. if his.IdCardType == 2 {
  21966. 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")
  21967. } else if his.IdCardType == 1 {
  21968. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21969. bas := strings.Split(psn_info.CardInfo, "|")
  21970. basNumber := bas[2]
  21971. card_sn := bas[3]
  21972. 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")
  21973. } else {
  21974. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21975. 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")
  21976. }
  21977. var dat map[string]interface{}
  21978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21979. fmt.Println(dat)
  21980. } else {
  21981. fmt.Println(err)
  21982. }
  21983. saveLog(result, request_log, "2206", "预结算")
  21984. userJSONBytes, _ := json.Marshal(dat)
  21985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21986. utils.ErrorLog("解析失败:%v", err)
  21987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21988. return
  21989. }
  21990. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21991. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21992. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21993. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21994. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21995. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21996. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21997. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21998. resp, requestErr := http.Get(api)
  21999. if requestErr != nil {
  22000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22001. return
  22002. }
  22003. body, ioErr := ioutil.ReadAll(resp.Body)
  22004. if ioErr != nil {
  22005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22007. return
  22008. }
  22009. var respJSON map[string]interface{}
  22010. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22013. return
  22014. }
  22015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22016. result, _ := json.Marshal(respJSON)
  22017. fmt.Println("log")
  22018. fmt.Println(string(result))
  22019. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22020. utils.ErrorLog("解析失败:%v", err)
  22021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22022. return
  22023. }
  22024. } else {
  22025. if miConfig.MdtrtareaAdmvs == "441202" {
  22026. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22027. if result3101.Infcode == 0 {
  22028. if len(result3101.Output.Result) > 0 {
  22029. var errMsgs []string
  22030. for _, item := range result3101.Output.Result {
  22031. errMsgs = append(errMsgs, item.VolaCont)
  22032. }
  22033. c.ServeSuccessJSON(map[string]interface{}{
  22034. "failed_code": -10,
  22035. "msg": errMsgs,
  22036. })
  22037. return
  22038. } else {
  22039. var result string
  22040. var request_log string
  22041. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22042. allTotal = fmt.Sprintf("%.2f", total_two)
  22043. if his.IdCardType == 4 {
  22044. 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)
  22045. } else {
  22046. 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)
  22047. }
  22048. var dat map[string]interface{}
  22049. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22050. fmt.Println(dat)
  22051. } else {
  22052. fmt.Println(err)
  22053. }
  22054. saveLog(result, request_log, "2206", "预结算")
  22055. //userJSONBytes, _ := json.Marshal(dat)
  22056. //
  22057. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22058. // utils.ErrorLog("解析失败:%v", err)
  22059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22060. // return
  22061. //}
  22062. userJSONBytes, _ := json.Marshal(dat)
  22063. if miConfig.Code == "H15049901371" {
  22064. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22065. utils.ErrorLog("解析失败:%v", err)
  22066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22067. return
  22068. }
  22069. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22070. res.Output = resSeven10265.Output
  22071. res.ErrMsg = resSeven10265.ErrMsg
  22072. res.Cainfo = resSeven10265.Cainfo
  22073. res.WarnMsg = resSeven10265.WarnMsg
  22074. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22075. res.Infcode = infocode
  22076. } else {
  22077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22078. utils.ErrorLog("解析失败:%v", err)
  22079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22080. return
  22081. }
  22082. }
  22083. }
  22084. } else {
  22085. c.ServeSuccessJSON(map[string]interface{}{
  22086. "failed_code": -10,
  22087. "msg": result3101.ErrMsg,
  22088. })
  22089. return
  22090. }
  22091. } else {
  22092. var result string
  22093. var request_log string
  22094. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22095. allTotal = fmt.Sprintf("%.2f", total_two)
  22096. if his.IdCardType == 4 {
  22097. 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)
  22098. } else {
  22099. 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)
  22100. }
  22101. var dat map[string]interface{}
  22102. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22103. fmt.Println(dat)
  22104. } else {
  22105. fmt.Println(err)
  22106. }
  22107. saveLog(result, request_log, "2206", "预结算")
  22108. //userJSONBytes, _ := json.Marshal(dat)
  22109. //
  22110. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22111. // utils.ErrorLog("解析失败:%v", err)
  22112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22113. // return
  22114. //}
  22115. userJSONBytes, _ := json.Marshal(dat)
  22116. if miConfig.Code == "H15049901371" {
  22117. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22118. utils.ErrorLog("解析失败:%v", err)
  22119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22120. return
  22121. }
  22122. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22123. res.Output = resSeven10265.Output
  22124. res.ErrMsg = resSeven10265.ErrMsg
  22125. res.Cainfo = resSeven10265.Cainfo
  22126. res.WarnMsg = resSeven10265.WarnMsg
  22127. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22128. res.Infcode = infocode
  22129. } else {
  22130. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22131. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  22132. utils.ErrorLog("解析失败:%v", err)
  22133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22134. return
  22135. }
  22136. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  22137. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  22138. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  22139. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22140. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  22141. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  22142. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  22143. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22144. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  22145. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22146. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22147. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22148. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22149. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22150. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22151. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  22152. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  22153. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  22154. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  22155. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  22156. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22157. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  22158. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  22159. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  22160. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  22161. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  22162. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  22163. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  22164. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  22165. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22166. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  22167. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  22168. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  22169. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22170. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22171. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22172. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22173. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  22174. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22175. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  22176. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  22177. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  22178. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  22179. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  22180. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  22181. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  22182. res.ErrMsg = gzresSeven10265Two.ErrMsg
  22183. res.Cainfo = gzresSeven10265Two.Cainfo
  22184. res.WarnMsg = gzresSeven10265Two.WarnMsg
  22185. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22186. //res.Infcode = infocode
  22187. } else {
  22188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22189. utils.ErrorLog("解析失败:%v", err)
  22190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22191. return
  22192. }
  22193. }
  22194. }
  22195. }
  22196. }
  22197. utils.ErrorLog("解析失败:%v", res.Infcode)
  22198. if res.Infcode == -1 {
  22199. errlog := &models.HisOrderError{
  22200. UserOrgId: adminUser.CurrentOrgId,
  22201. Ctime: time.Now().Unix(),
  22202. Mtime: time.Now().Unix(),
  22203. Number: chrg_bchno,
  22204. ErrMsg: res.ErrMsg,
  22205. Status: 1,
  22206. PatientId: id,
  22207. RecordTime: recordDateTime,
  22208. Stage: 20,
  22209. }
  22210. service.CreateErrMsgLog(errlog)
  22211. c.ServeSuccessJSON(map[string]interface{}{
  22212. "failed_code": -10,
  22213. "msg": res.ErrMsg,
  22214. })
  22215. return
  22216. }
  22217. if res.Infcode != 0 {
  22218. errlog := &models.HisOrderError{
  22219. UserOrgId: adminUser.CurrentOrgId,
  22220. Ctime: time.Now().Unix(),
  22221. Mtime: time.Now().Unix(),
  22222. Number: chrg_bchno,
  22223. ErrMsg: res.ErrMsg,
  22224. Status: 1,
  22225. PatientId: id,
  22226. RecordTime: recordDateTime,
  22227. Stage: 20,
  22228. }
  22229. service.CreateErrMsgLog(errlog)
  22230. c.ServeSuccessJSON(map[string]interface{}{
  22231. "failed_code": -10,
  22232. "msg": res.ErrMsg,
  22233. })
  22234. return
  22235. } else {
  22236. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  22237. order.OrderStatus = 1
  22238. order.IsPre = 1
  22239. order.Status = 1
  22240. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  22241. order.SetlId = res.Output.Setlinfo.SetlID
  22242. order.PsnNo = res.Output.Setlinfo.PsnNo
  22243. order.PsnName = res.Output.Setlinfo.PsnName
  22244. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  22245. order.Certno = res.Output.Setlinfo.Certno
  22246. order.Gend = res.Output.Setlinfo.Gend
  22247. order.Naty = res.Output.Setlinfo.Naty
  22248. order.Age = res.Output.Setlinfo.Age
  22249. order.Insutype = res.Output.Setlinfo.Insutype
  22250. order.PsnType = res.Output.Setlinfo.PsnType
  22251. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  22252. order.SetlTime = res.Output.Setlinfo.SetlTime
  22253. order.AcctUsedFlag = acct_used_flag
  22254. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  22255. if res.Output.Setlinfo.MedType == "140101" {
  22256. order.MedType = "14"
  22257. } else {
  22258. if res.Output.Setlinfo.MedType == "110104" {
  22259. order.MedType = "11"
  22260. } else {
  22261. order.MedType = res.Output.Setlinfo.MedType
  22262. }
  22263. }
  22264. if res.Output.Setlinfo.MedType == "992102" {
  22265. order.MedType = "992102"
  22266. }
  22267. if res.Output.Setlinfo.MedType == "140104" {
  22268. order.MedType = "140104"
  22269. }
  22270. if res.Output.Setlinfo.MedType == "14" {
  22271. order.MedType = "14"
  22272. }
  22273. if reg_type == 1112 {
  22274. order.MedType = "1112"
  22275. }
  22276. if reg_type == 1111 {
  22277. order.MedType = "1111"
  22278. }
  22279. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  22280. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  22281. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  22282. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  22283. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  22284. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  22285. order.HifpPay = res.Output.Setlinfo.HifpPay
  22286. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  22287. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  22288. order.HifesPay = res.Output.Setlinfo.HifesPay
  22289. order.HifobPay = res.Output.Setlinfo.HifobPay
  22290. order.MafPay = res.Output.Setlinfo.MafPay
  22291. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  22292. order.OthPay = res.Output.Setlinfo.OthPay
  22293. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  22294. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  22295. order.AcctPay = res.Output.Setlinfo.AcctPay
  22296. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  22297. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  22298. order.Balc = res.Output.Setlinfo.Balc
  22299. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  22300. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  22301. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  22302. order.ClrWay = res.Output.Setlinfo.ClrWay
  22303. order.Creator = order.Creator
  22304. order.Modify = roles.AdminUserId
  22305. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  22306. //detailStr := string(setlDetail)
  22307. //order.SetlDetail = detailStr
  22308. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  22309. err = service.UpDateOrder(order)
  22310. if err == nil {
  22311. c.ServeSuccessJSON(map[string]interface{}{
  22312. "msg": "预结算成功",
  22313. })
  22314. } else {
  22315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  22316. return
  22317. }
  22318. }
  22319. } else {
  22320. adminUser := c.GetAdminUserInfo()
  22321. errlog := &models.HisOrderError{
  22322. UserOrgId: adminUser.CurrentOrgId,
  22323. Ctime: time.Now().Unix(),
  22324. Mtime: time.Now().Unix(),
  22325. ErrMsg: res.ErrMsg,
  22326. Status: 1,
  22327. PatientId: id,
  22328. RecordTime: recordDateTime,
  22329. Stage: 4,
  22330. }
  22331. service.CreateErrMsgLog(errlog)
  22332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  22333. return
  22334. }
  22335. } else {
  22336. if miConfig.MdtrtareaAdmvs == "150499" {
  22337. order := &models.HisOrder{
  22338. UserOrgId: adminUser.CurrentOrgId,
  22339. HisPatientId: his.ID,
  22340. PatientId: his.PatientId,
  22341. SettleAccountsDate: recordDateTime,
  22342. Ctime: time.Now().Unix(),
  22343. Mtime: time.Now().Unix(),
  22344. MdtrtId: his.Number,
  22345. PsnNo: his.PsnNo,
  22346. MedType: strconv.FormatInt(reg_type, 10),
  22347. Status: 1,
  22348. Number: chrg_bchno,
  22349. Infcode: res.Infcode,
  22350. WarnMsg: res.WarnMsg,
  22351. Cainfo: res.Cainfo,
  22352. ErrMsg: res.ErrMsg,
  22353. RespondTime: res.RefmsgTime,
  22354. InfRefmsgid: res.InfRefmsgid,
  22355. OrderStatus: 1,
  22356. IsMedicineInsurance: 1,
  22357. SettleType: settle_accounts_type,
  22358. SettleStartTime: start_time,
  22359. SettleEndTime: end_time,
  22360. Creator: roles.AdminUserId,
  22361. Modify: roles.AdminUserId,
  22362. PType: 2,
  22363. Diagnosis: diagnosis_id,
  22364. }
  22365. err = service.CreateOrder(order)
  22366. if err != nil {
  22367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22368. return
  22369. }
  22370. }
  22371. adminUser := c.GetAdminUserInfo()
  22372. errlog := &models.HisOrderError{
  22373. UserOrgId: adminUser.CurrentOrgId,
  22374. Ctime: time.Now().Unix(),
  22375. Mtime: time.Now().Unix(),
  22376. ErrMsg: res.ErrMsg,
  22377. Status: 1,
  22378. PatientId: id,
  22379. RecordTime: recordDateTime,
  22380. Stage: 4,
  22381. }
  22382. service.CreateErrMsgLog(errlog)
  22383. c.ServeSuccessJSON(map[string]interface{}{
  22384. "failed_code": -10,
  22385. "msg": res.ErrMsg,
  22386. })
  22387. return
  22388. }
  22389. }
  22390. }
  22391. }
  22392. // 退款
  22393. func (c *HisApiController) Refund() {
  22394. order_id, _ := c.GetInt64("order_id")
  22395. admin_user_id, _ := c.GetInt64("admin_user_id")
  22396. adminUser := c.GetAdminUserInfo()
  22397. var order models.HisOrder
  22398. order, _ = service.GetHisOrderByID(order_id)
  22399. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22400. if order.ID == 0 {
  22401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22402. return
  22403. }
  22404. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  22405. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22406. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22407. if config.IsOpen == 1 { //对接了医保,走医保流程
  22408. var res ResultSixteen
  22409. var ahres ResultSevenAH
  22410. var resSixteen10265 ResultSixteen10265
  22411. var resSixteen10265Two ResultSixteen10265Two
  22412. var gz ResultgzSixteen10265Two
  22413. var src_resquest string
  22414. var result string
  22415. if miConfig.MdtrtareaAdmvs == "421300" {
  22416. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22417. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22418. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22419. resp3, requestErr3 := http.Get(api3)
  22420. if requestErr3 != nil {
  22421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22422. return
  22423. }
  22424. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22425. if ioErr3 != nil {
  22426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22428. return
  22429. }
  22430. var respJSON3 map[string]interface{}
  22431. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22434. return
  22435. }
  22436. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22437. userJSONBytes3, _ := json.Marshal(respJSON3)
  22438. fmt.Println("log")
  22439. fmt.Println(string(userJSONBytes3))
  22440. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22441. utils.ErrorLog("解析失败:%v", err)
  22442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22443. return
  22444. }
  22445. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22446. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22447. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22448. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22449. resp3, requestErr3 := http.Get(api3)
  22450. if requestErr3 != nil {
  22451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22452. return
  22453. }
  22454. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22455. if ioErr3 != nil {
  22456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22458. return
  22459. }
  22460. var respJSON3 map[string]interface{}
  22461. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22464. return
  22465. }
  22466. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22467. userJSONBytes3, _ := json.Marshal(respJSON3)
  22468. fmt.Println("log")
  22469. fmt.Println(string(userJSONBytes3))
  22470. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22471. utils.ErrorLog("解析失败:%v", err)
  22472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22473. return
  22474. }
  22475. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22476. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  22477. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22478. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22479. resp3, requestErr3 := http.Get(api3)
  22480. if requestErr3 != nil {
  22481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22482. return
  22483. }
  22484. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22485. if ioErr3 != nil {
  22486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22488. return
  22489. }
  22490. var respJSON3 map[string]interface{}
  22491. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22494. return
  22495. }
  22496. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22497. userJSONBytes3, _ := json.Marshal(respJSON3)
  22498. fmt.Println("log")
  22499. fmt.Println(string(userJSONBytes3))
  22500. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22501. utils.ErrorLog("解析失败:%v", err)
  22502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22503. return
  22504. }
  22505. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22506. var api3 string
  22507. if miConfig.MdtrtareaAdmvs == "320921" {
  22508. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22509. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22510. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22511. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22512. } else {
  22513. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22514. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22515. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22516. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22517. }
  22518. resp3, requestErr3 := http.Get(api3)
  22519. if requestErr3 != nil {
  22520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22521. return
  22522. }
  22523. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22524. if ioErr3 != nil {
  22525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22527. return
  22528. }
  22529. var respJSON3 map[string]interface{}
  22530. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22533. return
  22534. }
  22535. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22536. userJSONBytes3, _ := json.Marshal(respJSON3)
  22537. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  22538. utils.ErrorLog("解析失败:%v", err)
  22539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22540. return
  22541. }
  22542. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22543. res.Output = resSixteen10265.Output
  22544. res.ErrMsg = resSixteen10265.ErrMsg
  22545. res.Cainfo = resSixteen10265.Cainfo
  22546. res.WarnMsg = resSixteen10265.WarnMsg
  22547. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22548. res.Infcode = infocode
  22549. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22550. var api3 string
  22551. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  22552. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22553. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22554. resp3, requestErr3 := http.Get(api3)
  22555. if requestErr3 != nil {
  22556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22557. return
  22558. }
  22559. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22560. if ioErr3 != nil {
  22561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22563. return
  22564. }
  22565. var respJSON3 map[string]interface{}
  22566. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22569. return
  22570. }
  22571. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22572. userJSONBytes3, _ := json.Marshal(respJSON3)
  22573. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  22574. utils.ErrorLog("解析失败:%v", err)
  22575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22576. return
  22577. }
  22578. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22579. res.Output = resSixteen10265.Output
  22580. res.ErrMsg = resSixteen10265.ErrMsg
  22581. res.Cainfo = resSixteen10265.Cainfo
  22582. res.WarnMsg = resSixteen10265.WarnMsg
  22583. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22584. res.Infcode = infocode
  22585. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22586. 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)
  22587. var dat map[string]interface{}
  22588. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22589. fmt.Println(dat)
  22590. } else {
  22591. fmt.Println(err)
  22592. }
  22593. saveLog(result, src_resquest, "2208", "退费")
  22594. userJSONBytes, _ := json.Marshal(dat)
  22595. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22596. utils.ErrorLog("解析失败:%v", err)
  22597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22598. return
  22599. }
  22600. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22601. 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, "")
  22602. var dat map[string]interface{}
  22603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22604. fmt.Println(dat)
  22605. } else {
  22606. fmt.Println(err)
  22607. }
  22608. saveLog(result, src_resquest, "2208", "退费")
  22609. userJSONBytes, _ := json.Marshal(dat)
  22610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22611. utils.ErrorLog("解析失败:%v", err)
  22612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22613. return
  22614. }
  22615. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22616. var api3 string
  22617. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  22618. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22619. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22620. resp3, requestErr3 := http.Get(api3)
  22621. if requestErr3 != nil {
  22622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22623. return
  22624. }
  22625. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22626. if ioErr3 != nil {
  22627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22629. return
  22630. }
  22631. var respJSON3 map[string]interface{}
  22632. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22635. return
  22636. }
  22637. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  22638. if status == "0" {
  22639. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  22640. c.ServeSuccessJSON(map[string]interface{}{
  22641. "failed_code": -10,
  22642. "msg": err_msg,
  22643. })
  22644. return
  22645. }
  22646. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22647. userJSONBytes3, _ := json.Marshal(respJSON3)
  22648. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22649. // utils.ErrorLog("解析失败:%v", err)
  22650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22651. // return
  22652. //}
  22653. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  22654. utils.ErrorLog("解析失败:%v", err)
  22655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22656. return
  22657. }
  22658. res.InfRefmsgid = ahres.InfRefmsgid
  22659. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  22660. // 创建对应的Time类型
  22661. t := time.UnixMilli(timestamp)
  22662. // 格式化成指定的日期字符串
  22663. str := t.Format("2006-01-02 15:04:05")
  22664. res.Output.Setlinfo.SetlTime = str
  22665. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  22666. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  22667. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22668. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  22669. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  22670. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  22671. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22672. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  22673. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  22674. //
  22675. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  22676. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  22677. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  22678. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22679. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  22680. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  22681. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  22682. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  22683. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  22684. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  22685. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22686. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  22687. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  22688. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  22689. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  22690. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  22691. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  22692. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  22693. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  22694. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  22695. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  22696. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  22697. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  22698. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  22699. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  22700. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  22701. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  22702. //res.Output.Setldetail = ahres.Output.Setldetail
  22703. res.ErrMsg = ahres.ErrMsg
  22704. res.Cainfo = ahres.Cainfo
  22705. res.WarnMsg = ahres.WarnMsg
  22706. res.Infcode = ahres.Infcode
  22707. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22708. 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, "")
  22709. var dat map[string]interface{}
  22710. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22711. fmt.Println(dat)
  22712. } else {
  22713. fmt.Println(err)
  22714. }
  22715. saveLog(result, src_resquest, "2208", "退费")
  22716. userJSONBytes, _ := json.Marshal(dat)
  22717. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22718. utils.ErrorLog("解析失败:%v", err)
  22719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22720. return
  22721. }
  22722. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22723. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  22724. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22725. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22726. resp3, requestErr3 := http.Get(api3)
  22727. if requestErr3 != nil {
  22728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22729. return
  22730. }
  22731. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22732. if ioErr3 != nil {
  22733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22735. return
  22736. }
  22737. var respJSON3 map[string]interface{}
  22738. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22741. return
  22742. }
  22743. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22744. userJSONBytes3, _ := json.Marshal(respJSON3)
  22745. fmt.Println("log")
  22746. fmt.Println(string(userJSONBytes3))
  22747. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22748. utils.ErrorLog("解析失败:%v", err)
  22749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22750. return
  22751. }
  22752. } else {
  22753. if miConfig.Code == "H15049901371" {
  22754. 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)
  22755. var dat map[string]interface{}
  22756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22757. fmt.Println(dat)
  22758. } else {
  22759. fmt.Println(err)
  22760. }
  22761. saveLog(result, src_resquest, "2208", "退费")
  22762. userJSONBytes, _ := json.Marshal(dat)
  22763. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  22764. utils.ErrorLog("解析失败:%v", err)
  22765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22766. return
  22767. }
  22768. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22769. res.Output = resSixteen10265.Output
  22770. res.ErrMsg = resSixteen10265.ErrMsg
  22771. res.Cainfo = resSixteen10265.Cainfo
  22772. res.WarnMsg = resSixteen10265.WarnMsg
  22773. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22774. res.Infcode = infocode
  22775. } else {
  22776. 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)
  22777. var dat map[string]interface{}
  22778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22779. fmt.Println(dat)
  22780. } else {
  22781. fmt.Println(err)
  22782. }
  22783. saveLog(result, src_resquest, "2208", "退费")
  22784. userJSONBytes, _ := json.Marshal(dat)
  22785. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22786. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  22787. utils.ErrorLog("解析失败:%v", err)
  22788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22789. return
  22790. }
  22791. res.Infcode = gz.Infcode
  22792. } else {
  22793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22794. utils.ErrorLog("解析失败:%v", err)
  22795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22796. return
  22797. }
  22798. }
  22799. }
  22800. }
  22801. if res.Infcode == 0 {
  22802. var res2 ResultSix
  22803. var resSix10265 ResultSix10265
  22804. if miConfig.MdtrtareaAdmvs == "421300" {
  22805. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  22806. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22807. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22808. resp3, requestErr3 := http.Get(api3)
  22809. if requestErr3 != nil {
  22810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22811. return
  22812. }
  22813. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22814. if ioErr3 != nil {
  22815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22817. return
  22818. }
  22819. var respJSON3 map[string]interface{}
  22820. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22823. return
  22824. }
  22825. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22826. userJSONBytes3, _ := json.Marshal(respJSON3)
  22827. fmt.Println("log")
  22828. fmt.Println(string(userJSONBytes3))
  22829. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22830. utils.ErrorLog("解析失败:%v", err)
  22831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22832. return
  22833. }
  22834. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22835. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  22836. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22837. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22838. resp3, requestErr3 := http.Get(api3)
  22839. if requestErr3 != nil {
  22840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22841. return
  22842. }
  22843. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22844. if ioErr3 != nil {
  22845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22847. return
  22848. }
  22849. var respJSON3 map[string]interface{}
  22850. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22853. return
  22854. }
  22855. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22856. userJSONBytes3, _ := json.Marshal(respJSON3)
  22857. fmt.Println("log")
  22858. fmt.Println(string(userJSONBytes3))
  22859. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22860. utils.ErrorLog("解析失败:%v", err)
  22861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22862. return
  22863. }
  22864. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22865. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  22866. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22867. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22868. resp3, requestErr3 := http.Get(api3)
  22869. if requestErr3 != nil {
  22870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22871. return
  22872. }
  22873. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22874. if ioErr3 != nil {
  22875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22877. return
  22878. }
  22879. var respJSON3 map[string]interface{}
  22880. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22883. return
  22884. }
  22885. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22886. userJSONBytes3, _ := json.Marshal(respJSON3)
  22887. fmt.Println("log")
  22888. fmt.Println(string(userJSONBytes3))
  22889. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22890. utils.ErrorLog("解析失败:%v", err)
  22891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22892. return
  22893. }
  22894. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22895. var api3 string
  22896. if miConfig.MdtrtareaAdmvs == "320921" {
  22897. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  22898. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22899. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22900. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22901. } else {
  22902. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22903. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  22904. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22905. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22906. }
  22907. resp3, requestErr3 := http.Get(api3)
  22908. if requestErr3 != nil {
  22909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22910. return
  22911. }
  22912. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22913. if ioErr3 != nil {
  22914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22916. return
  22917. }
  22918. var respJSON3 map[string]interface{}
  22919. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22922. return
  22923. }
  22924. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22925. userJSONBytes3, _ := json.Marshal(respJSON3)
  22926. fmt.Println("log")
  22927. fmt.Println(string(userJSONBytes3))
  22928. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  22929. utils.ErrorLog("解析失败:%v", err)
  22930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22931. return
  22932. }
  22933. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22934. res2.Output = resSix10265.Output
  22935. res2.ErrMsg = resSix10265.ErrMsg
  22936. res2.Cainfo = resSix10265.Cainfo
  22937. res2.WarnMsg = resSix10265.WarnMsg
  22938. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22939. res2.Infcode = infocode
  22940. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22941. var api3 string
  22942. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  22943. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22944. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22945. resp3, requestErr3 := http.Get(api3)
  22946. if requestErr3 != nil {
  22947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22948. return
  22949. }
  22950. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22951. if ioErr3 != nil {
  22952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22954. return
  22955. }
  22956. var respJSON3 map[string]interface{}
  22957. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22960. return
  22961. }
  22962. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22963. userJSONBytes3, _ := json.Marshal(respJSON3)
  22964. fmt.Println("log")
  22965. fmt.Println(string(userJSONBytes3))
  22966. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  22967. utils.ErrorLog("解析失败:%v", err)
  22968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22969. return
  22970. }
  22971. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22972. res2.Output = resSix10265.Output
  22973. res2.ErrMsg = resSix10265.ErrMsg
  22974. res2.Cainfo = resSix10265.Cainfo
  22975. res2.WarnMsg = resSix10265.WarnMsg
  22976. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22977. res2.Infcode = infocode
  22978. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22979. 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)
  22980. var dat map[string]interface{}
  22981. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  22982. fmt.Println(dat)
  22983. } else {
  22984. fmt.Println(err)
  22985. }
  22986. saveLog(result2, src_request, "2205", "撤销明细")
  22987. userJSONBytes, _ := json.Marshal(dat)
  22988. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22989. utils.ErrorLog("解析失败:%v", err)
  22990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22991. return
  22992. }
  22993. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22994. 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, "")
  22995. var dat map[string]interface{}
  22996. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  22997. fmt.Println(dat)
  22998. } else {
  22999. fmt.Println(err)
  23000. }
  23001. saveLog(result2, src_request, "2205", "撤销明细")
  23002. userJSONBytes, _ := json.Marshal(dat)
  23003. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23004. utils.ErrorLog("解析失败:%v", err)
  23005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23006. return
  23007. }
  23008. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23009. var api3 string
  23010. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  23011. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23012. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23013. resp3, requestErr3 := http.Get(api3)
  23014. if requestErr3 != nil {
  23015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23016. return
  23017. }
  23018. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23019. if ioErr3 != nil {
  23020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23022. return
  23023. }
  23024. var respJSON3 map[string]interface{}
  23025. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23028. return
  23029. }
  23030. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23031. if status == "0" {
  23032. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23033. c.ServeSuccessJSON(map[string]interface{}{
  23034. "failed_code": -10,
  23035. "msg": err_msg,
  23036. })
  23037. return
  23038. }
  23039. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23040. userJSONBytes3, _ := json.Marshal(respJSON3)
  23041. fmt.Println("log")
  23042. fmt.Println(string(userJSONBytes3))
  23043. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23044. utils.ErrorLog("解析失败:%v", err)
  23045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23046. return
  23047. }
  23048. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23049. 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, "")
  23050. var dat map[string]interface{}
  23051. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23052. fmt.Println(dat)
  23053. } else {
  23054. fmt.Println(err)
  23055. }
  23056. saveLog(result2, src_request, "2205", "撤销明细")
  23057. userJSONBytes, _ := json.Marshal(dat)
  23058. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23059. utils.ErrorLog("解析失败:%v", err)
  23060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23061. return
  23062. }
  23063. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23064. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  23065. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23066. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23067. resp3, requestErr3 := http.Get(api3)
  23068. if requestErr3 != nil {
  23069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23070. return
  23071. }
  23072. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23073. if ioErr3 != nil {
  23074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23076. return
  23077. }
  23078. var respJSON3 map[string]interface{}
  23079. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23082. return
  23083. }
  23084. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23085. userJSONBytes3, _ := json.Marshal(respJSON3)
  23086. fmt.Println("log")
  23087. fmt.Println(string(userJSONBytes3))
  23088. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23089. utils.ErrorLog("解析失败:%v", err)
  23090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23091. return
  23092. }
  23093. } else {
  23094. if miConfig.Code == "H15049901371" {
  23095. 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)
  23096. var dat map[string]interface{}
  23097. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23098. fmt.Println(dat)
  23099. } else {
  23100. fmt.Println(err)
  23101. }
  23102. saveLog(result2, src_request, "2205", "撤销明细")
  23103. userJSONBytes, _ := json.Marshal(dat)
  23104. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  23105. utils.ErrorLog("解析失败:%v", err)
  23106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23107. return
  23108. }
  23109. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23110. res2.Output = resSix10265.Output
  23111. res2.ErrMsg = resSix10265.ErrMsg
  23112. res2.Cainfo = resSix10265.Cainfo
  23113. res2.WarnMsg = resSix10265.WarnMsg
  23114. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23115. res2.Infcode = infocode
  23116. } else {
  23117. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23118. res2.Infcode = 0
  23119. } else {
  23120. 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)
  23121. var dat map[string]interface{}
  23122. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23123. fmt.Println(dat)
  23124. } else {
  23125. fmt.Println(err)
  23126. }
  23127. saveLog(result2, src_request, "2205", "撤销明细")
  23128. userJSONBytes, _ := json.Marshal(dat)
  23129. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23130. utils.ErrorLog("解析失败:%v", err)
  23131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23132. return
  23133. }
  23134. }
  23135. }
  23136. }
  23137. if res2.Infcode == -1 {
  23138. c.ServeSuccessJSON(map[string]interface{}{
  23139. "failed_code": -10,
  23140. "msg": res2.ErrMsg,
  23141. })
  23142. return
  23143. }
  23144. if res2.Infcode == 0 {
  23145. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  23146. if err == nil {
  23147. //当押金不为零时产生退费记录
  23148. if order.Decimal != 0 {
  23149. tmp := strconv.FormatInt(order.ID, 10)
  23150. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  23151. if err != nil {
  23152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23153. return
  23154. }
  23155. }
  23156. c.ServeSuccessJSON(map[string]interface{}{
  23157. "msg": "退费成功",
  23158. })
  23159. } else {
  23160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23161. return
  23162. }
  23163. } else {
  23164. c.ServeSuccessJSON(map[string]interface{}{
  23165. "failed_code": -10,
  23166. "msg": res2.ErrMsg,
  23167. })
  23168. }
  23169. } else {
  23170. c.ServeSuccessJSON(map[string]interface{}{
  23171. "failed_code": -10,
  23172. "msg": res.ErrMsg,
  23173. })
  23174. }
  23175. }
  23176. }
  23177. func (c *HisApiController) RefundNumber() {
  23178. record_time := c.GetString("record_time")
  23179. //patient_id, _ := c.GetInt64("patient_id")
  23180. admin_user_id, _ := c.GetInt64("admin_user_id")
  23181. his_patient_id, _ := c.GetInt64("id")
  23182. timeLayout := "2006-01-02"
  23183. loc, _ := time.LoadLocation("Local")
  23184. adminUser := c.GetAdminUserInfo()
  23185. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23186. fmt.Println(err)
  23187. if err != nil {
  23188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23189. return
  23190. }
  23191. recordDateTime := theTime.Unix()
  23192. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23193. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  23194. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23195. //order, _ := service.GetHisOrderByID(order_id)
  23196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23197. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23198. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23199. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  23200. if count > 0 {
  23201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  23202. return
  23203. }
  23204. if config.IsOpen == 1 { //对接了医保,走医保流程
  23205. var res2 ResultSix
  23206. var res3 GZResultSix
  23207. var resSix10265 ResultSix10265
  23208. if miConfig.MdtrtareaAdmvs == "421300" {
  23209. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23210. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23211. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23212. resp3, requestErr3 := http.Get(api3)
  23213. if requestErr3 != nil {
  23214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23215. return
  23216. }
  23217. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23218. if ioErr3 != nil {
  23219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23221. return
  23222. }
  23223. var respJSON3 map[string]interface{}
  23224. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23227. return
  23228. }
  23229. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23230. userJSONBytes3, _ := json.Marshal(respJSON3)
  23231. fmt.Println("log")
  23232. fmt.Println(string(userJSONBytes3))
  23233. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23234. utils.ErrorLog("解析失败:%v", err)
  23235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23236. return
  23237. }
  23238. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23239. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23240. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23241. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23242. resp3, requestErr3 := http.Get(api3)
  23243. if requestErr3 != nil {
  23244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23245. return
  23246. }
  23247. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23248. if ioErr3 != nil {
  23249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23251. return
  23252. }
  23253. var respJSON3 map[string]interface{}
  23254. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23257. return
  23258. }
  23259. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23260. userJSONBytes3, _ := json.Marshal(respJSON3)
  23261. fmt.Println("log")
  23262. fmt.Println(string(userJSONBytes3))
  23263. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23264. utils.ErrorLog("解析失败:%v", err)
  23265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23266. return
  23267. }
  23268. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23269. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  23270. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23271. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23272. resp3, requestErr3 := http.Get(api3)
  23273. if requestErr3 != nil {
  23274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23275. return
  23276. }
  23277. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23278. if ioErr3 != nil {
  23279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23281. return
  23282. }
  23283. var respJSON3 map[string]interface{}
  23284. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23287. return
  23288. }
  23289. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23290. userJSONBytes3, _ := json.Marshal(respJSON3)
  23291. fmt.Println("log")
  23292. fmt.Println(string(userJSONBytes3))
  23293. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23294. utils.ErrorLog("解析失败:%v", err)
  23295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23296. return
  23297. }
  23298. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23299. var api3 string
  23300. if miConfig.MdtrtareaAdmvs == "320921" {
  23301. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23302. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23303. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23304. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23305. } else {
  23306. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23307. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23308. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23309. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23310. }
  23311. resp3, requestErr3 := http.Get(api3)
  23312. if requestErr3 != nil {
  23313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23314. return
  23315. }
  23316. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23317. if ioErr3 != nil {
  23318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23320. return
  23321. }
  23322. var respJSON3 map[string]interface{}
  23323. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23326. return
  23327. }
  23328. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23329. userJSONBytes3, _ := json.Marshal(respJSON3)
  23330. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23331. utils.ErrorLog("解析失败:%v", err)
  23332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23333. return
  23334. }
  23335. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23336. res2.Output = resSix10265.Output
  23337. res2.ErrMsg = resSix10265.ErrMsg
  23338. res2.Cainfo = resSix10265.Cainfo
  23339. res2.WarnMsg = resSix10265.WarnMsg
  23340. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23341. res2.Infcode = infocode
  23342. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23343. var api3 string
  23344. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  23345. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23346. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23347. resp3, requestErr3 := http.Get(api3)
  23348. if requestErr3 != nil {
  23349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23350. return
  23351. }
  23352. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23353. if ioErr3 != nil {
  23354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23356. return
  23357. }
  23358. var respJSON3 map[string]interface{}
  23359. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23362. return
  23363. }
  23364. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23365. userJSONBytes3, _ := json.Marshal(respJSON3)
  23366. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23367. utils.ErrorLog("解析失败:%v", err)
  23368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23369. return
  23370. }
  23371. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23372. res2.Output = resSix10265.Output
  23373. res2.ErrMsg = resSix10265.ErrMsg
  23374. res2.Cainfo = resSix10265.Cainfo
  23375. res2.WarnMsg = resSix10265.WarnMsg
  23376. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23377. res2.Infcode = infocode
  23378. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23379. 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)
  23380. var dat map[string]interface{}
  23381. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23382. fmt.Println(dat)
  23383. } else {
  23384. fmt.Println(err)
  23385. }
  23386. saveLog(result, request, "2202", "退号")
  23387. userJSONBytes, _ := json.Marshal(dat)
  23388. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23389. utils.ErrorLog("解析失败:%v", err)
  23390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23391. return
  23392. }
  23393. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23394. 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, "")
  23395. var dat map[string]interface{}
  23396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23397. fmt.Println(dat)
  23398. } else {
  23399. fmt.Println(err)
  23400. }
  23401. saveLog(result, request, "2202", "退号")
  23402. userJSONBytes, _ := json.Marshal(dat)
  23403. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23404. utils.ErrorLog("解析失败:%v", err)
  23405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23406. return
  23407. }
  23408. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23409. var api3 string
  23410. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  23411. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23412. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23413. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23414. resp3, requestErr3 := http.Get(api3)
  23415. if requestErr3 != nil {
  23416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23417. return
  23418. }
  23419. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23420. if ioErr3 != nil {
  23421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23423. return
  23424. }
  23425. var respJSON3 map[string]interface{}
  23426. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23429. return
  23430. }
  23431. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23432. if status == "0" {
  23433. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23434. c.ServeSuccessJSON(map[string]interface{}{
  23435. "failed_code": -10,
  23436. "msg": err_msg,
  23437. })
  23438. return
  23439. }
  23440. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23441. userJSONBytes3, _ := json.Marshal(respJSON3)
  23442. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23443. utils.ErrorLog("解析失败:%v", err)
  23444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23445. return
  23446. }
  23447. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  23448. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23449. 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, "")
  23450. var dat map[string]interface{}
  23451. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23452. fmt.Println(dat)
  23453. } else {
  23454. fmt.Println(err)
  23455. }
  23456. saveLog(result, request, "2202", "退号")
  23457. userJSONBytes, _ := json.Marshal(dat)
  23458. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23459. utils.ErrorLog("解析失败:%v", err)
  23460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23461. return
  23462. }
  23463. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23464. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  23465. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23466. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23467. resp3, requestErr3 := http.Get(api3)
  23468. if requestErr3 != nil {
  23469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23470. return
  23471. }
  23472. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23473. if ioErr3 != nil {
  23474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23476. return
  23477. }
  23478. var respJSON3 map[string]interface{}
  23479. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23482. return
  23483. }
  23484. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23485. userJSONBytes3, _ := json.Marshal(respJSON3)
  23486. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23487. utils.ErrorLog("解析失败:%v", err)
  23488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23489. return
  23490. }
  23491. } else {
  23492. var api3 string
  23493. if miConfig.Code == "H15049901371" {
  23494. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  23495. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23496. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23497. } else {
  23498. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  23499. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23500. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23501. }
  23502. resp3, requestErr3 := http.Get(api3)
  23503. if requestErr3 != nil {
  23504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23505. return
  23506. }
  23507. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23508. if ioErr3 != nil {
  23509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23511. return
  23512. }
  23513. var respJSON3 map[string]interface{}
  23514. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23517. return
  23518. }
  23519. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23520. userJSONBytes3, _ := json.Marshal(respJSON3)
  23521. if miConfig.Code == "H15049901371" {
  23522. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23523. utils.ErrorLog("解析失败:%v", err)
  23524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23525. return
  23526. }
  23527. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23528. res2.Output = resSix10265.Output
  23529. res2.ErrMsg = resSix10265.ErrMsg
  23530. res2.Cainfo = resSix10265.Cainfo
  23531. res2.WarnMsg = resSix10265.WarnMsg
  23532. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23533. res2.Infcode = infocode
  23534. } else {
  23535. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23536. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  23537. utils.ErrorLog("解析失败:%v", err)
  23538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23539. return
  23540. }
  23541. res2.Infcode = res3.Infcode
  23542. } else {
  23543. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23544. utils.ErrorLog("解析失败:%v", err)
  23545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23546. return
  23547. }
  23548. }
  23549. }
  23550. }
  23551. if res2.Infcode == -1 {
  23552. utils.ErrorLog("解析失败:%v", res2.Infcode)
  23553. c.ServeSuccessJSON(map[string]interface{}{
  23554. "failed_code": -10,
  23555. "msg": res2.ErrMsg,
  23556. })
  23557. return
  23558. }
  23559. if res2.Infcode == 0 {
  23560. if err == nil {
  23561. c.ServeSuccessJSON(map[string]interface{}{
  23562. "msg": "退号成功",
  23563. })
  23564. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  23565. } else {
  23566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23567. return
  23568. }
  23569. }
  23570. } else {
  23571. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  23572. //if err == nil {
  23573. // c.ServeSuccessJSON(map[string]interface{}{
  23574. // "msg": "退费成功",
  23575. // })
  23576. //} else {
  23577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23578. // return
  23579. //}
  23580. }
  23581. }
  23582. func (c *HisApiController) RefundDetail() {
  23583. order_id, _ := c.GetInt64("order_id")
  23584. admin_user_id, _ := c.GetInt64("admin_user_id")
  23585. //his_patient_id, _ := c.GetInt64("his_patient_id")
  23586. number := c.GetString("number")
  23587. record_time := c.GetString("record_time")
  23588. patient_id, _ := c.GetInt64("patient_id")
  23589. //med_type, _ := c.GetInt64("med_type")
  23590. timeLayout := "2006-01-02"
  23591. loc, _ := time.LoadLocation("Local")
  23592. adminUser := c.GetAdminUserInfo()
  23593. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23594. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23595. fmt.Println(err)
  23596. if err != nil {
  23597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23598. return
  23599. }
  23600. recordDateTime := theTime.Unix()
  23601. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  23602. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23603. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23604. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23605. var order models.HisOrder
  23606. order, _ = service.GetHisOrderByID(order_id)
  23607. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23608. if config.IsOpen == 1 { //对接了医保,走医保流程
  23609. var res2 ResultSix
  23610. if miConfig.MdtrtareaAdmvs == "421300" {
  23611. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23612. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23613. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23614. resp3, requestErr3 := http.Get(api3)
  23615. if requestErr3 != nil {
  23616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23617. return
  23618. }
  23619. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23620. if ioErr3 != nil {
  23621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23623. return
  23624. }
  23625. var respJSON3 map[string]interface{}
  23626. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23629. return
  23630. }
  23631. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23632. userJSONBytes3, _ := json.Marshal(respJSON3)
  23633. fmt.Println("log")
  23634. fmt.Println(string(userJSONBytes3))
  23635. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23636. utils.ErrorLog("解析失败:%v", err)
  23637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23638. return
  23639. }
  23640. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23641. if err == nil {
  23642. c.ServeSuccessJSON(map[string]interface{}{
  23643. "msg": "撤销明细成功",
  23644. })
  23645. return
  23646. } else {
  23647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23648. return
  23649. }
  23650. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23651. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23652. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23653. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23654. resp3, requestErr3 := http.Get(api3)
  23655. if requestErr3 != nil {
  23656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23657. return
  23658. }
  23659. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23660. if ioErr3 != nil {
  23661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23663. return
  23664. }
  23665. var respJSON3 map[string]interface{}
  23666. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23669. return
  23670. }
  23671. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23672. userJSONBytes3, _ := json.Marshal(respJSON3)
  23673. fmt.Println("log")
  23674. fmt.Println(string(userJSONBytes3))
  23675. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23676. utils.ErrorLog("解析失败:%v", err)
  23677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23678. return
  23679. }
  23680. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23681. if err == nil {
  23682. c.ServeSuccessJSON(map[string]interface{}{
  23683. "msg": "撤销明细成功",
  23684. })
  23685. return
  23686. } else {
  23687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23688. return
  23689. }
  23690. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23691. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  23692. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23693. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23694. resp3, requestErr3 := http.Get(api3)
  23695. if requestErr3 != nil {
  23696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23697. return
  23698. }
  23699. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23700. if ioErr3 != nil {
  23701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23703. return
  23704. }
  23705. var respJSON3 map[string]interface{}
  23706. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23709. return
  23710. }
  23711. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23712. userJSONBytes3, _ := json.Marshal(respJSON3)
  23713. fmt.Println("log")
  23714. fmt.Println(string(userJSONBytes3))
  23715. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23716. utils.ErrorLog("解析失败:%v", err)
  23717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23718. return
  23719. }
  23720. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23721. if err == nil {
  23722. c.ServeSuccessJSON(map[string]interface{}{
  23723. "msg": "撤销明细成功",
  23724. })
  23725. return
  23726. } else {
  23727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23728. return
  23729. }
  23730. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23731. var resSix10265 ResultSix10265
  23732. var api3 string
  23733. if miConfig.MdtrtareaAdmvs == "320921" {
  23734. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23735. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23736. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23737. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23738. } else {
  23739. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23740. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23741. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23742. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23743. }
  23744. resp3, requestErr3 := http.Get(api3)
  23745. utils.ErrorLog("接口: %v", requestErr3)
  23746. if requestErr3 != nil {
  23747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23748. return
  23749. }
  23750. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23751. if ioErr3 != nil {
  23752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23754. return
  23755. }
  23756. var respJSON3 map[string]interface{}
  23757. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23760. return
  23761. }
  23762. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23763. userJSONBytes3, _ := json.Marshal(respJSON3)
  23764. fmt.Println("log")
  23765. fmt.Println(string(userJSONBytes3))
  23766. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23767. utils.ErrorLog("解析失败:%v", err)
  23768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23769. return
  23770. }
  23771. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23772. res2.Output = resSix10265.Output
  23773. res2.ErrMsg = resSix10265.ErrMsg
  23774. res2.Cainfo = resSix10265.Cainfo
  23775. res2.WarnMsg = resSix10265.WarnMsg
  23776. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23777. res2.Infcode = infocode
  23778. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23779. if err == nil {
  23780. c.ServeSuccessJSON(map[string]interface{}{
  23781. "msg": "撤销明细成功",
  23782. })
  23783. return
  23784. } else {
  23785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23786. return
  23787. }
  23788. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23789. var api3 string
  23790. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  23791. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23792. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23793. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23794. resp3, requestErr3 := http.Get(api3)
  23795. utils.ErrorLog("接口: %v", requestErr3)
  23796. if requestErr3 != nil {
  23797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23798. return
  23799. }
  23800. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23801. if ioErr3 != nil {
  23802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23804. return
  23805. }
  23806. var respJSON3 map[string]interface{}
  23807. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23810. return
  23811. }
  23812. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23813. if status == "0" {
  23814. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23815. c.ServeSuccessJSON(map[string]interface{}{
  23816. "failed_code": -10,
  23817. "msg": err_msg,
  23818. })
  23819. return
  23820. }
  23821. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23822. userJSONBytes3, _ := json.Marshal(respJSON3)
  23823. fmt.Println("log")
  23824. fmt.Println(string(userJSONBytes3))
  23825. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23826. utils.ErrorLog("解析失败:%v", err)
  23827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23828. return
  23829. }
  23830. fmt.Println(res2.Infcode)
  23831. if res2.Infcode == -1 {
  23832. c.ServeSuccessJSON(map[string]interface{}{
  23833. "failed_code": -10,
  23834. "msg": res2.ErrMsg,
  23835. })
  23836. return
  23837. }
  23838. if res2.Infcode == 0 {
  23839. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23840. if err == nil {
  23841. c.ServeSuccessJSON(map[string]interface{}{
  23842. "msg": "撤销明细成功",
  23843. })
  23844. return
  23845. } else {
  23846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23847. return
  23848. }
  23849. } else {
  23850. c.ServeSuccessJSON(map[string]interface{}{
  23851. "failed_code": -10,
  23852. "msg": res2.ErrMsg,
  23853. })
  23854. }
  23855. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23856. if err == nil {
  23857. c.ServeSuccessJSON(map[string]interface{}{
  23858. "msg": "撤销明细成功",
  23859. })
  23860. return
  23861. } else {
  23862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23863. return
  23864. }
  23865. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23866. var resSix10265 ResultSix10265
  23867. var api3 string
  23868. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  23869. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23870. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23871. resp3, requestErr3 := http.Get(api3)
  23872. if requestErr3 != nil {
  23873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23874. return
  23875. }
  23876. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23877. if ioErr3 != nil {
  23878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23880. return
  23881. }
  23882. var respJSON3 map[string]interface{}
  23883. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23886. return
  23887. }
  23888. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23889. userJSONBytes3, _ := json.Marshal(respJSON3)
  23890. fmt.Println("log")
  23891. fmt.Println(string(userJSONBytes3))
  23892. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23893. utils.ErrorLog("解析失败:%v", err)
  23894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23895. return
  23896. }
  23897. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23898. res2.Output = resSix10265.Output
  23899. res2.ErrMsg = resSix10265.ErrMsg
  23900. res2.Cainfo = resSix10265.Cainfo
  23901. res2.WarnMsg = resSix10265.WarnMsg
  23902. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23903. res2.Infcode = infocode
  23904. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23905. if err == nil {
  23906. c.ServeSuccessJSON(map[string]interface{}{
  23907. "msg": "撤销明细成功",
  23908. })
  23909. return
  23910. } else {
  23911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23912. return
  23913. }
  23914. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23915. 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)
  23916. var dat map[string]interface{}
  23917. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23918. fmt.Println(dat)
  23919. } else {
  23920. fmt.Println(err)
  23921. }
  23922. saveLog(result2, src_request, "2205", "撤销明细")
  23923. userJSONBytes, _ := json.Marshal(dat)
  23924. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23925. utils.ErrorLog("解析失败:%v", err)
  23926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23927. return
  23928. }
  23929. if res2.Infcode == 0 {
  23930. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23931. if err == nil {
  23932. c.ServeSuccessJSON(map[string]interface{}{
  23933. "msg": "撤销明细成功",
  23934. })
  23935. return
  23936. } else {
  23937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23938. return
  23939. }
  23940. } else {
  23941. c.ServeSuccessJSON(map[string]interface{}{
  23942. "failed_code": -10,
  23943. "msg": res2.ErrMsg,
  23944. })
  23945. }
  23946. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23947. 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, "")
  23948. var dat map[string]interface{}
  23949. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23950. fmt.Println(dat)
  23951. } else {
  23952. fmt.Println(err)
  23953. }
  23954. saveLog(result2, src_request, "2205", "撤销明细")
  23955. userJSONBytes, _ := json.Marshal(dat)
  23956. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23957. utils.ErrorLog("解析失败:%v", err)
  23958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23959. return
  23960. }
  23961. if res2.Infcode == 0 {
  23962. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23963. if err == nil {
  23964. c.ServeSuccessJSON(map[string]interface{}{
  23965. "msg": "撤销明细成功",
  23966. })
  23967. return
  23968. } else {
  23969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23970. return
  23971. }
  23972. } else {
  23973. c.ServeSuccessJSON(map[string]interface{}{
  23974. "failed_code": -10,
  23975. "msg": res2.ErrMsg,
  23976. })
  23977. }
  23978. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23979. 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, "")
  23980. var dat map[string]interface{}
  23981. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23982. fmt.Println(dat)
  23983. } else {
  23984. fmt.Println(err)
  23985. }
  23986. saveLog(result2, src_request, "2205", "撤销明细")
  23987. userJSONBytes, _ := json.Marshal(dat)
  23988. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23989. utils.ErrorLog("解析失败:%v", err)
  23990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23991. return
  23992. }
  23993. if res2.Infcode == 0 {
  23994. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23995. if err == nil {
  23996. c.ServeSuccessJSON(map[string]interface{}{
  23997. "msg": "撤销明细成功",
  23998. })
  23999. return
  24000. } else {
  24001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24002. return
  24003. }
  24004. } else {
  24005. c.ServeSuccessJSON(map[string]interface{}{
  24006. "failed_code": -10,
  24007. "msg": res2.ErrMsg,
  24008. })
  24009. }
  24010. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24011. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  24012. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24013. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24014. resp2, requestErr2 := http.Get(api2)
  24015. if requestErr2 != nil {
  24016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24017. return
  24018. }
  24019. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  24020. if ioErr2 != nil {
  24021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  24022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24023. return
  24024. }
  24025. var respJSON2 map[string]interface{}
  24026. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  24027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24029. return
  24030. }
  24031. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24032. userJSONBytes3, _ := json.Marshal(respJSON2)
  24033. fmt.Println("log")
  24034. fmt.Println(string(userJSONBytes3))
  24035. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24036. utils.ErrorLog("解析失败:%v", err)
  24037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24038. return
  24039. }
  24040. if res2.Infcode == 0 {
  24041. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24042. if err == nil {
  24043. c.ServeSuccessJSON(map[string]interface{}{
  24044. "msg": "撤销明细成功",
  24045. })
  24046. return
  24047. } else {
  24048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24049. return
  24050. }
  24051. } else {
  24052. c.ServeSuccessJSON(map[string]interface{}{
  24053. "failed_code": -10,
  24054. "msg": res2.ErrMsg,
  24055. })
  24056. }
  24057. } else {
  24058. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  24059. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24060. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24061. resp2, requestErr2 := http.Get(api2)
  24062. if requestErr2 != nil {
  24063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24064. return
  24065. }
  24066. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  24067. if ioErr2 != nil {
  24068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  24069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24070. return
  24071. }
  24072. var respJSON2 map[string]interface{}
  24073. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  24074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24076. return
  24077. }
  24078. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24079. if err == nil {
  24080. c.ServeSuccessJSON(map[string]interface{}{
  24081. "msg": "撤销明细成功",
  24082. })
  24083. return
  24084. } else {
  24085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24086. return
  24087. }
  24088. }
  24089. } else {
  24090. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24091. if err == nil {
  24092. c.ServeSuccessJSON(map[string]interface{}{
  24093. "msg": "退费成功",
  24094. })
  24095. } else {
  24096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24097. return
  24098. }
  24099. }
  24100. }
  24101. // 对账
  24102. func (c *HisApiController) GetCheckAccount() {
  24103. start_time := c.GetString("start_time")
  24104. end_time := c.GetString("end_time")
  24105. insutype := c.GetString("insutype")
  24106. clr_type := c.GetString("clr_type")
  24107. clr_org := c.GetString("clr_optins")
  24108. admin_user_id, _ := c.GetInt64("admin_user_id")
  24109. adminUser := c.GetAdminUserInfo()
  24110. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24111. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24112. if len(clr_org) == 0 {
  24113. clr_org = miConfig.InsuplcAdmdvs
  24114. }
  24115. timeLayout := "2006-01-02"
  24116. loc, _ := time.LoadLocation("Local")
  24117. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  24118. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  24119. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  24120. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  24121. fixmedins_setl_cnt := int64(len(orders))
  24122. var medfee_sumamt float64
  24123. var acct_pay float64
  24124. var fund_pay_sumamt float64
  24125. for _, item := range orders {
  24126. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  24127. acct_pay = acct_pay + item.AcctPay
  24128. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  24129. }
  24130. var user_name string
  24131. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24132. if role.ID == 0 {
  24133. user_name = "xxx"
  24134. } else {
  24135. user_name = role.UserName
  24136. }
  24137. var res ResultEight
  24138. var res10188 ResultEightFor10188
  24139. if config.IsOpen == 1 {
  24140. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24141. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  24142. "insutype=" + insutype +
  24143. "&clr_type=" + clr_type +
  24144. "&setl_optins=" + clr_org +
  24145. "&stmt_begndate=" + start_time +
  24146. "&stm_enddate=" + end_time +
  24147. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24148. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24149. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24150. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24151. "&fixmedins_code=" + miConfig.Code +
  24152. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24153. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24154. "&secret_key=" + miConfig.SecretKey +
  24155. "&org_name=" + miConfig.OrgName +
  24156. "&doctor=" + user_name +
  24157. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24158. fmt.Println(api)
  24159. resp, requestErr := http.Get(api)
  24160. if requestErr != nil {
  24161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24162. return
  24163. }
  24164. body, ioErr := ioutil.ReadAll(resp.Body)
  24165. fmt.Println(body)
  24166. if ioErr != nil {
  24167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24169. return
  24170. }
  24171. var respJSON map[string]interface{}
  24172. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24175. return
  24176. }
  24177. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24178. userJSONBytes, _ := json.Marshal(respJSON)
  24179. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24180. utils.ErrorLog("解析失败:%v", err)
  24181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24182. return
  24183. }
  24184. res.InfRefmsgid = res10188.InfRefmsgid
  24185. res.Output = res10188.Output
  24186. res.ErrMsg = res10188.ErrMsg
  24187. res.Cainfo = res10188.Cainfo
  24188. res.WarnMsg = res10188.WarnMsg
  24189. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24190. res.Infcode = infocode
  24191. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24192. if clr_type != "9903" {
  24193. clr_type = "99" // 就诊 ID(来自2201接口返回)
  24194. }
  24195. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  24196. "insutype=" + insutype +
  24197. "&clr_type=" + clr_type +
  24198. "&setl_optins=" + clr_org +
  24199. "&stmt_begndate=" + start_time +
  24200. "&stm_enddate=" + end_time +
  24201. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24202. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24203. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24204. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24205. "&fixmedins_code=" + miConfig.Code +
  24206. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24207. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24208. "&secret_key=" + miConfig.SecretKey +
  24209. "&org_name=" + miConfig.OrgName +
  24210. "&doctor=" + user_name
  24211. resp, requestErr := http.Get(api)
  24212. if requestErr != nil {
  24213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24214. return
  24215. }
  24216. body, ioErr := ioutil.ReadAll(resp.Body)
  24217. if ioErr != nil {
  24218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24220. return
  24221. }
  24222. var respJSON map[string]interface{}
  24223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24226. return
  24227. }
  24228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24229. result, _ := json.Marshal(respJSON)
  24230. fmt.Println("log")
  24231. fmt.Println(string(result))
  24232. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  24233. utils.ErrorLog("解析失败:%v", err)
  24234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24235. return
  24236. }
  24237. res.InfRefmsgid = res10188.InfRefmsgid
  24238. res.Output = res10188.Output
  24239. res.ErrMsg = res10188.ErrMsg
  24240. res.Cainfo = res10188.Cainfo
  24241. res.WarnMsg = res10188.WarnMsg
  24242. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24243. res.Infcode = infocode
  24244. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24245. var baseParams models.BaseParams
  24246. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24247. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24248. baseParams.SecretKey = miConfig.SecretKey
  24249. baseParams.OrgName = miConfig.OrgName
  24250. baseParams.FixmedinsCode = miConfig.Code
  24251. baseParams.EncKey = miConfig.EncKey
  24252. baseParams.AppSecret = miConfig.AppSecret
  24253. baseParams.SignKey = miConfig.SignKey
  24254. baseParams.AppID = miConfig.Code
  24255. baseParams.Doctor = role.UserName
  24256. baseParams.RequestUrl = miConfig.Url
  24257. businessParams := models.BusinessParams{
  24258. Insutype: insutype,
  24259. ClrType: clr_type,
  24260. SetlOptins: clr_org,
  24261. StmtBegndate: start_time,
  24262. StmtEnddate: end_time,
  24263. MedfeeSumamt: medfee_sumamt,
  24264. FundPaySumamt: fund_pay_sumamt,
  24265. AcctPay: acct_pay,
  24266. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24267. }
  24268. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24269. fmt.Println(requestLog)
  24270. fmt.Println(result)
  24271. fmt.Println(err_msg)
  24272. var dat map[string]interface{}
  24273. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24274. fmt.Println(dat)
  24275. } else {
  24276. fmt.Println(err)
  24277. }
  24278. userJSONBytes, _ := json.Marshal(dat)
  24279. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24280. utils.ErrorLog("解析失败:%v", err)
  24281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24282. return
  24283. }
  24284. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24285. var baseParams models.BaseParams
  24286. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24287. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24288. baseParams.SecretKey = miConfig.SecretKey
  24289. baseParams.OrgName = miConfig.OrgName
  24290. baseParams.FixmedinsCode = miConfig.Code
  24291. baseParams.EncKey = miConfig.EncKey
  24292. baseParams.AppSecret = miConfig.AppSecret
  24293. baseParams.SignKey = miConfig.SignKey
  24294. baseParams.AppID = miConfig.Code
  24295. baseParams.Doctor = role.UserName
  24296. baseParams.RequestUrl = miConfig.Url
  24297. baseParams.AccessKey = miConfig.AccessKey
  24298. businessParams := models.BusinessParams{
  24299. Insutype: insutype,
  24300. ClrType: clr_type,
  24301. SetlOptins: "430822",
  24302. StmtBegndate: start_time,
  24303. StmtEnddate: end_time,
  24304. MedfeeSumamt: medfee_sumamt,
  24305. FundPaySumamt: fund_pay_sumamt,
  24306. AcctPay: acct_pay,
  24307. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24308. }
  24309. 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)
  24310. fmt.Println(requestLog)
  24311. fmt.Println(result)
  24312. var dat map[string]interface{}
  24313. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24314. fmt.Println(dat)
  24315. } else {
  24316. fmt.Println(err)
  24317. }
  24318. userJSONBytes, _ := json.Marshal(dat)
  24319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24320. utils.ErrorLog("解析失败:%v", err)
  24321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24322. return
  24323. }
  24324. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24325. var baseParams models.BaseParams
  24326. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24327. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24328. baseParams.SecretKey = miConfig.SecretKey
  24329. baseParams.OrgName = miConfig.OrgName
  24330. baseParams.FixmedinsCode = miConfig.Code
  24331. baseParams.EncKey = miConfig.EncKey
  24332. baseParams.AppSecret = miConfig.AppSecret
  24333. baseParams.SignKey = miConfig.SignKey
  24334. baseParams.AppID = miConfig.Code
  24335. baseParams.Doctor = role.UserName
  24336. baseParams.RequestUrl = miConfig.Url
  24337. businessParams := models.BusinessParams{
  24338. Insutype: insutype,
  24339. ClrType: clr_type,
  24340. SetlOptins: clr_org,
  24341. StmtBegndate: start_time,
  24342. StmtEnddate: end_time,
  24343. MedfeeSumamt: medfee_sumamt,
  24344. FundPaySumamt: fund_pay_sumamt,
  24345. AcctPay: acct_pay,
  24346. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24347. }
  24348. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24349. fmt.Println(requestLog)
  24350. fmt.Println(result)
  24351. fmt.Println(err_msg)
  24352. var dat map[string]interface{}
  24353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24354. fmt.Println(dat)
  24355. } else {
  24356. fmt.Println(err)
  24357. }
  24358. userJSONBytes, _ := json.Marshal(dat)
  24359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24360. utils.ErrorLog("解析失败:%v", err)
  24361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24362. return
  24363. }
  24364. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24365. if len(clr_type) == 0 {
  24366. clr_type = "11"
  24367. }
  24368. api := miConfig.Url + "gdyb/ten?" +
  24369. "insutype=" + insutype +
  24370. "&clr_type=" + clr_type +
  24371. "&setl_optins=" + clr_org +
  24372. "&stmt_begndate=" + start_time +
  24373. "&stm_enddate=" + end_time +
  24374. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24375. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24376. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24377. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24378. "&fixmedins_code=" + miConfig.Code +
  24379. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24380. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24381. "&secret_key=" + miConfig.SecretKey +
  24382. "&org_name=" + miConfig.OrgName +
  24383. "&doctor=" + user_name
  24384. fmt.Println(api)
  24385. resp, requestErr := http.Get(api)
  24386. if requestErr != nil {
  24387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24388. return
  24389. }
  24390. body, ioErr := ioutil.ReadAll(resp.Body)
  24391. fmt.Println(body)
  24392. if ioErr != nil {
  24393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24395. return
  24396. }
  24397. var respJSON map[string]interface{}
  24398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24401. return
  24402. }
  24403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24404. userJSONBytes, _ := json.Marshal(respJSON)
  24405. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24406. utils.ErrorLog("解析失败:%v", err)
  24407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24408. return
  24409. }
  24410. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24411. var baseParams models.BaseParams
  24412. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24413. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24414. baseParams.SecretKey = miConfig.SecretKey
  24415. baseParams.OrgName = miConfig.OrgName
  24416. baseParams.FixmedinsCode = miConfig.Code
  24417. baseParams.EncKey = miConfig.EncKey
  24418. baseParams.AppSecret = miConfig.AppSecret
  24419. baseParams.SignKey = miConfig.SignKey
  24420. baseParams.AppID = miConfig.Code
  24421. baseParams.Doctor = role.UserName
  24422. baseParams.RequestUrl = miConfig.Url
  24423. if clr_type == "9903" {
  24424. clr_type = "9901"
  24425. }
  24426. businessParams := models.BusinessParams{
  24427. Insutype: insutype,
  24428. ClrType: clr_type,
  24429. SetlOptins: "360302",
  24430. StmtBegndate: start_time,
  24431. StmtEnddate: end_time,
  24432. MedfeeSumamt: 0,
  24433. FundPaySumamt: 0,
  24434. AcctPay: 0,
  24435. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24436. }
  24437. 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))
  24438. fmt.Println(requestLog)
  24439. fmt.Println(result)
  24440. var dat map[string]interface{}
  24441. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24442. fmt.Println(dat)
  24443. } else {
  24444. fmt.Println(err)
  24445. }
  24446. userJSONBytes, _ := json.Marshal(dat)
  24447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24448. utils.ErrorLog("解析失败:%v", err)
  24449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24450. return
  24451. }
  24452. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24453. var api string
  24454. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  24455. "&clr_type=" + clr_type +
  24456. "&setl_optins=" + clr_org +
  24457. "&stmt_begndate=" + start_time +
  24458. "&stm_enddate=" + end_time +
  24459. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24460. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24461. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24462. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24463. "&fixmedins_code=" + miConfig.Code +
  24464. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24465. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24466. "&secret_key=" + miConfig.SecretKey +
  24467. "&org_name=" + miConfig.OrgName +
  24468. "&doctor=" + user_name + "&url=" + miConfig.Url
  24469. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24470. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24471. resp, requestErr := http.Get(api)
  24472. if requestErr != nil {
  24473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24474. return
  24475. }
  24476. body, ioErr := ioutil.ReadAll(resp.Body)
  24477. if ioErr != nil {
  24478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24480. return
  24481. }
  24482. var respJSON map[string]interface{}
  24483. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24486. return
  24487. }
  24488. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24489. if status == "0" {
  24490. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24491. c.ServeSuccessJSON(map[string]interface{}{
  24492. "failed_code": -10,
  24493. "msg": err_msg,
  24494. })
  24495. return
  24496. }
  24497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24498. userJSONBytes, _ := json.Marshal(respJSON)
  24499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24500. utils.ErrorLog("解析失败:%v", err)
  24501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24502. return
  24503. }
  24504. } else {
  24505. if len(clr_type) == 0 {
  24506. clr_type = "11"
  24507. }
  24508. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24509. "insutype=" + insutype +
  24510. "&clr_type=" + clr_type +
  24511. "&setl_optins=" + clr_org +
  24512. "&stmt_begndate=" + start_time +
  24513. "&stm_enddate=" + end_time +
  24514. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24515. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24516. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24517. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24518. "&fixmedins_code=" + miConfig.Code +
  24519. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24520. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24521. "&secret_key=" + miConfig.SecretKey +
  24522. "&org_name=" + miConfig.OrgName +
  24523. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24524. fmt.Println(api)
  24525. resp, requestErr := http.Get(api)
  24526. if requestErr != nil {
  24527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24528. return
  24529. }
  24530. body, ioErr := ioutil.ReadAll(resp.Body)
  24531. fmt.Println(body)
  24532. if ioErr != nil {
  24533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24535. return
  24536. }
  24537. var respJSON map[string]interface{}
  24538. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24541. return
  24542. }
  24543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24544. userJSONBytes, _ := json.Marshal(respJSON)
  24545. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24546. utils.ErrorLog("解析失败:%v", err)
  24547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24548. return
  24549. }
  24550. }
  24551. if res.Infcode == 0 {
  24552. if res.Output.Stmtinfo.StmtRslt == "0" {
  24553. micc := &models.MedicalInsuranceCostCompare{
  24554. StartTime: startime.Unix(),
  24555. EndTime: endtime.Unix(),
  24556. Insutype: insutype,
  24557. CheckType: 1,
  24558. Num: fixmedins_setl_cnt,
  24559. Mtime: time.Now().Unix(),
  24560. Status: 1,
  24561. UserOrgId: adminUser.CurrentOrgId,
  24562. CostTotal: medfee_sumamt,
  24563. FuncTotal: fund_pay_sumamt,
  24564. PsnPay: acct_pay,
  24565. Creator: admin_user_id,
  24566. Ctime: time.Now().Unix(),
  24567. ClrType: clr_type,
  24568. }
  24569. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  24570. if err == nil {
  24571. c.ServeSuccessJSON(map[string]interface{}{
  24572. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  24573. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  24574. })
  24575. } else {
  24576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24577. }
  24578. } else {
  24579. c.ServeSuccessJSON(map[string]interface{}{
  24580. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  24581. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  24582. })
  24583. }
  24584. } else {
  24585. c.ServeSuccessJSON(map[string]interface{}{
  24586. "failed_code": -10,
  24587. "msg": res.ErrMsg,
  24588. })
  24589. }
  24590. }
  24591. }
  24592. func (c *HisApiController) Check310() {
  24593. adminUser := c.GetAdminUserInfo()
  24594. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24595. var user_name string
  24596. user_name = "高慧裕"
  24597. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24598. "insutype=" + "310" +
  24599. "&clr_type=" + "" +
  24600. "&setl_optins=" + "441202" +
  24601. "&stmt_begndate=" + "2022-03-01" +
  24602. "&stm_enddate=" + "2022-03-31" +
  24603. "&medfee_sumamt=" + "194930.12" +
  24604. "&fund_pay_sumamt=" + "188741.46" +
  24605. "&acct_pay=" + "0" +
  24606. "&fixmedins_setl_cnt=" + "452" +
  24607. "&fixmedins_code=" + miConfig.Code +
  24608. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24609. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24610. "&secret_key=" + miConfig.SecretKey +
  24611. "&org_name=" + miConfig.OrgName +
  24612. "&doctor=" + user_name
  24613. fmt.Println(api)
  24614. resp, requestErr := http.Get(api)
  24615. if requestErr != nil {
  24616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24617. return
  24618. }
  24619. body, ioErr := ioutil.ReadAll(resp.Body)
  24620. fmt.Println(body)
  24621. if ioErr != nil {
  24622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24624. return
  24625. }
  24626. var respJSON map[string]interface{}
  24627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24630. return
  24631. }
  24632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24633. userJSONBytes, _ := json.Marshal(respJSON)
  24634. var res ResultEight
  24635. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24636. utils.ErrorLog("解析失败:%v", err)
  24637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24638. return
  24639. }
  24640. }
  24641. func (c *HisApiController) Check390() {
  24642. adminUser := c.GetAdminUserInfo()
  24643. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24644. var user_name string
  24645. user_name = "高慧裕"
  24646. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24647. "insutype=" + "390" +
  24648. "&clr_type=" + "" +
  24649. "&setl_optins=" + "441202" +
  24650. "&stmt_begndate=" + "2022-03-01" +
  24651. "&stm_enddate=" + "2022-03-31" +
  24652. "&medfee_sumamt=" + "1068448.89" +
  24653. "&fund_pay_sumamt=" + "1014677.62" +
  24654. "&acct_pay=" + "0" +
  24655. "&fixmedins_setl_cnt=" + "1950" +
  24656. "&fixmedins_code=" + miConfig.Code +
  24657. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24658. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24659. "&secret_key=" + miConfig.SecretKey +
  24660. "&org_name=" + miConfig.OrgName +
  24661. "&doctor=" + user_name
  24662. fmt.Println(api)
  24663. resp, requestErr := http.Get(api)
  24664. if requestErr != nil {
  24665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24666. return
  24667. }
  24668. body, ioErr := ioutil.ReadAll(resp.Body)
  24669. fmt.Println(body)
  24670. if ioErr != nil {
  24671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24673. return
  24674. }
  24675. var respJSON map[string]interface{}
  24676. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24679. return
  24680. }
  24681. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24682. userJSONBytes, _ := json.Marshal(respJSON)
  24683. var res ResultEight
  24684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24685. utils.ErrorLog("解析失败:%v", err)
  24686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24687. return
  24688. }
  24689. }
  24690. // 对账明细
  24691. func (c *HisApiController) GetCheckDetailAccount() {
  24692. start_time := c.GetString("start_time")
  24693. end_time := c.GetString("end_time")
  24694. admin_user_id, _ := c.GetInt64("admin_user_id")
  24695. adminUser := c.GetAdminUserInfo()
  24696. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24697. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24698. timeLayout := "2006-01-02"
  24699. loc, _ := time.LoadLocation("Local")
  24700. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  24701. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  24702. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  24703. rand.Seed(time.Now().UnixNano())
  24704. num := rand.Intn(30000)
  24705. Mkdir(miConfig.OrgName)
  24706. file := strconv.FormatInt(int64(num), 10)
  24707. file_name := file + ".txt"
  24708. zip_name := file + ".zip"
  24709. zip_path := miConfig.OrgName + "/" + zip_name
  24710. file_path := miConfig.OrgName + "/" + file_name
  24711. decimal.DivisionPrecision = 2
  24712. var medfee_sumamt float64
  24713. var psn_cash_pay float64
  24714. var fund_pay_sumamt float64
  24715. fixmedins_setl_cnt := int64(len(orders))
  24716. for _, item := range orders {
  24717. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  24718. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  24719. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  24720. }
  24721. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  24722. defer f.Close()
  24723. if err != nil {
  24724. fmt.Println(err.Error())
  24725. } else {
  24726. for _, item := range orders {
  24727. var refd_setl_flag string
  24728. if item.OrderStatus == 2 {
  24729. refd_setl_flag = "0"
  24730. var str string
  24731. str = item.SetlId + " " +
  24732. item.MdtrtId + " " +
  24733. item.PsnNo + " " +
  24734. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  24735. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  24736. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  24737. _, err = f.Write([]byte(str))
  24738. }
  24739. if item.OrderStatus == 3 {
  24740. var str string
  24741. str = item.SetlId + " " +
  24742. item.MdtrtId + " " +
  24743. item.PsnNo + " " +
  24744. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  24745. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  24746. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  24747. _, err = f.Write([]byte(str))
  24748. var str2 string
  24749. str2 = item.SetlId + " " +
  24750. item.MdtrtId + " " +
  24751. item.PsnNo + " " +
  24752. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  24753. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  24754. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  24755. _, err = f.Write([]byte(str2))
  24756. }
  24757. }
  24758. }
  24759. Zip(file_path, zip_path)
  24760. fmt.Println(ReadFile(zip_path))
  24761. fmt.Println(string(ReadFile(zip_path)))
  24762. if config.IsOpen == 1 {
  24763. var user_name string
  24764. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24765. if role.ID == 0 {
  24766. user_name = "管理员"
  24767. } else {
  24768. user_name = role.UserName
  24769. }
  24770. baseParams := models.BaseParams{
  24771. SecretKey: miConfig.SecretKey,
  24772. FixmedinsCode: miConfig.Code,
  24773. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  24774. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  24775. OrgName: miConfig.OrgName,
  24776. Doctor: user_name,
  24777. }
  24778. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  24779. var dat map[string]interface{}
  24780. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24781. fmt.Println(dat)
  24782. } else {
  24783. fmt.Println(err)
  24784. }
  24785. userJSONBytes, _ := json.Marshal(dat)
  24786. var res ResultNine
  24787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24788. utils.ErrorLog("解析失败:%v", err)
  24789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24790. return
  24791. }
  24792. if res.Infcode == 0 {
  24793. fileNo := res.Output.FileQuryNo
  24794. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  24795. "file_qury_no=" + fileNo +
  24796. "&setl_optins=" + "定点医保中心" +
  24797. "&stmt_begndate=" + start_time +
  24798. "&stm_enddate=" + end_time +
  24799. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24800. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24801. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  24802. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24803. "&fixmedins_code=" + miConfig.Code +
  24804. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24805. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24806. "&secret_key=" + miConfig.SecretKey +
  24807. "&org_name=" + miConfig.OrgName +
  24808. "&doctor=" + user_name
  24809. resp, requestErr := http.Get(api)
  24810. if requestErr != nil {
  24811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24812. return
  24813. }
  24814. body, ioErr := ioutil.ReadAll(resp.Body)
  24815. if ioErr != nil {
  24816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24818. return
  24819. }
  24820. var respJSON map[string]interface{}
  24821. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24824. return
  24825. }
  24826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24827. userJSONBytes, _ := json.Marshal(respJSON)
  24828. var res ResultTen
  24829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24830. utils.ErrorLog("解析失败:%v", err)
  24831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24832. return
  24833. }
  24834. if res.Infcode == 0 {
  24835. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  24836. micc := &models.MedicalInsuranceCostCompare{
  24837. StartTime: startime.Unix(),
  24838. EndTime: endtime.Unix(),
  24839. Insutype: "0",
  24840. CheckType: 2,
  24841. Num: fixmedins_setl_cnt,
  24842. Mtime: time.Now().Unix(),
  24843. Status: 1,
  24844. UserOrgId: adminUser.CurrentOrgId,
  24845. CostTotal: medfee_sumamt,
  24846. FuncTotal: fund_pay_sumamt,
  24847. PsnPay: psn_cash_pay,
  24848. Creator: admin_user_id,
  24849. Ctime: time.Now().Unix(),
  24850. }
  24851. service.CreateMedicalInsuranceCostCompareRecord(micc)
  24852. c.ServeSuccessJSON(map[string]interface{}{
  24853. "msg": "明细对账成功",
  24854. })
  24855. }
  24856. } else {
  24857. }
  24858. }
  24859. }
  24860. type CustomOrderInfo struct {
  24861. Name string
  24862. Spec string
  24863. Unit string
  24864. Count float64
  24865. Price float64
  24866. Total float64
  24867. }
  24868. func (c *HisApiController) GetBatchSettleAccounts() {
  24869. admin_user_id, _ := c.GetInt64("admin_user_id")
  24870. order_ids := c.GetString("order_ids")
  24871. order_ids_arr := strings.Split(order_ids, ",")
  24872. data3 := []map[string]interface{}{}
  24873. for _, item := range order_ids_arr {
  24874. id, _ := strconv.ParseInt(item, 10, 64)
  24875. order_id := id
  24876. adminUser := c.GetAdminUserInfo()
  24877. order, _ := service.GetHisOrderByID(order_id)
  24878. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24879. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  24880. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  24881. orderInfos = append(orderInfos, orderInfos_two...)
  24882. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  24883. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  24884. var diagnosis_ids []string
  24885. if his.ID > 0 {
  24886. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  24887. } else {
  24888. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  24889. }
  24890. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  24891. var dia_config []*models.HisXtDiagnoseConfig
  24892. var name string
  24893. for _, item := range diagnosis_ids {
  24894. id, _ := strconv.ParseInt(item, 10, 64)
  24895. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24896. dia_config = append(dia_config, &diagnosisConfig)
  24897. if len(name) == 0 {
  24898. name = diagnosisConfig.ClassName
  24899. }
  24900. //} else {
  24901. // name = name + "," + diagnosisConfig.ClassName
  24902. //}
  24903. }
  24904. var bedCostTotal float64 = 0 //床位总费
  24905. var bedCostSelfTotal float64 = 0 //床位自费
  24906. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  24907. var bedSelfTotal float64 = 0 //床位部分项目自费
  24908. var bedInscpTotal float64 = 0 //床位部分项目自费
  24909. var operationCostTotal float64 = 0 //手术费
  24910. var operationCostSelfTotal float64 = 0 //手术费
  24911. var operationCostPartSelfTotal float64 = 0 //手术费
  24912. var operationSelfTotal float64 = 0 //床位部分项目自费
  24913. var operationInscpTotal float64 = 0 //床位部分项目自费
  24914. var otherCostTotal float64 = 0 //其他费用
  24915. var otherCostSelfTotal float64 = 0 //其他费用
  24916. var otherCostPartSelfTotal float64 = 0 //其他费用
  24917. var otherSelfTotal float64 = 0 //床位部分项目自费
  24918. var otherInscpTotal float64 = 0 //床位部分项目自费
  24919. var materialCostTotal float64 = 0 //材料费
  24920. var materialCostSelfTotal float64 = 0 //材料费
  24921. var materialCostPartSelfTotal float64 = 0 //材料费
  24922. var materialSelfTotal float64 = 0 //床位部分项目自费
  24923. var materialInscpTotal float64 = 0 //床位部分项目自费
  24924. var westernMedicineCostTotal float64 = 0 //西药费
  24925. var westernMedicineCostSelfTotal float64 = 0 //西药费
  24926. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  24927. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  24928. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  24929. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  24930. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  24931. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  24932. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  24933. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  24934. var checkCostTotal float64 = 0 //检查费
  24935. var checkCostSelfTotal float64 = 0 //检查费
  24936. var checkCostPartSelfTotal float64 = 0 //检查费
  24937. var checkSelfTotal float64 = 0 //床位部分项目自费
  24938. var checkInscpTotal float64 = 0 //床位部分项目自费
  24939. var laboratoryCostTotal float64 = 0 //化验费
  24940. var laboratoryCostSelfTotal float64 = 0 //化验费
  24941. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  24942. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  24943. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  24944. var treatCostTotal float64 = 0 //治疗费用
  24945. var treatCostSelfTotal float64 = 0 //治疗费用
  24946. var treatCostPartSelfTotal float64 = 0 //治疗费用
  24947. var treatSelfTotal float64 = 0 //床位部分项目自费
  24948. var treatInscpTotal float64 = 0 //床位部分项目自费
  24949. decimal.DivisionPrecision = 2
  24950. for _, item := range orderInfos {
  24951. if item.MedChrgitmType == "01" { //床位费
  24952. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24953. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24954. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24955. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24956. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24957. }
  24958. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  24959. if item.MedChrgitmType == "03" { //检查费
  24960. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24961. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24962. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24963. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24964. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24965. }
  24966. } else {
  24967. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  24968. fmt.Println("------------")
  24969. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24970. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24971. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24972. }
  24973. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  24974. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24975. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24976. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24977. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24978. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24979. }
  24980. }
  24981. if item.MedChrgitmType == "04" { //化验费
  24982. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24983. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24984. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24985. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24986. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24987. }
  24988. if item.MedChrgitmType == "05" { //治疗费
  24989. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24990. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24991. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24992. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24993. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24994. }
  24995. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  24996. fmt.Println("------------")
  24997. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24998. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24999. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25000. }
  25001. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25002. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25003. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25004. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25005. }
  25006. //if item.MedChrgitmType == "06" { //手术费
  25007. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25008. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25009. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25010. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25011. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25012. //
  25013. //}
  25014. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25015. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25016. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25017. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25018. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25019. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25020. }
  25021. if item.MedChrgitmType == "09" { //西药费
  25022. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25023. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25024. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25025. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25026. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25027. }
  25028. if item.MedChrgitmType == "11" { //中成费
  25029. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25030. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25031. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25032. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25033. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25034. }
  25035. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25036. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25037. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25038. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25039. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25040. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25041. }
  25042. }
  25043. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25044. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25045. var user_name string
  25046. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25047. if role.ID == 0 {
  25048. user_name = "管理员"
  25049. } else {
  25050. user_name = role.UserName
  25051. }
  25052. baseParams := models.BaseParams{
  25053. SecretKey: miConfig.SecretKey,
  25054. FixmedinsCode: miConfig.Code,
  25055. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25056. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25057. OrgName: miConfig.OrgName,
  25058. Doctor: user_name,
  25059. RequestUrl: miConfig.Url,
  25060. AccessKey: miConfig.AccessKey,
  25061. }
  25062. businessParams := models.BusinessParams{
  25063. PsnNo: order.PsnNo,
  25064. MdtrtId: order.MdtrtId,
  25065. SetlId: order.SetlId,
  25066. }
  25067. var res ResultEleven
  25068. var resEleven10265 ResultEleven10265
  25069. if config.IsOpen == 1 {
  25070. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  25071. result := service.Gdyb5203(baseParams, businessParams)
  25072. service.Gdyb5204(baseParams, businessParams)
  25073. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  25074. var dat map[string]interface{}
  25075. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25076. fmt.Println(dat)
  25077. } else {
  25078. fmt.Println(err)
  25079. }
  25080. userJSONBytes, _ := json.Marshal(dat)
  25081. if miConfig.Code == "H15049901371" {
  25082. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  25083. utils.ErrorLog("解析失败:%v", err)
  25084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25085. return
  25086. }
  25087. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25088. res.Output = resEleven10265.Output
  25089. res.ErrMsg = resEleven10265.ErrMsg
  25090. res.Cainfo = resEleven10265.Cainfo
  25091. res.WarnMsg = resEleven10265.WarnMsg
  25092. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25093. res.Infcode = infocode
  25094. } else {
  25095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25096. utils.ErrorLog("解析失败:%v", err)
  25097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25098. return
  25099. }
  25100. }
  25101. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25102. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  25103. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  25104. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25105. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  25106. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25107. var doctor_name string
  25108. if roles.ID == 0 {
  25109. doctor_name = "管理员"
  25110. } else {
  25111. doctor_name = roles.UserName
  25112. }
  25113. yiliao_leibie := ""
  25114. switch order.MedType {
  25115. case "11":
  25116. yiliao_leibie = "普通门诊"
  25117. break
  25118. case "12":
  25119. yiliao_leibie = "门诊挂号"
  25120. break
  25121. case "13":
  25122. yiliao_leibie = "急诊"
  25123. break
  25124. case "14":
  25125. yiliao_leibie = "门诊特殊病"
  25126. break
  25127. case "15":
  25128. yiliao_leibie = "门诊统筹"
  25129. break
  25130. case "16":
  25131. yiliao_leibie = "门诊慢性病"
  25132. break
  25133. case "21":
  25134. yiliao_leibie = "普通住院"
  25135. break
  25136. }
  25137. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25138. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  25139. if res.Infcode == 0 {
  25140. data2 := map[string]interface{}{
  25141. "diagnosis": name,
  25142. "order_infos": orderInfos,
  25143. "number": order.MdtrtId,
  25144. "date": order.SettleAccountsDate,
  25145. "charge_admin": charge_admin,
  25146. "printor_admin": printor_admin,
  25147. "info": res.Output.Setlinfo,
  25148. "order": order,
  25149. "bedCostTotal": bedCostTotal,
  25150. "bedCostSelfTotal": bedCostSelfTotal,
  25151. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  25152. "bedSelfTotal": bedSelfTotal,
  25153. "bedInscpTotal": bedInscpTotal,
  25154. "operationCostTotal": operationCostTotal,
  25155. "operationCostSelfTotal": operationCostSelfTotal,
  25156. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  25157. "operationSelfTotal": operationSelfTotal,
  25158. "operationInscpTotal": operationInscpTotal,
  25159. "otherCostTotal": otherCostTotal,
  25160. "otherCostSelfTotal": otherCostSelfTotal,
  25161. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  25162. "otherSelfTotal": otherSelfTotal,
  25163. "otherInscpTotal": otherInscpTotal,
  25164. "materialCostTotal": materialCostTotal,
  25165. "materialCostSelfTotal": materialCostSelfTotal,
  25166. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25167. "materialSelfTotal": materialSelfTotal,
  25168. "materialInscpTotal": materialInscpTotal,
  25169. "westernMedicineCostTotal": westernMedicineCostTotal,
  25170. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25171. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25172. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25173. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25174. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25175. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25176. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25177. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25178. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25179. "checkCostTotal": checkCostTotal,
  25180. "checkCostSelfTotal": checkCostSelfTotal,
  25181. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25182. "checkSelfTotal": checkSelfTotal,
  25183. "checkInscpTotal": checkInscpTotal,
  25184. "laboratoryCostTotal": laboratoryCostTotal,
  25185. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  25186. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  25187. "laboratorySelfTotal": laboratorySelfTotal,
  25188. "laboratoryInscpTotal": laboratoryInscpTotal,
  25189. "treatCostTotal": treatCostTotal,
  25190. "treatCostSelfTotal": treatCostSelfTotal,
  25191. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  25192. "treatSelfTotal": treatSelfTotal,
  25193. "treatInscpTotal": treatInscpTotal,
  25194. "doctor_info": doctor_info,
  25195. "doctor_code": adminRole_two.DoctorCode,
  25196. "doctor_name": doctor_name,
  25197. "health_card_no": order.PsnNo,
  25198. "department": departments.Name,
  25199. "yiliao_leibie": yiliao_leibie,
  25200. "after_money": order.AccountPrice,
  25201. "patient": patient,
  25202. "org_name": miConfig.OrgName,
  25203. "org_code": miConfig.Code,
  25204. "order_number": order.Number,
  25205. "his_hospital": his_hospital,
  25206. "his": his,
  25207. "dia_config": dia_config,
  25208. "psn_cash_pay": order.PsnCashPay,
  25209. //"check_order_info": cus_slice,
  25210. }
  25211. data3 = append(data3, data2)
  25212. }
  25213. }
  25214. }
  25215. c.ServeSuccessJSON(map[string]interface{}{
  25216. "infos": data3,
  25217. })
  25218. }
  25219. func (c *HisApiController) GetSettleAccounts() {
  25220. //id, _ := c.GetInt64("id")
  25221. //record_time := c.GetString("record_time")
  25222. order_id, _ := c.GetInt64("order_id")
  25223. admin_user_id, _ := c.GetInt64("admin_user_id")
  25224. //timeLayout := "2006-01-02"
  25225. //loc, _ := time.LoadLocation("Local")
  25226. //
  25227. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25228. //if err != nil {
  25229. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25230. // return
  25231. //}Hbyb5203
  25232. //recordDateTime := theTime.Unix()
  25233. adminUser := c.GetAdminUserInfo()
  25234. order, _ := service.GetHisOrderByID(order_id)
  25235. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25236. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  25237. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  25238. orderInfos = append(orderInfos, orderInfos_two...)
  25239. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  25240. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  25241. var diagnosis_ids []string
  25242. if his.ID > 0 {
  25243. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  25244. } else {
  25245. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  25246. }
  25247. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  25248. var dia_config []*models.HisXtDiagnoseConfig
  25249. var name string
  25250. for _, item := range diagnosis_ids {
  25251. id, _ := strconv.ParseInt(item, 10, 64)
  25252. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25253. dia_config = append(dia_config, &diagnosisConfig)
  25254. if len(name) == 0 {
  25255. name = diagnosisConfig.ClassName
  25256. } else {
  25257. name = name + "," + diagnosisConfig.ClassName
  25258. }
  25259. }
  25260. if patient.UserOrgId == 10215 {
  25261. name = "慢性肾功能不全(血透治疗)"
  25262. }
  25263. var bedCostTotal float64 = 0 //床位总费
  25264. var bedCostSelfTotal float64 = 0 //床位自费
  25265. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  25266. var bedSelfTotal float64 = 0 //床位部分项目自费
  25267. var bedInscpTotal float64 = 0 //床位部分项目自费
  25268. var operationCostTotal float64 = 0 //手术费
  25269. var operationCostSelfTotal float64 = 0 //手术费
  25270. var operationCostPartSelfTotal float64 = 0 //手术费
  25271. var operationSelfTotal float64 = 0 //床位部分项目自费
  25272. var operationInscpTotal float64 = 0 //床位部分项目自费
  25273. var otherCostTotal float64 = 0 //其他费用
  25274. var otherCostSelfTotal float64 = 0 //其他费用
  25275. var otherCostPartSelfTotal float64 = 0 //其他费用
  25276. var otherSelfTotal float64 = 0 //床位部分项目自费
  25277. var otherInscpTotal float64 = 0 //床位部分项目自费
  25278. var materialCostTotal float64 = 0 //材料费
  25279. var materialCostSelfTotal float64 = 0 //材料费
  25280. var materialCostPartSelfTotal float64 = 0 //材料费
  25281. var materialSelfTotal float64 = 0 //床位部分项目自费
  25282. var materialInscpTotal float64 = 0 //床位部分项目自费
  25283. var westernMedicineCostTotal float64 = 0 //西药费
  25284. var westernMedicineCostSelfTotal float64 = 0 //西药费
  25285. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  25286. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  25287. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  25288. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  25289. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  25290. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  25291. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  25292. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  25293. var checkCostTotal float64 = 0 //检查费
  25294. var checkCostSelfTotal float64 = 0 //检查费
  25295. var checkCostPartSelfTotal float64 = 0 //检查费
  25296. var checkSelfTotal float64 = 0 //床位部分项目自费
  25297. var checkInscpTotal float64 = 0 //床位部分项目自费
  25298. var laboratoryCostTotal float64 = 0 //化验费
  25299. var laboratoryCostSelfTotal float64 = 0 //化验费
  25300. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  25301. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  25302. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  25303. var treatCostTotal float64 = 0 //治疗费用
  25304. var treatCostSelfTotal float64 = 0 //治疗费用
  25305. var treatCostPartSelfTotal float64 = 0 //治疗费用
  25306. var treatSelfTotal float64 = 0 //床位部分项目自费
  25307. var treatInscpTotal float64 = 0 //床位部分项目自费
  25308. decimal.DivisionPrecision = 2
  25309. for _, item := range orderInfos {
  25310. if item.MedChrgitmType == "01" { //床位费
  25311. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25312. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25313. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25314. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25315. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25316. }
  25317. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  25318. if item.MedChrgitmType == "03" { //检查费
  25319. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25320. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25321. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25322. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25323. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25324. }
  25325. } else {
  25326. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  25327. fmt.Println("------------")
  25328. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25329. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25330. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25331. }
  25332. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  25333. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25334. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25335. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25336. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25337. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25338. }
  25339. }
  25340. if item.MedChrgitmType == "04" { //化验费
  25341. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25342. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25343. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25344. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25345. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25346. }
  25347. if item.MedChrgitmType == "05" { //治疗费
  25348. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25349. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25350. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25351. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25352. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25353. }
  25354. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  25355. fmt.Println("------------")
  25356. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25357. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25358. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25359. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25360. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25361. }
  25362. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25363. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25364. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25365. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25366. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25367. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25368. }
  25369. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25370. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25371. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25372. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25373. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25374. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25375. }
  25376. if item.MedChrgitmType == "09" { //西药费
  25377. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25378. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25379. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25380. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25381. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25382. }
  25383. if item.MedChrgitmType == "11" { //中成费
  25384. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25385. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25386. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25387. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25388. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25389. }
  25390. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25391. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25392. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25393. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25394. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25395. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25396. }
  25397. }
  25398. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25399. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25400. var user_name string
  25401. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25402. if role.ID == 0 {
  25403. user_name = "管理员"
  25404. } else {
  25405. user_name = role.UserName
  25406. }
  25407. baseParams := models.BaseParams{
  25408. SecretKey: miConfig.SecretKey,
  25409. FixmedinsCode: miConfig.Code,
  25410. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25411. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25412. OrgName: miConfig.OrgName,
  25413. Doctor: user_name,
  25414. RequestUrl: miConfig.Url,
  25415. AccessKey: miConfig.AccessKey,
  25416. }
  25417. businessParams := models.BusinessParams{
  25418. PsnNo: order.PsnNo,
  25419. MdtrtId: order.MdtrtId,
  25420. SetlId: order.SetlId,
  25421. }
  25422. var res ResultEleven
  25423. var resah ResultElevenah
  25424. var resEleven10265 ResultEleven10265
  25425. if config.IsOpen == 1 {
  25426. if miConfig.MdtrtareaAdmvs == "421300" {
  25427. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25428. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25429. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25430. resp, requestErr := http.Get(api)
  25431. if requestErr != nil {
  25432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25433. return
  25434. }
  25435. body, ioErr := ioutil.ReadAll(resp.Body)
  25436. if ioErr != nil {
  25437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25439. return
  25440. }
  25441. var respJSON map[string]interface{}
  25442. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25445. return
  25446. }
  25447. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25448. result, _ := json.Marshal(respJSON)
  25449. fmt.Println("log")
  25450. fmt.Println(string(result))
  25451. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25452. utils.ErrorLog("解析失败:%v", err)
  25453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25454. return
  25455. }
  25456. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25457. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25458. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25459. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25460. resp, requestErr := http.Get(api)
  25461. if requestErr != nil {
  25462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25463. return
  25464. }
  25465. body, ioErr := ioutil.ReadAll(resp.Body)
  25466. if ioErr != nil {
  25467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25469. return
  25470. }
  25471. var respJSON map[string]interface{}
  25472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25475. return
  25476. }
  25477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25478. result, _ := json.Marshal(respJSON)
  25479. fmt.Println("log")
  25480. fmt.Println(string(result))
  25481. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25482. utils.ErrorLog("解析失败:%v", err)
  25483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25484. return
  25485. }
  25486. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25487. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25488. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25489. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  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. if ioErr != nil {
  25497. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25499. return
  25500. }
  25501. var respJSON map[string]interface{}
  25502. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25505. return
  25506. }
  25507. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25508. result, _ := json.Marshal(respJSON)
  25509. fmt.Println("log")
  25510. fmt.Println(string(result))
  25511. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25512. utils.ErrorLog("解析失败:%v", err)
  25513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25514. return
  25515. }
  25516. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25517. var api string
  25518. if miConfig.MdtrtareaAdmvs == "320921" {
  25519. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25520. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25521. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25522. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25523. } else {
  25524. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25525. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25526. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25527. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25528. }
  25529. resp, requestErr := http.Get(api)
  25530. if requestErr != nil {
  25531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25532. return
  25533. }
  25534. body, ioErr := ioutil.ReadAll(resp.Body)
  25535. if ioErr != nil {
  25536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25538. return
  25539. }
  25540. var respJSON map[string]interface{}
  25541. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25544. return
  25545. }
  25546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25547. result, _ := json.Marshal(respJSON)
  25548. fmt.Println("log")
  25549. fmt.Println(string(result))
  25550. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  25551. utils.ErrorLog("解析失败:%v", err)
  25552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25553. return
  25554. }
  25555. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25556. res.Output = resEleven10265.Output
  25557. res.ErrMsg = resEleven10265.ErrMsg
  25558. res.Cainfo = resEleven10265.Cainfo
  25559. res.WarnMsg = resEleven10265.WarnMsg
  25560. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25561. res.Infcode = infocode
  25562. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25563. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  25564. saveLog(result, requestLog, "5203", "结算单")
  25565. var dat map[string]interface{}
  25566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25567. fmt.Println(dat)
  25568. } else {
  25569. fmt.Println(err)
  25570. }
  25571. userJSONBytes, _ := json.Marshal(dat)
  25572. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25573. utils.ErrorLog("解析失败:%v", err)
  25574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25575. return
  25576. }
  25577. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25578. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  25579. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  25580. fmt.Println(result3)
  25581. fmt.Println(requestLog3)
  25582. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  25583. fmt.Println(result2)
  25584. fmt.Println(requestLog2)
  25585. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  25586. saveLog(result, requestLog, "5203", "结算单")
  25587. var dat map[string]interface{}
  25588. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25589. fmt.Println(dat)
  25590. } else {
  25591. fmt.Println(err)
  25592. }
  25593. userJSONBytes, _ := json.Marshal(dat)
  25594. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25595. utils.ErrorLog("解析失败:%v", err)
  25596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25597. return
  25598. }
  25599. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25600. var api string
  25601. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25602. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25603. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25604. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25605. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25606. resp, requestErr := http.Get(api)
  25607. if requestErr != nil {
  25608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25609. return
  25610. }
  25611. body, ioErr := ioutil.ReadAll(resp.Body)
  25612. if ioErr != nil {
  25613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25615. return
  25616. }
  25617. var respJSON map[string]interface{}
  25618. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25621. return
  25622. }
  25623. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25624. if status == "0" {
  25625. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25626. c.ServeSuccessJSON(map[string]interface{}{
  25627. "failed_code": -10,
  25628. "msg": err_msg,
  25629. })
  25630. return
  25631. }
  25632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25633. result, _ := json.Marshal(respJSON)
  25634. fmt.Println("log")
  25635. fmt.Println(string(result))
  25636. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  25637. utils.ErrorLog("解析失败:%v", err)
  25638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25639. return
  25640. }
  25641. res.InfRefmsgid = resah.InfRefmsgid
  25642. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25643. // 创建对应的Time类型
  25644. t := time.UnixMilli(timestamp)
  25645. // 格式化成指定的日期字符串
  25646. str := t.Format("2006-01-02 15:04:05")
  25647. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25648. // 创建对应的Time类型
  25649. t3 := time.UnixMilli(timestamp2)
  25650. // 格式化成指定的日期字符串
  25651. str2 := t3.Format("2006-01-02 15:04:05")
  25652. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  25653. // 创建对应的Time类型
  25654. t4 := time.UnixMilli(timestamp3)
  25655. // 格式化成指定的日期字符串
  25656. str3 := t4.Format("2006-01-02 15:04:05")
  25657. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  25658. // 创建对应的Time类型
  25659. t5 := time.UnixMilli(timestamp4)
  25660. // 格式化成指定的日期字符串
  25661. str5 := t5.Format("2006-01-02 15:04:05")
  25662. res.Output.Setlinfo.Brdy = str2
  25663. res.Output.Setlinfo.SetlTime = str
  25664. res.Output.Setlinfo.Begndate = str3
  25665. res.Output.Setlinfo.Enddate = str5
  25666. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  25667. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  25668. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  25669. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  25670. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  25671. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  25672. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  25673. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  25674. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  25675. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  25676. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  25677. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  25678. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25679. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  25680. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  25681. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  25682. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  25683. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  25684. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  25685. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  25686. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  25687. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  25688. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  25689. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  25690. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  25691. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25692. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  25693. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  25694. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  25695. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  25696. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  25697. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  25698. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  25699. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  25700. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  25701. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  25702. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  25703. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  25704. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  25705. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  25706. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  25707. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  25708. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  25709. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  25710. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  25711. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  25712. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  25713. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  25714. //res.Output.Setldetail = resah.Output.Setldetail
  25715. res.ErrMsg = resah.ErrMsg
  25716. res.Cainfo = resah.Cainfo
  25717. res.WarnMsg = resah.WarnMsg
  25718. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25719. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  25720. saveLog(result, requestLog, "5203", "结算单")
  25721. var dat map[string]interface{}
  25722. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25723. fmt.Println(dat)
  25724. } else {
  25725. fmt.Println(err)
  25726. }
  25727. userJSONBytes, _ := json.Marshal(dat)
  25728. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25729. utils.ErrorLog("解析失败:%v", err)
  25730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25731. return
  25732. }
  25733. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25734. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25735. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25736. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25737. resp, requestErr := http.Get(api)
  25738. if requestErr != nil {
  25739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25740. return
  25741. }
  25742. body, ioErr := ioutil.ReadAll(resp.Body)
  25743. if ioErr != nil {
  25744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25746. return
  25747. }
  25748. var respJSON map[string]interface{}
  25749. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25752. return
  25753. }
  25754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25755. result, _ := json.Marshal(respJSON)
  25756. fmt.Println("log")
  25757. fmt.Println(string(result))
  25758. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  25759. utils.ErrorLog("解析失败:%v", err)
  25760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25761. return
  25762. }
  25763. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25764. res.Output = resEleven10265.Output
  25765. res.ErrMsg = resEleven10265.ErrMsg
  25766. res.Cainfo = resEleven10265.Cainfo
  25767. res.WarnMsg = resEleven10265.WarnMsg
  25768. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25769. res.Infcode = infocode
  25770. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25771. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25772. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25773. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25774. resp, requestErr := http.Get(api)
  25775. if requestErr != nil {
  25776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25777. return
  25778. }
  25779. body, ioErr := ioutil.ReadAll(resp.Body)
  25780. if ioErr != nil {
  25781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25783. return
  25784. }
  25785. var respJSON map[string]interface{}
  25786. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25789. return
  25790. }
  25791. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25792. result, _ := json.Marshal(respJSON)
  25793. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25794. utils.ErrorLog("解析失败:%v", err)
  25795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25796. return
  25797. }
  25798. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25799. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  25800. //return
  25801. } else {
  25802. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25803. if len(his.InsuplcAdmdvs) == 0 {
  25804. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25805. } else {
  25806. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  25807. }
  25808. result := service.Gdyb5203(baseParams, businessParams)
  25809. //service.Gdyb5204(baseParams, businessParams)
  25810. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  25811. var dat map[string]interface{}
  25812. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25813. fmt.Println(dat)
  25814. } else {
  25815. fmt.Println(err)
  25816. }
  25817. userJSONBytes, _ := json.Marshal(dat)
  25818. if miConfig.Code == "H15049901371" {
  25819. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  25820. utils.ErrorLog("解析失败:%v", err)
  25821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25822. return
  25823. }
  25824. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25825. res.Output = resEleven10265.Output
  25826. res.ErrMsg = resEleven10265.ErrMsg
  25827. res.Cainfo = resEleven10265.Cainfo
  25828. res.WarnMsg = resEleven10265.WarnMsg
  25829. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25830. res.Infcode = infocode
  25831. } else {
  25832. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25833. utils.ErrorLog("解析失败:%v", err)
  25834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25835. return
  25836. }
  25837. }
  25838. }
  25839. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25840. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  25841. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  25842. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25843. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  25844. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25845. var doctor_name string
  25846. if roles.ID == 0 {
  25847. doctor_name = "管理员"
  25848. } else {
  25849. doctor_name = roles.UserName
  25850. }
  25851. yiliao_leibie := ""
  25852. switch order.MedType {
  25853. case "11":
  25854. yiliao_leibie = "普通门诊"
  25855. break
  25856. case "12":
  25857. yiliao_leibie = "门诊挂号"
  25858. break
  25859. case "13":
  25860. yiliao_leibie = "急诊"
  25861. break
  25862. case "14":
  25863. yiliao_leibie = "门诊特殊病"
  25864. break
  25865. case "15":
  25866. yiliao_leibie = "门诊统筹"
  25867. break
  25868. case "16":
  25869. yiliao_leibie = "门诊慢性病"
  25870. break
  25871. case "21":
  25872. yiliao_leibie = "普通住院"
  25873. break
  25874. }
  25875. //var rf []CustomFundPay
  25876. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  25877. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25878. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  25879. if res.Infcode == 0 {
  25880. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  25881. c.ServeSuccessJSON(map[string]interface{}{
  25882. "diagnosis": name,
  25883. "order_infos": orderInfos,
  25884. "number": order.MdtrtId,
  25885. "date": order.SettleAccountsDate,
  25886. "charge_admin": charge_admin,
  25887. "printor_admin": printor_admin,
  25888. "info": res.Output.Setlinfo,
  25889. "order": order,
  25890. "bedCostTotal": bedCostTotal,
  25891. "bedCostSelfTotal": bedCostSelfTotal,
  25892. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  25893. "bedSelfTotal": bedSelfTotal,
  25894. "bedInscpTotal": bedInscpTotal,
  25895. "operationCostTotal": operationCostTotal,
  25896. "operationCostSelfTotal": operationCostSelfTotal,
  25897. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  25898. "operationSelfTotal": operationSelfTotal,
  25899. "operationInscpTotal": operationInscpTotal,
  25900. "otherCostTotal": otherCostTotal,
  25901. "otherCostSelfTotal": otherCostSelfTotal,
  25902. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  25903. "otherSelfTotal": otherSelfTotal,
  25904. "otherInscpTotal": otherInscpTotal,
  25905. "materialCostTotal": materialCostTotal,
  25906. "materialCostSelfTotal": materialCostSelfTotal,
  25907. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25908. "materialSelfTotal": materialSelfTotal,
  25909. "materialInscpTotal": materialInscpTotal,
  25910. "westernMedicineCostTotal": westernMedicineCostTotal,
  25911. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25912. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25913. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25914. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25915. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25916. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25917. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25918. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25919. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25920. "checkCostTotal": checkCostTotal,
  25921. "checkCostSelfTotal": checkCostSelfTotal,
  25922. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25923. "checkSelfTotal": checkSelfTotal,
  25924. "checkInscpTotal": checkInscpTotal,
  25925. "laboratoryCostTotal": laboratoryCostTotal,
  25926. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  25927. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  25928. "laboratorySelfTotal": laboratorySelfTotal,
  25929. "laboratoryInscpTotal": laboratoryInscpTotal,
  25930. "treatCostTotal": treatCostTotal,
  25931. "treatCostSelfTotal": treatCostSelfTotal,
  25932. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  25933. "treatSelfTotal": treatSelfTotal,
  25934. "treatInscpTotal": treatInscpTotal,
  25935. "doctor_info": doctor_info,
  25936. "doctor_code": adminRole_two.DoctorCode,
  25937. "doctor_name": doctor_name,
  25938. "health_card_no": order.PsnNo,
  25939. "department": departments.Name,
  25940. "yiliao_leibie": yiliao_leibie,
  25941. "after_money": order.AccountPrice,
  25942. "patient": patient,
  25943. "org_name": miConfig.OrgName,
  25944. "org_code": miConfig.Code,
  25945. "order_number": order.Number,
  25946. "his_hospital": his_hospital,
  25947. "his": his,
  25948. "dia_config": dia_config,
  25949. "psn_cash_pay": order.PsnCashPay,
  25950. //"funds": rf,
  25951. //"check_order_info": cus_slice,
  25952. })
  25953. } else {
  25954. c.ServeSuccessJSON(map[string]interface{}{
  25955. "diagnosis": name,
  25956. "order_infos": orderInfos,
  25957. "number": order.MdtrtId,
  25958. "date": order.SettleAccountsDate,
  25959. "charge_admin": charge_admin,
  25960. "printor_admin": printor_admin,
  25961. "info": order,
  25962. "order": order,
  25963. "bedCostTotal": bedCostTotal,
  25964. "bedCostSelfTotal": bedCostSelfTotal,
  25965. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  25966. "bedSelfTotal": bedSelfTotal,
  25967. "bedInscpTotal": bedInscpTotal,
  25968. "operationCostTotal": operationCostTotal,
  25969. "operationCostSelfTotal": operationCostSelfTotal,
  25970. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  25971. "operationSelfTotal": operationSelfTotal,
  25972. "operationInscpTotal": operationInscpTotal,
  25973. "otherCostTotal": otherCostTotal,
  25974. "otherCostSelfTotal": otherCostSelfTotal,
  25975. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  25976. "otherSelfTotal": otherSelfTotal,
  25977. "otherInscpTotal": otherInscpTotal,
  25978. "materialCostTotal": materialCostTotal,
  25979. "materialCostSelfTotal": materialCostSelfTotal,
  25980. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25981. "materialSelfTotal": materialSelfTotal,
  25982. "materialInscpTotal": materialInscpTotal,
  25983. "westernMedicineCostTotal": westernMedicineCostTotal,
  25984. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25985. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25986. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25987. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25988. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25989. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25990. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25991. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25992. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25993. "checkCostTotal": checkCostTotal,
  25994. "checkCostSelfTotal": checkCostSelfTotal,
  25995. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25996. "checkSelfTotal": checkSelfTotal,
  25997. "checkInscpTotal": checkInscpTotal,
  25998. "laboratoryCostTotal": laboratoryCostTotal,
  25999. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26000. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26001. "laboratorySelfTotal": laboratorySelfTotal,
  26002. "laboratoryInscpTotal": laboratoryInscpTotal,
  26003. "treatCostTotal": treatCostTotal,
  26004. "treatCostSelfTotal": treatCostSelfTotal,
  26005. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26006. "treatSelfTotal": treatSelfTotal,
  26007. "treatInscpTotal": treatInscpTotal,
  26008. "doctor_info": doctor_info,
  26009. "doctor_code": adminRole_two.DoctorCode,
  26010. "doctor_name": doctor_name,
  26011. "health_card_no": order.PsnNo,
  26012. "department": departments.Name,
  26013. "yiliao_leibie": yiliao_leibie,
  26014. "after_money": order.AccountPrice,
  26015. "patient": patient,
  26016. "org_name": miConfig.OrgName,
  26017. "org_code": miConfig.Code,
  26018. "order_number": order.Number,
  26019. "his_hospital": his_hospital,
  26020. "his": his,
  26021. "dia_config": dia_config,
  26022. "psn_cash_pay": order.PsnCashPay,
  26023. //"funds": rf,
  26024. //"check_order_info": cus_slice,
  26025. })
  26026. }
  26027. }
  26028. }
  26029. }
  26030. //func (c *HisApiController) CheckTreatment() {
  26031. // patient_id, _ := c.GetInt64("patient_id")
  26032. // id_card_no := c.GetString("id_card_no")
  26033. // insutype := c.GetString("insutype")
  26034. // med_type := c.GetString("med_type")
  26035. // admin_user_id, _ := c.GetInt64("admin_user_id")
  26036. //
  26037. // adminUser := c.GetAdminUserInfo()
  26038. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  26039. //
  26040. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26041. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26042. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26043. //
  26044. // if miConfig.MdtrtareaAdmvs == "421300" {
  26045. // var res ResultTwo
  26046. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  26047. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26048. // "&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)
  26049. // resp, requestErr := http.Get(api)
  26050. // if requestErr != nil {
  26051. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26052. // return
  26053. // }
  26054. //
  26055. // body, ioErr := ioutil.ReadAll(resp.Body)
  26056. // if ioErr != nil {
  26057. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26059. // return
  26060. // }
  26061. // var respJSON map[string]interface{}
  26062. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26063. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26065. // return
  26066. // }
  26067. //
  26068. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26069. // result, _ := json.Marshal(respJSON)
  26070. //
  26071. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26072. // utils.ErrorLog("解析失败:%v", err)
  26073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26074. // return
  26075. // }
  26076. //
  26077. // if res.Infcode == 0 {
  26078. //
  26079. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  26080. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26081. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  26082. // resp, requestErr := http.Get(api)
  26083. // if requestErr != nil {
  26084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26085. // return
  26086. // }
  26087. //
  26088. // body, ioErr := ioutil.ReadAll(resp.Body)
  26089. // if ioErr != nil {
  26090. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26091. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26092. // return
  26093. // }
  26094. // var respJSON map[string]interface{}
  26095. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26096. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26098. // return
  26099. // }
  26100. // var res Result2001
  26101. //
  26102. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26103. // result2, _ := json.Marshal(respJSON)
  26104. //
  26105. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  26106. // utils.ErrorLog("解析失败:%v", err)
  26107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26108. // return
  26109. // }
  26110. //
  26111. // if res.Infcode == 0 {
  26112. // c.ServeSuccessJSON(map[string]interface{}{
  26113. // "msg": res.Output.Trtinfo,
  26114. // })
  26115. // }
  26116. //
  26117. // } else {
  26118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  26119. // return
  26120. // }
  26121. //
  26122. // } else {
  26123. //
  26124. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  26125. // var dat map[string]interface{}
  26126. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26127. // fmt.Println(dat)
  26128. // } else {
  26129. // fmt.Println(err)
  26130. // }
  26131. // userJSONBytes, _ := json.Marshal(dat)
  26132. // var res ResultTwo
  26133. // var res10265 ResultTwo10265
  26134. // if miConfig.Code == "H15049901371" {
  26135. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  26136. // utils.ErrorLog("解析失败:%v", err)
  26137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26138. // return
  26139. // }
  26140. // res.ErrMsg = res10265.ErrMsg
  26141. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26142. // res.Infcode = infocode
  26143. // res.Output = res10265.Output
  26144. // res.InfRefmsgid = res10265.InfRefmsgid
  26145. // } else {
  26146. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26147. // utils.ErrorLog("解析失败:%v", err)
  26148. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26149. // return
  26150. // }
  26151. // }
  26152. //
  26153. // var user_name string
  26154. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  26155. // if role.ID == 0 {
  26156. // user_name = "xxx"
  26157. // } else {
  26158. // user_name = role.UserName
  26159. // }
  26160. //
  26161. // baseParams := models.BaseParams{
  26162. // SecretKey: miConfig.SecretKey,
  26163. // FixmedinsCode: miConfig.Code,
  26164. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26165. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26166. // OrgName: miConfig.OrgName,
  26167. // Doctor: user_name,
  26168. // }
  26169. //
  26170. // if config.IsOpen == 1 {
  26171. // if miConfig.Code == "H15049901371" {
  26172. // if med_type == "14" {
  26173. // if insutype == "390" {
  26174. // med_type = "9933"
  26175. // } else if insutype == "310" {
  26176. // med_type = "990502"
  26177. // }
  26178. // } else if med_type == "11" {
  26179. // med_type = "11"
  26180. // }
  26181. // }
  26182. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  26183. // var dat map[string]interface{}
  26184. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26185. // fmt.Println(dat)
  26186. // } else {
  26187. // fmt.Println(err)
  26188. // }
  26189. // var res Result2001
  26190. // var res10265 Result2001Org10265
  26191. // if miConfig.Code == "H15049901371" {
  26192. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  26193. // utils.ErrorLog("解析失败:%v", err)
  26194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26195. // return
  26196. // }
  26197. // res.ErrMsg = res10265.ErrMsg
  26198. // res.Output = res10265.Output
  26199. // res.InfRefmsgid = res10265.InfRefmsgid
  26200. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26201. // res.Infcode = infocode
  26202. // } else {
  26203. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26204. // utils.ErrorLog("解析失败:%v", err)
  26205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26206. // return
  26207. // }
  26208. // }
  26209. // if res.Infcode == 0 {
  26210. // c.ServeSuccessJSON(map[string]interface{}{
  26211. // "msg": res.Output.Trtinfo,
  26212. // })
  26213. // }
  26214. // }
  26215. // }
  26216. //}
  26217. //func (c *HisApiController) PutRecord() {
  26218. // id, _ := c.GetInt64("id")
  26219. // record_time := c.GetString("record_time")
  26220. // timeLayout := "2006-01-02"
  26221. // loc, _ := time.LoadLocation("Local")
  26222. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26223. // if err != nil {
  26224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26225. // return
  26226. // }
  26227. // recordDateTime := theTime.Unix()
  26228. //
  26229. // adminInfo := c.GetAdminUserInfo()
  26230. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  26231. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26232. //
  26233. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26234. //
  26235. // fmt.Println(miConfig.SecretKey)
  26236. //
  26237. // if patient == nil {
  26238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  26239. // return
  26240. // }
  26241. // if len(patient.IdCardNo) == 0 {
  26242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  26243. // return
  26244. // }
  26245. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  26246. // if config.IsOpen == 1 {
  26247. // 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
  26248. // resp, requestErr := http.Get(api)
  26249. // if requestErr != nil {
  26250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26251. // return
  26252. // }
  26253. // defer resp.Body.Close()
  26254. // body, ioErr := ioutil.ReadAll(resp.Body)
  26255. // if ioErr != nil {
  26256. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26258. // return
  26259. // }
  26260. // var respJSON map[string]interface{}
  26261. //
  26262. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26263. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26264. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26265. // return
  26266. // }
  26267. //
  26268. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26269. // userJSONBytes, _ := json.Marshal(userJSON)
  26270. // var res ResultTwo
  26271. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26272. // utils.ErrorLog("解析失败:%v", err)
  26273. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26274. // return
  26275. // }
  26276. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  26277. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  26278. // infoStr := string(Iinfos)
  26279. // idetinfoStr := string(Idetinfos)
  26280. //
  26281. // if res.Infcode == 0 {
  26282. // his := models.VMHisPatient{
  26283. // Status: 1,
  26284. // Ctime: time.Now().Unix(),
  26285. // Mtime: time.Now().Unix(),
  26286. // PsnNo: res.Output.Baseinfo.PsnNo,
  26287. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  26288. // Certno: res.Output.Baseinfo.Certno,
  26289. // PsnName: res.Output.Baseinfo.PsnName,
  26290. // Gend: res.Output.Baseinfo.Gend,
  26291. // Naty: res.Output.Baseinfo.Naty,
  26292. // Brdy: res.Output.Baseinfo.Brdy,
  26293. // Age: res.Output.Baseinfo.Age,
  26294. // Iinfo: infoStr,
  26295. // Idetinfo: idetinfoStr,
  26296. // PatientId: patient.ID,
  26297. // RecordDate: theTime.Unix(),
  26298. // UserOrgId: adminInfo.CurrentOrgId,
  26299. // AdminUserId: adminInfo.AdminUser.Id,
  26300. // IsReturn: 1,
  26301. // }
  26302. //
  26303. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  26304. // //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")
  26305. // //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")
  26306. //
  26307. // //var dat map[string]interface{}
  26308. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26309. // // fmt.Println(dat)
  26310. // //} else {
  26311. // // fmt.Println(err)
  26312. // //}
  26313. //
  26314. // var dat2 map[string]interface{}
  26315. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26316. // fmt.Println(dat2)
  26317. // } else {
  26318. // fmt.Println(err)
  26319. // }
  26320. //
  26321. // } else {
  26322. // adminUser := c.GetAdminUserInfo()
  26323. // errlog := &models.HisOrderError{
  26324. // UserOrgId: adminUser.CurrentOrgId,
  26325. // Ctime: time.Now().Unix(),
  26326. // Mtime: time.Now().Unix(),
  26327. // ErrMsg: res.ErrMsg,
  26328. // Status: 1,
  26329. // PatientId: id,
  26330. // RecordTime: recordDateTime,
  26331. // Stage: 1,
  26332. // }
  26333. // service.CreateErrMsgLog(errlog)
  26334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26335. // return
  26336. // }
  26337. // }
  26338. //
  26339. //}
  26340. //func (c *HisApiController) GetUploadDiag() {
  26341. // id, _ := c.GetInt64("id")
  26342. // record_time := c.GetString("record_time")
  26343. //
  26344. // diagnosis_id, _ := c.GetInt64("diagnosis")
  26345. // sick_type, _ := c.GetInt64("sick_type")
  26346. // reg_type, _ := c.GetInt64("reg_type")
  26347. //
  26348. // timeLayout := "2006-01-02"
  26349. // loc, _ := time.LoadLocation("Local")
  26350. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26351. // if err != nil {
  26352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26353. // return
  26354. // }
  26355. //
  26356. // var patientPrescription models.HisPrescriptionInfo
  26357. // recordDateTime := theTime.Unix()
  26358. // adminInfo := c.GetAdminUserInfo()
  26359. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26360. //
  26361. // if patientPrescription.ID == 0 {
  26362. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26363. // }
  26364. //
  26365. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26366. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  26367. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26368. // sickConfig, _ := service.FindSickById(sick_type)
  26369. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26370. //
  26371. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  26372. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  26373. // "&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 +
  26374. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  26375. // resp2, requestErr2 := http.Get(api2)
  26376. // if requestErr2 != nil {
  26377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26378. // return
  26379. // }
  26380. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  26381. // if ioErr2 != nil {
  26382. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  26383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26384. // return
  26385. // }
  26386. // var respJSON2 map[string]interface{}
  26387. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  26388. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26390. // return
  26391. // }
  26392. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26393. // userJSONBytes2, _ := json.Marshal(respJSON2)
  26394. //
  26395. // var res2 ResultSix
  26396. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26397. // utils.ErrorLog("解析失败:%v", err)
  26398. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26399. // return
  26400. // }
  26401. // if res2.Infcode != 0 {
  26402. // adminUser := c.GetAdminUserInfo()
  26403. // errlog := &models.HisOrderError{
  26404. // UserOrgId: adminUser.CurrentOrgId,
  26405. // Ctime: time.Now().Unix(),
  26406. // Mtime: time.Now().Unix(),
  26407. // ErrMsg: res2.ErrMsg,
  26408. // Status: 1,
  26409. // PatientId: id,
  26410. // RecordTime: recordDateTime,
  26411. // Stage: 3,
  26412. // }
  26413. // service.CreateErrMsgLog(errlog)
  26414. //
  26415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  26416. // return
  26417. // }
  26418. //
  26419. // c.ServeSuccessJSON(map[string]interface{}{
  26420. // "msg": "上传成功",
  26421. // })
  26422. //
  26423. //}
  26424. type QueryResult struct {
  26425. ID int64
  26426. Name string
  26427. Code string
  26428. List_type_code string
  26429. }
  26430. func (c *HisApiController) GetCheckCode() {
  26431. ids_str := c.GetString("ids")
  26432. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  26433. ids_arr := strings.Split(ids_str, ",")
  26434. var queryResult []QueryResult
  26435. ids := make([]int64, 0)
  26436. for _, item := range ids_arr {
  26437. id, _ := strconv.ParseInt(item, 10, 64)
  26438. ids = append(ids, id)
  26439. }
  26440. if record_type == 1 {
  26441. drugs, _ := service.GetBatchDrugList(ids)
  26442. for _, item := range drugs {
  26443. result := QueryResult{
  26444. ID: item.ID,
  26445. Name: item.DrugName,
  26446. Code: item.MedicalInsuranceNumber,
  26447. List_type_code: "101",
  26448. }
  26449. queryResult = append(queryResult, result)
  26450. }
  26451. } else if record_type == 2 {
  26452. goods, _ := service.GetBatchGoodInformationList(ids)
  26453. fmt.Println(goods)
  26454. for _, item := range goods {
  26455. result := QueryResult{
  26456. ID: item.ID,
  26457. Name: item.GoodName,
  26458. Code: item.SocialSecurityDirectoryCode,
  26459. List_type_code: "301",
  26460. }
  26461. queryResult = append(queryResult, result)
  26462. }
  26463. } else if record_type == 3 {
  26464. projects, _ := service.GetBathchMyPorjecgList(ids)
  26465. for _, item := range projects {
  26466. result := QueryResult{
  26467. ID: item.ID,
  26468. Name: item.ProjectName,
  26469. Code: item.MedicalCode,
  26470. List_type_code: "201",
  26471. }
  26472. queryResult = append(queryResult, result)
  26473. }
  26474. }
  26475. admin_user_id, _ := c.GetInt64("admin_user_id")
  26476. adminUser := c.GetAdminUserInfo()
  26477. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26478. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26479. var user_name string
  26480. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26481. if role.ID == 0 {
  26482. user_name = "管理员"
  26483. } else {
  26484. user_name = role.UserName
  26485. }
  26486. baseParams := models.BaseParams{
  26487. SecretKey: miConfig.SecretKey,
  26488. FixmedinsCode: miConfig.Code,
  26489. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26490. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26491. OrgName: miConfig.OrgName,
  26492. Doctor: user_name,
  26493. }
  26494. var result string
  26495. if miConfig.MdtrtareaAdmvs == "430800" {
  26496. for _, item := range queryResult {
  26497. if record_type == 1 {
  26498. 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)
  26499. } else if record_type == 2 {
  26500. fmt.Println(item.Code)
  26501. 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)
  26502. } else if record_type == 3 {
  26503. 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)
  26504. }
  26505. var dat map[string]interface{}
  26506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26507. fmt.Println(dat)
  26508. } else {
  26509. fmt.Println(err)
  26510. }
  26511. userJSONBytes, _ := json.Marshal(dat)
  26512. var res ResultSix
  26513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26514. utils.ErrorLog("解析失败:%v", err)
  26515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26516. return
  26517. }
  26518. if res.Infcode == 0 {
  26519. if record_type == 1 {
  26520. service.UpdateBaseDrugById(item.ID)
  26521. } else if record_type == 2 {
  26522. service.UpdateGoodInformaitonByDetail(item.ID)
  26523. } else if record_type == 3 {
  26524. service.UpdateProjectById(item.ID)
  26525. }
  26526. c.ServeSuccessJSON(map[string]interface{}{
  26527. "failed_code": 0,
  26528. "msg": "目录对照成功",
  26529. })
  26530. } else {
  26531. c.ServeSuccessJSON(map[string]interface{}{
  26532. "failed_code": -10,
  26533. "msg": res.ErrMsg,
  26534. })
  26535. }
  26536. }
  26537. } else {
  26538. for _, item := range queryResult {
  26539. var result string
  26540. if record_type == 1 {
  26541. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26542. } else if record_type == 2 {
  26543. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26544. } else if record_type == 3 {
  26545. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26546. }
  26547. var dat map[string]interface{}
  26548. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26549. fmt.Println(dat)
  26550. } else {
  26551. fmt.Println(err)
  26552. }
  26553. userJSONBytes, _ := json.Marshal(dat)
  26554. var res ResultSix
  26555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26556. utils.ErrorLog("解析失败:%v", err)
  26557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26558. return
  26559. }
  26560. if res.Infcode == 0 {
  26561. if record_type == 1 {
  26562. service.UpdateBaseDrugById(item.ID)
  26563. } else if record_type == 2 {
  26564. service.UpdateGoodInformaitonByDetail(item.ID)
  26565. } else if record_type == 3 {
  26566. service.UpdateProjectById(item.ID)
  26567. }
  26568. c.ServeSuccessJSON(map[string]interface{}{
  26569. "failed_code": 0,
  26570. "msg": "目录对照成功",
  26571. })
  26572. } else {
  26573. c.ServeSuccessJSON(map[string]interface{}{
  26574. "failed_code": -10,
  26575. "msg": res.ErrMsg,
  26576. })
  26577. }
  26578. }
  26579. }
  26580. }
  26581. func (c *HisApiController) UnCheckCode() {
  26582. ids_str := c.GetString("ids")
  26583. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  26584. admin_user_id, _ := c.GetInt64("admin_user_id")
  26585. ids_arr := strings.Split(ids_str, ",")
  26586. var queryResult []QueryResult
  26587. ids := make([]int64, 0)
  26588. for _, item := range ids_arr {
  26589. id, _ := strconv.ParseInt(item, 10, 64)
  26590. ids = append(ids, id)
  26591. }
  26592. if record_type == 1 {
  26593. drugs, _ := service.GetBatchDrugList(ids)
  26594. for _, item := range drugs {
  26595. result := QueryResult{
  26596. ID: item.ID,
  26597. Name: item.DrugName,
  26598. Code: item.MedicalInsuranceNumber,
  26599. List_type_code: "101",
  26600. }
  26601. queryResult = append(queryResult, result)
  26602. }
  26603. } else if record_type == 2 {
  26604. goods, _ := service.GetBatchGoodInformationList(ids)
  26605. for _, item := range goods {
  26606. result := QueryResult{
  26607. ID: item.ID,
  26608. Name: item.GoodName,
  26609. Code: item.SocialSecurityDirectoryCode,
  26610. List_type_code: "301",
  26611. }
  26612. queryResult = append(queryResult, result)
  26613. }
  26614. } else if record_type == 3 {
  26615. projects, _ := service.GetBathchMyPorjecgList(ids)
  26616. for _, item := range projects {
  26617. result := QueryResult{
  26618. ID: item.ID,
  26619. Name: item.ProjectName,
  26620. Code: item.MedicalCode,
  26621. List_type_code: "201",
  26622. }
  26623. queryResult = append(queryResult, result)
  26624. }
  26625. }
  26626. adminUser := c.GetAdminUserInfo()
  26627. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26628. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26629. var user_name string
  26630. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26631. if role.ID == 0 {
  26632. user_name = "xxx"
  26633. } else {
  26634. user_name = role.UserName
  26635. }
  26636. baseParams := &models.BaseParams{
  26637. SecretKey: miConfig.SecretKey,
  26638. FixmedinsCode: miConfig.Code,
  26639. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26640. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26641. OrgName: miConfig.OrgName,
  26642. Doctor: user_name,
  26643. }
  26644. if config.IsOpen == 1 {
  26645. if miConfig.MdtrtareaAdmvs == "430800" {
  26646. for _, item := range queryResult {
  26647. var result string
  26648. if record_type == 1 {
  26649. 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)
  26650. } else if record_type == 2 {
  26651. fmt.Println(item.Code)
  26652. 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)
  26653. } else if record_type == 3 {
  26654. 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)
  26655. }
  26656. var dat map[string]interface{}
  26657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26658. fmt.Println(dat)
  26659. } else {
  26660. fmt.Println(err)
  26661. }
  26662. userJSONBytes, _ := json.Marshal(dat)
  26663. var res ResultSix
  26664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26665. utils.ErrorLog("解析失败:%v", err)
  26666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26667. return
  26668. }
  26669. if res.Infcode == 0 {
  26670. if record_type == 1 {
  26671. service.UpdateBaseDrugById(item.ID)
  26672. } else if record_type == 2 {
  26673. service.UpdateGoodInformaitonByDetail(item.ID)
  26674. } else if record_type == 3 {
  26675. service.UpdateProjectById(item.ID)
  26676. }
  26677. c.ServeSuccessJSON(map[string]interface{}{
  26678. "failed_code": 0,
  26679. "msg": "目录对照成功",
  26680. })
  26681. } else {
  26682. c.ServeSuccessJSON(map[string]interface{}{
  26683. "failed_code": -10,
  26684. "msg": res.ErrMsg,
  26685. })
  26686. }
  26687. }
  26688. } else {
  26689. for _, item := range queryResult {
  26690. var result string
  26691. if record_type == 1 {
  26692. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  26693. } else if record_type == 2 {
  26694. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  26695. } else if record_type == 3 {
  26696. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  26697. }
  26698. var dat2 map[string]interface{}
  26699. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  26700. fmt.Println(dat2)
  26701. } else {
  26702. fmt.Println(err)
  26703. }
  26704. userJSONBytes, _ := json.Marshal(dat2)
  26705. var res ResultSix
  26706. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26707. utils.ErrorLog("解析失败:%v", err)
  26708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26709. return
  26710. }
  26711. if res.Infcode == 0 {
  26712. if record_type == 1 {
  26713. service.UpdateDrugByIdDetail(item.ID)
  26714. } else if record_type == 2 {
  26715. service.UpdateGoodInfoById(item.ID)
  26716. } else if record_type == 3 {
  26717. service.UpdateMyProjectById(item.ID)
  26718. }
  26719. c.ServeSuccessJSON(map[string]interface{}{
  26720. "failed_code": 0,
  26721. "msg": "撤销目录对照成功",
  26722. })
  26723. } else {
  26724. c.ServeSuccessJSON(map[string]interface{}{
  26725. "failed_code": -10,
  26726. "msg": res.ErrMsg,
  26727. })
  26728. }
  26729. }
  26730. }
  26731. }
  26732. }
  26733. func (c *HisApiController) GetPatientInfo() {
  26734. id_card_no := c.GetString("id_card_no")
  26735. admin_user_id, _ := c.GetInt64("admin_user_id")
  26736. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  26737. if patient.ID == 0 {
  26738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  26739. return
  26740. }
  26741. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  26742. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  26743. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  26744. var res ResultTwo
  26745. var res10265 ResultTwo10265
  26746. if config.IsOpen == 1 {
  26747. if miConfig.MdtrtareaAdmvs == "150499" {
  26748. //请求内网数据
  26749. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  26750. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  26751. "&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
  26752. resp, requestErr := http.Get(api)
  26753. if requestErr != nil {
  26754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26755. return
  26756. }
  26757. body, ioErr := ioutil.ReadAll(resp.Body)
  26758. if ioErr != nil {
  26759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26761. return
  26762. }
  26763. var respJSON map[string]interface{}
  26764. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26767. return
  26768. }
  26769. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26770. result_byte, _ := json.Marshal(respJSON)
  26771. result := string(result_byte)
  26772. var dat map[string]interface{}
  26773. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26774. fmt.Println(dat)
  26775. } else {
  26776. fmt.Println(err)
  26777. }
  26778. userJSONBytes, _ := json.Marshal(dat)
  26779. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  26780. utils.ErrorLog("解析失败:%v", err)
  26781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26782. return
  26783. }
  26784. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26785. res.Infcode = Infcode
  26786. res.ErrMsg = res10265.ErrMsg
  26787. res.Output = res10265.Output
  26788. res.InfRefmsgid = res10265.InfRefmsgid
  26789. res.RespondTime = res10265.RespondTime
  26790. res.WarnInfo = res10265.WarnInfo
  26791. } else {
  26792. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  26793. var dat map[string]interface{}
  26794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26795. fmt.Println(dat)
  26796. } else {
  26797. fmt.Println(err)
  26798. }
  26799. userJSONBytes, _ := json.Marshal(dat)
  26800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26801. utils.ErrorLog("解析失败:%v", err)
  26802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26803. return
  26804. }
  26805. }
  26806. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26807. // utils.ErrorLog("解析失败:%v", err)
  26808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26809. // return
  26810. //}
  26811. for index, item := range res.Output.Iinfo {
  26812. if item.PsnInsuStas == "2" {
  26813. fmt.Println("--------")
  26814. res.Output.Iinfo[index].Insutype = "300"
  26815. res.Output.Iinfo[index].PsnInsuStas = "1"
  26816. }
  26817. }
  26818. fmt.Println(res.Output.Iinfo)
  26819. if res.Infcode != 0 {
  26820. c.ServeSuccessJSON(map[string]interface{}{
  26821. "failed_code": -10,
  26822. "msg": res.ErrMsg,
  26823. })
  26824. } else {
  26825. c.ServeSuccessJSON(map[string]interface{}{
  26826. "failed_code": 0,
  26827. "info": res,
  26828. })
  26829. }
  26830. }
  26831. }
  26832. func (c *HisApiController) PsnPutOnRecord() {
  26833. record_type, _ := c.GetInt64("type")
  26834. patient_id, _ := c.GetInt64("patient_id")
  26835. admin_user_id, _ := c.GetInt64("admin_user_id")
  26836. start_time := c.GetString("start_time")
  26837. end_time := c.GetString("end_time")
  26838. adminUser := c.GetAdminUserInfo()
  26839. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26840. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26841. var patients []*models.Patients
  26842. if record_type == 1 { //全部备案
  26843. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  26844. patients = append(patients, patient...)
  26845. } else { //单个备案
  26846. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  26847. patients = append(patients, patient)
  26848. }
  26849. var user_name string
  26850. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26851. if role.ID == 0 {
  26852. user_name = "xxx"
  26853. } else {
  26854. user_name = role.UserName
  26855. }
  26856. if config.IsOpen == 1 {
  26857. for _, item := range patients {
  26858. 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
  26859. resp, requestErr := http.Get(api)
  26860. if requestErr != nil {
  26861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26862. return
  26863. }
  26864. defer resp.Body.Close()
  26865. body, ioErr := ioutil.ReadAll(resp.Body)
  26866. if ioErr != nil {
  26867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26869. return
  26870. }
  26871. var respJSON map[string]interface{}
  26872. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26875. return
  26876. }
  26877. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26878. userJSONBytes, _ := json.Marshal(userJSON)
  26879. var res ResultTwo
  26880. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26881. utils.ErrorLog("解析失败:%v", err)
  26882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26883. return
  26884. }
  26885. if res.Infcode == 0 {
  26886. 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)
  26887. var dat map[string]interface{}
  26888. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26889. fmt.Println(dat)
  26890. } else {
  26891. fmt.Println(err)
  26892. }
  26893. userJSONBytes, _ := json.Marshal(dat)
  26894. var res2 ResultThirteen
  26895. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26896. utils.ErrorLog("解析失败:%v", err)
  26897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26898. return
  26899. }
  26900. if res2.Infcode == 0 {
  26901. psnResult := &models.GdybPsnRecord{
  26902. UserOrgId: adminUser.CurrentOrgId,
  26903. PatientId: item.ID,
  26904. PsnNo: res.Output.Baseinfo.PsnNo,
  26905. Ctime: time.Now().Unix(),
  26906. Mtime: time.Now().Unix(),
  26907. Status: 1,
  26908. IsCancel: 1,
  26909. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  26910. }
  26911. service.CreatePsnRecord(psnResult)
  26912. } else {
  26913. c.ServeSuccessJSON(map[string]interface{}{
  26914. "failed_code": -10,
  26915. "msg": res2.ErrMsg,
  26916. })
  26917. return
  26918. }
  26919. }
  26920. }
  26921. }
  26922. }
  26923. func (c *HisApiController) PsnUnPutOnRecord() {
  26924. id, _ := c.GetInt64("id")
  26925. //record_type, _ := c.GetInt64("type")
  26926. admin_user_id, _ := c.GetInt64("admin_user_id")
  26927. adminUser := c.GetAdminUserInfo()
  26928. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26929. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26930. var user_name string
  26931. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26932. if role.ID == 0 {
  26933. user_name = "xxx"
  26934. } else {
  26935. user_name = role.UserName
  26936. }
  26937. psn_record, _ := service.GetPsnRecordById(id)
  26938. if psn_record.ID == 0 {
  26939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  26940. return
  26941. }
  26942. if config.IsOpen == 1 {
  26943. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  26944. var dat map[string]interface{}
  26945. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26946. fmt.Println(dat)
  26947. } else {
  26948. fmt.Println(err)
  26949. }
  26950. userJSONBytes, _ := json.Marshal(dat)
  26951. var res ResultFourteen
  26952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26953. utils.ErrorLog("解析失败:%v", err)
  26954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26955. return
  26956. }
  26957. if res.Infcode == 0 {
  26958. psn_record.IsCancel = 2
  26959. service.CreatePsnRecord(&psn_record)
  26960. } else {
  26961. c.ServeSuccessJSON(map[string]interface{}{
  26962. "failed_code": -10,
  26963. "msg": res.ErrMsg,
  26964. })
  26965. return
  26966. }
  26967. }
  26968. }
  26969. func (c *HisApiController) PsnPutNCDSOnRecord() {
  26970. patient_id, _ := c.GetInt64("patient_id")
  26971. insutype_two := c.GetString("insutype")
  26972. psn_no := c.GetString("psn_no")
  26973. doctor_id, _ := c.GetInt64("doctor_id")
  26974. sick_id, _ := c.GetInt64("sick_id")
  26975. department_id, _ := c.GetInt64("department_id")
  26976. start_time := c.GetString("start_time")
  26977. end_time := c.GetString("end_time")
  26978. check_time := c.GetString("check_time")
  26979. hospital_code := c.GetString("hospital_code")
  26980. hospital_name := c.GetString("hospital_name")
  26981. adminUser := c.GetAdminUserInfo()
  26982. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  26983. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26984. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26985. sick, _ := service.FindSickById(sick_id)
  26986. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  26987. if len(hospital_code) == 0 {
  26988. hospital_code = miConfig.Code
  26989. }
  26990. if len(hospital_name) == 0 {
  26991. hospital_name = miConfig.OrgName
  26992. }
  26993. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  26994. var res ResultTwo
  26995. var res10265 ResultTwo10265
  26996. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26997. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  26998. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  26999. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27000. "&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
  27001. resp, requestErr := http.Get(api)
  27002. if requestErr != nil {
  27003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27004. return
  27005. }
  27006. body, ioErr := ioutil.ReadAll(resp.Body)
  27007. if ioErr != nil {
  27008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27010. return
  27011. }
  27012. var respJSON map[string]interface{}
  27013. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27016. return
  27017. }
  27018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27019. result, _ := json.Marshal(respJSON)
  27020. fmt.Println("log")
  27021. fmt.Println(string(result))
  27022. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27023. utils.ErrorLog("解析失败:%v", err)
  27024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27025. return
  27026. }
  27027. res.ErrMsg = res10265.ErrMsg
  27028. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27029. res.Infcode = infocode
  27030. res.Output = res10265.Output
  27031. res.InfRefmsgid = res10265.InfRefmsgid
  27032. } else {
  27033. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27034. if miConfig.Code == "H15049901371" {
  27035. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27036. utils.ErrorLog("解析失败:%v", err)
  27037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27038. return
  27039. }
  27040. res.ErrMsg = res10265.ErrMsg
  27041. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27042. res.Infcode = infocode
  27043. res.Output = res10265.Output
  27044. res.InfRefmsgid = res10265.InfRefmsgid
  27045. } else {
  27046. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27047. utils.ErrorLog("解析失败:%v", err)
  27048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27049. return
  27050. }
  27051. }
  27052. }
  27053. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27054. infoStr := string(Iinfos)
  27055. var rf []*ResultFive
  27056. json.Unmarshal([]byte(infoStr), &rf)
  27057. var insuplc_admdvs string
  27058. var insutype string
  27059. var is390 int = 0
  27060. var is310 int = 0
  27061. var insutypes []*ResultFive
  27062. for _, item := range rf {
  27063. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27064. insutypes = append(insutypes, item)
  27065. }
  27066. }
  27067. if len(insutypes) == 1 {
  27068. insutype = insutypes[0].Insutype
  27069. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27070. } else {
  27071. for _, i := range insutypes {
  27072. if i.Insutype == "390" {
  27073. is390 = 1
  27074. }
  27075. if i.Insutype == "310" {
  27076. is310 = 1
  27077. }
  27078. }
  27079. }
  27080. if is390 == 1 {
  27081. insutype = "390"
  27082. }
  27083. if is310 == 1 {
  27084. insutype = "310"
  27085. }
  27086. if len(insutypes) == 2 {
  27087. insutype = insutype_two
  27088. }
  27089. if len(insutypes) == 0 {
  27090. insutype = "310"
  27091. }
  27092. insutype = insutype_two
  27093. fmt.Println(insutype)
  27094. for _, item := range rf {
  27095. fmt.Println(item.Insutype)
  27096. fmt.Println(insutype)
  27097. if item.Insutype == insutype {
  27098. fmt.Println(item.Insutype)
  27099. fmt.Println(insutype)
  27100. insuplc_admdvs = item.InsuplcAdmdvs
  27101. }
  27102. }
  27103. fmt.Println(insuplc_admdvs)
  27104. var res2 ResultThirteen
  27105. var res10265_2 ResultThirteen10265
  27106. if config.IsOpen == 1 {
  27107. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27108. } else {
  27109. if miConfig.MdtrtareaAdmvs == "150499" {
  27110. //
  27111. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  27112. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27113. // "&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
  27114. //resp, requestErr := http.Get(api)
  27115. //if requestErr != nil {
  27116. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27117. // return
  27118. //}
  27119. //
  27120. //body, ioErr := ioutil.ReadAll(resp.Body)
  27121. //if ioErr != nil {
  27122. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27123. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27124. // return
  27125. //}
  27126. //var respJSON map[string]interface{}
  27127. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27128. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27130. // return
  27131. //}
  27132. //
  27133. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27134. //result, _ := json.Marshal(respJSON)
  27135. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  27136. // utils.ErrorLog("解析失败:%v", err)
  27137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27138. // return
  27139. //}
  27140. //infocode = resThree.Infcode
  27141. //result, _ := json.Marshal(respJSON)
  27142. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  27143. // utils.ErrorLog("解析失败:%v", err)
  27144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27145. // return
  27146. //}
  27147. //
  27148. //resThree.ErrMsg = resThree10265.ErrMsg
  27149. //
  27150. //resThree.Output = resThree10265.Output
  27151. //
  27152. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  27153. //
  27154. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  27155. //
  27156. } else {
  27157. 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)
  27158. var dat map[string]interface{}
  27159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27160. fmt.Println(dat)
  27161. } else {
  27162. fmt.Println(err)
  27163. }
  27164. userJSONBytes, _ := json.Marshal(dat)
  27165. if miConfig.Code == "H15049901371" {
  27166. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  27167. utils.ErrorLog("解析失败:%v", err)
  27168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27169. return
  27170. }
  27171. res2.ErrMsg = res10265_2.ErrMsg
  27172. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  27173. res2.Infcode = infocode
  27174. res2.Output = res10265_2.Output
  27175. res2.InfRefmsgid = res10265_2.InfRefmsgid
  27176. } else {
  27177. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27178. utils.ErrorLog("解析失败:%v", err)
  27179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27180. return
  27181. }
  27182. }
  27183. }
  27184. }
  27185. if res2.Infcode == 0 {
  27186. psnResult := &models.GdybPsnNcdsRecord{
  27187. UserOrgId: adminUser.CurrentOrgId,
  27188. PatientId: patient.ID,
  27189. PsnNo: psn_no,
  27190. DoctorId: doctor.AdminUserId,
  27191. DepartmentId: department_id,
  27192. SickType: sick_id,
  27193. Insutype: insutype,
  27194. Ctime: time.Now().Unix(),
  27195. Mtime: time.Now().Unix(),
  27196. Status: 1,
  27197. IsCancel: 1,
  27198. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  27199. }
  27200. service.CreatePsnNCDSRecord(psnResult)
  27201. c.ServeSuccessJSON(map[string]interface{}{
  27202. "failed_code": 0,
  27203. "msg": "备案成功",
  27204. "result": psnResult,
  27205. })
  27206. } else {
  27207. c.ServeSuccessJSON(map[string]interface{}{
  27208. "failed_code": -10,
  27209. "msg": res2.ErrMsg,
  27210. })
  27211. return
  27212. }
  27213. }
  27214. }
  27215. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  27216. id, _ := c.GetInt64("id")
  27217. admin_user_id, _ := c.GetInt64("admin_user_id")
  27218. adminUser := c.GetAdminUserInfo()
  27219. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27220. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27221. //config, _ := service.Ge(adminUser.CurrentOrgId)
  27222. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  27223. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27224. //var user_name string
  27225. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27226. //if role.ID == 0 {
  27227. // user_name = "xxx"
  27228. //} else {
  27229. // user_name = role.UserName
  27230. //}
  27231. psn_record, _ := service.GetPsnNCDSRecordById(id)
  27232. if psn_record.ID == 0 {
  27233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  27234. return
  27235. }
  27236. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27237. var res ResultTwo
  27238. var res10265 ResultTwo10265
  27239. if miConfig.Code == "H15049901371" {
  27240. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27241. utils.ErrorLog("解析失败:%v", err)
  27242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27243. return
  27244. }
  27245. res.ErrMsg = res10265.ErrMsg
  27246. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27247. res.Infcode = infocode
  27248. res.Output = res10265.Output
  27249. res.InfRefmsgid = res10265.InfRefmsgid
  27250. } else {
  27251. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27252. utils.ErrorLog("解析失败:%v", err)
  27253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27254. return
  27255. }
  27256. }
  27257. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27258. infoStr := string(Iinfos)
  27259. var rf []*ResultFive
  27260. json.Unmarshal([]byte(infoStr), &rf)
  27261. var insuplc_admdvs string
  27262. var insutype string
  27263. var is390 int = 0
  27264. var is310 int = 0
  27265. var insutypes []*ResultFive
  27266. for _, item := range rf {
  27267. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27268. insutypes = append(insutypes, item)
  27269. }
  27270. }
  27271. if len(insutypes) == 1 {
  27272. insutype = insutypes[0].Insutype
  27273. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27274. } else {
  27275. for _, i := range insutypes {
  27276. if i.Insutype == "390" {
  27277. is390 = 1
  27278. }
  27279. if i.Insutype == "310" {
  27280. is310 = 1
  27281. }
  27282. }
  27283. }
  27284. if is390 == 1 {
  27285. insutype = "390"
  27286. }
  27287. if is310 == 1 {
  27288. insutype = "310"
  27289. }
  27290. if len(insutypes) == 0 {
  27291. insutype = "310"
  27292. }
  27293. insutype = psn_record.Insutype
  27294. for _, item := range rf {
  27295. if item.Insutype == insutype {
  27296. insuplc_admdvs = item.InsuplcAdmdvs
  27297. }
  27298. }
  27299. if config.IsOpen == 1 {
  27300. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  27301. var dat map[string]interface{}
  27302. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27303. fmt.Println(dat)
  27304. } else {
  27305. fmt.Println(err)
  27306. }
  27307. userJSONBytes, _ := json.Marshal(dat)
  27308. var res ResultFourteen
  27309. var res10265 ResultFourteen10265
  27310. if miConfig.Code == "H15049901371" {
  27311. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27312. utils.ErrorLog("解析失败:%v", err)
  27313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27314. return
  27315. }
  27316. res.ErrMsg = res10265.ErrMsg
  27317. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27318. res.Infcode = infocode
  27319. res.Output = res10265.Output
  27320. res.InfRefmsgid = res10265.InfRefmsgid
  27321. } else {
  27322. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27323. utils.ErrorLog("解析失败:%v", err)
  27324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27325. return
  27326. }
  27327. }
  27328. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27329. // utils.ErrorLog("解析失败:%v", err)
  27330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27331. // return
  27332. //}
  27333. if res.Infcode == 0 {
  27334. psn_record.IsCancel = 2
  27335. service.CreatePsnNCDSRecord(&psn_record)
  27336. c.ServeSuccessJSON(map[string]interface{}{
  27337. "failed_code": 0,
  27338. "msg": "撤销备案成功",
  27339. })
  27340. } else {
  27341. c.ServeSuccessJSON(map[string]interface{}{
  27342. "failed_code": -10,
  27343. "msg": res.ErrMsg,
  27344. })
  27345. return
  27346. }
  27347. }
  27348. }
  27349. func (c *HisApiController) TestTest() {
  27350. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  27351. fmt.Println(patient.Iinfo)
  27352. }
  27353. type CustomData struct {
  27354. MsgId string
  27355. PsnNo string
  27356. Info string
  27357. }
  27358. func (c *HisApiController) ReversalData() {
  27359. var customData []*CustomData
  27360. custom := &CustomData{
  27361. MsgId: "H44022900158202103301714472004",
  27362. PsnNo: "44020000001101329945",
  27363. Info: "2207",
  27364. }
  27365. customData = append(customData, custom)
  27366. custom1 := &CustomData{
  27367. MsgId: "H4402290015820210330172057803",
  27368. PsnNo: "44020000001101161813",
  27369. Info: "2207",
  27370. }
  27371. customData = append(customData, custom1)
  27372. custom2 := &CustomData{
  27373. MsgId: "H44022900158202103301705198813",
  27374. PsnNo: "44190000133097375417",
  27375. Info: "2207",
  27376. }
  27377. customData = append(customData, custom2)
  27378. custom3 := &CustomData{
  27379. MsgId: "H44022900158202103301715524756",
  27380. PsnNo: "44020000001100187221",
  27381. Info: "2207",
  27382. }
  27383. customData = append(customData, custom3)
  27384. custom4 := &CustomData{
  27385. MsgId: "H44022900158202103301730376224",
  27386. PsnNo: "44020000001101959155",
  27387. Info: "2207",
  27388. }
  27389. customData = append(customData, custom4)
  27390. custom5 := &CustomData{
  27391. MsgId: "H44022900158202103301748008725",
  27392. PsnNo: "44020000001104246641",
  27393. Info: "2207",
  27394. }
  27395. customData = append(customData, custom5)
  27396. custom6 := &CustomData{
  27397. MsgId: "H44022900158202103301718096755",
  27398. PsnNo: "44020000001102211860",
  27399. Info: "2207",
  27400. }
  27401. customData = append(customData, custom6)
  27402. custom7 := &CustomData{
  27403. MsgId: "H44022900158202103301736551640",
  27404. PsnNo: "44020000001102687718",
  27405. Info: "2207",
  27406. }
  27407. customData = append(customData, custom7)
  27408. custom8 := &CustomData{
  27409. MsgId: "H44022900158202103301743097676",
  27410. PsnNo: "44020000001102127785",
  27411. Info: "2207",
  27412. }
  27413. customData = append(customData, custom8)
  27414. custom9 := &CustomData{
  27415. MsgId: "H44022900158202103301712304203",
  27416. PsnNo: "44020000001101518097",
  27417. Info: "2207",
  27418. }
  27419. customData = append(customData, custom9)
  27420. custom10 := &CustomData{
  27421. MsgId: "H44022900158202103301738448785",
  27422. PsnNo: "44020000001100500813",
  27423. Info: "2207",
  27424. }
  27425. customData = append(customData, custom10)
  27426. custom11 := &CustomData{
  27427. MsgId: "H44022900158202103301732455843",
  27428. PsnNo: "44020000001102690557",
  27429. Info: "2207",
  27430. }
  27431. customData = append(customData, custom11)
  27432. custom12 := &CustomData{
  27433. MsgId: "H44022900158202103301745421708",
  27434. PsnNo: "44020000001102211928",
  27435. Info: "2207",
  27436. }
  27437. customData = append(customData, custom12)
  27438. custom1212 := &CustomData{
  27439. MsgId: "H440229001582021033017351627",
  27440. PsnNo: "44020000001102481733",
  27441. Info: "2207",
  27442. }
  27443. customData = append(customData, custom1212)
  27444. custom13 := &CustomData{
  27445. MsgId: "H44022900158202103301740327951",
  27446. PsnNo: "44020000001103174866",
  27447. Info: "2207",
  27448. }
  27449. customData = append(customData, custom13)
  27450. custom14 := &CustomData{
  27451. MsgId: "H4402290015820210330174922668",
  27452. PsnNo: "44020000001102927272",
  27453. Info: "2207",
  27454. }
  27455. customData = append(customData, custom14)
  27456. custom15 := &CustomData{
  27457. MsgId: "H44022900158202103301752362273",
  27458. PsnNo: "44020000001102942890",
  27459. Info: "2207",
  27460. }
  27461. customData = append(customData, custom15)
  27462. custom16 := &CustomData{
  27463. MsgId: "H44022900158202103301751082917",
  27464. PsnNo: "44020000001101662162",
  27465. Info: "2207",
  27466. }
  27467. customData = append(customData, custom16)
  27468. custom17 := &CustomData{
  27469. MsgId: "H44022900158202103301754147728",
  27470. PsnNo: "44020000000229014511",
  27471. Info: "2207",
  27472. }
  27473. customData = append(customData, custom17)
  27474. adminUser := c.GetAdminUserInfo()
  27475. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27476. for _, item := range customData {
  27477. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  27478. fmt.Println(result)
  27479. }
  27480. }
  27481. func (c *HisApiController) GetAllopatry() {
  27482. year := c.GetString("year")
  27483. month := c.GetString("month")
  27484. admin_user_id, _ := c.GetInt64("admin_user_id")
  27485. adminUser := c.GetAdminUserInfo()
  27486. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27487. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27488. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27489. var dat map[string]interface{}
  27490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27491. fmt.Println(dat)
  27492. } else {
  27493. fmt.Println(err)
  27494. }
  27495. userJSONBytes, _ := json.Marshal(dat)
  27496. var res models.Result9001
  27497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27498. utils.ErrorLog("解析失败:%v", err)
  27499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27500. return
  27501. }
  27502. fmt.Println(res.Output.Signinoutb)
  27503. fmt.Println(res.Output.Signinoutb.SignNo)
  27504. fmt.Println(string(userJSONBytes))
  27505. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  27506. var dat3 map[string]interface{}
  27507. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  27508. fmt.Println(dat3)
  27509. } else {
  27510. fmt.Println(err)
  27511. }
  27512. userJSONBytes3, _ := json.Marshal(dat3)
  27513. var res3 models.Result3260
  27514. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  27515. utils.ErrorLog("解析失败:%v", err)
  27516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27517. return
  27518. }
  27519. var curpage int
  27520. var pagesize int = 100
  27521. var start int = 1
  27522. //var stop int
  27523. //pagecount := 10
  27524. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  27525. var res22 []models.Result3260
  27526. for curpage = 1; curpage <= pagecount; curpage++ {
  27527. if curpage == 1 {
  27528. start = 0
  27529. } else {
  27530. start = (curpage-1)*pagesize + 1
  27531. }
  27532. fmt.Println(start)
  27533. //stop = curpage * pagesize
  27534. //if stop > int(res3.Output.Totalrow) {
  27535. // stop =int(res3.Output.Totalrow)
  27536. //}
  27537. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  27538. var dat2 map[string]interface{}
  27539. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27540. fmt.Println(dat)
  27541. } else {
  27542. fmt.Println(err)
  27543. }
  27544. userJSONBytes2, _ := json.Marshal(dat2)
  27545. var res2 models.Result3260
  27546. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27547. utils.ErrorLog("解析失败:%v", err)
  27548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27549. return
  27550. }
  27551. if res2.Infcode == 0 {
  27552. res22 = append(res22, res2)
  27553. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27554. //var dat2 map[string]interface{}
  27555. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  27556. // fmt.Println(dat)
  27557. //} else {
  27558. // fmt.Println(err)
  27559. //}
  27560. //c.ServeSuccessJSON(map[string]interface{}{
  27561. // "list": res2.Output.Data,
  27562. //})
  27563. //continue
  27564. }
  27565. }
  27566. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  27567. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  27568. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  27569. //var dat2 map[string]interface{}
  27570. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27571. // fmt.Println(dat)
  27572. //} else {
  27573. // fmt.Println(err)
  27574. //}
  27575. //userJSONBytes2, _ := json.Marshal(dat2)
  27576. //var res2 models.Result3260
  27577. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27578. // utils.ErrorLog("解析失败:%v", err)
  27579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27580. // return
  27581. //}
  27582. //if res2.Infcode == 0 {
  27583. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27584. // var dat2 map[string]interface{}
  27585. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  27586. // fmt.Println(dat)
  27587. // } else {
  27588. // fmt.Println(err)
  27589. // }
  27590. // c.ServeSuccessJSON(map[string]interface{}{
  27591. // "list": res2.Output.Data,
  27592. // })
  27593. //}
  27594. }
  27595. func (c *HisApiController) ComfirmAllopatry() {
  27596. year := c.GetString("year")
  27597. month := c.GetString("month")
  27598. admin_user_id, _ := c.GetInt64("admin_user_id")
  27599. adminUser := c.GetAdminUserInfo()
  27600. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27601. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27602. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27603. var dat map[string]interface{}
  27604. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27605. fmt.Println(dat)
  27606. } else {
  27607. fmt.Println(err)
  27608. }
  27609. userJSONBytes, _ := json.Marshal(dat)
  27610. var res models.Result9001
  27611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27612. utils.ErrorLog("解析失败:%v", err)
  27613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27614. return
  27615. }
  27616. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  27617. var dat2 map[string]interface{}
  27618. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27619. fmt.Println(dat)
  27620. } else {
  27621. fmt.Println(err)
  27622. }
  27623. userJSONBytes2, _ := json.Marshal(dat2)
  27624. var res2 models.Result3260
  27625. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27626. utils.ErrorLog("解析失败:%v", err)
  27627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27628. return
  27629. }
  27630. //if res2.Infcode == 0 {
  27631. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27632. // var dat map[string]interface{}
  27633. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27634. // fmt.Println(dat)
  27635. // } else {
  27636. // fmt.Println(err)
  27637. // }
  27638. // userJSONBytes, _ := json.Marshal(dat)
  27639. // var res3 models.Result3261
  27640. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  27641. // utils.ErrorLog("解析失败:%v", err)
  27642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27643. // return
  27644. // }
  27645. //
  27646. // if res3.Infcode == 0 {
  27647. // record := &models.HisYidiClearRecord{
  27648. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27649. // Ctime: time.Now().Unix(),
  27650. // Mtime: time.Now().Unix(),
  27651. // Status: 1,
  27652. // MsgId: msgId,
  27653. // }
  27654. // service.SaveClearRecord(record)
  27655. // c.ServeSuccessJSON(map[string]interface{}{
  27656. // "msg": "提取成功",
  27657. // })
  27658. // }
  27659. //}
  27660. }
  27661. func (c *HisApiController) RefundAllopatry() {
  27662. year := c.GetString("year")
  27663. month := c.GetString("month")
  27664. //id, _ := c.GetInt64("id")
  27665. admin_user_id, _ := c.GetInt64("admin_user_id")
  27666. adminUser := c.GetAdminUserInfo()
  27667. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27668. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27669. //record, _ := service.GetClearRecordById(id)
  27670. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27671. var dat map[string]interface{}
  27672. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27673. fmt.Println(dat)
  27674. } else {
  27675. fmt.Println(err)
  27676. }
  27677. userJSONBytes, _ := json.Marshal(dat)
  27678. var res models.Result9001
  27679. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27680. utils.ErrorLog("解析失败:%v", err)
  27681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27682. return
  27683. }
  27684. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  27685. var dat2 map[string]interface{}
  27686. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  27687. fmt.Println(dat)
  27688. } else {
  27689. fmt.Println(err)
  27690. }
  27691. userJSONBytes2, _ := json.Marshal(dat2)
  27692. var empty ResultFourteen
  27693. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  27694. utils.ErrorLog("解析失败:%v", err)
  27695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27696. return
  27697. }
  27698. if empty.Infcode == 0 {
  27699. c.ServeSuccessJSON(map[string]interface{}{
  27700. "msg": "撤销成功",
  27701. })
  27702. return
  27703. }
  27704. }
  27705. func (c *HisApiController) ReversalOtherData() {
  27706. var customData []*CustomData
  27707. custom := &CustomData{
  27708. MsgId: "H44022900158202103301714472004",
  27709. PsnNo: "44020000001101329945",
  27710. Info: "2208",
  27711. }
  27712. customData = append(customData, custom)
  27713. custom1 := &CustomData{
  27714. MsgId: "H4402290015820210330172057803",
  27715. PsnNo: "44020000001101161813",
  27716. Info: "2208",
  27717. }
  27718. customData = append(customData, custom1)
  27719. custom2 := &CustomData{
  27720. MsgId: "H44022900158202103301705198813",
  27721. PsnNo: "44190000133097375417",
  27722. Info: "2208",
  27723. }
  27724. customData = append(customData, custom2)
  27725. custom3 := &CustomData{
  27726. MsgId: "H44022900158202103301715524756",
  27727. PsnNo: "44020000001100187221",
  27728. Info: "2208",
  27729. }
  27730. customData = append(customData, custom3)
  27731. custom4 := &CustomData{
  27732. MsgId: "H44022900158202103301730376224",
  27733. PsnNo: "44020000001101959155",
  27734. Info: "2208",
  27735. }
  27736. customData = append(customData, custom4)
  27737. custom5 := &CustomData{
  27738. MsgId: "H44022900158202103301748008725",
  27739. PsnNo: "44020000001104246641",
  27740. Info: "2208",
  27741. }
  27742. customData = append(customData, custom5)
  27743. custom6 := &CustomData{
  27744. MsgId: "H44022900158202103301718096755",
  27745. PsnNo: "44020000001102211860",
  27746. Info: "2208",
  27747. }
  27748. customData = append(customData, custom6)
  27749. custom7 := &CustomData{
  27750. MsgId: "H44022900158202103301736551640",
  27751. PsnNo: "44020000001102687718",
  27752. Info: "2208",
  27753. }
  27754. customData = append(customData, custom7)
  27755. custom8 := &CustomData{
  27756. MsgId: "H44022900158202103301743097676",
  27757. PsnNo: "44020000001102127785",
  27758. Info: "2208",
  27759. }
  27760. customData = append(customData, custom8)
  27761. custom9 := &CustomData{
  27762. MsgId: "H44022900158202103301712304203",
  27763. PsnNo: "44020000001101518097",
  27764. Info: "2208",
  27765. }
  27766. customData = append(customData, custom9)
  27767. custom10 := &CustomData{
  27768. MsgId: "H44022900158202103301738448785",
  27769. PsnNo: "44020000001100500813",
  27770. Info: "2208",
  27771. }
  27772. customData = append(customData, custom10)
  27773. custom11 := &CustomData{
  27774. MsgId: "H44022900158202103301732455843",
  27775. PsnNo: "44020000001102690557",
  27776. Info: "2208",
  27777. }
  27778. customData = append(customData, custom11)
  27779. custom12 := &CustomData{
  27780. MsgId: "H44022900158202103301745421708",
  27781. PsnNo: "44020000001102211928",
  27782. Info: "2208",
  27783. }
  27784. customData = append(customData, custom12)
  27785. custom1212 := &CustomData{
  27786. MsgId: "H440229001582021033017351627",
  27787. PsnNo: "44020000001102481733",
  27788. Info: "2208",
  27789. }
  27790. customData = append(customData, custom1212)
  27791. custom13 := &CustomData{
  27792. MsgId: "H44022900158202103301740327951",
  27793. PsnNo: "44020000001103174866",
  27794. Info: "2208",
  27795. }
  27796. customData = append(customData, custom13)
  27797. custom14 := &CustomData{
  27798. MsgId: "H4402290015820210330174922668",
  27799. PsnNo: "44020000001102927272",
  27800. Info: "2208",
  27801. }
  27802. customData = append(customData, custom14)
  27803. custom15 := &CustomData{
  27804. MsgId: "H44022900158202103301752362273",
  27805. PsnNo: "44020000001102942890",
  27806. Info: "2208",
  27807. }
  27808. customData = append(customData, custom15)
  27809. custom16 := &CustomData{
  27810. MsgId: "H44022900158202103301751082917",
  27811. PsnNo: "44020000001101662162",
  27812. Info: "2208",
  27813. }
  27814. customData = append(customData, custom16)
  27815. custom17 := &CustomData{
  27816. MsgId: "H44022900158202103301754147728",
  27817. PsnNo: "44020000000229014511",
  27818. Info: "2208",
  27819. }
  27820. customData = append(customData, custom17)
  27821. adminUser := c.GetAdminUserInfo()
  27822. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27823. for _, item := range customData {
  27824. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  27825. fmt.Println(result)
  27826. }
  27827. }
  27828. func PathExists(path string) (bool, error) {
  27829. _, err := os.Stat(path)
  27830. if err == nil {
  27831. return true, nil
  27832. }
  27833. if os.IsNotExist(err) {
  27834. return false, nil
  27835. }
  27836. return false, err
  27837. }
  27838. // 创建文件夹
  27839. func Mkdir(dir string) {
  27840. // 创建文件夹
  27841. exist, err := PathExists(dir)
  27842. if err != nil {
  27843. fmt.Println(err.Error())
  27844. } else {
  27845. if exist {
  27846. fmt.Println(dir + "文件夹已存在!")
  27847. } else {
  27848. // 文件夹名称,权限
  27849. err := os.Mkdir(dir, os.ModePerm)
  27850. if err != nil {
  27851. fmt.Println(dir+"文件夹创建失败:", err.Error())
  27852. } else {
  27853. fmt.Println(dir + "文件夹创建成功!")
  27854. }
  27855. }
  27856. }
  27857. }
  27858. // 压缩文件
  27859. func Zip(srcFile string, destZip string) error {
  27860. zipfile, err := os.Create(destZip)
  27861. if err != nil {
  27862. return err
  27863. }
  27864. defer zipfile.Close()
  27865. archive := zip.NewWriter(zipfile)
  27866. defer archive.Close()
  27867. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  27868. if err != nil {
  27869. return err
  27870. }
  27871. header, err := zip.FileInfoHeader(info)
  27872. if err != nil {
  27873. return err
  27874. }
  27875. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  27876. // header.Name = path
  27877. if info.IsDir() {
  27878. header.Name += "/"
  27879. } else {
  27880. header.Method = zip.Deflate
  27881. }
  27882. writer, err := archive.CreateHeader(header)
  27883. if err != nil {
  27884. return err
  27885. }
  27886. if !info.IsDir() {
  27887. file, err := os.Open(path)
  27888. if err != nil {
  27889. return err
  27890. }
  27891. defer file.Close()
  27892. _, err = io.Copy(writer, file)
  27893. }
  27894. return err
  27895. })
  27896. return err
  27897. }
  27898. func ReadFile(filePath string) []byte {
  27899. f, err := os.Open(filePath)
  27900. if err != nil {
  27901. fmt.Println("read file fail", err)
  27902. return nil
  27903. }
  27904. defer f.Close()
  27905. fd, err := ioutil.ReadAll(f)
  27906. if err != nil {
  27907. fmt.Println("read to fd fail", err)
  27908. return nil
  27909. }
  27910. return fd
  27911. }
  27912. func saveLogq(result string, request string, infno string, desc string) {
  27913. dir := "日志"
  27914. utils.Mkdir(dir)
  27915. month := time.Unix(1557042972, 0).Format("1")
  27916. year := time.Now().Format("2006")
  27917. month = time.Now().Format("01")
  27918. day := time.Now().Format("02")
  27919. hour := time.Now().Format("15")
  27920. min := time.Now().Format("04")
  27921. sec := time.Now().Format("05")
  27922. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  27923. file := year + month + day + "_log"
  27924. file_name := file + ".txt"
  27925. file_path := "日志" + "/" + file_name
  27926. exist, _ := utils.PathExists(file_path)
  27927. if exist { //存在
  27928. fmt.Println("存在")
  27929. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  27930. if err != nil {
  27931. fmt.Println("read fail")
  27932. }
  27933. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  27934. n, _ := f.Seek(0, 2)
  27935. _, err = f.WriteAt([]byte(content), n)
  27936. } else { //不存在
  27937. fmt.Println("文件不存在,创建文件")
  27938. f, err := os.Create("日志" + "/" + file_name)
  27939. defer f.Close()
  27940. if err != nil {
  27941. } else {
  27942. _, err = f.Write([]byte("记录日志"))
  27943. }
  27944. }
  27945. }
  27946. func saveLog(result string, request string, infno string, desc string) {
  27947. org_id, _ := beego.AppConfig.Int64("org_id")
  27948. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  27949. dir := miConfig.OrgName + "日志"
  27950. utils.Mkdir(dir)
  27951. month := time.Unix(1557042972, 0).Format("1")
  27952. year := time.Now().Format("2006")
  27953. month = time.Now().Format("01")
  27954. day := time.Now().Format("02")
  27955. hour := time.Now().Format("15")
  27956. min := time.Now().Format("04")
  27957. sec := time.Now().Format("05")
  27958. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  27959. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  27960. file_name := file + ".txt"
  27961. file_path := miConfig.OrgName + "日志" + "/" + file_name
  27962. exist, _ := utils.PathExists(file_path)
  27963. if exist { //存在
  27964. fmt.Println("存在")
  27965. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  27966. if err != nil {
  27967. fmt.Println("read fail")
  27968. }
  27969. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  27970. n, _ := f.Seek(0, 2)
  27971. _, err = f.WriteAt([]byte(content), n)
  27972. } else { //不存在
  27973. fmt.Println("文件不存在,创建文件")
  27974. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  27975. defer f.Close()
  27976. if err != nil {
  27977. } else {
  27978. _, err = f.Write([]byte("记录日志"))
  27979. }
  27980. }
  27981. }
  27982. type Charset string
  27983. const (
  27984. UTF8 = Charset("UTF-8")
  27985. GB18030 = Charset("GB18030")
  27986. )
  27987. func ConvertToString(src string, srcCode string, tagCode string) string {
  27988. srcCoder := mahonia.NewDecoder(srcCode)
  27989. srcResult := srcCoder.ConvertString(src)
  27990. tagCoder := mahonia.NewDecoder(tagCode)
  27991. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  27992. result := string(cdata)
  27993. return result
  27994. }
  27995. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  27996. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  27997. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  27998. var token string
  27999. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28000. var api string
  28001. if miConfig.MdtrtareaAdmvs == "320921" {
  28002. 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 +
  28003. "&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
  28004. fmt.Println(api)
  28005. } else {
  28006. 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 +
  28007. "&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
  28008. }
  28009. resp, requestErr := http.Get(api)
  28010. if requestErr != nil {
  28011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28012. return ""
  28013. }
  28014. body, ioErr := ioutil.ReadAll(resp.Body)
  28015. if ioErr != nil {
  28016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28018. return ""
  28019. }
  28020. var respJSON map[string]interface{}
  28021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28024. return ""
  28025. }
  28026. var status string
  28027. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28028. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28029. var res ResultTwo //1101结果
  28030. var res10265 ResultTwo10265 //1101结果
  28031. if status == "0" { //读卡成功
  28032. var card_info string //卡信息
  28033. var busi_card_info string
  28034. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28035. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28036. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28037. fmt.Println(card_info)
  28038. fmt.Println(busi_card_info)
  28039. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28040. result, _ := json.Marshal(respJSON)
  28041. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28042. utils.ErrorLog("解析失败:%v", err)
  28043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28044. return ""
  28045. }
  28046. res.ErrMsg = res10265.ErrMsg
  28047. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28048. res.Infcode = infocode
  28049. res.Output = res10265.Output
  28050. res.InfRefmsgid = res10265.InfRefmsgid
  28051. if res.Infcode == 0 {
  28052. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28053. if err == gorm.ErrRecordNotFound {
  28054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28055. return ""
  28056. } else if err != nil {
  28057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28058. return ""
  28059. } else {
  28060. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28061. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28062. infoStr := string(Iinfos)
  28063. idetinfoStr := string(Idetinfos)
  28064. psn := &models.HisPsn{
  28065. PsnNo: res.Output.Baseinfo.PsnNo,
  28066. PatientId: patient.ID,
  28067. Certno: res.Output.Baseinfo.Certno,
  28068. Gend: res.Output.Baseinfo.Gend,
  28069. Naty: res.Output.Baseinfo.Naty,
  28070. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28071. PsnName: res.Output.Baseinfo.PsnName,
  28072. Idetinfo: idetinfoStr,
  28073. Insuinfo: infoStr,
  28074. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28075. CardInfo: card_info,
  28076. VerifyNumber: token,
  28077. }
  28078. service.CreateHisPsn(psn)
  28079. return token
  28080. }
  28081. }
  28082. } else {
  28083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28084. return ""
  28085. }
  28086. } else { //读卡失败
  28087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28088. return ""
  28089. }
  28090. return token
  28091. }
  28092. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  28093. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28094. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28095. var token string
  28096. var api string
  28097. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  28098. "&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
  28099. fmt.Println(api)
  28100. resp, requestErr := http.Get(api)
  28101. if requestErr != nil {
  28102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28103. return ""
  28104. }
  28105. body, ioErr := ioutil.ReadAll(resp.Body)
  28106. if ioErr != nil {
  28107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28109. return ""
  28110. }
  28111. var respJSON map[string]interface{}
  28112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28115. return ""
  28116. }
  28117. var status string
  28118. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28119. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28120. var res ResultTwo //1101结果
  28121. if status == "1" { //读卡成功
  28122. var card_info string //卡信息
  28123. var busi_card_info string
  28124. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28125. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28126. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28127. fmt.Println(card_info)
  28128. fmt.Println(busi_card_info)
  28129. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28130. result, _ := json.Marshal(respJSON)
  28131. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28132. utils.ErrorLog("解析失败:%v", err)
  28133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28134. return ""
  28135. }
  28136. if res.Infcode == 0 {
  28137. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28138. if err == gorm.ErrRecordNotFound {
  28139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28140. return ""
  28141. } else if err != nil {
  28142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28143. return ""
  28144. } else {
  28145. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28146. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28147. infoStr := string(Iinfos)
  28148. idetinfoStr := string(Idetinfos)
  28149. psn := &models.HisPsn{
  28150. PsnNo: res.Output.Baseinfo.PsnNo,
  28151. PatientId: patient.ID,
  28152. Certno: res.Output.Baseinfo.Certno,
  28153. Gend: res.Output.Baseinfo.Gend,
  28154. Naty: res.Output.Baseinfo.Naty,
  28155. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28156. PsnName: res.Output.Baseinfo.PsnName,
  28157. Idetinfo: idetinfoStr,
  28158. Insuinfo: infoStr,
  28159. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28160. CardInfo: card_info,
  28161. VerifyNumber: token,
  28162. }
  28163. service.CreateHisPsn(psn)
  28164. return token
  28165. }
  28166. }
  28167. } else {
  28168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28169. return ""
  28170. }
  28171. return token
  28172. }
  28173. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  28174. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28175. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28176. var token string
  28177. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28178. var api string
  28179. if miConfig.MdtrtareaAdmvs == "320921" {
  28180. 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 +
  28181. "&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
  28182. fmt.Println(api)
  28183. } else {
  28184. 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 +
  28185. "&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
  28186. }
  28187. resp, requestErr := http.Get(api)
  28188. if requestErr != nil {
  28189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28190. return ""
  28191. }
  28192. body, ioErr := ioutil.ReadAll(resp.Body)
  28193. if ioErr != nil {
  28194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28196. return ""
  28197. }
  28198. var respJSON map[string]interface{}
  28199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28202. return ""
  28203. }
  28204. var status string
  28205. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28206. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28207. var res ResultTwo //1101结果
  28208. var res10265 ResultTwo10265 //1101结果
  28209. if status == "0" { //读卡成功
  28210. var card_info string //卡信息
  28211. var busi_card_info string
  28212. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28213. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28214. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28215. fmt.Println(card_info)
  28216. fmt.Println(busi_card_info)
  28217. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28218. result, _ := json.Marshal(respJSON)
  28219. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28220. utils.ErrorLog("解析失败:%v", err)
  28221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28222. return ""
  28223. }
  28224. res.ErrMsg = res10265.ErrMsg
  28225. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28226. res.Infcode = infocode
  28227. res.Output = res10265.Output
  28228. res.InfRefmsgid = res10265.InfRefmsgid
  28229. if res.Infcode == 0 {
  28230. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28231. if err == gorm.ErrRecordNotFound {
  28232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28233. return ""
  28234. } else if err != nil {
  28235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28236. return ""
  28237. } else {
  28238. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28239. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28240. infoStr := string(Iinfos)
  28241. idetinfoStr := string(Idetinfos)
  28242. psn := &models.HisPsn{
  28243. PsnNo: res.Output.Baseinfo.PsnNo,
  28244. PatientId: patient.ID,
  28245. Certno: res.Output.Baseinfo.Certno,
  28246. Gend: res.Output.Baseinfo.Gend,
  28247. Naty: res.Output.Baseinfo.Naty,
  28248. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28249. PsnName: res.Output.Baseinfo.PsnName,
  28250. Idetinfo: idetinfoStr,
  28251. Insuinfo: infoStr,
  28252. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28253. CardInfo: card_info,
  28254. VerifyNumber: token,
  28255. }
  28256. service.CreateHisPsn(psn)
  28257. return token
  28258. }
  28259. }
  28260. } else {
  28261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28262. return ""
  28263. }
  28264. } else { //读卡失败
  28265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28266. return ""
  28267. }
  28268. return token
  28269. }
  28270. func DeleteExtraSpaceTwo(s string) string {
  28271. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28272. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28273. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28274. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28275. s2 := make([]byte, len(s1)) //定义字符数组切片
  28276. copy(s2, s1) //将字符串复制到切片
  28277. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28278. for len(spc_index) > 0 { //找到适配项
  28279. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28280. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28281. }
  28282. return string(s2)
  28283. }
  28284. func Remove0000(s string) string {
  28285. str := make([]rune, 0, len(s))
  28286. for _, v := range []rune(s) {
  28287. if v == 0 {
  28288. continue
  28289. }
  28290. str = append(str, v)
  28291. }
  28292. return string(str)
  28293. }
  28294. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  28295. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  28296. readCard := DllDef.MustFindProc("EcQuery")
  28297. pCardInfo := make([]byte, 8192)
  28298. pBusiCardInfo := make([]byte, 8192)
  28299. data := make(map[string]interface{})
  28300. //pData := make(map[string]interface{})
  28301. inputData := make(map[string]interface{})
  28302. inputData["orgId"] = code
  28303. inputData["businessType"] = "01101"
  28304. inputData["operatorId"] = operator_id
  28305. inputData["operatorName"] = operator_name
  28306. inputData["officeId"] = "001"
  28307. inputData["officeName"] = "血透室"
  28308. //
  28309. data["data"] = inputData
  28310. data["transType"] = "ec.query"
  28311. data["orgId"] = code
  28312. bytesData, _ := json.Marshal(data)
  28313. pCardInfo = bytesData
  28314. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  28315. fmt.Println(ret2)
  28316. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  28317. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  28318. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  28319. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  28320. if ret2 != 0 {
  28321. return "", ""
  28322. }
  28323. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  28324. }
  28325. func DeleteExtraSpace(s string) string {
  28326. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28327. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28328. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28329. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28330. s2 := make([]byte, len(s1)) //定义字符数组切片
  28331. copy(s2, s1) //将字符串复制到切片
  28332. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28333. for len(spc_index) > 0 { //找到适配项
  28334. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28335. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28336. }
  28337. return string(s2)
  28338. }
  28339. // 对账
  28340. func (c *HisApiController) Post3202() {
  28341. start_time := c.GetString("start_time")
  28342. end_time := c.GetString("end_time")
  28343. //insutype := c.GetString("insutype")
  28344. clr_type := c.GetString("clr_type")
  28345. clr_org := c.GetString("clr_optins")
  28346. admin_user_id, _ := c.GetInt64("admin_user_id")
  28347. adminUser := c.GetAdminUserInfo()
  28348. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28349. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28350. if len(clr_org) == 0 {
  28351. clr_org = miConfig.MdtrtareaAdmvs
  28352. }
  28353. timeLayout := "2006-01-02"
  28354. loc, _ := time.LoadLocation("Local")
  28355. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28356. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28357. var orders []*models.HisOrder
  28358. if clr_org == "421300" {
  28359. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28360. } else {
  28361. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28362. }
  28363. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28364. //fixmedins_setl_cnt := int64(len(orders))
  28365. var medfee_sumamt float64
  28366. var acct_pay float64
  28367. var fund_pay_sumamt float64
  28368. for _, item := range orders {
  28369. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28370. acct_pay = acct_pay + item.AcctPay
  28371. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28372. }
  28373. //var medfee_sumamt_two float64
  28374. //var acct_pay_two float64
  28375. //var fund_pay_sumamt_two float64
  28376. //for _, item := range orders_two {
  28377. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  28378. // acct_pay_two = acct_pay_two + item.AcctPay
  28379. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  28380. //}
  28381. //var user_name string
  28382. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28383. //if role.ID == 0 {
  28384. // user_name = "xxx"
  28385. //} else {
  28386. // user_name = role.UserName
  28387. //}
  28388. var res ResultSix
  28389. if config.IsOpen == 1 {
  28390. var bps []*models.BusinessParamsTwo
  28391. var bp models.BusinessParamsTwo
  28392. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28393. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  28394. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  28395. bp.MedfeeSumamt = medfee_sumamt_str
  28396. bp.AcctPay = acct_pay_str
  28397. bp.FundPaySumamt = fund_pay_sumamt_str
  28398. bp.Insutype = ""
  28399. bp.StmtBegndate = start_time
  28400. bp.ClrType = clr_type
  28401. bp.SetlOptins = clr_org
  28402. bp.StmtEnddate = end_time
  28403. bps = append(bps, &bp)
  28404. data := make(map[string]interface{})
  28405. data["bps"] = bps
  28406. data["org_name"] = miConfig.OrgName
  28407. data["doctor"] = role.UserName
  28408. data["fixmedins_code"] = miConfig.Code
  28409. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28410. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28411. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28412. if miConfig.MdtrtareaAdmvs == "421300" {
  28413. client := &http.Client{}
  28414. bytesData, _ := json.Marshal(data)
  28415. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28416. resp, _ := client.Do(req)
  28417. defer resp.Body.Close()
  28418. body, ioErr := ioutil.ReadAll(resp.Body)
  28419. if ioErr != nil {
  28420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28422. return
  28423. }
  28424. var respJSON map[string]interface{}
  28425. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28428. return
  28429. }
  28430. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28431. userJSONBytes, _ := json.Marshal(respJSON)
  28432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28433. utils.ErrorLog("解析失败:%v", err)
  28434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28435. return
  28436. }
  28437. }
  28438. if miConfig.MdtrtareaAdmvs == "420200" {
  28439. client := &http.Client{}
  28440. bytesData, _ := json.Marshal(data)
  28441. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28442. resp, _ := client.Do(req)
  28443. defer resp.Body.Close()
  28444. body, ioErr := ioutil.ReadAll(resp.Body)
  28445. if ioErr != nil {
  28446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28448. return
  28449. }
  28450. var respJSON map[string]interface{}
  28451. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28454. return
  28455. }
  28456. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28457. userJSONBytes, _ := json.Marshal(respJSON)
  28458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28459. utils.ErrorLog("解析失败:%v", err)
  28460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28461. return
  28462. }
  28463. }
  28464. if miConfig.MdtrtareaAdmvs == "421182" {
  28465. client := &http.Client{}
  28466. bytesData, _ := json.Marshal(data)
  28467. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  28468. resp, _ := client.Do(req)
  28469. defer resp.Body.Close()
  28470. body, ioErr := ioutil.ReadAll(resp.Body)
  28471. if ioErr != nil {
  28472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28474. return
  28475. }
  28476. var respJSON map[string]interface{}
  28477. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28480. return
  28481. }
  28482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28483. userJSONBytes, _ := json.Marshal(respJSON)
  28484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28485. utils.ErrorLog("解析失败:%v", err)
  28486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28487. return
  28488. }
  28489. }
  28490. if res.Infcode == 0 {
  28491. c.ServeSuccessJSON(map[string]interface{}{
  28492. "msg": "发起成功",
  28493. })
  28494. } else {
  28495. c.ServeSuccessJSON(map[string]interface{}{
  28496. "failed_code": -10,
  28497. "msg": res.ErrMsg,
  28498. })
  28499. }
  28500. }
  28501. }
  28502. func (c *HisApiController) Post3202b() {
  28503. start_time := c.GetString("start_time")
  28504. end_time := c.GetString("end_time")
  28505. //insutype := c.GetString("insutype")
  28506. clr_type := c.GetString("clr_type")
  28507. clr_org := c.GetString("clr_optins")
  28508. admin_user_id, _ := c.GetInt64("admin_user_id")
  28509. adminUser := c.GetAdminUserInfo()
  28510. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28511. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28512. if len(clr_org) == 0 {
  28513. clr_org = miConfig.MdtrtareaAdmvs
  28514. }
  28515. timeLayout := "2006-01-02"
  28516. loc, _ := time.LoadLocation("Local")
  28517. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28518. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28519. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28520. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28521. //fixmedins_setl_cnt := int64(len(orders))
  28522. var medfee_sumamt float64
  28523. var acct_pay float64
  28524. var fund_pay_sumamt float64
  28525. for _, item := range orders {
  28526. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28527. acct_pay = acct_pay + item.AcctPay
  28528. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28529. }
  28530. //var medfee_sumamt_two float64
  28531. //var acct_pay_two float64
  28532. //var fund_pay_sumamt_two float64
  28533. //for _, item := range orders_two {
  28534. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  28535. // acct_pay_two = acct_pay_two + item.AcctPay
  28536. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  28537. //}
  28538. //var user_name string
  28539. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28540. //if role.ID == 0 {
  28541. // user_name = "xxx"
  28542. //} else {
  28543. // user_name = role.UserName
  28544. //}
  28545. var res ResultSix
  28546. if config.IsOpen == 1 {
  28547. var bps []*models.BusinessParamsTwo
  28548. var bp models.BusinessParamsTwo
  28549. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28550. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  28551. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  28552. bp.MedfeeSumamt = medfee_sumamt_str
  28553. bp.AcctPay = acct_pay_str
  28554. bp.FundPaySumamt = fund_pay_sumamt_str
  28555. bp.Insutype = "390"
  28556. bp.StmtBegndate = start_time
  28557. bp.ClrType = clr_type
  28558. bp.SetlOptins = clr_org
  28559. bp.StmtEnddate = end_time
  28560. bps = append(bps, &bp)
  28561. data := make(map[string]interface{})
  28562. data["bps"] = bps
  28563. data["org_name"] = miConfig.OrgName
  28564. data["doctor"] = role.UserName
  28565. data["fixmedins_code"] = miConfig.Code
  28566. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28567. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28568. if miConfig.MdtrtareaAdmvs == "421300" {
  28569. client := &http.Client{}
  28570. bytesData, _ := json.Marshal(data)
  28571. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  28572. resp, _ := client.Do(req)
  28573. defer resp.Body.Close()
  28574. body, ioErr := ioutil.ReadAll(resp.Body)
  28575. if ioErr != nil {
  28576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28578. return
  28579. }
  28580. var respJSON map[string]interface{}
  28581. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28584. return
  28585. }
  28586. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28587. userJSONBytes, _ := json.Marshal(respJSON)
  28588. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28589. utils.ErrorLog("解析失败:%v", err)
  28590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28591. return
  28592. }
  28593. }
  28594. if miConfig.MdtrtareaAdmvs == "420200" {
  28595. client := &http.Client{}
  28596. bytesData, _ := json.Marshal(data)
  28597. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  28598. resp, _ := client.Do(req)
  28599. defer resp.Body.Close()
  28600. body, ioErr := ioutil.ReadAll(resp.Body)
  28601. if ioErr != nil {
  28602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28604. return
  28605. }
  28606. var respJSON map[string]interface{}
  28607. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28610. return
  28611. }
  28612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28613. userJSONBytes, _ := json.Marshal(respJSON)
  28614. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28615. utils.ErrorLog("解析失败:%v", err)
  28616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28617. return
  28618. }
  28619. }
  28620. if miConfig.MdtrtareaAdmvs == "421182" {
  28621. client := &http.Client{}
  28622. bytesData, _ := json.Marshal(data)
  28623. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  28624. resp, _ := client.Do(req)
  28625. defer resp.Body.Close()
  28626. body, ioErr := ioutil.ReadAll(resp.Body)
  28627. if ioErr != nil {
  28628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28630. return
  28631. }
  28632. var respJSON map[string]interface{}
  28633. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28636. return
  28637. }
  28638. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28639. userJSONBytes, _ := json.Marshal(respJSON)
  28640. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28641. utils.ErrorLog("解析失败:%v", err)
  28642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28643. return
  28644. }
  28645. }
  28646. if res.Infcode == 0 {
  28647. c.ServeSuccessJSON(map[string]interface{}{
  28648. "msg": "发起成功",
  28649. })
  28650. } else {
  28651. c.ServeSuccessJSON(map[string]interface{}{
  28652. "failed_code": -10,
  28653. "msg": res.ErrMsg,
  28654. })
  28655. }
  28656. }
  28657. }
  28658. func (c *HisApiController) Post1608() {
  28659. start_time := c.GetString("start_time")
  28660. end_time := c.GetString("end_time")
  28661. admin_user_id, _ := c.GetInt64("admin_user_id")
  28662. adminUser := c.GetAdminUserInfo()
  28663. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28664. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28665. timeLayout := "2006-01-02"
  28666. loc, _ := time.LoadLocation("Local")
  28667. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28668. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28669. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28670. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28671. fixmedins_setl_cnt := int64(len(orders))
  28672. var medfee_sumamt float64
  28673. var func_smamt float64
  28674. for _, item := range orders {
  28675. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28676. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  28677. }
  28678. times := strings.Split(start_time, "-")
  28679. time_tows := strings.Split(end_time, "-")
  28680. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28681. var res ResultSix
  28682. if config.IsOpen == 1 {
  28683. //var bps []*models.BusinessParamsTwo
  28684. //var bp models.BusinessParamsTwo
  28685. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28686. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  28687. data := make(map[string]interface{})
  28688. data["org_name"] = miConfig.OrgName
  28689. data["doctor"] = role.UserName
  28690. data["func_smamt"] = func_smamt_str
  28691. data["fixmedins_code"] = miConfig.Code
  28692. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28693. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28694. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  28695. data["medfee_sumamt"] = medfee_sumamt_str
  28696. data["start_time"] = times[0] + times[1] + times[2]
  28697. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  28698. if miConfig.MdtrtareaAdmvs == "421300" {
  28699. client := &http.Client{}
  28700. bytesData, _ := json.Marshal(data)
  28701. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  28702. resp, _ := client.Do(req)
  28703. defer resp.Body.Close()
  28704. body, ioErr := ioutil.ReadAll(resp.Body)
  28705. if ioErr != nil {
  28706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28708. return
  28709. }
  28710. var respJSON map[string]interface{}
  28711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28714. return
  28715. }
  28716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28717. userJSONBytes, _ := json.Marshal(respJSON)
  28718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28719. utils.ErrorLog("解析失败:%v", err)
  28720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28721. return
  28722. }
  28723. }
  28724. if miConfig.MdtrtareaAdmvs == "420200" {
  28725. client := &http.Client{}
  28726. bytesData, _ := json.Marshal(data)
  28727. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  28728. resp, _ := client.Do(req)
  28729. defer resp.Body.Close()
  28730. body, ioErr := ioutil.ReadAll(resp.Body)
  28731. if ioErr != nil {
  28732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28734. return
  28735. }
  28736. var respJSON map[string]interface{}
  28737. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28740. return
  28741. }
  28742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28743. userJSONBytes, _ := json.Marshal(respJSON)
  28744. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28745. utils.ErrorLog("解析失败:%v", err)
  28746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28747. return
  28748. }
  28749. }
  28750. if miConfig.MdtrtareaAdmvs == "421182" {
  28751. client := &http.Client{}
  28752. bytesData, _ := json.Marshal(data)
  28753. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  28754. resp, _ := client.Do(req)
  28755. defer resp.Body.Close()
  28756. body, ioErr := ioutil.ReadAll(resp.Body)
  28757. if ioErr != nil {
  28758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28760. return
  28761. }
  28762. var respJSON map[string]interface{}
  28763. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28766. return
  28767. }
  28768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28769. userJSONBytes, _ := json.Marshal(respJSON)
  28770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28771. utils.ErrorLog("解析失败:%v", err)
  28772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28773. return
  28774. }
  28775. }
  28776. if res.Infcode == 0 {
  28777. c.ServeSuccessJSON(map[string]interface{}{
  28778. "msg": "发起成功",
  28779. })
  28780. } else {
  28781. c.ServeSuccessJSON(map[string]interface{}{
  28782. "failed_code": -10,
  28783. "msg": res.ErrMsg,
  28784. })
  28785. }
  28786. }
  28787. }
  28788. // 5.11.1.1【5262】结算信息按时间段查询
  28789. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  28790. admin_user_id, _ := c.GetInt64("admin_user_id")
  28791. adminUser := c.GetAdminUserInfo()
  28792. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28793. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28794. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28795. var res Result5262
  28796. if config.IsOpen == 1 {
  28797. if miConfig.MdtrtareaAdmvs == "421300" {
  28798. data := make(map[string]interface{})
  28799. data["bps"] = bp
  28800. data["org_name"] = miConfig.OrgName
  28801. data["doctor"] = role.UserName
  28802. data["fixmedins_code"] = miConfig.Code
  28803. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28804. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28805. data["page"] = strconv.FormatInt(page, 10)
  28806. data["limit"] = strconv.FormatInt(limit, 10)
  28807. fmt.Println(data)
  28808. client := &http.Client{}
  28809. bytesData, _ := json.Marshal(data)
  28810. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  28811. resp, _ := client.Do(req)
  28812. defer resp.Body.Close()
  28813. body, ioErr := ioutil.ReadAll(resp.Body)
  28814. if ioErr != nil {
  28815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28817. return
  28818. }
  28819. var respJSON map[string]interface{}
  28820. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28823. return
  28824. }
  28825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28826. userJSONBytes, _ := json.Marshal(respJSON)
  28827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28828. utils.ErrorLog("解析失败:%v", err)
  28829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28830. return
  28831. }
  28832. }
  28833. if miConfig.MdtrtareaAdmvs == "420200" {
  28834. data := make(map[string]interface{})
  28835. data["bps"] = bp
  28836. data["org_name"] = miConfig.OrgName
  28837. data["doctor"] = role.UserName
  28838. data["fixmedins_code"] = miConfig.Code
  28839. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28840. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28841. data["page"] = strconv.FormatInt(page, 10)
  28842. data["limit"] = strconv.FormatInt(limit, 10)
  28843. fmt.Println(data)
  28844. client := &http.Client{}
  28845. bytesData, _ := json.Marshal(data)
  28846. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  28847. resp, _ := client.Do(req)
  28848. defer resp.Body.Close()
  28849. body, ioErr := ioutil.ReadAll(resp.Body)
  28850. if ioErr != nil {
  28851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28853. return
  28854. }
  28855. var respJSON map[string]interface{}
  28856. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28859. return
  28860. }
  28861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28862. userJSONBytes, _ := json.Marshal(respJSON)
  28863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28864. utils.ErrorLog("解析失败:%v", err)
  28865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28866. return
  28867. }
  28868. }
  28869. if miConfig.MdtrtareaAdmvs == "421182" {
  28870. data := make(map[string]interface{})
  28871. data["bps"] = bp
  28872. data["org_name"] = miConfig.OrgName
  28873. data["doctor"] = role.UserName
  28874. data["fixmedins_code"] = miConfig.Code
  28875. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28876. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28877. data["page"] = strconv.FormatInt(page, 10)
  28878. data["limit"] = strconv.FormatInt(limit, 10)
  28879. fmt.Println(data)
  28880. client := &http.Client{}
  28881. bytesData, _ := json.Marshal(data)
  28882. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  28883. resp, _ := client.Do(req)
  28884. defer resp.Body.Close()
  28885. body, ioErr := ioutil.ReadAll(resp.Body)
  28886. if ioErr != nil {
  28887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28889. return
  28890. }
  28891. var respJSON map[string]interface{}
  28892. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28895. return
  28896. }
  28897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28898. userJSONBytes, _ := json.Marshal(respJSON)
  28899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28900. utils.ErrorLog("解析失败:%v", err)
  28901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28902. return
  28903. }
  28904. }
  28905. if res.Infcode == 0 {
  28906. c.ServeSuccessJSON(map[string]interface{}{
  28907. "order": res.Output.Result,
  28908. "total": res.Output.PageInfo.RecordCounts,
  28909. })
  28910. } else {
  28911. c.ServeSuccessJSON(map[string]interface{}{
  28912. "failed_code": -10,
  28913. "msg": res.ErrMsg,
  28914. })
  28915. }
  28916. }
  28917. }
  28918. // 5.11.1.2【5267】异地结算信息时间段查询
  28919. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  28920. admin_user_id, _ := c.GetInt64("admin_user_id")
  28921. adminUser := c.GetAdminUserInfo()
  28922. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28923. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28924. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28925. var res Result5267
  28926. if config.IsOpen == 1 {
  28927. if miConfig.MdtrtareaAdmvs == "421300" {
  28928. data := make(map[string]interface{})
  28929. data["bps"] = bp
  28930. data["org_name"] = miConfig.OrgName
  28931. data["doctor"] = role.UserName
  28932. data["fixmedins_code"] = miConfig.Code
  28933. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28934. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28935. data["page"] = page
  28936. data["limit"] = limit
  28937. fmt.Println(data)
  28938. client := &http.Client{}
  28939. bytesData, _ := json.Marshal(data)
  28940. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  28941. resp, _ := client.Do(req)
  28942. defer resp.Body.Close()
  28943. body, ioErr := ioutil.ReadAll(resp.Body)
  28944. if ioErr != nil {
  28945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28947. return
  28948. }
  28949. var respJSON map[string]interface{}
  28950. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28953. return
  28954. }
  28955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28956. userJSONBytes, _ := json.Marshal(respJSON)
  28957. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28958. utils.ErrorLog("解析失败:%v", err)
  28959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28960. return
  28961. }
  28962. }
  28963. if miConfig.MdtrtareaAdmvs == "420200" {
  28964. data := make(map[string]interface{})
  28965. data["bps"] = bp
  28966. data["org_name"] = miConfig.OrgName
  28967. data["doctor"] = role.UserName
  28968. data["fixmedins_code"] = miConfig.Code
  28969. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28970. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28971. data["page"] = page
  28972. data["limit"] = limit
  28973. fmt.Println(data)
  28974. client := &http.Client{}
  28975. bytesData, _ := json.Marshal(data)
  28976. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  28977. resp, _ := client.Do(req)
  28978. defer resp.Body.Close()
  28979. body, ioErr := ioutil.ReadAll(resp.Body)
  28980. if ioErr != nil {
  28981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28983. return
  28984. }
  28985. var respJSON map[string]interface{}
  28986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28989. return
  28990. }
  28991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28992. userJSONBytes, _ := json.Marshal(respJSON)
  28993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28994. utils.ErrorLog("解析失败:%v", err)
  28995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28996. return
  28997. }
  28998. }
  28999. if miConfig.MdtrtareaAdmvs == "421182" {
  29000. data := make(map[string]interface{})
  29001. data["bps"] = bp
  29002. data["org_name"] = miConfig.OrgName
  29003. data["doctor"] = role.UserName
  29004. data["fixmedins_code"] = miConfig.Code
  29005. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29006. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29007. data["page"] = page
  29008. data["limit"] = limit
  29009. fmt.Println(data)
  29010. client := &http.Client{}
  29011. bytesData, _ := json.Marshal(data)
  29012. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  29013. resp, _ := client.Do(req)
  29014. defer resp.Body.Close()
  29015. body, ioErr := ioutil.ReadAll(resp.Body)
  29016. if ioErr != nil {
  29017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29019. return
  29020. }
  29021. var respJSON map[string]interface{}
  29022. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29025. return
  29026. }
  29027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29028. userJSONBytes, _ := json.Marshal(respJSON)
  29029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29030. utils.ErrorLog("解析失败:%v", err)
  29031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29032. return
  29033. }
  29034. }
  29035. if res.Infcode == 0 {
  29036. c.ServeSuccessJSON(map[string]interface{}{
  29037. "order": res.Output.Result,
  29038. "total": res.Output.PageInfo.RecordCounts,
  29039. })
  29040. } else {
  29041. c.ServeSuccessJSON(map[string]interface{}{
  29042. "failed_code": -10,
  29043. "msg": res.ErrMsg,
  29044. })
  29045. }
  29046. }
  29047. }
  29048. func (c *HisApiController) Post3501() {
  29049. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29050. data := make(map[string]interface{})
  29051. var struct3501s []models.Struct3501
  29052. var struct3501 models.Struct3501
  29053. struct3501.OrgName = miConfig.OrgName
  29054. struct3501.AccessKey = miConfig.AccessKey
  29055. struct3501.RequestUrl = miConfig.Url
  29056. struct3501.SecretKey = miConfig.SecretKey
  29057. struct3501.ManuDate = "2022-08-17"
  29058. struct3501.FixmedinsBchno = ""
  29059. struct3501.ManuLotnum = ""
  29060. struct3501.RxFlag = "0"
  29061. struct3501.ExpyEnd = "2022-08-17"
  29062. struct3501.Invdate = "2022-08-17"
  29063. struct3501.InvCnt = "20.25"
  29064. struct3501.Memo = ""
  29065. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29066. struct3501.FixmedinsHilistId = miConfig.Code
  29067. struct3501.FixmedinsHilistName = miConfig.OrgName
  29068. struct3501s = append(struct3501s, struct3501)
  29069. data["struct_3501s"] = struct3501s
  29070. client := &http.Client{}
  29071. bytesData, _ := json.Marshal(data)
  29072. var req *http.Request
  29073. if miConfig.MdtrtareaAdmvs == "320921" {
  29074. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29075. } else {
  29076. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29077. }
  29078. resp, _ := client.Do(req)
  29079. defer resp.Body.Close()
  29080. body, ioErr := ioutil.ReadAll(resp.Body)
  29081. if ioErr != nil {
  29082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29084. return
  29085. }
  29086. var respJSON map[string]interface{}
  29087. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29090. return
  29091. }
  29092. var res ResultSix
  29093. var resSix10265 ResultSix10265 //1101结果
  29094. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29095. result, _ := json.Marshal(respJSON)
  29096. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29097. utils.ErrorLog("解析失败:%v", err)
  29098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29099. return
  29100. }
  29101. res.InfRefmsgid = resSix10265.InfRefmsgid
  29102. res.Output = resSix10265.Output
  29103. res.ErrMsg = resSix10265.ErrMsg
  29104. res.Cainfo = resSix10265.Cainfo
  29105. res.WarnMsg = resSix10265.WarnMsg
  29106. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29107. res.Infcode = infocode
  29108. if infocode == 0 {
  29109. c.ServeSuccessJSON(map[string]interface{}{
  29110. "msg": "上传成功",
  29111. })
  29112. return
  29113. } else {
  29114. c.ServeSuccessJSON(map[string]interface{}{
  29115. "failed_code": -10,
  29116. "msg": res.ErrMsg,
  29117. })
  29118. return
  29119. }
  29120. }
  29121. func (c *HisApiController) Post3502() {
  29122. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29123. data := make(map[string]interface{})
  29124. var struct3502s []models.Struct3502
  29125. var struct3502 models.Struct3502
  29126. struct3502.OrgName = miConfig.OrgName
  29127. struct3502.AccessKey = miConfig.AccessKey
  29128. struct3502.RequestUrl = miConfig.Url
  29129. struct3502.SecretKey = miConfig.SecretKey
  29130. struct3502.ManuDate = "2022-08-15"
  29131. struct3502.FixmedinsBchno = ""
  29132. struct3502.ManuLotnum = ""
  29133. struct3502.RxFlag = "0"
  29134. struct3502.ExpyEnd = "2022-08-15"
  29135. struct3502.Invdate = "2022-08-15"
  29136. struct3502.InvCnt = "20.25"
  29137. struct3502.Memo = ""
  29138. struct3502.MedListCodg = "XB01ABD056B002020200517"
  29139. struct3502.FixmedinsHilistId = miConfig.Code
  29140. struct3502.FixmedinsHilistName = miConfig.OrgName
  29141. struct3502s = append(struct3502s, struct3502)
  29142. data["struct_3502s"] = struct3502s
  29143. client := &http.Client{}
  29144. bytesData, _ := json.Marshal(data)
  29145. var req *http.Request
  29146. if miConfig.MdtrtareaAdmvs == "320921" {
  29147. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29148. } else {
  29149. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29150. }
  29151. resp, _ := client.Do(req)
  29152. defer resp.Body.Close()
  29153. body, ioErr := ioutil.ReadAll(resp.Body)
  29154. if ioErr != nil {
  29155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29157. return
  29158. }
  29159. var respJSON map[string]interface{}
  29160. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29163. return
  29164. }
  29165. var res ResultSix
  29166. var resSix10265 ResultSix10265 //1101结果
  29167. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29168. result, _ := json.Marshal(respJSON)
  29169. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29170. utils.ErrorLog("解析失败:%v", err)
  29171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29172. return
  29173. }
  29174. res.InfRefmsgid = resSix10265.InfRefmsgid
  29175. res.Output = resSix10265.Output
  29176. res.ErrMsg = resSix10265.ErrMsg
  29177. res.Cainfo = resSix10265.Cainfo
  29178. res.WarnMsg = resSix10265.WarnMsg
  29179. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29180. res.Infcode = infocode
  29181. if infocode == 0 {
  29182. c.ServeSuccessJSON(map[string]interface{}{
  29183. "msg": "上传成功",
  29184. })
  29185. return
  29186. } else {
  29187. c.ServeSuccessJSON(map[string]interface{}{
  29188. "failed_code": -10,
  29189. "msg": res.ErrMsg,
  29190. })
  29191. return
  29192. }
  29193. }
  29194. func (c *HisApiController) Post3503() {
  29195. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29196. data := make(map[string]interface{})
  29197. var struct3501s []models.Struct3501
  29198. var struct3501 models.Struct3501
  29199. struct3501.OrgName = miConfig.OrgName
  29200. struct3501.AccessKey = miConfig.AccessKey
  29201. struct3501.RequestUrl = miConfig.Url
  29202. struct3501.SecretKey = miConfig.SecretKey
  29203. struct3501.ManuDate = "2022-08-15"
  29204. struct3501.FixmedinsBchno = ""
  29205. struct3501.ManuLotnum = ""
  29206. struct3501.RxFlag = "0"
  29207. struct3501.ExpyEnd = "2022-08-15"
  29208. struct3501.Invdate = "2022-08-15"
  29209. struct3501.InvCnt = "20.25"
  29210. struct3501.Memo = ""
  29211. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29212. struct3501.FixmedinsHilistId = miConfig.Code
  29213. struct3501.FixmedinsHilistName = miConfig.OrgName
  29214. struct3501s = append(struct3501s, struct3501)
  29215. data["struct_3501s"] = struct3501s
  29216. client := &http.Client{}
  29217. bytesData, _ := json.Marshal(data)
  29218. var req *http.Request
  29219. if miConfig.MdtrtareaAdmvs == "320921" {
  29220. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29221. } else {
  29222. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29223. }
  29224. resp, _ := client.Do(req)
  29225. defer resp.Body.Close()
  29226. body, ioErr := ioutil.ReadAll(resp.Body)
  29227. if ioErr != nil {
  29228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29230. return
  29231. }
  29232. var respJSON map[string]interface{}
  29233. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29236. return
  29237. }
  29238. var res ResultSix
  29239. var resSix10265 ResultSix10265 //1101结果
  29240. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29241. result, _ := json.Marshal(respJSON)
  29242. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29243. utils.ErrorLog("解析失败:%v", err)
  29244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29245. return
  29246. }
  29247. res.InfRefmsgid = resSix10265.InfRefmsgid
  29248. res.Output = resSix10265.Output
  29249. res.ErrMsg = resSix10265.ErrMsg
  29250. res.Cainfo = resSix10265.Cainfo
  29251. res.WarnMsg = resSix10265.WarnMsg
  29252. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29253. res.Infcode = infocode
  29254. if infocode == 0 {
  29255. c.ServeSuccessJSON(map[string]interface{}{
  29256. "msg": "上传成功",
  29257. })
  29258. return
  29259. } else {
  29260. c.ServeSuccessJSON(map[string]interface{}{
  29261. "failed_code": -10,
  29262. "msg": res.ErrMsg,
  29263. })
  29264. return
  29265. }
  29266. }
  29267. func (c *HisApiController) Post3504() {
  29268. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29269. data := make(map[string]interface{})
  29270. var struct3501s []models.Struct3501
  29271. var struct3501 models.Struct3501
  29272. struct3501.OrgName = miConfig.OrgName
  29273. struct3501.AccessKey = miConfig.AccessKey
  29274. struct3501.RequestUrl = miConfig.Url
  29275. struct3501.SecretKey = miConfig.SecretKey
  29276. struct3501.ManuDate = "2022-08-15"
  29277. struct3501.FixmedinsBchno = ""
  29278. struct3501.ManuLotnum = ""
  29279. struct3501.RxFlag = "0"
  29280. struct3501.ExpyEnd = "2022-08-15"
  29281. struct3501.Invdate = "2022-08-15"
  29282. struct3501.InvCnt = "20.25"
  29283. struct3501.Memo = ""
  29284. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29285. struct3501.FixmedinsHilistId = miConfig.Code
  29286. struct3501.FixmedinsHilistName = miConfig.OrgName
  29287. struct3501s = append(struct3501s, struct3501)
  29288. data["struct_3501s"] = struct3501s
  29289. client := &http.Client{}
  29290. bytesData, _ := json.Marshal(data)
  29291. var req *http.Request
  29292. if miConfig.MdtrtareaAdmvs == "320921" {
  29293. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29294. } else {
  29295. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29296. }
  29297. resp, _ := client.Do(req)
  29298. defer resp.Body.Close()
  29299. body, ioErr := ioutil.ReadAll(resp.Body)
  29300. if ioErr != nil {
  29301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29303. return
  29304. }
  29305. var respJSON map[string]interface{}
  29306. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29309. return
  29310. }
  29311. var res ResultSix
  29312. var resSix10265 ResultSix10265 //1101结果
  29313. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29314. result, _ := json.Marshal(respJSON)
  29315. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29316. utils.ErrorLog("解析失败:%v", err)
  29317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29318. return
  29319. }
  29320. res.InfRefmsgid = resSix10265.InfRefmsgid
  29321. res.Output = resSix10265.Output
  29322. res.ErrMsg = resSix10265.ErrMsg
  29323. res.Cainfo = resSix10265.Cainfo
  29324. res.WarnMsg = resSix10265.WarnMsg
  29325. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29326. res.Infcode = infocode
  29327. if infocode == 0 {
  29328. c.ServeSuccessJSON(map[string]interface{}{
  29329. "msg": "上传成功",
  29330. })
  29331. return
  29332. } else {
  29333. c.ServeSuccessJSON(map[string]interface{}{
  29334. "failed_code": -10,
  29335. "msg": res.ErrMsg,
  29336. })
  29337. return
  29338. }
  29339. }
  29340. func (c *HisApiController) Post3505() {
  29341. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29342. data := make(map[string]interface{})
  29343. var struct3501s []models.Struct3501
  29344. var struct3501 models.Struct3501
  29345. struct3501.OrgName = miConfig.OrgName
  29346. struct3501.AccessKey = miConfig.AccessKey
  29347. struct3501.RequestUrl = miConfig.Url
  29348. struct3501.SecretKey = miConfig.SecretKey
  29349. struct3501.ManuDate = "2022-08-15"
  29350. struct3501.FixmedinsBchno = ""
  29351. struct3501.ManuLotnum = ""
  29352. struct3501.RxFlag = "0"
  29353. struct3501.ExpyEnd = "2022-08-15"
  29354. struct3501.Invdate = "2022-08-15"
  29355. struct3501.InvCnt = "20.25"
  29356. struct3501.Memo = ""
  29357. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29358. struct3501.FixmedinsHilistId = miConfig.Code
  29359. struct3501.FixmedinsHilistName = miConfig.OrgName
  29360. struct3501s = append(struct3501s, struct3501)
  29361. data["struct_3501s"] = struct3501s
  29362. client := &http.Client{}
  29363. bytesData, _ := json.Marshal(data)
  29364. var req *http.Request
  29365. if miConfig.MdtrtareaAdmvs == "320921" {
  29366. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29367. } else {
  29368. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29369. }
  29370. resp, _ := client.Do(req)
  29371. defer resp.Body.Close()
  29372. body, ioErr := ioutil.ReadAll(resp.Body)
  29373. if ioErr != nil {
  29374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29376. return
  29377. }
  29378. var respJSON map[string]interface{}
  29379. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29382. return
  29383. }
  29384. var res ResultSix
  29385. var resSix10265 ResultSix10265 //1101结果
  29386. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29387. result, _ := json.Marshal(respJSON)
  29388. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29389. utils.ErrorLog("解析失败:%v", err)
  29390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29391. return
  29392. }
  29393. res.InfRefmsgid = resSix10265.InfRefmsgid
  29394. res.Output = resSix10265.Output
  29395. res.ErrMsg = resSix10265.ErrMsg
  29396. res.Cainfo = resSix10265.Cainfo
  29397. res.WarnMsg = resSix10265.WarnMsg
  29398. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29399. res.Infcode = infocode
  29400. if infocode == 0 {
  29401. c.ServeSuccessJSON(map[string]interface{}{
  29402. "msg": "上传成功",
  29403. })
  29404. return
  29405. } else {
  29406. c.ServeSuccessJSON(map[string]interface{}{
  29407. "failed_code": -10,
  29408. "msg": res.ErrMsg,
  29409. })
  29410. return
  29411. }
  29412. }
  29413. func (c *HisApiController) Post3506() {
  29414. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29415. data := make(map[string]interface{})
  29416. var struct3501s []models.Struct3501
  29417. var struct3501 models.Struct3501
  29418. struct3501.OrgName = miConfig.OrgName
  29419. struct3501.AccessKey = miConfig.AccessKey
  29420. struct3501.RequestUrl = miConfig.Url
  29421. struct3501.SecretKey = miConfig.SecretKey
  29422. struct3501.ManuDate = "2022-08-15"
  29423. struct3501.FixmedinsBchno = ""
  29424. struct3501.ManuLotnum = ""
  29425. struct3501.RxFlag = "0"
  29426. struct3501.ExpyEnd = "2022-08-15"
  29427. struct3501.Invdate = "2022-08-15"
  29428. struct3501.InvCnt = "20.25"
  29429. struct3501.Memo = ""
  29430. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29431. struct3501.FixmedinsHilistId = miConfig.Code
  29432. struct3501.FixmedinsHilistName = miConfig.OrgName
  29433. struct3501s = append(struct3501s, struct3501)
  29434. data["struct_3501s"] = struct3501s
  29435. client := &http.Client{}
  29436. bytesData, _ := json.Marshal(data)
  29437. var req *http.Request
  29438. if miConfig.MdtrtareaAdmvs == "320921" {
  29439. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29440. } else {
  29441. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29442. }
  29443. resp, _ := client.Do(req)
  29444. defer resp.Body.Close()
  29445. body, ioErr := ioutil.ReadAll(resp.Body)
  29446. if ioErr != nil {
  29447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29449. return
  29450. }
  29451. var respJSON map[string]interface{}
  29452. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29455. return
  29456. }
  29457. var res ResultSix
  29458. var resSix10265 ResultSix10265 //1101结果
  29459. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29460. result, _ := json.Marshal(respJSON)
  29461. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29462. utils.ErrorLog("解析失败:%v", err)
  29463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29464. return
  29465. }
  29466. res.InfRefmsgid = resSix10265.InfRefmsgid
  29467. res.Output = resSix10265.Output
  29468. res.ErrMsg = resSix10265.ErrMsg
  29469. res.Cainfo = resSix10265.Cainfo
  29470. res.WarnMsg = resSix10265.WarnMsg
  29471. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29472. res.Infcode = infocode
  29473. if infocode == 0 {
  29474. c.ServeSuccessJSON(map[string]interface{}{
  29475. "msg": "上传成功",
  29476. })
  29477. return
  29478. } else {
  29479. c.ServeSuccessJSON(map[string]interface{}{
  29480. "failed_code": -10,
  29481. "msg": res.ErrMsg,
  29482. })
  29483. return
  29484. }
  29485. }
  29486. func (c *HisApiController) Post3507() {
  29487. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29488. data := make(map[string]interface{})
  29489. var struct3501s []models.Struct3501
  29490. var struct3501 models.Struct3501
  29491. struct3501.OrgName = miConfig.OrgName
  29492. struct3501.AccessKey = miConfig.AccessKey
  29493. struct3501.RequestUrl = miConfig.Url
  29494. struct3501.SecretKey = miConfig.SecretKey
  29495. struct3501.ManuDate = "2022-08-15"
  29496. struct3501.FixmedinsBchno = ""
  29497. struct3501.ManuLotnum = ""
  29498. struct3501.RxFlag = "0"
  29499. struct3501.ExpyEnd = "2022-08-15"
  29500. struct3501.Invdate = "2022-08-15"
  29501. struct3501.InvCnt = "20.25"
  29502. struct3501.Memo = ""
  29503. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29504. struct3501.FixmedinsHilistId = miConfig.Code
  29505. struct3501.FixmedinsHilistName = miConfig.OrgName
  29506. struct3501s = append(struct3501s, struct3501)
  29507. data["struct_3501s"] = struct3501s
  29508. client := &http.Client{}
  29509. bytesData, _ := json.Marshal(data)
  29510. var req *http.Request
  29511. if miConfig.MdtrtareaAdmvs == "320921" {
  29512. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29513. } else {
  29514. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29515. }
  29516. resp, _ := client.Do(req)
  29517. defer resp.Body.Close()
  29518. body, ioErr := ioutil.ReadAll(resp.Body)
  29519. if ioErr != nil {
  29520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29522. return
  29523. }
  29524. var respJSON map[string]interface{}
  29525. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29528. return
  29529. }
  29530. var res ResultSix
  29531. var resSix10265 ResultSix10265 //1101结果
  29532. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29533. result, _ := json.Marshal(respJSON)
  29534. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29535. utils.ErrorLog("解析失败:%v", err)
  29536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29537. return
  29538. }
  29539. res.InfRefmsgid = resSix10265.InfRefmsgid
  29540. res.Output = resSix10265.Output
  29541. res.ErrMsg = resSix10265.ErrMsg
  29542. res.Cainfo = resSix10265.Cainfo
  29543. res.WarnMsg = resSix10265.WarnMsg
  29544. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29545. res.Infcode = infocode
  29546. if infocode == 0 {
  29547. c.ServeSuccessJSON(map[string]interface{}{
  29548. "msg": "上传成功",
  29549. })
  29550. return
  29551. } else {
  29552. c.ServeSuccessJSON(map[string]interface{}{
  29553. "failed_code": -10,
  29554. "msg": res.ErrMsg,
  29555. })
  29556. return
  29557. }
  29558. }
  29559. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  29560. // WebSocket服务器地址
  29561. serverURL := "ws://127.0.0.1:8899"
  29562. // 解析WebSocket服务器地址
  29563. u, err := url.Parse(serverURL)
  29564. if err != nil {
  29565. }
  29566. // 建立WebSocket连接
  29567. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29568. if err != nil {
  29569. }
  29570. defer conn.Close()
  29571. input2 := make(map[string]interface{})
  29572. input := make(map[string]interface{})
  29573. inputData := make(map[string]interface{})
  29574. inputData["orgId"] = code
  29575. inputData["businessType"] = "01101"
  29576. inputData["operatorId"] = operator_id
  29577. inputData["operatorName"] = operator_name
  29578. inputData["officeId"] = "001"
  29579. inputData["officeName"] = "血透室"
  29580. inputData["deviceType"] = ""
  29581. input["data"] = inputData
  29582. input["orgId"] = code
  29583. input["transType"] = "ec.query"
  29584. //if md == ""
  29585. if md[:4] == "4403" {
  29586. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29587. } else if md[:4] == "4401" {
  29588. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29589. } else {
  29590. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29591. }
  29592. input2["indata"] = input
  29593. fmt.Println(input2)
  29594. bytesData, _ := json.Marshal(input2)
  29595. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29596. if err != nil {
  29597. fmt.Println(err)
  29598. }
  29599. // 接收消息
  29600. _, receivedMessage, err := conn.ReadMessage()
  29601. if err != nil {
  29602. fmt.Println(err)
  29603. }
  29604. return "", string(receivedMessage)
  29605. }
  29606. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  29607. // WebSocket服务器地址
  29608. serverURL := "ws://127.0.0.1:8899"
  29609. // 解析WebSocket服务器地址
  29610. u, err := url.Parse(serverURL)
  29611. if err != nil {
  29612. }
  29613. // 建立WebSocket连接
  29614. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29615. if err != nil {
  29616. }
  29617. defer conn.Close()
  29618. input2 := make(map[string]interface{})
  29619. input := make(map[string]interface{})
  29620. inputData := make(map[string]interface{})
  29621. inputData["orgId"] = code
  29622. inputData["businessType"] = "01103"
  29623. inputData["operatorId"] = operator_id
  29624. inputData["operatorName"] = operator_name
  29625. inputData["officeId"] = "001"
  29626. inputData["officeName"] = "血透室"
  29627. inputData["deviceType"] = ""
  29628. input["data"] = inputData
  29629. input["orgId"] = code
  29630. input["transType"] = "ec.query"
  29631. //if md ==
  29632. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  29633. input2["indata"] = input
  29634. fmt.Println(input2)
  29635. bytesData, _ := json.Marshal(input2)
  29636. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29637. if err != nil {
  29638. fmt.Println(err)
  29639. }
  29640. // 接收消息
  29641. _, receivedMessage, err := conn.ReadMessage()
  29642. if err != nil {
  29643. fmt.Println(err)
  29644. }
  29645. return "", string(receivedMessage)
  29646. }
  29647. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  29648. // WebSocket服务器地址
  29649. serverURL := "ws://127.0.0.1:8899"
  29650. // 解析WebSocket服务器地址
  29651. u, err := url.Parse(serverURL)
  29652. if err != nil {
  29653. }
  29654. // 建立WebSocket连接
  29655. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29656. if err != nil {
  29657. }
  29658. defer conn.Close()
  29659. input2 := make(map[string]interface{})
  29660. input := make(map[string]interface{})
  29661. inputData := make(map[string]interface{})
  29662. inputData["orgId"] = code
  29663. inputData["businessType"] = "01101"
  29664. inputData["operatorId"] = operator_id
  29665. inputData["operatorName"] = operator_name
  29666. inputData["officeId"] = "001"
  29667. inputData["officeName"] = "血透室"
  29668. inputData["deviceType"] = ""
  29669. input["data"] = inputData
  29670. input["orgId"] = code
  29671. input["transType"] = "ec.query"
  29672. //if md == ""
  29673. if md[:4] == "4403" {
  29674. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29675. } else if md[:4] == "4401" {
  29676. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29677. } else {
  29678. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29679. }
  29680. input2["indata"] = input
  29681. fmt.Println(input2)
  29682. bytesData, _ := json.Marshal(input2)
  29683. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29684. if err != nil {
  29685. fmt.Println(err)
  29686. }
  29687. // 接收消息
  29688. _, receivedMessage, err := conn.ReadMessage()
  29689. if err != nil {
  29690. fmt.Println(err)
  29691. }
  29692. return "", string(receivedMessage)
  29693. }
  29694. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  29695. // WebSocket服务器地址
  29696. serverURL := "ws://127.0.0.1:8899"
  29697. // 解析WebSocket服务器地址
  29698. u, err := url.Parse(serverURL)
  29699. if err != nil {
  29700. }
  29701. // 建立WebSocket连接
  29702. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29703. if err != nil {
  29704. }
  29705. defer conn.Close()
  29706. input2 := make(map[string]interface{})
  29707. input := make(map[string]interface{})
  29708. inputData := make(map[string]interface{})
  29709. inputData["orgId"] = code
  29710. inputData["businessType"] = "01301"
  29711. inputData["operatorId"] = operator_id
  29712. inputData["operatorName"] = operator_name
  29713. inputData["officeId"] = "001"
  29714. inputData["officeName"] = "血透室"
  29715. inputData["deviceType"] = ""
  29716. input["data"] = inputData
  29717. input["orgId"] = code
  29718. input["transType"] = "ec.query"
  29719. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29720. input2["indata"] = input
  29721. bytesData, _ := json.Marshal(input2)
  29722. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29723. if err != nil {
  29724. fmt.Println(err)
  29725. }
  29726. // 接收消息
  29727. _, receivedMessage, err := conn.ReadMessage()
  29728. if err != nil {
  29729. fmt.Println(err)
  29730. }
  29731. return "", string(receivedMessage)
  29732. }
  29733. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  29734. newArr = make([]string, 0)
  29735. for i := 0; i < len(arr); i++ {
  29736. repeat := false
  29737. for j := i + 1; j < len(arr); j++ {
  29738. if arr[i] == arr[j] {
  29739. repeat = true
  29740. break
  29741. }
  29742. }
  29743. if !repeat {
  29744. newArr = append(newArr, arr[i])
  29745. }
  29746. }
  29747. return
  29748. }