his_api_controller.go 1.3MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. "gdyb/controllers"
  13. "gdyb/enums"
  14. "gdyb/models"
  15. "gdyb/service"
  16. "gdyb/utils"
  17. "github.com/astaxie/beego"
  18. "github.com/axgle/mahonia"
  19. "github.com/go-ole/go-ole/oleutil"
  20. "github.com/gorilla/websocket"
  21. "github.com/jinzhu/gorm"
  22. "github.com/shopspring/decimal"
  23. "io"
  24. "io/ioutil"
  25. //"math"
  26. "math/rand"
  27. "net/http"
  28. "net/url"
  29. "os"
  30. "path/filepath"
  31. "regexp"
  32. "strconv"
  33. "strings"
  34. "syscall"
  35. "time"
  36. "unsafe"
  37. )
  38. type HisApiController struct {
  39. controllers.BaseAuthAPIController
  40. }
  41. func HisManagerApiRegistRouters() {
  42. //挂号
  43. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  44. //上传就诊信息-上传明细-结算
  45. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  46. //查询
  47. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  48. //对总账
  49. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  50. //对明细
  51. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  52. //退费,退明细
  53. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  54. //退号
  55. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  56. //退明细
  57. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  58. //上传就诊信息-上传明细-预结算
  59. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  60. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  61. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  62. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  63. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  64. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  65. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  66. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  67. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  68. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  69. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  70. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  71. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  72. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  73. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  74. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  75. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  76. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  77. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  78. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  79. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  80. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  81. beego.Router("/api/check", &HisApiController{}, "get:Check")
  82. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  83. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  84. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  85. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  86. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  87. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  88. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  89. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  90. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  91. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  92. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  93. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  94. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  95. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  96. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  97. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  98. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  99. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  100. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  101. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  102. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  103. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  104. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  108. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  109. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  110. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  111. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  112. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  113. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  114. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  115. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  116. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  136. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  137. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  138. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  139. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  140. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  141. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  142. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  143. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  144. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  145. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  146. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  147. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  148. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  149. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  150. //库盘和变更
  151. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  152. //删除库盘和变更
  153. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  154. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  155. //药品变更
  156. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  157. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  158. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  159. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  160. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  161. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  162. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  163. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  164. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  165. }
  166. func (c *HisApiController) Get3508() {
  167. admin_user_id, _ := c.GetInt64("admin_user_id")
  168. drug_id, _ := c.GetInt64("id")
  169. start_time := c.GetString("start_time")
  170. end_time := c.GetString("end_time")
  171. adminUser := c.GetAdminUserInfo()
  172. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  173. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  174. drug, _ := service.GetDrugByID(drug_id)
  175. var struct3508 models.Struct3508
  176. struct3508.OrgName = miConfig.OrgName
  177. struct3508.FixmedinsCode = miConfig.Code
  178. struct3508.AccessKey = miConfig.AccessKey
  179. struct3508.Opter = curRoles.UserName
  180. struct3508.RequestUrl = miConfig.Url
  181. struct3508.Url = miConfig.Url
  182. struct3508.AppId = miConfig.Cainfo
  183. struct3508.AppSecret = miConfig.AppSecret
  184. struct3508.Enckey = miConfig.EncKey
  185. struct3508.SignKey = miConfig.SignKey
  186. struct3508.SecretKey = miConfig.SecretKey
  187. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  188. struct3508.Begndate = start_time
  189. struct3508.Enddate = end_time
  190. result1, result2, _ := service.FJyb3508(struct3508)
  191. saveLog(result1, result2, "3508", "3508")
  192. var res models.Result3508
  193. var respJSON2 map[string]interface{}
  194. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  197. return
  198. }
  199. userJSONBytes2, _ := json.Marshal(respJSON2)
  200. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  201. utils.ErrorLog("解析失败:%v", err)
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  203. return
  204. }
  205. if res.Infcode == -1 {
  206. c.ServeSuccessJSON(map[string]interface{}{
  207. "failed_code": -10,
  208. "msg": res.ErrMsg,
  209. })
  210. } else {
  211. c.ServeSuccessJSON(map[string]interface{}{
  212. "info": res.Output,
  213. })
  214. }
  215. }
  216. func (c *HisApiController) Get3509() {
  217. admin_user_id, _ := c.GetInt64("admin_user_id")
  218. drug_id, _ := c.GetInt64("id")
  219. start_time := c.GetString("start_time")
  220. end_time := c.GetString("end_time")
  221. adminUser := c.GetAdminUserInfo()
  222. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  223. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  224. drug, _ := service.GetDrugByID(drug_id)
  225. var struct3508 models.Struct3509
  226. struct3508.OrgName = miConfig.OrgName
  227. struct3508.FixmedinsCode = miConfig.Code
  228. struct3508.AccessKey = miConfig.AccessKey
  229. struct3508.Opter = curRoles.UserName
  230. struct3508.RequestUrl = miConfig.Url
  231. struct3508.Url = miConfig.Url
  232. struct3508.AppId = miConfig.Cainfo
  233. struct3508.AppSecret = miConfig.AppSecret
  234. struct3508.Enckey = miConfig.EncKey
  235. struct3508.SignKey = miConfig.SignKey
  236. struct3508.SecretKey = miConfig.SecretKey
  237. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  238. struct3508.Begndate = start_time
  239. struct3508.Enddate = end_time
  240. result1, result2, _ := service.FJyb3509(struct3508)
  241. saveLog(result1, result2, "3509", "3509")
  242. var res models.Result3509
  243. var respJSON2 map[string]interface{}
  244. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  247. return
  248. }
  249. userJSONBytes2, _ := json.Marshal(respJSON2)
  250. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  251. utils.ErrorLog("解析失败:%v", err)
  252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  253. return
  254. }
  255. if res.Infcode == -1 {
  256. c.ServeSuccessJSON(map[string]interface{}{
  257. "failed_code": -10,
  258. "msg": res.ErrMsg,
  259. })
  260. } else {
  261. c.ServeSuccessJSON(map[string]interface{}{
  262. "info": res.Output,
  263. })
  264. }
  265. }
  266. func (c *HisApiController) Get3510() {
  267. admin_user_id, _ := c.GetInt64("admin_user_id")
  268. drug_id, _ := c.GetInt64("id")
  269. start_time := c.GetString("start_time")
  270. end_time := c.GetString("end_time")
  271. adminUser := c.GetAdminUserInfo()
  272. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  273. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  274. drug, _ := service.GetDrugByID(drug_id)
  275. var struct3508 models.Struct3510
  276. struct3508.FixmedinsCode = miConfig.Code
  277. struct3508.OrgName = miConfig.OrgName
  278. struct3508.AccessKey = miConfig.AccessKey
  279. struct3508.Opter = curRoles.UserName
  280. struct3508.RequestUrl = miConfig.Url
  281. struct3508.Url = miConfig.Url
  282. struct3508.AppId = miConfig.Cainfo
  283. struct3508.AppSecret = miConfig.AppSecret
  284. struct3508.Enckey = miConfig.EncKey
  285. struct3508.SignKey = miConfig.SignKey
  286. struct3508.SecretKey = miConfig.SecretKey
  287. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  288. struct3508.Begndate = start_time
  289. struct3508.Enddate = end_time
  290. result1, result2, _ := service.FJyb3510(struct3508)
  291. saveLog(result1, result2, "3510", "3510")
  292. var res models.Result3510
  293. var respJSON2 map[string]interface{}
  294. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  297. return
  298. }
  299. userJSONBytes2, _ := json.Marshal(respJSON2)
  300. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  301. utils.ErrorLog("解析失败:%v", err)
  302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  303. return
  304. }
  305. if res.Infcode == -1 {
  306. c.ServeSuccessJSON(map[string]interface{}{
  307. "failed_code": -10,
  308. "msg": res.ErrMsg,
  309. })
  310. } else {
  311. c.ServeSuccessJSON(map[string]interface{}{
  312. "info": res.Output,
  313. })
  314. }
  315. }
  316. func (c *HisApiController) Get3511() {
  317. admin_user_id, _ := c.GetInt64("admin_user_id")
  318. drug_id, _ := c.GetInt64("id")
  319. start_time := c.GetString("start_time")
  320. end_time := c.GetString("end_time")
  321. adminUser := c.GetAdminUserInfo()
  322. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  323. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  324. drug, _ := service.GetDrugByID(drug_id)
  325. var struct3508 models.Struct3511
  326. struct3508.FixmedinsCode = miConfig.Code
  327. struct3508.OrgName = miConfig.OrgName
  328. struct3508.AccessKey = miConfig.AccessKey
  329. struct3508.Opter = curRoles.UserName
  330. struct3508.RequestUrl = miConfig.Url
  331. struct3508.Url = miConfig.Url
  332. struct3508.AppId = miConfig.Cainfo
  333. struct3508.AppSecret = miConfig.AppSecret
  334. struct3508.Enckey = miConfig.EncKey
  335. struct3508.SignKey = miConfig.SignKey
  336. struct3508.SecretKey = miConfig.SecretKey
  337. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  338. struct3508.Begndate = start_time
  339. struct3508.Enddate = end_time
  340. result1, result2, _ := service.FJyb3511(struct3508)
  341. saveLog(result1, result2, "3511", "3511")
  342. var res models.Result3511
  343. var respJSON2 map[string]interface{}
  344. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  347. return
  348. }
  349. userJSONBytes2, _ := json.Marshal(respJSON2)
  350. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  351. utils.ErrorLog("解析失败:%v", err)
  352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  353. return
  354. }
  355. if res.Infcode == -1 {
  356. c.ServeSuccessJSON(map[string]interface{}{
  357. "failed_code": -10,
  358. "msg": res.ErrMsg,
  359. })
  360. } else {
  361. c.ServeSuccessJSON(map[string]interface{}{
  362. "info": res.Output,
  363. })
  364. }
  365. }
  366. func (c *HisApiController) Get3512() {
  367. admin_user_id, _ := c.GetInt64("admin_user_id")
  368. drug_id, _ := c.GetInt64("id")
  369. start_time := c.GetString("start_time")
  370. end_time := c.GetString("end_time")
  371. adminUser := c.GetAdminUserInfo()
  372. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  373. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  374. drug, _ := service.GetDrugByID(drug_id)
  375. var struct3508 models.Struct3512
  376. struct3508.FixmedinsCode = miConfig.Code
  377. struct3508.OrgName = miConfig.OrgName
  378. struct3508.AccessKey = miConfig.AccessKey
  379. struct3508.Opter = curRoles.UserName
  380. struct3508.RequestUrl = miConfig.Url
  381. struct3508.Url = miConfig.Url
  382. struct3508.AppId = miConfig.Cainfo
  383. struct3508.AppSecret = miConfig.AppSecret
  384. struct3508.Enckey = miConfig.EncKey
  385. struct3508.SignKey = miConfig.SignKey
  386. struct3508.SecretKey = miConfig.SecretKey
  387. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  388. struct3508.Begndate = start_time
  389. struct3508.Enddate = end_time
  390. result1, result2, _ := service.FJyb3512(struct3508)
  391. saveLog(result1, result2, "3512", "3512")
  392. var res models.Result3512
  393. var respJSON2 map[string]interface{}
  394. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  397. return
  398. }
  399. userJSONBytes2, _ := json.Marshal(respJSON2)
  400. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  401. utils.ErrorLog("解析失败:%v", err)
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  403. return
  404. }
  405. if res.Infcode == -1 {
  406. c.ServeSuccessJSON(map[string]interface{}{
  407. "failed_code": -10,
  408. "msg": res.ErrMsg,
  409. })
  410. } else {
  411. c.ServeSuccessJSON(map[string]interface{}{
  412. "info": res.Output,
  413. })
  414. }
  415. }
  416. func (c *HisApiController) Get3513() {
  417. admin_user_id, _ := c.GetInt64("admin_user_id")
  418. drug_id, _ := c.GetInt64("id")
  419. start_time := c.GetString("start_time")
  420. end_time := c.GetString("end_time")
  421. adminUser := c.GetAdminUserInfo()
  422. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  423. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  424. drug, _ := service.GetDrugByID(drug_id)
  425. var struct3508 models.Struct3513
  426. struct3508.FixmedinsCode = miConfig.Code
  427. struct3508.OrgName = miConfig.OrgName
  428. struct3508.AccessKey = miConfig.AccessKey
  429. struct3508.Opter = curRoles.UserName
  430. struct3508.RequestUrl = miConfig.Url
  431. struct3508.Url = miConfig.Url
  432. struct3508.AppId = miConfig.Cainfo
  433. struct3508.AppSecret = miConfig.AppSecret
  434. struct3508.Enckey = miConfig.EncKey
  435. struct3508.SignKey = miConfig.SignKey
  436. struct3508.SecretKey = miConfig.SecretKey
  437. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  438. struct3508.Begndate = start_time
  439. struct3508.Enddate = end_time
  440. result1, result2, _ := service.FJyb3513(struct3508)
  441. saveLog(result1, result2, "3513", "3513")
  442. var res models.Result3513
  443. var respJSON2 map[string]interface{}
  444. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  447. return
  448. }
  449. userJSONBytes2, _ := json.Marshal(respJSON2)
  450. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  451. utils.ErrorLog("解析失败:%v", err)
  452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  453. return
  454. }
  455. if res.Infcode == -1 {
  456. c.ServeSuccessJSON(map[string]interface{}{
  457. "failed_code": -10,
  458. "msg": res.ErrMsg,
  459. })
  460. } else {
  461. c.ServeSuccessJSON(map[string]interface{}{
  462. "info": res.Output,
  463. })
  464. }
  465. }
  466. func (c *HisApiController) Get35081() {
  467. admin_user_id, _ := c.GetInt64("admin_user_id")
  468. drug_id, _ := c.GetInt64("id")
  469. //start_time := c.GetString("start_time")
  470. //end_time := c.GetString("end_time")
  471. page, _ := c.GetInt("page")
  472. adminUser := c.GetAdminUserInfo()
  473. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  474. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  475. drug, _ := service.GetDrugByID(drug_id)
  476. var struct3508 models.Struct35081
  477. struct3508.FixmedinsCode = miConfig.Code
  478. struct3508.OrgName = miConfig.OrgName
  479. struct3508.AccessKey = miConfig.AccessKey
  480. struct3508.Opter = curRoles.UserName
  481. struct3508.RequestUrl = miConfig.Url
  482. struct3508.Url = miConfig.Url
  483. struct3508.AppId = miConfig.Cainfo
  484. struct3508.AppSecret = miConfig.AppSecret
  485. struct3508.Enckey = miConfig.EncKey
  486. struct3508.SignKey = miConfig.SignKey
  487. struct3508.SecretKey = miConfig.SecretKey
  488. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  489. struct3508.PageNum = page
  490. struct3508.PageSize = 10
  491. result1, result2, _ := service.FJyb35081(struct3508)
  492. saveLog(result1, result2, "35081", "35081")
  493. var res models.Result35081
  494. var respJSON2 map[string]interface{}
  495. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  498. return
  499. }
  500. userJSONBytes2, _ := json.Marshal(respJSON2)
  501. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  502. utils.ErrorLog("解析失败:%v", err)
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  504. return
  505. }
  506. if res.Infcode == -1 {
  507. c.ServeSuccessJSON(map[string]interface{}{
  508. "failed_code": -10,
  509. "msg": res.ErrMsg,
  510. })
  511. } else {
  512. c.ServeSuccessJSON(map[string]interface{}{
  513. "info": res.Output,
  514. })
  515. }
  516. }
  517. func (c *HisApiController) Get35082() {
  518. admin_user_id, _ := c.GetInt64("admin_user_id")
  519. drug_id, _ := c.GetInt64("id")
  520. //start_time := c.GetString("start_time")
  521. //end_time := c.GetString("end_time")
  522. page, _ := c.GetInt("page")
  523. adminUser := c.GetAdminUserInfo()
  524. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  525. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  526. drug, _ := service.GetDrugByID(drug_id)
  527. var struct3508 models.Struct35082
  528. struct3508.FixmedinsCode = miConfig.Code
  529. struct3508.OrgName = miConfig.OrgName
  530. struct3508.AccessKey = miConfig.AccessKey
  531. struct3508.Opter = curRoles.UserName
  532. struct3508.RequestUrl = miConfig.Url
  533. struct3508.Url = miConfig.Url
  534. struct3508.AppId = miConfig.Cainfo
  535. struct3508.AppSecret = miConfig.AppSecret
  536. struct3508.Enckey = miConfig.EncKey
  537. struct3508.SignKey = miConfig.SignKey
  538. struct3508.SecretKey = miConfig.SecretKey
  539. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  540. struct3508.PageNum = page
  541. struct3508.PageSize = 10
  542. result1, result2, _ := service.FJyb35082(struct3508)
  543. saveLog(result1, result2, "35082", "35082")
  544. var res models.Result35082
  545. var respJSON2 map[string]interface{}
  546. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  549. return
  550. }
  551. userJSONBytes2, _ := json.Marshal(respJSON2)
  552. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  553. utils.ErrorLog("解析失败:%v", err)
  554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  555. return
  556. }
  557. if res.Infcode == -1 {
  558. c.ServeSuccessJSON(map[string]interface{}{
  559. "failed_code": -10,
  560. "msg": res.ErrMsg,
  561. })
  562. } else {
  563. c.ServeSuccessJSON(map[string]interface{}{
  564. "info": res.Output,
  565. })
  566. }
  567. }
  568. func (c *HisApiController) FJ3501AND3502() {
  569. ids := c.GetString("ids")
  570. admin_user_id, _ := c.GetInt64("admin_user_id")
  571. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  572. id_arr := strings.Split(ids, ",")
  573. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  574. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  575. //库盘
  576. var errs []string
  577. for _, drug := range drugs {
  578. if drug.IsPc == 0 && drug.IsBg == 0 {
  579. var res2 ResultSix
  580. var res3 ResultSix
  581. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  582. var struct3501 models.Struct3501
  583. struct3501.OrgName = miConfig.OrgName
  584. struct3501.AccessKey = miConfig.AccessKey
  585. struct3501.Opter = roles.UserName
  586. struct3501.RequestUrl = miConfig.Url
  587. struct3501.Url = miConfig.Url
  588. struct3501.AppId = miConfig.Cainfo
  589. struct3501.AppSecret = miConfig.AppSecret
  590. struct3501.Enckey = miConfig.EncKey
  591. struct3501.SignKey = miConfig.SignKey
  592. struct3501.SecretKey = miConfig.SecretKey
  593. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  594. struct3501.FixmedinsHilistId = miConfig.Code
  595. struct3501.FixmedinsHilistName = miConfig.OrgName
  596. struct3501.RxFlag = "0"
  597. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  598. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  599. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  600. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  601. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  602. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  603. struct3501.FixmedinsBchno = number
  604. memo := make(map[string]interface{})
  605. memo["pric"] = drug.Price
  606. bytesData, _ := json.Marshal(memo)
  607. struct3501.Memo = string(bytesData)
  608. result1, result2, _ := service.FJyb3501(struct3501)
  609. saveLog(result1, result2, "3501", "3501")
  610. //saveLog(result, requestLog, "2201", "挂号")
  611. var respJSON2 map[string]interface{}
  612. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  615. return
  616. }
  617. userJSONBytes2, _ := json.Marshal(respJSON2)
  618. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  619. utils.ErrorLog("解析失败:%v", err)
  620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  621. return
  622. }
  623. if res2.Infcode != -1 {
  624. drug.IsPc = 1
  625. drug.Bchno = number
  626. drug.PcDate = time.Now().Format("2006-01-02")
  627. err := service.SaveW(drug)
  628. if err == nil {
  629. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  630. var struct3502 models.Struct3502
  631. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  632. struct3502.FixmedinsHilistId = miConfig.Code
  633. struct3502.FixmedinsHilistName = miConfig.OrgName
  634. struct3502.FixmedinsCode = miConfig.Code
  635. struct3502.RxFlag = "0"
  636. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  637. struct3502.OrgName = miConfig.OrgName
  638. struct3502.Opter = roles.UserName
  639. struct3502.AccessKey = miConfig.AccessKey
  640. struct3502.RequestUrl = miConfig.Url
  641. struct3502.SecretKey = miConfig.SecretKey
  642. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  643. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  644. struct3502.Url = miConfig.Url
  645. struct3502.AppId = miConfig.Cainfo
  646. struct3502.AppSecret = miConfig.AppSecret
  647. struct3502.Enckey = miConfig.EncKey
  648. struct3502.SignKey = miConfig.SignKey
  649. struct3502.SecretKey = miConfig.SecretKey
  650. struct3502.Memo = ""
  651. struct3502.InvChgType = "108"
  652. struct3502.FixmedinsBchno = bg_number
  653. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  654. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  655. result11, result22, _ := service.FJyb3502(struct3502)
  656. saveLog(result11, result22, "3502", "3502")
  657. var respJSON3 map[string]interface{}
  658. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  661. return
  662. }
  663. userJSONBytes3, _ := json.Marshal(respJSON3)
  664. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  665. utils.ErrorLog("解析失败:%v", err)
  666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  667. return
  668. }
  669. if res3.Infcode == -1 {
  670. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  671. c.ServeSuccessJSON(map[string]interface{}{
  672. "failed_code": -10,
  673. "msg": res3.ErrMsg,
  674. })
  675. } else {
  676. drug.IsBg = 1
  677. drug.BgBchno = bg_number
  678. service.SaveW(drug)
  679. }
  680. }
  681. } else {
  682. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  683. }
  684. }
  685. //变更
  686. if drug.IsPc == 1 && drug.IsBg == 0 {
  687. var res3 ResultSix
  688. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  689. var struct3502 models.Struct3502
  690. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  691. struct3502.FixmedinsHilistId = miConfig.Code
  692. struct3502.FixmedinsHilistName = miConfig.OrgName
  693. struct3502.FixmedinsCode = miConfig.Code
  694. struct3502.Opter = roles.UserName
  695. struct3502.RxFlag = "0"
  696. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  697. struct3502.OrgName = miConfig.OrgName
  698. struct3502.AccessKey = miConfig.AccessKey
  699. struct3502.RequestUrl = miConfig.Url
  700. struct3502.SecretKey = miConfig.SecretKey
  701. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  702. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  703. struct3502.InvChgType = "108"
  704. struct3502.Url = miConfig.Url
  705. struct3502.AppId = miConfig.Cainfo
  706. struct3502.AppSecret = miConfig.AppSecret
  707. struct3502.Enckey = miConfig.EncKey
  708. struct3502.SignKey = miConfig.SignKey
  709. struct3502.SecretKey = miConfig.SecretKey
  710. struct3502.FixmedinsBchno = bg_number
  711. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  712. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  713. result1, result2, _ := service.FJyb3502(struct3502)
  714. saveLog(result1, result2, "3502", "3502")
  715. var respJSON3 map[string]interface{}
  716. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  719. return
  720. }
  721. userJSONBytes3, _ := json.Marshal(respJSON3)
  722. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  723. utils.ErrorLog("解析失败:%v", err)
  724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  725. return
  726. }
  727. if res3.Infcode == -1 {
  728. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  729. } else {
  730. drug.IsBg = 1
  731. drug.BgBchno = bg_number
  732. service.SaveW(drug)
  733. }
  734. }
  735. }
  736. if len(errs) == 0 {
  737. c.ServeSuccessJSON(map[string]interface{}{
  738. "msg": "盘存变更成功",
  739. })
  740. } else {
  741. c.ServeSuccessJSON(map[string]interface{}{
  742. "failed_code": -10,
  743. "msg": errs,
  744. })
  745. }
  746. }
  747. func (c *HisApiController) DeletePCandBG() {
  748. ids := c.GetString("ids")
  749. id_arr := strings.Split(ids, ",")
  750. admin_user_id, _ := c.GetInt64("admin_user_id")
  751. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  752. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  753. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  754. var err []string
  755. for _, item := range drugs {
  756. if item.IsPc == 1 && item.IsBg == 1 {
  757. var res FJ3507Result
  758. var res2 FJ3507Result
  759. var struct3507 models.Struct3507
  760. struct3507.FixmedinsBchno = item.Bchno
  761. struct3507.InvDataType = "1"
  762. struct3507.Opter = roles.UserName
  763. struct3507.OrgName = miConfig.OrgName
  764. struct3507.AccessKey = miConfig.AccessKey
  765. struct3507.RequestUrl = miConfig.Url
  766. struct3507.FixmedinsCode = miConfig.Code
  767. struct3507.SecretKey = miConfig.SecretKey
  768. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  769. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  770. struct3507.Url = miConfig.Url
  771. struct3507.AppId = miConfig.Cainfo
  772. struct3507.AppSecret = miConfig.AppSecret
  773. struct3507.Enckey = miConfig.EncKey
  774. struct3507.SignKey = miConfig.SignKey
  775. struct3507.SecretKey = miConfig.SecretKey
  776. result, result1, _ := service.FJyb3507(struct3507)
  777. saveLog(result, result1, "3507", "3507")
  778. var respJSON2 map[string]interface{}
  779. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  782. return
  783. }
  784. userJSONBytes2, _ := json.Marshal(respJSON2)
  785. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  786. utils.ErrorLog("解析失败:%v", err)
  787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  788. return
  789. }
  790. if res.Infcode != -1 {
  791. item.IsPc = 0
  792. err2 := service.SaveW(item)
  793. if err2 == nil {
  794. var struct3507_2 models.Struct3507
  795. struct3507_2.OrgName = miConfig.OrgName
  796. struct3507_2.AccessKey = miConfig.AccessKey
  797. struct3507_2.RequestUrl = miConfig.Url
  798. struct3507_2.Opter = roles.UserName
  799. struct3507_2.FixmedinsCode = miConfig.Code
  800. struct3507_2.SecretKey = miConfig.SecretKey
  801. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  802. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  803. struct3507_2.Url = miConfig.Url
  804. struct3507_2.AppId = miConfig.Cainfo
  805. struct3507_2.AppSecret = miConfig.AppSecret
  806. struct3507_2.Enckey = miConfig.EncKey
  807. struct3507_2.SignKey = miConfig.SignKey
  808. struct3507_2.SecretKey = miConfig.SecretKey
  809. struct3507_2.FixmedinsBchno = item.BgBchno
  810. struct3507_2.InvDataType = "2"
  811. result11, result22, _ := service.FJyb3507(struct3507_2)
  812. saveLog(result11, result22, "3507", "3507")
  813. var respJSON3 map[string]interface{}
  814. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  817. return
  818. }
  819. userJSONBytes3, _ := json.Marshal(respJSON3)
  820. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  821. utils.ErrorLog("解析失败:%v", err)
  822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  823. return
  824. }
  825. if res2.Infcode != -1 {
  826. item.IsBg = 0
  827. item.Bchno = ""
  828. item.BgBchno = ""
  829. item.PcDate = ""
  830. service.SaveW(item)
  831. } else {
  832. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  833. }
  834. }
  835. } else {
  836. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  837. }
  838. }
  839. if item.IsPc == 1 && item.IsBg == 0 {
  840. var res FJ3507Result
  841. var struct3507 models.Struct3507
  842. struct3507.FixmedinsBchno = item.Bchno
  843. struct3507.InvDataType = "1"
  844. struct3507.Opter = roles.UserName
  845. struct3507.FixmedinsCode = miConfig.Code
  846. struct3507.OrgName = miConfig.OrgName
  847. struct3507.AccessKey = miConfig.AccessKey
  848. struct3507.RequestUrl = miConfig.Url
  849. struct3507.SecretKey = miConfig.SecretKey
  850. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  851. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  852. struct3507.Url = miConfig.Url
  853. struct3507.AppId = miConfig.Cainfo
  854. struct3507.AppSecret = miConfig.AppSecret
  855. struct3507.Enckey = miConfig.EncKey
  856. struct3507.SignKey = miConfig.SignKey
  857. struct3507.SecretKey = miConfig.SecretKey
  858. result, result1, _ := service.FJyb3507(struct3507)
  859. saveLog(result, result1, "3507", "3507")
  860. var respJSON3 map[string]interface{}
  861. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  864. return
  865. }
  866. userJSONBytes3, _ := json.Marshal(respJSON3)
  867. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  868. utils.ErrorLog("解析失败:%v", err)
  869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  870. return
  871. }
  872. if res.Infcode != -1 {
  873. item.IsPc = 0
  874. item.Bchno = ""
  875. item.BgBchno = ""
  876. item.PcDate = ""
  877. service.SaveW(item)
  878. } else {
  879. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  880. }
  881. }
  882. if item.IsPc == 0 && item.IsBg == 1 {
  883. var res FJ3507Result
  884. var struct3507 models.Struct3507
  885. struct3507.FixmedinsBchno = item.BgBchno
  886. struct3507.InvDataType = "2"
  887. struct3507.Opter = roles.UserName
  888. struct3507.FixmedinsCode = miConfig.Code
  889. struct3507.OrgName = miConfig.OrgName
  890. struct3507.AccessKey = miConfig.AccessKey
  891. struct3507.RequestUrl = miConfig.Url
  892. struct3507.SecretKey = miConfig.SecretKey
  893. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  894. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  895. struct3507.Url = miConfig.Url
  896. struct3507.AppId = miConfig.Cainfo
  897. struct3507.AppSecret = miConfig.AppSecret
  898. struct3507.Enckey = miConfig.EncKey
  899. struct3507.SignKey = miConfig.SignKey
  900. struct3507.SecretKey = miConfig.SecretKey
  901. result, result1, _ := service.FJyb3507(struct3507)
  902. saveLog(result, result1, "3507", "3507")
  903. var respJSON3 map[string]interface{}
  904. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  907. return
  908. }
  909. userJSONBytes3, _ := json.Marshal(respJSON3)
  910. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  911. utils.ErrorLog("解析失败:%v", err)
  912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  913. return
  914. }
  915. if res.Infcode != -1 {
  916. item.IsBg = 0
  917. item.Bchno = ""
  918. item.BgBchno = ""
  919. item.PcDate = ""
  920. service.SaveW(item)
  921. } else {
  922. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  923. }
  924. }
  925. }
  926. if len(err) == 0 {
  927. c.ServeSuccessJSON(map[string]interface{}{
  928. "msg": "删除盘存变更成功",
  929. })
  930. } else {
  931. c.ServeSuccessJSON(map[string]interface{}{
  932. "failed_code": -10,
  933. "msg": err,
  934. })
  935. }
  936. }
  937. func (c *HisApiController) DeleteXSandBG() {
  938. ids := c.GetString("ids")
  939. id_arr := strings.Split(ids, ",")
  940. admin_user_id, _ := c.GetInt64("admin_user_id")
  941. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  942. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  943. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  944. var err []string
  945. for _, item := range flows {
  946. if item.IsSale == 1 && item.IsChange == 1 {
  947. var res FJ3507Result
  948. var res2 FJ3507Result
  949. var struct3507 models.Struct3507
  950. struct3507.FixmedinsBchno = item.Bchno
  951. struct3507.InvDataType = "4"
  952. struct3507.Opter = roles.UserName
  953. struct3507.OrgName = miConfig.OrgName
  954. struct3507.AccessKey = miConfig.AccessKey
  955. struct3507.RequestUrl = miConfig.Url
  956. struct3507.FixmedinsCode = miConfig.Code
  957. struct3507.SecretKey = miConfig.SecretKey
  958. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  959. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  960. struct3507.Url = miConfig.Url
  961. struct3507.AppId = miConfig.Cainfo
  962. struct3507.AppSecret = miConfig.AppSecret
  963. struct3507.Enckey = miConfig.EncKey
  964. struct3507.SignKey = miConfig.SignKey
  965. struct3507.SecretKey = miConfig.SecretKey
  966. result, result1, _ := service.FJyb3507(struct3507)
  967. saveLog(result, result1, "3507", "3507")
  968. var respJSON2 map[string]interface{}
  969. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  972. return
  973. }
  974. userJSONBytes2, _ := json.Marshal(respJSON2)
  975. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  976. utils.ErrorLog("解析失败:%v", err)
  977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. return
  979. }
  980. if res.Infcode != -1 {
  981. item.IsSale = 0
  982. item.SaleDate = ""
  983. item.Bchno = ""
  984. err2 := service.SaveDF(item)
  985. if err2 == nil {
  986. var struct3507_2 models.Struct3507
  987. struct3507_2.OrgName = miConfig.OrgName
  988. struct3507_2.AccessKey = miConfig.AccessKey
  989. struct3507_2.RequestUrl = miConfig.Url
  990. struct3507_2.Opter = roles.UserName
  991. struct3507_2.FixmedinsCode = miConfig.Code
  992. struct3507_2.SecretKey = miConfig.SecretKey
  993. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  994. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  995. struct3507_2.Url = miConfig.Url
  996. struct3507_2.AppId = miConfig.Cainfo
  997. struct3507_2.AppSecret = miConfig.AppSecret
  998. struct3507_2.Enckey = miConfig.EncKey
  999. struct3507_2.SignKey = miConfig.SignKey
  1000. struct3507_2.SecretKey = miConfig.SecretKey
  1001. struct3507_2.FixmedinsBchno = item.BgBchno
  1002. struct3507_2.InvDataType = "2"
  1003. result11, result22, _ := service.FJyb3507(struct3507_2)
  1004. saveLog(result11, result22, "3507", "3507")
  1005. var respJSON3 map[string]interface{}
  1006. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1009. return
  1010. }
  1011. userJSONBytes3, _ := json.Marshal(respJSON3)
  1012. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1013. utils.ErrorLog("解析失败:%v", err)
  1014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1015. return
  1016. }
  1017. if res2.Infcode != -1 {
  1018. item.IsChange = 0
  1019. item.BgBchno = ""
  1020. service.SaveDF2(item)
  1021. } else {
  1022. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1023. }
  1024. }
  1025. } else {
  1026. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1027. }
  1028. }
  1029. if item.IsSale == 2 && item.IsChange == 1 {
  1030. var res FJ3507Result
  1031. var res2 FJ3507Result
  1032. var struct3507 models.Struct3507
  1033. struct3507.FixmedinsBchno = item.Bchno
  1034. struct3507.InvDataType = "4"
  1035. struct3507.Opter = roles.UserName
  1036. struct3507.OrgName = miConfig.OrgName
  1037. struct3507.AccessKey = miConfig.AccessKey
  1038. struct3507.RequestUrl = miConfig.Url
  1039. struct3507.FixmedinsCode = miConfig.Code
  1040. struct3507.SecretKey = miConfig.SecretKey
  1041. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1042. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1043. struct3507.Url = miConfig.Url
  1044. struct3507.AppId = miConfig.Cainfo
  1045. struct3507.AppSecret = miConfig.AppSecret
  1046. struct3507.Enckey = miConfig.EncKey
  1047. struct3507.SignKey = miConfig.SignKey
  1048. struct3507.SecretKey = miConfig.SecretKey
  1049. result, result1, _ := service.FJyb3507(struct3507)
  1050. saveLog(result, result1, "3507", "3507")
  1051. var respJSON2 map[string]interface{}
  1052. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1055. return
  1056. }
  1057. userJSONBytes2, _ := json.Marshal(respJSON2)
  1058. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1059. utils.ErrorLog("解析失败:%v", err)
  1060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1061. return
  1062. }
  1063. if res.Infcode != -1 {
  1064. item.IsSale = 0
  1065. item.SaleDate = ""
  1066. item.Bchno = ""
  1067. err2 := service.SaveDF(item)
  1068. if err2 == nil {
  1069. var struct3507_2 models.Struct3507
  1070. struct3507_2.OrgName = miConfig.OrgName
  1071. struct3507_2.AccessKey = miConfig.AccessKey
  1072. struct3507_2.RequestUrl = miConfig.Url
  1073. struct3507_2.Opter = roles.UserName
  1074. struct3507_2.FixmedinsCode = miConfig.Code
  1075. struct3507_2.SecretKey = miConfig.SecretKey
  1076. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1077. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1078. struct3507_2.Url = miConfig.Url
  1079. struct3507_2.AppId = miConfig.Cainfo
  1080. struct3507_2.AppSecret = miConfig.AppSecret
  1081. struct3507_2.Enckey = miConfig.EncKey
  1082. struct3507_2.SignKey = miConfig.SignKey
  1083. struct3507_2.SecretKey = miConfig.SecretKey
  1084. struct3507_2.FixmedinsBchno = item.BgBchno
  1085. struct3507_2.InvDataType = "2"
  1086. result11, result22, _ := service.FJyb3507(struct3507_2)
  1087. saveLog(result11, result22, "3507", "3507")
  1088. var respJSON3 map[string]interface{}
  1089. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. userJSONBytes3, _ := json.Marshal(respJSON3)
  1095. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1096. utils.ErrorLog("解析失败:%v", err)
  1097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1098. return
  1099. }
  1100. if res2.Infcode != -1 {
  1101. item.IsChange = 0
  1102. item.BgBchno = ""
  1103. service.SaveDF2(item)
  1104. } else {
  1105. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1106. }
  1107. }
  1108. } else {
  1109. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1110. }
  1111. }
  1112. if item.IsSale == 1 && item.IsChange == 0 {
  1113. var res FJ3507Result
  1114. var struct3507 models.Struct3507
  1115. struct3507.FixmedinsBchno = item.Bchno
  1116. struct3507.InvDataType = "4"
  1117. struct3507.Opter = roles.UserName
  1118. struct3507.FixmedinsCode = miConfig.Code
  1119. struct3507.OrgName = miConfig.OrgName
  1120. struct3507.AccessKey = miConfig.AccessKey
  1121. struct3507.RequestUrl = miConfig.Url
  1122. struct3507.SecretKey = miConfig.SecretKey
  1123. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1124. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1125. struct3507.Url = miConfig.Url
  1126. struct3507.AppId = miConfig.Cainfo
  1127. struct3507.AppSecret = miConfig.AppSecret
  1128. struct3507.Enckey = miConfig.EncKey
  1129. struct3507.SignKey = miConfig.SignKey
  1130. struct3507.SecretKey = miConfig.SecretKey
  1131. result, result1, _ := service.FJyb3507(struct3507)
  1132. saveLog(result, result1, "3507", "3507")
  1133. var respJSON3 map[string]interface{}
  1134. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1137. return
  1138. }
  1139. userJSONBytes3, _ := json.Marshal(respJSON3)
  1140. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1141. utils.ErrorLog("解析失败:%v", err)
  1142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1143. return
  1144. }
  1145. if res.Infcode != -1 {
  1146. item.IsSale = 0
  1147. item.SaleDate = ""
  1148. service.SaveDF(item)
  1149. } else {
  1150. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1151. }
  1152. }
  1153. if item.IsSale == 2 && item.IsChange == 0 {
  1154. var res FJ3507Result
  1155. var struct3507 models.Struct3507
  1156. struct3507.FixmedinsBchno = item.Bchno
  1157. struct3507.InvDataType = "4"
  1158. struct3507.Opter = roles.UserName
  1159. struct3507.FixmedinsCode = miConfig.Code
  1160. struct3507.OrgName = miConfig.OrgName
  1161. struct3507.AccessKey = miConfig.AccessKey
  1162. struct3507.RequestUrl = miConfig.Url
  1163. struct3507.SecretKey = miConfig.SecretKey
  1164. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1165. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1166. struct3507.Url = miConfig.Url
  1167. struct3507.AppId = miConfig.Cainfo
  1168. struct3507.AppSecret = miConfig.AppSecret
  1169. struct3507.Enckey = miConfig.EncKey
  1170. struct3507.SignKey = miConfig.SignKey
  1171. struct3507.SecretKey = miConfig.SecretKey
  1172. result, result1, _ := service.FJyb3507(struct3507)
  1173. saveLog(result, result1, "3507", "3507")
  1174. var respJSON3 map[string]interface{}
  1175. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1178. return
  1179. }
  1180. userJSONBytes3, _ := json.Marshal(respJSON3)
  1181. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1182. utils.ErrorLog("解析失败:%v", err)
  1183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1184. return
  1185. }
  1186. if res.Infcode != -1 {
  1187. item.IsSale = 0
  1188. item.SaleDate = ""
  1189. item.Bchno = ""
  1190. service.SaveDF(item)
  1191. } else {
  1192. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1193. }
  1194. }
  1195. if item.IsSale == 0 && item.IsChange == 1 {
  1196. var res FJ3507Result
  1197. var struct3507 models.Struct3507
  1198. struct3507.FixmedinsBchno = item.BgBchno
  1199. struct3507.InvDataType = "2"
  1200. struct3507.Opter = roles.UserName
  1201. struct3507.FixmedinsCode = miConfig.Code
  1202. struct3507.OrgName = miConfig.OrgName
  1203. struct3507.AccessKey = miConfig.AccessKey
  1204. struct3507.RequestUrl = miConfig.Url
  1205. struct3507.SecretKey = miConfig.SecretKey
  1206. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1207. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1208. struct3507.Url = miConfig.Url
  1209. struct3507.AppId = miConfig.Cainfo
  1210. struct3507.AppSecret = miConfig.AppSecret
  1211. struct3507.Enckey = miConfig.EncKey
  1212. struct3507.SignKey = miConfig.SignKey
  1213. struct3507.SecretKey = miConfig.SecretKey
  1214. result, result1, _ := service.FJyb3507(struct3507)
  1215. saveLog(result, result1, "3507", "3507")
  1216. var respJSON3 map[string]interface{}
  1217. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1220. return
  1221. }
  1222. userJSONBytes3, _ := json.Marshal(respJSON3)
  1223. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1224. utils.ErrorLog("解析失败:%v", err)
  1225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1226. return
  1227. }
  1228. if res.Infcode != -1 {
  1229. item.IsChange = 0
  1230. item.BgBchno = ""
  1231. service.SaveDF2(item)
  1232. } else {
  1233. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1234. }
  1235. }
  1236. }
  1237. if len(err) == 0 {
  1238. c.ServeSuccessJSON(map[string]interface{}{
  1239. "msg": "删除销售变更成功",
  1240. })
  1241. } else {
  1242. c.ServeSuccessJSON(map[string]interface{}{
  1243. "failed_code": -10,
  1244. "msg": err,
  1245. })
  1246. }
  1247. }
  1248. func (c *HisApiController) ChangeDrug() {
  1249. ids := c.GetString("ids")
  1250. id_arr := strings.Split(ids, ",")
  1251. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  1252. admin_user_id, _ := c.GetInt64("admin_user_id")
  1253. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1254. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1255. var err []string
  1256. for _, item := range flows {
  1257. var res3 ResultSix
  1258. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  1259. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  1260. if prescription.OrderStatus == 2 {
  1261. //已经结算
  1262. //判断是否已经销售
  1263. if item.IsSale == 1 { //是否已经销售,1是 0否
  1264. //是否已经变更 1是 0否
  1265. if item.IsChange == 0 { //没变更,进行变更操作
  1266. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  1267. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
  1268. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  1269. var respJSON3 map[string]interface{}
  1270. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1273. return
  1274. }
  1275. userJSONBytes3, _ := json.Marshal(respJSON3)
  1276. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1277. utils.ErrorLog("解析失败:%v", err)
  1278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1279. return
  1280. }
  1281. if res3.Infcode != -1 {
  1282. item.IsChange = 1
  1283. item.BgBchno = bg_number
  1284. service.SaveDF2(item)
  1285. } else {
  1286. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1287. }
  1288. }
  1289. } else { //没销售,
  1290. var res FJ3507Result
  1291. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  1292. //进行商品销售接口
  1293. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  1294. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  1295. var respJSON3 map[string]interface{}
  1296. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  1297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1299. return
  1300. }
  1301. userJSONBytes3, _ := json.Marshal(respJSON3)
  1302. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1303. utils.ErrorLog("解析失败:%v", err)
  1304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1305. return
  1306. }
  1307. if res.Infcode != -1 {
  1308. item.IsSale = 1
  1309. item.Bchno = number
  1310. item.SaleDate = time.Now().Format("2006-01-02")
  1311. err5 := service.SaveDF(item)
  1312. if err5 == nil {
  1313. if item.IsChange == 0 { //没变更,进行变更操作
  1314. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  1315. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
  1316. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  1317. var respJSON3 map[string]interface{}
  1318. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1321. return
  1322. }
  1323. userJSONBytes3, _ := json.Marshal(respJSON3)
  1324. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1325. utils.ErrorLog("解析失败:%v", err)
  1326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1327. return
  1328. }
  1329. if res3.Infcode != -1 {
  1330. item.IsChange = 1
  1331. item.BgBchno = bg_number
  1332. service.SaveDF2(item)
  1333. } else {
  1334. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1335. }
  1336. }
  1337. }
  1338. } else {
  1339. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  1340. }
  1341. }
  1342. } else { //还没结算
  1343. if item.IsChange == 0 { //没变更,进行变更操作
  1344. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  1345. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
  1346. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  1347. var respJSON3 map[string]interface{}
  1348. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1351. return
  1352. }
  1353. userJSONBytes3, _ := json.Marshal(respJSON3)
  1354. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1355. utils.ErrorLog("解析失败:%v", err)
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1357. return
  1358. }
  1359. if res3.Infcode != -1 {
  1360. item.IsChange = 1
  1361. item.BgBchno = bg_number
  1362. service.SaveDF2(item)
  1363. } else {
  1364. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1365. }
  1366. }
  1367. }
  1368. } else if item.ConsumableType == 7 {
  1369. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  1370. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  1371. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  1372. //判断是否已经销售
  1373. if item.IsSale == 2 { //是否已经销售,1是 0否
  1374. //是否已经变更 1是 0否
  1375. if item.IsChange == 0 { //没变更,进行变更操作
  1376. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  1377. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
  1378. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  1379. var respJSON3 map[string]interface{}
  1380. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1383. return
  1384. }
  1385. userJSONBytes3, _ := json.Marshal(respJSON3)
  1386. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1387. utils.ErrorLog("解析失败:%v", err)
  1388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1389. return
  1390. }
  1391. if res3.Infcode != -1 {
  1392. item.IsChange = 1
  1393. item.BgBchno = bg_number
  1394. service.SaveDF2(item)
  1395. } else {
  1396. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1397. }
  1398. }
  1399. } else { //没销售,
  1400. //进行商品销售退货接口
  1401. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  1402. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  1403. saveLog(result111, result222, "3506", "销售退货")
  1404. var res7 FJ3507Result
  1405. //进行商品销售接口
  1406. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  1407. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  1408. var respJSON3 map[string]interface{}
  1409. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  1410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. return
  1413. }
  1414. userJSONBytes3, _ := json.Marshal(respJSON3)
  1415. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  1416. utils.ErrorLog("解析失败:%v", err)
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1418. return
  1419. }
  1420. if res7.Infcode != -1 {
  1421. item.IsSale = 2
  1422. item.SaleDate = item.SaleDate
  1423. item.Bchno = number
  1424. service.SaveDF(item)
  1425. if item.IsChange == 0 { //没变更,进行变更操作
  1426. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  1427. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
  1428. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  1429. var respJSON3 map[string]interface{}
  1430. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1433. return
  1434. }
  1435. userJSONBytes3, _ := json.Marshal(respJSON3)
  1436. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1437. utils.ErrorLog("解析失败:%v", err)
  1438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1439. return
  1440. }
  1441. if res3.Infcode != -1 {
  1442. item.IsChange = 1
  1443. item.BgBchno = bg_number
  1444. service.SaveDF2(item)
  1445. } else {
  1446. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1447. }
  1448. }
  1449. } else {
  1450. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  1451. }
  1452. }
  1453. } else { //还没结算
  1454. if item.IsChange == 0 { //没变更,进行变更操作
  1455. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  1456. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
  1457. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  1458. var respJSON3 map[string]interface{}
  1459. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1462. return
  1463. }
  1464. userJSONBytes3, _ := json.Marshal(respJSON3)
  1465. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1466. utils.ErrorLog("解析失败:%v", err)
  1467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1468. return
  1469. }
  1470. if res3.Infcode != -1 {
  1471. item.IsChange = 1
  1472. item.BgBchno = bg_number
  1473. service.SaveDF2(item)
  1474. } else {
  1475. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1476. }
  1477. }
  1478. }
  1479. }
  1480. }
  1481. if len(err) == 0 {
  1482. c.ServeSuccessJSON(map[string]interface{}{
  1483. "msg": "销售变更成功",
  1484. })
  1485. } else {
  1486. c.ServeSuccessJSON(map[string]interface{}{
  1487. "failed_code": -10,
  1488. "msg": err,
  1489. })
  1490. }
  1491. }
  1492. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  1493. var struct3502 models.Struct3502
  1494. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1495. struct3502.FixmedinsHilistId = miConfig.Code
  1496. struct3502.FixmedinsHilistName = miConfig.OrgName
  1497. struct3502.FixmedinsCode = miConfig.Code
  1498. struct3502.Opter = role.UserName
  1499. struct3502.RxFlag = "0"
  1500. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1501. struct3502.OrgName = miConfig.OrgName
  1502. struct3502.AccessKey = miConfig.AccessKey
  1503. struct3502.RequestUrl = miConfig.Url
  1504. struct3502.SecretKey = miConfig.SecretKey
  1505. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1506. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1507. struct3502.Url = miConfig.Url
  1508. struct3502.AppId = miConfig.Cainfo
  1509. struct3502.AppSecret = miConfig.AppSecret
  1510. struct3502.Enckey = miConfig.EncKey
  1511. struct3502.SignKey = miConfig.SignKey
  1512. struct3502.SecretKey = miConfig.SecretKey
  1513. struct3502.InvChgType = chgType
  1514. struct3502.FixmedinsBchno = number
  1515. struct3502.Cnt = strconv.FormatInt(count, 10)
  1516. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  1517. result1, result2, _ := service.FJyb3502(struct3502)
  1518. return result1, result2
  1519. }
  1520. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  1521. var struct3505 models.Struct3505
  1522. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1523. struct3505.FixmedinsHilistId = miConfig.Code
  1524. struct3505.FixmedinsHilistName = miConfig.OrgName
  1525. struct3505.FixmedinsBchno = number
  1526. struct3505.Opter = role.UserName
  1527. struct3505.FixmedinsCode = miConfig.Code
  1528. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  1529. struct3505.PrscDrName = roles.UserName
  1530. struct3505.PharName = "刘水山"
  1531. struct3505.PharPracCertNo = "2015026350260000002611351127"
  1532. order := service.GetHisOrderByNumber(pre.BatchNumber)
  1533. struct3505.SetlId = order.SetlId
  1534. struct3505.MdtrtSn = order.MdtrtId
  1535. struct3505.ManuLotnum = drug.Number
  1536. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1537. struct3505.ExpyEnd = ""
  1538. struct3505.RxFlag = "0"
  1539. struct3505.TrdnFlag = "1"
  1540. struct3505.RtalDocno = order.Number
  1541. struct3505.Url = miConfig.Url
  1542. struct3505.AppId = miConfig.Cainfo
  1543. struct3505.AppSecret = miConfig.AppSecret
  1544. struct3505.Enckey = miConfig.EncKey
  1545. struct3505.SignKey = miConfig.SignKey
  1546. struct3505.SecretKey = miConfig.SecretKey
  1547. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  1548. struct3505.SelRetnCnt = strValue
  1549. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1550. struct3505.SelRetnOpterName = role.UserName
  1551. if order.IsMedicineInsurance == 1 {
  1552. struct3505.MdtrtSetlType = "1"
  1553. } else {
  1554. struct3505.MdtrtSetlType = "2"
  1555. }
  1556. struct3505.OrgName = miConfig.OrgName
  1557. struct3505.AccessKey = miConfig.AccessKey
  1558. struct3505.RequestUrl = miConfig.Url
  1559. struct3505.SecretKey = miConfig.SecretKey
  1560. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1561. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1562. result1, result2, _ := service.FJyb3505(struct3505)
  1563. return result1, result2
  1564. }
  1565. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  1566. var struct3506 models.Struct3506
  1567. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1568. struct3506.FixmedinsHilistId = miConfig.Code
  1569. struct3506.FixmedinsHilistName = miConfig.OrgName
  1570. struct3506.FixmedinsCode = miConfig.Code
  1571. struct3506.FixmedinsBchno = number
  1572. struct3506.Opter = role.UserName
  1573. order := service.GetHisOrderByNumber(pre.BatchNumber)
  1574. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  1575. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1576. struct3506.MdtrtSn = order.MdtrtId
  1577. struct3506.ExpyEnd = ""
  1578. struct3506.RxFlag = "0"
  1579. struct3506.TrdnFlag = "1"
  1580. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  1581. struct3506.SelRetnCnt = strValue
  1582. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1583. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  1584. struct3506.SelRetnOpterName = role.UserName
  1585. struct3506.OrgName = miConfig.OrgName
  1586. struct3506.AccessKey = miConfig.AccessKey
  1587. struct3506.RequestUrl = miConfig.Url
  1588. struct3506.SecretKey = miConfig.SecretKey
  1589. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1590. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1591. struct3506.Url = miConfig.Url
  1592. struct3506.AppId = miConfig.Cainfo
  1593. struct3506.AppSecret = miConfig.AppSecret
  1594. struct3506.Enckey = miConfig.EncKey
  1595. struct3506.SignKey = miConfig.SignKey
  1596. struct3506.SecretKey = miConfig.SecretKey
  1597. result1, result2, _ := service.FJyb3506(struct3506)
  1598. return result1, result2
  1599. }
  1600. func (c *HisApiController) Get1318() {
  1601. adminUser := c.GetAdminUserInfo()
  1602. admin_user_id, _ := c.GetInt64("admin_user_id")
  1603. code := c.GetString("code")
  1604. code = ""
  1605. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1606. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1607. api := ""
  1608. if miConfig.MdtrtareaAdmvs == "320921" {
  1609. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1610. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  1611. } else {
  1612. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1613. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  1614. }
  1615. resp, requestErr := http.Get(api)
  1616. if requestErr != nil {
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1618. return
  1619. }
  1620. body, ioErr := ioutil.ReadAll(resp.Body)
  1621. if ioErr != nil {
  1622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1624. return
  1625. }
  1626. var respJSON map[string]interface{}
  1627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. return
  1631. }
  1632. //var res Result2406
  1633. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1634. result, _ := json.Marshal(respJSON)
  1635. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1636. utils.ErrorLog("解析失败:%v", err)
  1637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1638. return
  1639. }
  1640. if res.Infcode == "0" {
  1641. c.ServeSuccessJSON(map[string]interface{}{
  1642. "result": "",
  1643. })
  1644. } else {
  1645. c.ServeSuccessJSON(map[string]interface{}{
  1646. "failed_code": -10,
  1647. "msg": res.ErrMsg,
  1648. })
  1649. */return
  1650. //}
  1651. }
  1652. func (c *HisApiController) Get2503() {
  1653. adminUser := c.GetAdminUserInfo()
  1654. admin_user_id, _ := c.GetInt64("admin_user_id")
  1655. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1656. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1657. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  1658. }
  1659. func (c *HisApiController) Get2406() {
  1660. id, _ := c.GetInt64("id")
  1661. record_time := c.GetString("record_time")
  1662. his_patient_id, _ := c.GetInt64("his_patient_id")
  1663. admin_user_id, _ := c.GetInt64("admin_user_id")
  1664. diagnosis_id := c.GetString("diagnosis")
  1665. timeLayout := "2006-01-02"
  1666. loc, _ := time.LoadLocation("Local")
  1667. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1668. if err != nil {
  1669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1670. return
  1671. }
  1672. recordDateTime := theTime.Unix()
  1673. adminUser := c.GetAdminUserInfo()
  1674. diagnosis_ids := strings.Split(diagnosis_id, ",")
  1675. var config []*models.HisXtDiagnoseConfig
  1676. for _, item := range diagnosis_ids {
  1677. id, _ := strconv.ParseInt(item, 10, 64)
  1678. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1679. config = append(config, &diagnosisConfig)
  1680. }
  1681. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1682. fmt.Println(his_patient_id)
  1683. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1684. //timestamp := time.Now().Unix()
  1685. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1686. var patientPrescription models.HisPrescriptionInfo
  1687. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1688. if patientPrescription.ID == 0 {
  1689. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1690. }
  1691. var res2 Result2406
  1692. if miConfig.MdtrtareaAdmvs == "341203" {
  1693. data := make(map[string]interface{})
  1694. client := &http.Client{}
  1695. data["psn_no"] = his.PsnNo
  1696. data["mdtrt_id"] = his.Number
  1697. data["operator"] = roles.UserName
  1698. data["cert_no"] = his.IdCardNo
  1699. data["org_name"] = miConfig.OrgName
  1700. data["psn_name"] = his.Name
  1701. data["ipt_otp_no"] = his.IptOtpNo
  1702. data["ipt_psn_sp_flag_type"] = "0901"
  1703. data["ipt_psn_sp_flag"] = "1"
  1704. data["fixmedins_code"] = miConfig.Code
  1705. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  1706. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1707. data["url"] = miConfig.Url
  1708. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  1709. bytesData, _ := json.Marshal(data)
  1710. var req *http.Request
  1711. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  1712. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  1713. resp, _ := client.Do(req)
  1714. defer resp.Body.Close()
  1715. body, ioErr := ioutil.ReadAll(resp.Body)
  1716. if ioErr != nil {
  1717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1719. return
  1720. }
  1721. var respJSON map[string]interface{}
  1722. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1725. return
  1726. }
  1727. status := respJSON["data"].(map[string]interface{})["status"].(string)
  1728. if status == "0" {
  1729. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  1730. c.ServeSuccessJSON(map[string]interface{}{
  1731. "failed_code": -10,
  1732. "msg": err_msg,
  1733. })
  1734. return
  1735. }
  1736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1737. userJSONBytes, _ := json.Marshal(respJSON)
  1738. fmt.Println("log")
  1739. fmt.Println(string(userJSONBytes))
  1740. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1741. utils.ErrorLog("解析失败:%v", err)
  1742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1743. return
  1744. }
  1745. }
  1746. if res2.Infcode != 0 {
  1747. adminUser := c.GetAdminUserInfo()
  1748. errlog := &models.HisOrderError{
  1749. UserOrgId: adminUser.CurrentOrgId,
  1750. Ctime: time.Now().Unix(),
  1751. Mtime: time.Now().Unix(),
  1752. ErrMsg: res2.ErrMsg,
  1753. Status: 1,
  1754. PatientId: id,
  1755. RecordTime: recordDateTime,
  1756. Stage: 3,
  1757. }
  1758. service.CreateErrMsgLog(errlog)
  1759. c.ServeSuccessJSON(map[string]interface{}{
  1760. "failed_code": -10,
  1761. "msg": res2.ErrMsg,
  1762. })
  1763. return
  1764. } else {
  1765. c.ServeSuccessJSON(map[string]interface{}{
  1766. "msg": "上传成功",
  1767. })
  1768. return
  1769. }
  1770. }
  1771. func (c *HisApiController) Get4105() {
  1772. }
  1773. func (c *HisApiController) Post5302() {
  1774. patient_id, _ := c.GetInt64("id")
  1775. admin_user_id, _ := c.GetInt64("admin_user_id")
  1776. p, _ := service.GetHisPatientById(patient_id)
  1777. adminUser := c.GetAdminUserInfo()
  1778. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1779. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1780. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  1781. }
  1782. func (c *HisApiController) Get4104() {
  1783. }
  1784. type Output struct {
  1785. CertNo string `json:"certno"`
  1786. PsnName string `json:"psn_name"`
  1787. CardNo string `json:"card_no"`
  1788. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1789. CardSN string `json:"card_sn"`
  1790. PsnCertType string `json:"psn_cert_type"`
  1791. MdtrtCertNo string `json:"mdtrt_cert_no"`
  1792. MdtrtCertType string `json:"mdtrt_cert_type"`
  1793. QRCode string `json:"qrCode"`
  1794. EcToken string `json:"ecToken"`
  1795. }
  1796. type AHResponse struct {
  1797. Body AHBody `json:"body"`
  1798. Code int `json:"code"`
  1799. CSBCode int `json:"csbCode"`
  1800. Message string `json:"message"`
  1801. RequestID string `json:"requestId"`
  1802. State struct{} `json:"state"`
  1803. }
  1804. type AHBody struct {
  1805. ErrMsg string `json:"err_msg"`
  1806. InfRefMsgID string `json:"inf_refmsgid"`
  1807. InfCode int `json:"infcode"`
  1808. Output struct {
  1809. Result []struct {
  1810. BasMednFlag string `json:"bas_medn_flag"`
  1811. ChldMedcFlag string `json:"chld_medc_flag"`
  1812. ChrgitmLv string `json:"chrgitm_lv"`
  1813. Cnt float64 `json:"cnt"`
  1814. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1815. DrtReimFlag string `json:"drt_reim_flag"`
  1816. FeedetlSn string `json:"feedetl_sn"`
  1817. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1818. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1819. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1820. ListSpItemFlag string `json:"list_sp_item_flag"`
  1821. LmtUsedFlag string `json:"lmt_used_flag"`
  1822. MedChrgitmType string `json:"med_chrgitm_type"`
  1823. Memo string `json:"memo"`
  1824. OverlmtAmt float64 `json:"overlmt_amt"`
  1825. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1826. Pric float64 `json:"pric"`
  1827. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1828. SelfpayProp float64 `json:"selfpay_prop"`
  1829. } `json:"result"`
  1830. } `json:"output"`
  1831. }
  1832. type Response struct {
  1833. Output Output `json:"output"`
  1834. Infcode int `json:"infcode"`
  1835. InfRefMsgID string `json:"inf_refmsgid"`
  1836. RefMsgTime string `json:"refmsg_time"`
  1837. RespondTime string `json:"respond_time"`
  1838. ErrMsg string `json:"err_msg"`
  1839. WarnMsg string `json:"warn_msg"`
  1840. SignType string `json:"signtype"`
  1841. CAInfo string `json:"cainfo"`
  1842. }
  1843. func (c *HisApiController) Getquerydata() {
  1844. query_type, _ := c.GetInt64("type")
  1845. refd_setl_flag := c.GetString("refd_setl_flag")
  1846. med_type := c.GetString("med_type")
  1847. //admin_user_id,_ := c.GetInt64("admin_user_id")
  1848. cert_no := c.GetString("cert_no")
  1849. psn_no := c.GetString("psn_no")
  1850. start_time := c.GetString("start_time")
  1851. end_time := c.GetString("end_time")
  1852. page, _ := c.GetInt64("page")
  1853. limit, _ := c.GetInt64("limit")
  1854. var bp models.BusinessParams5262
  1855. bp.RefdSetlFlag = refd_setl_flag
  1856. bp.MedType = med_type
  1857. bp.Certno = cert_no
  1858. bp.Psnno = psn_no
  1859. bp.QBegntime = start_time
  1860. bp.QEndtime = end_time
  1861. if query_type == 1 { //本地
  1862. Post5262(c, bp, page, limit)
  1863. } else { //异地
  1864. Post5267(c, bp, page, limit)
  1865. }
  1866. }
  1867. func (c *HisApiController) Drugscheck() {
  1868. admin_user_id, _ := c.GetInt64("admin_user_id")
  1869. adminUser := c.GetAdminUserInfo()
  1870. var queryResult []QueryResult
  1871. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  1872. for _, item := range drugs {
  1873. result := QueryResult{
  1874. ID: item.ID,
  1875. Name: item.DrugName,
  1876. Code: item.MedicalInsuranceNumber,
  1877. List_type_code: "101",
  1878. }
  1879. queryResult = append(queryResult, result)
  1880. }
  1881. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1882. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1883. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1884. for _, item := range queryResult {
  1885. 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)
  1886. }
  1887. }
  1888. func (c *HisApiController) Goodcheck() {
  1889. admin_user_id, _ := c.GetInt64("admin_user_id")
  1890. adminUser := c.GetAdminUserInfo()
  1891. var queryResult []QueryResult
  1892. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  1893. for _, item := range goods {
  1894. result := QueryResult{
  1895. ID: item.ID,
  1896. Name: item.GoodName,
  1897. Code: item.SocialSecurityDirectoryCode,
  1898. List_type_code: "301",
  1899. }
  1900. queryResult = append(queryResult, result)
  1901. }
  1902. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1903. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1904. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1905. for _, item := range queryResult {
  1906. 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)
  1907. //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)
  1908. }
  1909. }
  1910. func (c *HisApiController) Projectcheck() {
  1911. admin_user_id, _ := c.GetInt64("admin_user_id")
  1912. adminUser := c.GetAdminUserInfo()
  1913. var queryResult []QueryResult
  1914. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  1915. for _, item := range projects {
  1916. result := QueryResult{
  1917. ID: item.ID,
  1918. Name: item.ProjectName,
  1919. Code: item.MedicalCode,
  1920. List_type_code: "201",
  1921. }
  1922. queryResult = append(queryResult, result)
  1923. }
  1924. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1925. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1926. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1927. for _, item := range queryResult {
  1928. 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)
  1929. }
  1930. }
  1931. //func (c *HisApiController)CancleDia(){
  1932. //
  1933. // id, _ := c.GetInt64("id")
  1934. // record_time := c.GetString("record_time")
  1935. // his_patient_id, _ := c.GetInt64("his_patient_id")
  1936. //
  1937. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1938. //
  1939. // diagnosis_id := c.GetString("diagnosis")
  1940. // sick_type, _ := c.GetInt64("sick_type")
  1941. // reg_type, _ := c.GetInt64("p_type")
  1942. // begin_time := c.GetString("begin_time")
  1943. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  1944. //
  1945. //
  1946. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  1947. //
  1948. // fmt.Println(acct_used_flag)
  1949. //
  1950. //
  1951. // timeLayout := "2006-01-02"
  1952. // loc, _ := time.LoadLocation("Local")
  1953. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1954. // if err != nil {
  1955. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1956. // return
  1957. // }
  1958. // recordDateTime := theTime.Unix()
  1959. // adminUser := c.GetAdminUserInfo()
  1960. //
  1961. //
  1962. //
  1963. //
  1964. //
  1965. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1966. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1967. // var patientPrescription models.HisPrescriptionInfo
  1968. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1969. // if patientPrescription.ID == 0 {
  1970. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1971. // }
  1972. // //if patientPrescription.Do
  1973. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1974. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1975. //
  1976. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1977. //
  1978. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  1979. //
  1980. // var config []*models.HisXtDiagnoseConfig
  1981. // for _, item := range diagnosis_ids {
  1982. // id, _ := strconv.ParseInt(item, 10, 64)
  1983. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  1984. // config = append(config, &diagnosisConfig)
  1985. // }
  1986. //
  1987. // sickConfig, _ := service.FindSickById(sick_type)
  1988. //
  1989. //
  1990. // data := make(map[string]interface{})
  1991. // client := &http.Client{}
  1992. // data["psn_no"] = his.PsnNo
  1993. // data["mdtrt_id"] = his.Number
  1994. // data["doctor"] = roles.UserName
  1995. // data["department"] = department.Name
  1996. // data["org_name"] = miConfig.OrgName
  1997. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  1998. // data["doctor_id"] = doctor_info.DoctorNumber
  1999. // data["new_doctor_name"] = doctor_info.UserName
  2000. // data["fixmedins_code"] = miConfig.Code
  2001. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  2002. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2003. // data["secret_key"] = miConfig.SecretKey
  2004. // data["sick_code"] = sickConfig.CountryCode
  2005. // data["sick_name"] = sickConfig.ClassName
  2006. // data["url"] = miConfig.Url
  2007. // data["ak"] = miConfig.AccessKey
  2008. // data["begin_time"] = begin_time
  2009. // data["cainfo"] = miConfig.Cainfo
  2010. // data["is_vaild"] = "0"
  2011. //
  2012. // data["dept"] = strconv.FormatInt(department.ID, 10)
  2013. // data["config"] = config
  2014. // bytesData, _ := json.Marshal(data)
  2015. //
  2016. // var req *http.Request
  2017. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  2018. // resp, _ := client.Do(req)
  2019. // defer resp.Body.Close()
  2020. // body, ioErr := ioutil.ReadAll(resp.Body)
  2021. // if ioErr != nil {
  2022. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2023. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2024. // return
  2025. // }
  2026. // var respJSON map[string]interface{}
  2027. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2028. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2030. // return
  2031. // }
  2032. //
  2033. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2034. // userJSONBytes, _ := json.Marshal(respJSON)
  2035. // fmt.Println("log")
  2036. // fmt.Println(string(userJSONBytes))
  2037. //
  2038. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  2039. // utils.ErrorLog("解析失败:%v", err)
  2040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2041. // return
  2042. // }
  2043. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  2044. // res2.Output = ressix10265.Output
  2045. // res2.ErrMsg = ressix10265.ErrMsg
  2046. // res2.Cainfo = ressix10265.Cainfo
  2047. // res2.WarnMsg = ressix10265.WarnMsg
  2048. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  2049. // res2.Infcode = infocode
  2050. //
  2051. //}
  2052. func (c *HisApiController) Get4102() {
  2053. order_id, _ := c.GetInt64("order_id")
  2054. admin_user_id, _ := c.GetInt64("admin_user_id")
  2055. stas_type := c.GetString("stas_type")
  2056. order, _ := service.GetHisOrderByIDTwo(order_id)
  2057. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2058. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2059. var pp models.PublicParams
  2060. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2061. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2062. pp.FixmedinsName = miConfig.OrgName
  2063. pp.FixmedinsCode = miConfig.Code
  2064. pp.RequestUrl = miConfig.Url
  2065. pp.Cainfo = miConfig.Cainfo
  2066. pp.SecretKey = miConfig.SecretKey
  2067. pp.AccessKey = miConfig.AccessKey
  2068. pp.OpterName = curRoles.UserName
  2069. if miConfig.MdtrtareaAdmvs == "350500" {
  2070. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  2071. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  2072. saveLog(result, request, "4102", "清单确认")
  2073. var dat map[string]interface{}
  2074. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2075. fmt.Println(dat)
  2076. } else {
  2077. fmt.Println(err)
  2078. }
  2079. var empty ResultFourteen
  2080. userJSONBytes, _ := json.Marshal(dat)
  2081. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  2082. utils.ErrorLog("解析失败:%v", err)
  2083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2084. return
  2085. }
  2086. if empty.Infcode == 0 {
  2087. c.ServeSuccessJSON(map[string]interface{}{
  2088. "msg": "确认成功",
  2089. })
  2090. return
  2091. }
  2092. } else {
  2093. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  2094. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  2095. result3, request3 := service.Jxyb4105(pp)
  2096. saveLog(result, request, "4102", "清单确认")
  2097. saveLog(result2, request2, "4103", "清单确认")
  2098. saveLog(result3, request3, "4105", "清单统计")
  2099. var dat map[string]interface{}
  2100. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2101. fmt.Println(dat)
  2102. } else {
  2103. fmt.Println(err)
  2104. }
  2105. var empty ResultFourteen
  2106. userJSONBytes, _ := json.Marshal(dat)
  2107. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  2108. utils.ErrorLog("解析失败:%v", err)
  2109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2110. return
  2111. }
  2112. if empty.Infcode == 0 {
  2113. c.ServeSuccessJSON(map[string]interface{}{
  2114. "msg": "确认成功",
  2115. })
  2116. return
  2117. }
  2118. }
  2119. }
  2120. // 对账权限查询
  2121. func (c *HisApiController) Get3260() {
  2122. admin_user_id, _ := c.GetInt64("admin_user_id")
  2123. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2124. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2125. var api string
  2126. var res models.JSResult3260
  2127. if miConfig.MdtrtareaAdmvs == "320921" {
  2128. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2129. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  2130. } else {
  2131. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2132. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  2133. }
  2134. resp, requestErr := http.Get(api)
  2135. if requestErr != nil {
  2136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2137. return
  2138. }
  2139. body, ioErr := ioutil.ReadAll(resp.Body)
  2140. if ioErr != nil {
  2141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2143. return
  2144. }
  2145. var respJSON map[string]interface{}
  2146. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2149. return
  2150. }
  2151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2152. result, _ := json.Marshal(respJSON)
  2153. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2154. utils.ErrorLog("解析失败:%v", err)
  2155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2156. return
  2157. }
  2158. if res.Infcode == "0" {
  2159. c.ServeSuccessJSON(map[string]interface{}{
  2160. "result": res.Output.Data,
  2161. })
  2162. } else {
  2163. c.ServeSuccessJSON(map[string]interface{}{
  2164. "failed_code": -10,
  2165. "msg": res.ErrMsg,
  2166. })
  2167. return
  2168. }
  2169. }
  2170. func (c *HisApiController) Get3261() {
  2171. admin_user_id, _ := c.GetInt64("admin_user_id")
  2172. //month := c.GetString("month")
  2173. startTime := c.GetString("start_time")
  2174. //endTime, _ := c.GetString("end_time")
  2175. times := strings.Split(startTime, "-")
  2176. stmt_mon := times[0] + times[1]
  2177. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2178. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2179. var api string
  2180. var res models.JSResult3261
  2181. //var res10265 Result5301For10265
  2182. if miConfig.MdtrtareaAdmvs == "320921" {
  2183. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2184. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  2185. } else {
  2186. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2187. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  2188. }
  2189. resp, requestErr := http.Get(api)
  2190. if requestErr != nil {
  2191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2192. return
  2193. }
  2194. body, ioErr := ioutil.ReadAll(resp.Body)
  2195. if ioErr != nil {
  2196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2198. return
  2199. }
  2200. var respJSON map[string]interface{}
  2201. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2204. return
  2205. }
  2206. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2207. result, _ := json.Marshal(respJSON)
  2208. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2209. utils.ErrorLog("解析失败:%v", err)
  2210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2211. return
  2212. }
  2213. if res.Infcode == "0" {
  2214. c.ServeSuccessJSON(map[string]interface{}{
  2215. "result": res.Output,
  2216. })
  2217. } else {
  2218. c.ServeSuccessJSON(map[string]interface{}{
  2219. "failed_code": -10,
  2220. "msg": res.ErrMsg,
  2221. })
  2222. return
  2223. }
  2224. }
  2225. type TempFun struct {
  2226. FundKey string
  2227. FundCode string
  2228. }
  2229. func (c *HisApiController) Get3262() {
  2230. admin_user_id, _ := c.GetInt64("admin_user_id")
  2231. startTime := c.GetString("start_time")
  2232. endTime := c.GetString("end_time")
  2233. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2234. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2235. //timeLayout := "2006-01-02"
  2236. //loc, _ := time.LoadLocation("Local")
  2237. //var theStartTIme int64
  2238. //if len(startTime) > 0 {
  2239. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  2240. // if err != nil {
  2241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2242. // return
  2243. // }
  2244. // theStartTIme = theTime.Unix()
  2245. //}
  2246. //var theEndtTIme int64
  2247. //if len(endTime) > 0 {
  2248. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  2249. // if err != nil {
  2250. // utils.ErrorLog(err.Error())
  2251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2252. // return
  2253. // }
  2254. // theEndtTIme = theTime.Unix()
  2255. //}
  2256. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2257. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2258. for _, team := range datas {
  2259. fmt.Println(team.PsnTime)
  2260. for _, team_two := range datas_two {
  2261. fmt.Println(team_two.PsnTime)
  2262. if team.FundKey == team_two.FundKey {
  2263. fmt.Println(team_two.PsnTime)
  2264. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  2265. fmt.Println(team.PsnTime)
  2266. }
  2267. }
  2268. }
  2269. fmt.Println("1111")
  2270. fmt.Println(datas)
  2271. fmt.Println("1111")
  2272. var twos []models.FixMonRecDetailFileInTwo
  2273. for _, team := range datas {
  2274. var two models.FixMonRecDetailFileInTwo
  2275. two.MedType = team.MedType
  2276. two.Insutype = team.Insutype
  2277. two.PsnType = team.PsnType
  2278. two.MedType = team.MedType
  2279. two.FixBlngAdmdvs = "999999"
  2280. two.InsuAdmdvs = "555555"
  2281. two.PsnTime = team.PsnTime
  2282. two.PsnCnt = team.PsnCnt
  2283. two.FundKey = team.FundKey
  2284. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  2285. fps, _ := strconv.ParseFloat(team.Fund, 64)
  2286. ia, _ := strconv.ParseFloat(team.Amt, 64)
  2287. two.MedfeeSumAmt = ms
  2288. two.InscpAmt = ia
  2289. two.FundPaySumAmt = fps
  2290. twos = append(twos, two)
  2291. }
  2292. //startTime := c.GetString("start_time")
  2293. //endTime, _ := c.GetString("end_time")
  2294. times := strings.Split(startTime, "-")
  2295. stmt_mon := times[0] + times[1]
  2296. var funs []models.FundDetail
  2297. for _, item := range datas {
  2298. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  2299. funs = append(funs, fun...)
  2300. }
  2301. var funInfos []models.Fund
  2302. //for _, item := range funs {
  2303. // var rf []models.FundInfo
  2304. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  2305. // for _, subitem := range rf {
  2306. // var fund models.Fund
  2307. // fund.FundCode = subitem.FundPayType
  2308. // fund.FundName = subitem.FundPayTypeName
  2309. // fund.FundAmt = subitem.FundPayAmt
  2310. // fund.FundKey = item.FundKey
  2311. // fund.InsuAdmdvs = "555555"
  2312. // fund.FixBlngAdmdvs = "999999"
  2313. // funInfos = append(funInfos, fund)
  2314. // }
  2315. //}
  2316. var tempFuns []TempFun
  2317. for _, funInfo := range funInfos {
  2318. var tempFun TempFun
  2319. tempFun.FundKey = funInfo.FundKey
  2320. tempFun.FundCode = funInfo.FundCode
  2321. tempFuns = append(tempFuns, tempFun)
  2322. }
  2323. tempFuns = RemoveRepeatedFunElement(tempFuns)
  2324. fmt.Println(tempFuns)
  2325. var funInfosTwo []models.Fund
  2326. decimal.DivisionPrecision = 2
  2327. for _, item := range tempFuns {
  2328. var fund models.Fund
  2329. for _, subItem := range funInfos {
  2330. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  2331. fund.FundKey = subItem.FundKey
  2332. fund.InsuAdmdvs = subItem.InsuAdmdvs
  2333. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  2334. fund.FundName = subItem.FundName
  2335. fund.FundCode = subItem.FundCode
  2336. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  2337. }
  2338. }
  2339. funInfosTwo = append(funInfosTwo, fund)
  2340. }
  2341. fmt.Println("funInfosTwo")
  2342. fmt.Println(funInfosTwo)
  2343. var upld_btch string
  2344. var empty models.JSResultEmpty
  2345. data := make(map[string]interface{})
  2346. data["org_name"] = miConfig.OrgName
  2347. data["doctor"] = curRoles.UserName
  2348. data["doctor_name"] = curRoles.UserName
  2349. data["fixmedins_code"] = miConfig.Code
  2350. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2351. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2352. data["secret_key"] = miConfig.SecretKey
  2353. data["url"] = miConfig.Url
  2354. data["ak"] = miConfig.AccessKey
  2355. data["cainfo"] = miConfig.Cainfo
  2356. data["datas"] = twos
  2357. data["fund"] = funInfosTwo
  2358. fmt.Println(twos)
  2359. month := time.Unix(1557042972, 0).Format("1")
  2360. year := time.Now().Format("2006")
  2361. month = time.Now().Format("01")
  2362. day := time.Now().Format("02")
  2363. hour := time.Now().Format("15")
  2364. min := time.Now().Format("04")
  2365. sec := time.Now().Format("05")
  2366. fix_fill_date := year + month + day + hour + min + sec
  2367. data["fix_fill_dept"] = miConfig.OrgName
  2368. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2369. data["fix_fill_psn"] = curRoles.UserName
  2370. data["fix_fill_date"] = fix_fill_date
  2371. data["stmt_loc"] = "2"
  2372. data["setl_mon"] = stmt_mon
  2373. upld_btch = "0"
  2374. data["upld_btch"] = upld_btch
  2375. //fmt.Println(data)
  2376. client := &http.Client{}
  2377. bytesData, _ := json.Marshal(data)
  2378. var req *http.Request
  2379. if miConfig.MdtrtareaAdmvs == "320921" {
  2380. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  2381. } else {
  2382. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  2383. }
  2384. resp, _ := client.Do(req)
  2385. defer resp.Body.Close()
  2386. body, ioErr := ioutil.ReadAll(resp.Body)
  2387. if ioErr != nil {
  2388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2390. }
  2391. var respJSON map[string]interface{}
  2392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2395. }
  2396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2397. //fmt.Println(respJSON)
  2398. result, _ := json.Marshal(respJSON)
  2399. //fmt.Println(result)
  2400. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  2401. utils.ErrorLog("解析失败:%v", err)
  2402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2403. }
  2404. if empty.Infcode != "0" {
  2405. c.ServeSuccessJSON(map[string]interface{}{
  2406. "failed_code": -10,
  2407. "msg": empty.ErrMsg,
  2408. })
  2409. return
  2410. } else {
  2411. c.ServeSuccessJSON(map[string]interface{}{
  2412. "msg": "上传成功",
  2413. })
  2414. return
  2415. }
  2416. }
  2417. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  2418. newArr = make([]TempFun, 0)
  2419. for i := 0; i < len(arr); i++ {
  2420. repeat := false
  2421. for j := i + 1; j < len(arr); j++ {
  2422. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  2423. repeat = true
  2424. break
  2425. }
  2426. }
  2427. if !repeat {
  2428. newArr = append(newArr, arr[i])
  2429. }
  2430. }
  2431. return
  2432. }
  2433. func (c *HisApiController) Get3263() {
  2434. admin_user_id, _ := c.GetInt64("admin_user_id")
  2435. startTime := c.GetString("start_time")
  2436. //endTime, _ := c.GetString("end_time")
  2437. times := strings.Split(startTime, "-")
  2438. setl_mon := times[0] + times[1]
  2439. upld_btch := "0"
  2440. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2441. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2442. var result3263 models.JSResult3263
  2443. data := make(map[string]interface{})
  2444. data["org_name"] = miConfig.OrgName
  2445. data["doctor"] = curRoles.UserName
  2446. data["doctor_name"] = curRoles.UserName
  2447. data["fixmedins_code"] = miConfig.Code
  2448. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2449. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2450. data["secret_key"] = miConfig.SecretKey
  2451. data["url"] = miConfig.Url
  2452. data["ak"] = miConfig.AccessKey
  2453. data["cainfo"] = miConfig.Cainfo
  2454. data["setl_mon"] = setl_mon
  2455. data["stmt_loc"] = "2"
  2456. data["upld_btch"] = upld_btch
  2457. client := &http.Client{}
  2458. bytesData, _ := json.Marshal(data)
  2459. var req *http.Request
  2460. if miConfig.MdtrtareaAdmvs == "320921" {
  2461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  2462. } else {
  2463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  2464. }
  2465. resp, _ := client.Do(req)
  2466. defer resp.Body.Close()
  2467. body, ioErr := ioutil.ReadAll(resp.Body)
  2468. if ioErr != nil {
  2469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2471. }
  2472. var respJSON map[string]interface{}
  2473. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2476. }
  2477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2478. fmt.Println(respJSON)
  2479. result, _ := json.Marshal(respJSON)
  2480. fmt.Println(result)
  2481. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2482. utils.ErrorLog("解析失败:%v", err)
  2483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. }
  2485. if result3263.Infcode != "0" {
  2486. c.ServeSuccessJSON(map[string]interface{}{
  2487. "failed_code": -10,
  2488. "msg": result3263.ErrMsg,
  2489. })
  2490. return
  2491. } else {
  2492. c.ServeSuccessJSON(map[string]interface{}{
  2493. "list": result3263.Output,
  2494. })
  2495. return
  2496. }
  2497. }
  2498. func (c *HisApiController) Get3264() {
  2499. admin_user_id, _ := c.GetInt64("admin_user_id")
  2500. startTime := c.GetString("start_time")
  2501. //endTime, _ := c.GetString("end_time")
  2502. times := strings.Split(startTime, "-")
  2503. setl_mon := times[0] + times[1]
  2504. upld_btch := "0"
  2505. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2506. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2507. //solidify_id := []
  2508. var result3263 models.JSResult3263
  2509. data := make(map[string]interface{})
  2510. data["org_name"] = miConfig.OrgName
  2511. data["doctor"] = curRoles.UserName
  2512. data["doctor_name"] = curRoles.UserName
  2513. data["fixmedins_code"] = miConfig.Code
  2514. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2515. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2516. data["secret_key"] = miConfig.SecretKey
  2517. data["url"] = miConfig.Url
  2518. data["ak"] = miConfig.AccessKey
  2519. data["cainfo"] = miConfig.Cainfo
  2520. data["setl_mon"] = setl_mon
  2521. data["stmt_loc"] = "2"
  2522. data["upld_btch"] = upld_btch
  2523. client := &http.Client{}
  2524. bytesData, _ := json.Marshal(data)
  2525. var req3263 *http.Request
  2526. if miConfig.MdtrtareaAdmvs == "320921" {
  2527. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  2528. } else {
  2529. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  2530. }
  2531. resp, _ := client.Do(req3263)
  2532. defer resp.Body.Close()
  2533. body, ioErr := ioutil.ReadAll(resp.Body)
  2534. if ioErr != nil {
  2535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2537. }
  2538. var respJSON3263 map[string]interface{}
  2539. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  2540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2542. }
  2543. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2544. fmt.Println(respJSON3263)
  2545. result, _ := json.Marshal(respJSON3263)
  2546. fmt.Println(result)
  2547. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2548. utils.ErrorLog("解析失败:%v", err)
  2549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2550. }
  2551. var ids []string
  2552. for _, item := range result3263.Output {
  2553. ids = append(ids, item.SolidifyID)
  2554. }
  2555. var empty models.JSResultEmpty
  2556. data2 := make(map[string]interface{})
  2557. data2["org_name"] = miConfig.OrgName
  2558. data2["doctor"] = curRoles.UserName
  2559. data2["doctor_name"] = curRoles.UserName
  2560. data2["fixmedins_code"] = miConfig.Code
  2561. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2562. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2563. data2["secret_key"] = miConfig.SecretKey
  2564. data2["url"] = miConfig.Url
  2565. data2["ak"] = miConfig.AccessKey
  2566. data2["cainfo"] = miConfig.Cainfo
  2567. data2["setl_mon"] = setl_mon
  2568. data2["stmt_loc"] = "2"
  2569. data2["upld_btch"] = upld_btch
  2570. data2["solidify_id"] = ids
  2571. client2 := &http.Client{}
  2572. bytesData2, _ := json.Marshal(data2)
  2573. var req *http.Request
  2574. if miConfig.MdtrtareaAdmvs == "320921" {
  2575. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  2576. } else {
  2577. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  2578. }
  2579. resp2, _ := client2.Do(req)
  2580. defer resp.Body.Close()
  2581. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2582. if ioErr2 != nil {
  2583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2585. }
  2586. var respJSON map[string]interface{}
  2587. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  2588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2590. }
  2591. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2592. fmt.Println(respJSON)
  2593. result2, _ := json.Marshal(respJSON)
  2594. fmt.Println(result2)
  2595. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  2596. utils.ErrorLog("解析失败:%v", err)
  2597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2598. }
  2599. if empty.Infcode != "0" {
  2600. c.ServeSuccessJSON(map[string]interface{}{
  2601. "failed_code": -10,
  2602. "msg": empty.ErrMsg,
  2603. })
  2604. return
  2605. } else {
  2606. c.ServeSuccessJSON(map[string]interface{}{
  2607. "msg": "",
  2608. })
  2609. return
  2610. }
  2611. }
  2612. func (c *HisApiController) Get3265() {
  2613. admin_user_id, _ := c.GetInt64("admin_user_id")
  2614. startTime := c.GetString("start_time")
  2615. //endTime, _ := c.GetString("end_time")
  2616. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2617. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2618. times := strings.Split(startTime, "-")
  2619. setl_mon := times[0] + times[1]
  2620. var upld_btch string
  2621. upld_btch = "0"
  2622. //var empty models.JSResultEmpty
  2623. var result3265 models.JSResult3264
  2624. var result3263 models.JSResult3263
  2625. data2 := make(map[string]interface{})
  2626. data2["org_name"] = miConfig.OrgName
  2627. data2["doctor"] = curRoles.UserName
  2628. data2["doctor_name"] = curRoles.UserName
  2629. data2["fixmedins_code"] = miConfig.Code
  2630. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2631. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2632. data2["secret_key"] = miConfig.SecretKey
  2633. data2["url"] = miConfig.Url
  2634. data2["ak"] = miConfig.AccessKey
  2635. data2["cainfo"] = miConfig.Cainfo
  2636. data2["setl_mon"] = setl_mon
  2637. data2["stmt_loc"] = "2"
  2638. data2["upld_btch"] = upld_btch
  2639. client2 := &http.Client{}
  2640. bytesData2, _ := json.Marshal(data2)
  2641. var req3263 *http.Request
  2642. if miConfig.MdtrtareaAdmvs == "320921" {
  2643. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  2644. } else {
  2645. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  2646. }
  2647. resp2, _ := client2.Do(req3263)
  2648. defer resp2.Body.Close()
  2649. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2650. if ioErr2 != nil {
  2651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2653. }
  2654. var respJSON3263 map[string]interface{}
  2655. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2658. }
  2659. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2660. fmt.Println(respJSON3263)
  2661. result2, _ := json.Marshal(respJSON3263)
  2662. fmt.Println(result2)
  2663. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2664. utils.ErrorLog("解析失败:%v", err)
  2665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2666. }
  2667. var ids []string
  2668. for _, item := range result3263.Output {
  2669. ids = append(ids, item.SolidifyID)
  2670. }
  2671. data := make(map[string]interface{})
  2672. data["org_name"] = miConfig.OrgName
  2673. data["doctor"] = curRoles.UserName
  2674. data["doctor_name"] = curRoles.UserName
  2675. data["fixmedins_code"] = miConfig.Code
  2676. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2677. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2678. data["secret_key"] = miConfig.SecretKey
  2679. data["url"] = miConfig.Url
  2680. data["ak"] = miConfig.AccessKey
  2681. data["cainfo"] = miConfig.Cainfo
  2682. data["setl_mon"] = setl_mon
  2683. data["solidify_id"] = ids
  2684. month := time.Unix(1557042972, 0).Format("1")
  2685. year := time.Now().Format("2006")
  2686. month = time.Now().Format("01")
  2687. day := time.Now().Format("02")
  2688. hour := time.Now().Format("15")
  2689. min := time.Now().Format("04")
  2690. sec := time.Now().Format("05")
  2691. fix_fill_date := year + month + day + hour + min + sec
  2692. data["fix_fill_dept"] = miConfig.OrgName
  2693. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2694. data["fix_fill_psn"] = curRoles.UserName
  2695. data["fix_fill_date"] = fix_fill_date
  2696. data["stmt_loc"] = "2"
  2697. data["upld_btch"] = upld_btch
  2698. client := &http.Client{}
  2699. bytesData, _ := json.Marshal(data)
  2700. var req *http.Request
  2701. if miConfig.MdtrtareaAdmvs == "320921" {
  2702. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  2703. } else {
  2704. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  2705. }
  2706. resp, _ := client.Do(req)
  2707. defer resp.Body.Close()
  2708. body, ioErr := ioutil.ReadAll(resp.Body)
  2709. if ioErr != nil {
  2710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2712. }
  2713. var respJSON map[string]interface{}
  2714. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2717. }
  2718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2719. fmt.Println(respJSON)
  2720. result, _ := json.Marshal(respJSON)
  2721. fmt.Println(result)
  2722. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2723. utils.ErrorLog("解析失败:%v", err)
  2724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2725. }
  2726. if result3265.Infcode != "0" {
  2727. c.ServeSuccessJSON(map[string]interface{}{
  2728. "failed_code": -10,
  2729. "msg": result3265.ErrMsg,
  2730. })
  2731. return
  2732. } else {
  2733. c.ServeSuccessJSON(map[string]interface{}{
  2734. "info": result3265.Output,
  2735. })
  2736. return
  2737. }
  2738. }
  2739. func (c *HisApiController) Get3266() {
  2740. admin_user_id, _ := c.GetInt64("admin_user_id")
  2741. startTime := c.GetString("start_time")
  2742. //endTime, _ := c.GetString("end_time")
  2743. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2744. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2745. times := strings.Split(startTime, "-")
  2746. stmt_mon := times[0] + times[1]
  2747. var upld_btch string
  2748. //var empty models.JSResultEmpty
  2749. var result3265 models.JSResult3264
  2750. data := make(map[string]interface{})
  2751. data["org_name"] = miConfig.OrgName
  2752. data["doctor"] = curRoles.UserName
  2753. data["doctor_name"] = curRoles.UserName
  2754. data["fixmedins_code"] = miConfig.Code
  2755. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2756. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2757. data["secret_key"] = miConfig.SecretKey
  2758. data["url"] = miConfig.Url
  2759. data["ak"] = miConfig.AccessKey
  2760. data["cainfo"] = miConfig.Cainfo
  2761. data["setl_mon"] = stmt_mon
  2762. month := time.Unix(1557042972, 0).Format("1")
  2763. year := time.Now().Format("2006")
  2764. month = time.Now().Format("01")
  2765. day := time.Now().Format("02")
  2766. hour := time.Now().Format("15")
  2767. min := time.Now().Format("04")
  2768. sec := time.Now().Format("05")
  2769. fix_fill_date := year + month + day + hour + min + sec
  2770. data["fix_fill_dept"] = miConfig.OrgName
  2771. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2772. data["fix_fill_psn"] = curRoles.UserName
  2773. data["fix_fill_date"] = fix_fill_date
  2774. data["stmt_loc"] = "2"
  2775. upld_btch = "0"
  2776. data["upld_btch"] = upld_btch
  2777. client := &http.Client{}
  2778. bytesData, _ := json.Marshal(data)
  2779. var req *http.Request
  2780. if miConfig.MdtrtareaAdmvs == "320921" {
  2781. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  2782. } else {
  2783. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  2784. }
  2785. resp, _ := client.Do(req)
  2786. defer resp.Body.Close()
  2787. body, ioErr := ioutil.ReadAll(resp.Body)
  2788. if ioErr != nil {
  2789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2791. }
  2792. var respJSON map[string]interface{}
  2793. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2796. }
  2797. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2798. fmt.Println(respJSON)
  2799. result, _ := json.Marshal(respJSON)
  2800. fmt.Println(result)
  2801. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2802. utils.ErrorLog("解析失败:%v", err)
  2803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2804. }
  2805. if result3265.Infcode != "0" {
  2806. c.ServeSuccessJSON(map[string]interface{}{
  2807. "failed_code": -10,
  2808. "msg": result3265.ErrMsg,
  2809. })
  2810. return
  2811. } else {
  2812. c.ServeSuccessJSON(map[string]interface{}{
  2813. "info": result3265.Output,
  2814. })
  2815. return
  2816. }
  2817. }
  2818. func (c *HisApiController) Get3267() {
  2819. admin_user_id, _ := c.GetInt64("admin_user_id")
  2820. startTime := c.GetString("start_time")
  2821. //endTime, _ := c.GetString("end_time")
  2822. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2823. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2824. times := strings.Split(startTime, "-")
  2825. setl_mon := times[0] + times[1]
  2826. var upld_btch string
  2827. //var empty models.JSResultEmpty
  2828. var result3265 models.JSResult3264
  2829. upld_btch = "0"
  2830. data := make(map[string]interface{})
  2831. data["org_name"] = miConfig.OrgName
  2832. data["doctor"] = curRoles.UserName
  2833. data["doctor_name"] = curRoles.UserName
  2834. data["fixmedins_code"] = miConfig.Code
  2835. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2836. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2837. data["secret_key"] = miConfig.SecretKey
  2838. data["url"] = miConfig.Url
  2839. data["ak"] = miConfig.AccessKey
  2840. data["cainfo"] = miConfig.Cainfo
  2841. data["setl_mon"] = setl_mon
  2842. data["stmt_loc"] = "2"
  2843. data["upld_btch"] = upld_btch
  2844. client := &http.Client{}
  2845. bytesData, _ := json.Marshal(data)
  2846. var req *http.Request
  2847. if miConfig.MdtrtareaAdmvs == "320921" {
  2848. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  2849. } else {
  2850. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  2851. }
  2852. resp, _ := client.Do(req)
  2853. defer resp.Body.Close()
  2854. body, ioErr := ioutil.ReadAll(resp.Body)
  2855. if ioErr != nil {
  2856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2858. }
  2859. var respJSON map[string]interface{}
  2860. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2863. }
  2864. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2865. fmt.Println(respJSON)
  2866. result, _ := json.Marshal(respJSON)
  2867. fmt.Println(result)
  2868. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2869. utils.ErrorLog("解析失败:%v", err)
  2870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2871. }
  2872. if result3265.Infcode != "0" {
  2873. c.ServeSuccessJSON(map[string]interface{}{
  2874. "failed_code": -10,
  2875. "msg": result3265.ErrMsg,
  2876. })
  2877. return
  2878. } else {
  2879. c.ServeSuccessJSON(map[string]interface{}{
  2880. "info": result3265.Output.Data,
  2881. })
  2882. return
  2883. }
  2884. }
  2885. func (c *HisApiController) Get3268() {
  2886. admin_user_id, _ := c.GetInt64("admin_user_id")
  2887. startTime := c.GetString("start_time")
  2888. endTime := c.GetString("end_time")
  2889. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2891. times := strings.Split(startTime, "-")
  2892. setl_mon := times[0] + times[1]
  2893. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2894. var twos []models.FixMonRecDetailFileInTwo
  2895. var funs []models.FundDetail
  2896. for _, item := range datas {
  2897. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  2898. funs = append(funs, fun...)
  2899. }
  2900. var funInfos []models.Fund
  2901. //for _, item := range funs {
  2902. // var rf []models.FundInfo
  2903. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  2904. // for _, subitem := range rf {
  2905. // var fund models.Fund
  2906. // fund.FundCode = subitem.FundPayType
  2907. // fund.FundName = subitem.FundPayTypeName
  2908. // fund.FundAmt = subitem.FundPayAmt
  2909. // fund.FundKey = item.FundKey
  2910. // fund.InsuAdmdvs = "555555"
  2911. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  2912. // funInfos = append(funInfos, fund)
  2913. // }
  2914. //}
  2915. for _, team := range datas {
  2916. var two models.FixMonRecDetailFileInTwo
  2917. two.SetlDate = time.Now().Format("2006-01-02")
  2918. two.MedType = team.MedType
  2919. two.Insutype = team.Insutype
  2920. two.PsnType = team.PsnType
  2921. two.MedType = team.MedType
  2922. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  2923. two.InsuAdmdvs = team.InsuAdmdvs
  2924. two.PsnTime = team.PsnTime
  2925. two.PsnCnt = team.PsnCnt
  2926. two.FundKey = team.FundKey
  2927. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  2928. fps, _ := strconv.ParseFloat(team.Fund, 64)
  2929. ia, _ := strconv.ParseFloat(team.Amt, 64)
  2930. two.MedfeeSumAmt = ms
  2931. two.InscpAmt = ia
  2932. two.FundPaySumAmt = fps
  2933. twos = append(twos, two)
  2934. }
  2935. var upld_btch string
  2936. upld_btch = "0"
  2937. var empty models.JSResultEmpty
  2938. data := make(map[string]interface{})
  2939. data["org_name"] = miConfig.OrgName
  2940. data["doctor"] = curRoles.UserName
  2941. data["doctor_name"] = curRoles.UserName
  2942. data["fixmedins_code"] = miConfig.Code
  2943. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2944. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2945. data["secret_key"] = miConfig.SecretKey
  2946. data["url"] = miConfig.Url
  2947. data["ak"] = miConfig.AccessKey
  2948. data["cainfo"] = miConfig.Cainfo
  2949. data["datas"] = twos
  2950. data["fund"] = funInfos
  2951. data["setl_mon"] = setl_mon
  2952. month := time.Unix(1557042972, 0).Format("1")
  2953. year := time.Now().Format("2006")
  2954. month = time.Now().Format("01")
  2955. day := time.Now().Format("02")
  2956. hour := time.Now().Format("15")
  2957. min := time.Now().Format("04")
  2958. sec := time.Now().Format("05")
  2959. fix_fill_date := year + month + day + hour + min + sec
  2960. data["fix_fill_dept"] = miConfig.OrgName
  2961. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2962. data["fix_fill_psn"] = curRoles.UserName
  2963. data["fix_fill_date"] = fix_fill_date
  2964. data["stmt_loc"] = "2"
  2965. data["upld_btch"] = upld_btch
  2966. client := &http.Client{}
  2967. bytesData, _ := json.Marshal(data)
  2968. var req *http.Request
  2969. if miConfig.MdtrtareaAdmvs == "320921" {
  2970. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2971. } else {
  2972. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2973. }
  2974. resp, _ := client.Do(req)
  2975. defer resp.Body.Close()
  2976. body, ioErr := ioutil.ReadAll(resp.Body)
  2977. if ioErr != nil {
  2978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2980. }
  2981. var respJSON map[string]interface{}
  2982. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2985. }
  2986. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2987. fmt.Println(respJSON)
  2988. result, _ := json.Marshal(respJSON)
  2989. fmt.Println(result)
  2990. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  2991. utils.ErrorLog("解析失败:%v", err)
  2992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2993. }
  2994. if empty.Infcode != "0" {
  2995. c.ServeSuccessJSON(map[string]interface{}{
  2996. "failed_code": -10,
  2997. "msg": empty.ErrMsg,
  2998. })
  2999. return
  3000. } else {
  3001. c.ServeSuccessJSON(map[string]interface{}{
  3002. "msg": "上传成功",
  3003. })
  3004. return
  3005. }
  3006. }
  3007. func (c *HisApiController) Get3269() {
  3008. admin_user_id, _ := c.GetInt64("admin_user_id")
  3009. startTime := c.GetString("start_time")
  3010. //endTime, _ := c.GetString("end_time")
  3011. times := strings.Split(startTime, "-")
  3012. setl_mon := times[0] + times[1]
  3013. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3014. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3015. var result3263 models.JSResult3263
  3016. data := make(map[string]interface{})
  3017. data["org_name"] = miConfig.OrgName
  3018. data["doctor"] = curRoles.UserName
  3019. data["doctor_name"] = curRoles.UserName
  3020. data["fixmedins_code"] = miConfig.Code
  3021. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3022. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3023. data["secret_key"] = miConfig.SecretKey
  3024. data["url"] = miConfig.Url
  3025. data["ak"] = miConfig.AccessKey
  3026. data["cainfo"] = miConfig.Cainfo
  3027. data["setl_mon"] = setl_mon
  3028. data["stmt_loc"] = "2"
  3029. client := &http.Client{}
  3030. bytesData, _ := json.Marshal(data)
  3031. var req *http.Request
  3032. if miConfig.MdtrtareaAdmvs == "320921" {
  3033. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  3034. } else {
  3035. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  3036. }
  3037. resp, _ := client.Do(req)
  3038. defer resp.Body.Close()
  3039. body, ioErr := ioutil.ReadAll(resp.Body)
  3040. if ioErr != nil {
  3041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3043. }
  3044. var respJSON map[string]interface{}
  3045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3048. }
  3049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3050. fmt.Println(respJSON)
  3051. result, _ := json.Marshal(respJSON)
  3052. fmt.Println(result)
  3053. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  3054. utils.ErrorLog("解析失败:%v", err)
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3056. }
  3057. if result3263.Infcode != "0" {
  3058. c.ServeSuccessJSON(map[string]interface{}{
  3059. "failed_code": -10,
  3060. "msg": result3263.ErrMsg,
  3061. })
  3062. return
  3063. } else {
  3064. c.ServeSuccessJSON(map[string]interface{}{
  3065. "msg": "上传成功",
  3066. })
  3067. return
  3068. }
  3069. }
  3070. func (c *HisApiController) Get3270() {
  3071. admin_user_id, _ := c.GetInt64("admin_user_id")
  3072. startTime := c.GetString("start_time")
  3073. //endTime, _ := c.GetString("end_time")
  3074. times := strings.Split(startTime, "-")
  3075. setl_mon := times[0] + times[1]
  3076. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3077. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3078. var result3263 models.JSResult3263
  3079. data2 := make(map[string]interface{})
  3080. data2["org_name"] = miConfig.OrgName
  3081. data2["doctor"] = curRoles.UserName
  3082. data2["doctor_name"] = curRoles.UserName
  3083. data2["fixmedins_code"] = miConfig.Code
  3084. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3085. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3086. data2["secret_key"] = miConfig.SecretKey
  3087. data2["url"] = miConfig.Url
  3088. data2["ak"] = miConfig.AccessKey
  3089. data2["cainfo"] = miConfig.Cainfo
  3090. data2["setl_mon"] = setl_mon
  3091. data2["stmt_loc"] = "2"
  3092. client2 := &http.Client{}
  3093. bytesData2, _ := json.Marshal(data2)
  3094. var req3263 *http.Request
  3095. if miConfig.MdtrtareaAdmvs == "320921" {
  3096. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  3097. } else {
  3098. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  3099. }
  3100. resp2, _ := client2.Do(req3263)
  3101. defer resp2.Body.Close()
  3102. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3103. if ioErr2 != nil {
  3104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3106. }
  3107. var respJSON3263 map[string]interface{}
  3108. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  3109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3111. }
  3112. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3113. fmt.Println(respJSON3263)
  3114. result2, _ := json.Marshal(respJSON3263)
  3115. fmt.Println(result2)
  3116. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  3117. utils.ErrorLog("解析失败:%v", err)
  3118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3119. }
  3120. var ids []string
  3121. for _, item := range result3263.Output {
  3122. ids = append(ids, item.SolidifyID)
  3123. }
  3124. var result3264 models.JSResult3264
  3125. data := make(map[string]interface{})
  3126. data["org_name"] = miConfig.OrgName
  3127. data["doctor"] = curRoles.UserName
  3128. data["doctor_name"] = curRoles.UserName
  3129. data["fixmedins_code"] = miConfig.Code
  3130. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3131. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3132. data["secret_key"] = miConfig.SecretKey
  3133. data["url"] = miConfig.Url
  3134. data["ak"] = miConfig.AccessKey
  3135. data["cainfo"] = miConfig.Cainfo
  3136. data["setl_mon"] = setl_mon
  3137. data["stmt_loc"] = "2"
  3138. data["solidify_id"] = ids
  3139. client := &http.Client{}
  3140. bytesData, _ := json.Marshal(data)
  3141. var req *http.Request
  3142. if miConfig.MdtrtareaAdmvs == "320921" {
  3143. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  3144. } else {
  3145. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  3146. }
  3147. resp, _ := client.Do(req)
  3148. defer resp.Body.Close()
  3149. body, ioErr := ioutil.ReadAll(resp.Body)
  3150. if ioErr != nil {
  3151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3153. }
  3154. var respJSON map[string]interface{}
  3155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3158. }
  3159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3160. fmt.Println(respJSON)
  3161. result, _ := json.Marshal(respJSON)
  3162. fmt.Println(result)
  3163. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  3164. utils.ErrorLog("解析失败:%v", err)
  3165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3166. }
  3167. if result3264.Infcode != "0" {
  3168. c.ServeSuccessJSON(map[string]interface{}{
  3169. "failed_code": -10,
  3170. "msg": result3264.ErrMsg,
  3171. })
  3172. return
  3173. } else {
  3174. c.ServeSuccessJSON(map[string]interface{}{
  3175. "info": result3264.Output,
  3176. })
  3177. return
  3178. }
  3179. }
  3180. func (c *HisApiController) Get3271() {
  3181. admin_user_id, _ := c.GetInt64("admin_user_id")
  3182. startTime := c.GetString("start_time")
  3183. //endTime, _ := c.GetString("end_time")
  3184. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3185. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3186. times := strings.Split(startTime, "-")
  3187. setl_mon := times[0] + times[1]
  3188. //var empty models.JSResultEmpty
  3189. var result3265 models.JSResult3264
  3190. var result3263 models.JSResult3263
  3191. data2 := make(map[string]interface{})
  3192. data2["org_name"] = miConfig.OrgName
  3193. data2["doctor"] = curRoles.UserName
  3194. data2["doctor_name"] = curRoles.UserName
  3195. data2["fixmedins_code"] = miConfig.Code
  3196. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3197. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3198. data2["secret_key"] = miConfig.SecretKey
  3199. data2["url"] = miConfig.Url
  3200. data2["ak"] = miConfig.AccessKey
  3201. data2["cainfo"] = miConfig.Cainfo
  3202. data2["setl_mon"] = setl_mon
  3203. data2["stmt_loc"] = "2"
  3204. client2 := &http.Client{}
  3205. bytesData2, _ := json.Marshal(data2)
  3206. var req3263 *http.Request
  3207. if miConfig.MdtrtareaAdmvs == "320921" {
  3208. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  3209. } else {
  3210. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  3211. }
  3212. resp2, _ := client2.Do(req3263)
  3213. defer resp2.Body.Close()
  3214. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3215. if ioErr2 != nil {
  3216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3218. }
  3219. var respJSON3263 map[string]interface{}
  3220. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  3221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3223. }
  3224. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3225. fmt.Println(respJSON3263)
  3226. result2, _ := json.Marshal(respJSON3263)
  3227. fmt.Println(result2)
  3228. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  3229. utils.ErrorLog("解析失败:%v", err)
  3230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3231. }
  3232. var ids []string
  3233. for _, item := range result3263.Output {
  3234. ids = append(ids, item.SolidifyID)
  3235. }
  3236. data := make(map[string]interface{})
  3237. data["org_name"] = miConfig.OrgName
  3238. data["doctor"] = curRoles.UserName
  3239. data["doctor_name"] = curRoles.UserName
  3240. data["fixmedins_code"] = miConfig.Code
  3241. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3242. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3243. data["secret_key"] = miConfig.SecretKey
  3244. data["url"] = miConfig.Url
  3245. data["ak"] = miConfig.AccessKey
  3246. data["cainfo"] = miConfig.Cainfo
  3247. data["setl_mon"] = setl_mon
  3248. data["solidify_id"] = ids
  3249. month := time.Unix(1557042972, 0).Format("1")
  3250. year := time.Now().Format("2006")
  3251. month = time.Now().Format("01")
  3252. day := time.Now().Format("02")
  3253. hour := time.Now().Format("15")
  3254. min := time.Now().Format("04")
  3255. sec := time.Now().Format("05")
  3256. fix_fill_date := year + month + day + hour + min + sec
  3257. data["fix_fill_dept"] = miConfig.OrgName
  3258. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  3259. data["fix_fill_psn"] = curRoles.UserName
  3260. data["fix_fill_date"] = fix_fill_date
  3261. data["stmt_loc"] = "2"
  3262. client := &http.Client{}
  3263. bytesData, _ := json.Marshal(data)
  3264. var req *http.Request
  3265. if miConfig.MdtrtareaAdmvs == "320921" {
  3266. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  3267. } else {
  3268. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  3269. }
  3270. resp, _ := client.Do(req)
  3271. defer resp.Body.Close()
  3272. body, ioErr := ioutil.ReadAll(resp.Body)
  3273. if ioErr != nil {
  3274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3276. }
  3277. var respJSON map[string]interface{}
  3278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3281. }
  3282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3283. fmt.Println(respJSON)
  3284. result, _ := json.Marshal(respJSON)
  3285. fmt.Println(result)
  3286. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  3287. utils.ErrorLog("解析失败:%v", err)
  3288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3289. }
  3290. if result3265.Infcode != "0" {
  3291. c.ServeSuccessJSON(map[string]interface{}{
  3292. "failed_code": -10,
  3293. "msg": result3265.ErrMsg,
  3294. })
  3295. return
  3296. } else {
  3297. c.ServeSuccessJSON(map[string]interface{}{
  3298. "info": result3265.Output.Data,
  3299. })
  3300. return
  3301. }
  3302. }
  3303. func (c *HisApiController) Get3272() {
  3304. admin_user_id, _ := c.GetInt64("admin_user_id")
  3305. startTime := c.GetString("start_time")
  3306. //endTime, _ := c.GetString("end_time")
  3307. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3308. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3309. times := strings.Split(startTime, "-")
  3310. setl_mon := times[0] + times[1]
  3311. var upld_btch string
  3312. //var empty models.JSResultEmpty
  3313. var result3265 models.JSResult3264
  3314. data := make(map[string]interface{})
  3315. data["org_name"] = miConfig.OrgName
  3316. data["doctor"] = curRoles.UserName
  3317. data["doctor_name"] = curRoles.UserName
  3318. data["fixmedins_code"] = miConfig.Code
  3319. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3320. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3321. data["secret_key"] = miConfig.SecretKey
  3322. data["url"] = miConfig.Url
  3323. data["ak"] = miConfig.AccessKey
  3324. data["cainfo"] = miConfig.Cainfo
  3325. data["setl_mon"] = setl_mon
  3326. month := time.Unix(1557042972, 0).Format("1")
  3327. year := time.Now().Format("2006")
  3328. month = time.Now().Format("01")
  3329. day := time.Now().Format("02")
  3330. hour := time.Now().Format("15")
  3331. min := time.Now().Format("04")
  3332. sec := time.Now().Format("05")
  3333. fix_fill_date := year + month + day + hour + min + sec
  3334. data["fix_fill_dept"] = miConfig.OrgName
  3335. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  3336. data["fix_fill_psn"] = curRoles.UserName
  3337. data["fix_fill_date"] = fix_fill_date
  3338. data["stmt_loc"] = "2"
  3339. data["upld_btch"] = upld_btch
  3340. client := &http.Client{}
  3341. bytesData, _ := json.Marshal(data)
  3342. var req *http.Request
  3343. if miConfig.MdtrtareaAdmvs == "320921" {
  3344. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  3345. } else {
  3346. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  3347. }
  3348. resp, _ := client.Do(req)
  3349. defer resp.Body.Close()
  3350. body, ioErr := ioutil.ReadAll(resp.Body)
  3351. if ioErr != nil {
  3352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3354. }
  3355. var respJSON map[string]interface{}
  3356. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3359. }
  3360. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3361. fmt.Println(respJSON)
  3362. result, _ := json.Marshal(respJSON)
  3363. fmt.Println(result)
  3364. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  3365. utils.ErrorLog("解析失败:%v", err)
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. }
  3368. if result3265.Infcode != "0" {
  3369. c.ServeSuccessJSON(map[string]interface{}{
  3370. "failed_code": -10,
  3371. "msg": result3265.ErrMsg,
  3372. })
  3373. return
  3374. } else {
  3375. c.ServeSuccessJSON(map[string]interface{}{
  3376. "info": result3265.Output,
  3377. })
  3378. return
  3379. }
  3380. }
  3381. func (c *HisApiController) Get3273() {
  3382. admin_user_id, _ := c.GetInt64("admin_user_id")
  3383. startTime := c.GetString("start_time")
  3384. //endTime, _ := c.GetString("end_time")
  3385. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3386. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3387. times := strings.Split(startTime, "-")
  3388. setl_mon := times[0] + times[1]
  3389. var result3265 models.JSResult3264
  3390. data := make(map[string]interface{})
  3391. data["org_name"] = miConfig.OrgName
  3392. data["doctor"] = curRoles.UserName
  3393. data["doctor_name"] = curRoles.UserName
  3394. data["fixmedins_code"] = miConfig.Code
  3395. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3396. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3397. data["secret_key"] = miConfig.SecretKey
  3398. data["url"] = miConfig.Url
  3399. data["ak"] = miConfig.AccessKey
  3400. data["cainfo"] = miConfig.Cainfo
  3401. data["setl_mon"] = setl_mon
  3402. data["stmt_loc"] = "2"
  3403. client := &http.Client{}
  3404. bytesData, _ := json.Marshal(data)
  3405. var req *http.Request
  3406. if miConfig.MdtrtareaAdmvs == "320921" {
  3407. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  3408. } else {
  3409. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  3410. }
  3411. resp, _ := client.Do(req)
  3412. defer resp.Body.Close()
  3413. body, ioErr := ioutil.ReadAll(resp.Body)
  3414. if ioErr != nil {
  3415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3417. }
  3418. var respJSON map[string]interface{}
  3419. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3422. }
  3423. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3424. fmt.Println(respJSON)
  3425. result, _ := json.Marshal(respJSON)
  3426. fmt.Println(result)
  3427. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  3428. utils.ErrorLog("解析失败:%v", err)
  3429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3430. }
  3431. if result3265.Infcode != "0" {
  3432. c.ServeSuccessJSON(map[string]interface{}{
  3433. "failed_code": -10,
  3434. "msg": result3265.ErrMsg,
  3435. })
  3436. return
  3437. } else {
  3438. c.ServeSuccessJSON(map[string]interface{}{
  3439. "info": result3265.Output.Data,
  3440. })
  3441. return
  3442. }
  3443. }
  3444. func (c *HisApiController) Get3274() {
  3445. //if miConfig.MdtrtareaAdmvs == "320921" {
  3446. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3447. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3448. // "&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
  3449. //
  3450. //} else {
  3451. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3452. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3453. // "&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
  3454. //
  3455. //}
  3456. }
  3457. func (c *HisApiController) Get3275() {
  3458. //if miConfig.MdtrtareaAdmvs == "320921" {
  3459. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3460. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3461. // "&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
  3462. //
  3463. //} else {
  3464. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3465. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3466. // "&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
  3467. //
  3468. //}
  3469. }
  3470. func (c *HisApiController) Get3276() {
  3471. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3472. //month := c.GetString("month")
  3473. //
  3474. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3475. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3476. //var api string
  3477. //var res Result5301
  3478. //
  3479. //if miConfig.MdtrtareaAdmvs == "320921" {
  3480. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  3481. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  3482. //} else {
  3483. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  3484. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  3485. //}
  3486. //
  3487. //resp, requestErr := http.Get(api)
  3488. //if requestErr != nil {
  3489. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3490. // return
  3491. //}
  3492. //
  3493. //body, ioErr := ioutil.ReadAll(resp.Body)
  3494. //if ioErr != nil {
  3495. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3497. // return
  3498. //}
  3499. //var respJSON map[string]interface{}
  3500. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3501. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3503. // return
  3504. //}
  3505. //
  3506. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3507. //result, _ := json.Marshal(respJSON)
  3508. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3509. // utils.ErrorLog("解析失败:%v", err)
  3510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3511. // return
  3512. //}
  3513. }
  3514. func (c *HisApiController) Get3277() {
  3515. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3516. //month := c.GetString("month")
  3517. //
  3518. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3519. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3520. //var api string
  3521. //var res Result5301
  3522. //
  3523. //if miConfig.MdtrtareaAdmvs == "320921" {
  3524. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  3525. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  3526. //} else {
  3527. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  3528. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  3529. //}
  3530. //
  3531. //resp, requestErr := http.Get(api)
  3532. //if requestErr != nil {
  3533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3534. // return
  3535. //}
  3536. //
  3537. //body, ioErr := ioutil.ReadAll(resp.Body)
  3538. //if ioErr != nil {
  3539. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3540. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3541. // return
  3542. //}
  3543. //var respJSON map[string]interface{}
  3544. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3545. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3546. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3547. // return
  3548. //}
  3549. //
  3550. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3551. //result, _ := json.Marshal(respJSON)
  3552. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3553. // utils.ErrorLog("解析失败:%v", err)
  3554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3555. // return
  3556. //}
  3557. }
  3558. func (c *HisApiController) GetCFYLJG001() {
  3559. admin_user_id, _ := c.GetInt64("admin_user_id")
  3560. patient_id, _ := c.GetInt64("patient_id")
  3561. his_patient_id, _ := c.GetInt64("his_patient_id")
  3562. record_time := c.GetString("record_time")
  3563. admin_user_id = 3626
  3564. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3565. psn, _ := service.GetPsnByPatientId(patient_id)
  3566. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3567. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3568. var cFYLJG001 models.CFYLJG001
  3569. timeLayout := "2006-01-02"
  3570. loc, _ := time.LoadLocation("Local")
  3571. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3572. if err != nil {
  3573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3574. return
  3575. }
  3576. recordDateTime := theTime.Unix()
  3577. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3578. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3579. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3580. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3581. //dept, _ := service.GetDepartMentDetail(info.Departments)
  3582. for _, item := range prescriptions {
  3583. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  3584. if his.IdCardType == 1 {
  3585. bas := strings.Split(psn.CardInfo, "|")
  3586. basNumber := bas[1]
  3587. fmt.Println(basNumber)
  3588. card_sn := bas[3]
  3589. card_no := bas[2]
  3590. cFYLJG001.MdtrtCertType = "03"
  3591. cFYLJG001.CardSn = card_sn
  3592. cFYLJG001.MdtrtCertNo = card_no
  3593. cFYLJG001.EcToken = ""
  3594. cFYLJG001.AuthNo = ""
  3595. } else if his.IdCardType == 2 {
  3596. cFYLJG001.MdtrtCertType = "02"
  3597. cFYLJG001.CardSn = ""
  3598. cFYLJG001.MdtrtCertNo = his.IdCardNo
  3599. cFYLJG001.EcToken = ""
  3600. cFYLJG001.AuthNo = ""
  3601. } else if his.IdCardType == 4 {
  3602. cFYLJG001.MdtrtCertType = "01"
  3603. cFYLJG001.CardSn = ""
  3604. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  3605. cFYLJG001.EcToken = psn.VerifyNumber
  3606. cFYLJG001.AuthNo = ""
  3607. }
  3608. cFYLJG001.BizTypeCode = "01"
  3609. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  3610. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  3611. cFYLJG001.RxTypeCode = "1"
  3612. tempTime := time.Unix(item.PreTime, 0)
  3613. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3614. cFYLJG001.PrscTime = timeFormatOne
  3615. var count float64
  3616. if item.Type == 1 {
  3617. for _, sumItem := range item.HisDoctorAdviceInfo {
  3618. count = count + sumItem.PrescribingNumber
  3619. }
  3620. }
  3621. cFYLJG001.RxDrugCnt = count
  3622. cFYLJG001.ValiDays = "5"
  3623. ts := time.Unix(item.PreTime, 0)
  3624. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  3625. tempTime3 := time.Unix(record_time2, 0)
  3626. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  3627. cFYLJG001.ValiEndTime = timeFormat3
  3628. cFYLJG001.RxCotnFlag = "0"
  3629. for _, subItem := range item.HisDoctorAdviceInfo {
  3630. var drug models.RxDrug
  3631. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  3632. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  3633. drug.RxItemTypeCode = "11"
  3634. drug.DrugDosform = "乳膏剂" //TODO
  3635. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  3636. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  3637. }
  3638. drug.MedcWayDscr = subItem.DeliveryWay
  3639. tempTime2 := time.Unix(subItem.StartTime, 0)
  3640. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3641. drug.MedcBegntime = timeFormatTwo
  3642. if subItem.Day > 0 {
  3643. ts := time.Unix(subItem.StartTime, 0)
  3644. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  3645. tempTime4 := time.Unix(record_time, 0)
  3646. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  3647. drug.MedcEndtime = timeFormat5
  3648. } else {
  3649. tempTime2 := time.Unix(subItem.StartTime, 0)
  3650. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3651. drug.MedcEndtime = timeFormatTwo
  3652. }
  3653. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  3654. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  3655. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  3656. drug.DrugCnt = subItem.PrescribingNumber
  3657. drug.DrugDosunt = subItem.PrescribingNumberUnit
  3658. drug.DrugGenname = subItem.AdviceName
  3659. drug.MedcWayCodg = subItem.DeliveryWay
  3660. //drug.DrugTotlcnt = subItem.PrescribingNumber
  3661. drug.SinDoscnt = subItem.SingleDose
  3662. drug.SinDosunt = subItem.SingleDoseUnit
  3663. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  3664. drug.UsedFrquName = subItem.ExecutionFrequency
  3665. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3666. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  3667. drug.HospApprFlag = "1"
  3668. cFYLJG001.List = append(cFYLJG001.List, drug)
  3669. }
  3670. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  3671. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  3672. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  3673. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  3674. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  3675. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  3676. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  3677. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  3678. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  3679. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  3680. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  3681. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  3682. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  3683. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  3684. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  3685. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  3686. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  3687. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  3688. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  3689. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  3690. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  3691. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  3692. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  3693. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  3694. tempTime2 := time.Now().Unix()
  3695. tempTime6 := time.Unix(tempTime2, 0)
  3696. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  3697. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  3698. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  3699. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  3700. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  3701. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  3702. //memo := make(map[string]interface{})
  3703. //inputData := make(map[string]interface{}, 0)
  3704. //type MyData struct {
  3705. // Insutype string `json:"insutype"`
  3706. //}
  3707. //
  3708. // data := MyData{
  3709. // Insutype: his.Insutype,
  3710. //}
  3711. //
  3712. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  3713. var config []*models.HisXtDiagnoseConfig
  3714. for _, item := range diagnosis_ids {
  3715. id, _ := strconv.ParseInt(item, 10, 64)
  3716. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3717. config = append(config, &diagnosisConfig)
  3718. }
  3719. for index, subitem := range config {
  3720. if index == 0 {
  3721. var dia models.DiseInfo
  3722. dia.DiagType = "1"
  3723. dia.MaindiagFlag = "1"
  3724. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3725. dia.DiagCode = subitem.CountryCode
  3726. dia.DiagName = subitem.ClassName
  3727. dia.DiagDept = "肾内科"
  3728. dia.DiagDrNo = doctor.DoctorNumber
  3729. dia.DiagDrName = doctor.UserName
  3730. tempTime3 := time.Unix(item.PreTime, 0)
  3731. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  3732. dia.DiagTime = timeFormatTwo
  3733. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  3734. } else {
  3735. var dia models.DiseInfo
  3736. dia.DiagType = "1"
  3737. dia.MaindiagFlag = "0"
  3738. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3739. dia.DiagCode = subitem.CountryCode
  3740. dia.DiagName = subitem.ClassName
  3741. dia.DiagDept = "肾内科"
  3742. dia.DiagDrNo = doctor.DoctorNumber
  3743. dia.DiagDrName = doctor.UserName
  3744. tempTime3 := time.Unix(item.PreTime, 0)
  3745. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  3746. dia.DiagTime = timeFormatTwo
  3747. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  3748. }
  3749. }
  3750. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  3751. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  3752. var res ResultCFYLJG001
  3753. var respJSON2 map[string]interface{}
  3754. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3757. return
  3758. }
  3759. userJSONBytes2, _ := json.Marshal(respJSON2)
  3760. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3761. utils.ErrorLog("解析失败:%v", err)
  3762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3763. return
  3764. }
  3765. if res.Infcode == -1 {
  3766. c.ServeSuccessJSON(map[string]interface{}{
  3767. "failed_code": -10,
  3768. "msg": res.ErrMsg,
  3769. })
  3770. return
  3771. } else {
  3772. var flow models.HisPrescriptionFlow
  3773. flow.Ctime = time.Now().Unix()
  3774. flow.SignDigest = ""
  3775. flow.RxTraceCode = res.Output.RxTraceCode
  3776. flow.HiRxno = res.Output.HiRxno
  3777. flow.MID = his.Number
  3778. flow.Status = 1
  3779. flow.DCode = doctor_info.DoctorNumber
  3780. flow.OriginalRxFile = ""
  3781. flow.OriginalValue = ""
  3782. flow.SignCertDn = ""
  3783. flow.UserOrgId = 10454
  3784. flow.SignCertSn = ""
  3785. flow.Mtime = time.Now().Unix()
  3786. service.Createflow(&flow)
  3787. c.ServeSuccessJSON(map[string]interface{}{
  3788. "msg": "上传成功",
  3789. })
  3790. }
  3791. }
  3792. }
  3793. func (c *HisApiController) GetCFYLJG002() {
  3794. admin_user_id, _ := c.GetInt64("admin_user_id")
  3795. his_patient_id, _ := c.GetInt64("his_patient_id")
  3796. record_time := c.GetString("record_time")
  3797. admin_user_id = 3626
  3798. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3799. //id, _ := c.GetInt64("id")
  3800. admin_user_id = 3626
  3801. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3802. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3803. flow, _ := service.Getflowtwo(his.Number)
  3804. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3805. //record_time := c.GetString("record_time")
  3806. patient_id, _ := c.GetInt64("patient_id")
  3807. //patient_id = 23834
  3808. //record_time = "2023-09-18"
  3809. timeLayout := "2006-01-02"
  3810. loc, _ := time.LoadLocation("Local")
  3811. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3812. if err != nil {
  3813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3814. return
  3815. }
  3816. recordDateTime := theTime.Unix()
  3817. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3818. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3819. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3820. dept, _ := service.GetDepartMentDetail(info.Departments)
  3821. inputData := make(map[string]interface{})
  3822. inputData["rxTraceCode"] = flow.RxTraceCode
  3823. inputData["hiRxno"] = flow.HiRxno
  3824. inputData["mdtrtId"] = flow.MID
  3825. inputData["patnName"] = his.PsnName
  3826. inputData["psnCertType"] = his.PsnCertType
  3827. inputData["certno"] = his.Certno
  3828. inputData["fixmedinsName"] = miConfig.OrgName
  3829. inputData["fixmedinsCode"] = miConfig.Code
  3830. inputData["drCode"] = doctor_info.DoctorNumber
  3831. inputData["prscDrName"] = doctor_info.UserName
  3832. inputData["pharDeptName"] = dept.Name
  3833. inputData["pharDeptCode"] = dept.Number
  3834. inputData["pharProfttlCodg"] = dept.Name
  3835. inputData["pharProfttlName"] = ""
  3836. inputData["pharCode"] = "HY440309002107"
  3837. inputData["pharCertType"] = "01"
  3838. inputData["pharCertno"] = "430482199408260023"
  3839. inputData["pharName"] = "彭斯遥"
  3840. inputData["pharPracCertNo"] = ""
  3841. tempTime2 := time.Unix(info.Ctime, 0)
  3842. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3843. inputData["pharChkTime"] = timeFormatTwo
  3844. bytesData, _ := json.Marshal(inputData)
  3845. fmt.Println(string(bytesData))
  3846. encoded := base64.StdEncoding.EncodeToString(bytesData)
  3847. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  3848. if err != nil {
  3849. fmt.Println("Error reading PDF file:", err)
  3850. return
  3851. }
  3852. // 将 PDF 文件内容进行 Base64 编码
  3853. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  3854. fmt.Println(err)
  3855. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  3856. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  3857. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  3858. var res2 Result002
  3859. var respJSON2 map[string]interface{}
  3860. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3863. return
  3864. }
  3865. userJSONBytes2, _ := json.Marshal(respJSON2)
  3866. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3867. utils.ErrorLog("解析失败:%v", err)
  3868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3869. return
  3870. }
  3871. if res2.Infcode == 0 {
  3872. flow.Ctime = time.Now().Unix()
  3873. flow.SignDigest = res2.Output.SignDigest
  3874. flow.RxFile = res2.Output.RxFile
  3875. flow.MID = his.Number
  3876. flow.Status = 1
  3877. flow.DCode = doctor_info.DoctorNumber
  3878. flow.OriginalRxFile = rx_encoded
  3879. flow.OriginalValue = encoded
  3880. flow.SignCertDn = res2.Output.SignCertDn
  3881. flow.SignCertSn = res2.Output.SignCertSn
  3882. flow.Mtime = time.Now().Unix()
  3883. service.Saveflow(flow)
  3884. c.ServeSuccessJSON(map[string]interface{}{
  3885. "msg": "预签名成功",
  3886. })
  3887. } else {
  3888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3889. return
  3890. }
  3891. }
  3892. func (c *HisApiController) GetCFYLJG003() {
  3893. admin_user_id, _ := c.GetInt64("admin_user_id")
  3894. his_patient_id, _ := c.GetInt64("his_patient_id")
  3895. record_time := c.GetString("record_time")
  3896. admin_user_id = 3626
  3897. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3898. //id, _ := c.GetInt64("id")
  3899. admin_user_id = 3626
  3900. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3901. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3902. flow, _ := service.Getflowtwo(his.Number)
  3903. //id = 3
  3904. patient_id, _ := c.GetInt64("patient_id")
  3905. //patient_id = 23834
  3906. //record_time = "2023-09-18"
  3907. timeLayout := "2006-01-02"
  3908. loc, _ := time.LoadLocation("Local")
  3909. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3910. if err != nil {
  3911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3912. return
  3913. }
  3914. recordDateTime := theTime.Unix()
  3915. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3916. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3917. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3918. dept, _ := service.GetDepartMentDetail(info.Departments)
  3919. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  3920. var cFYLJG003 models.CFYLJG003
  3921. cFYLJG003.RxTraceCode = flow.RxTraceCode
  3922. cFYLJG003.HiRxno = flow.HiRxno
  3923. cFYLJG003.MdtrtID = flow.MID
  3924. cFYLJG003.PatnName = his.Name
  3925. cFYLJG003.Certno = his.Certno
  3926. cFYLJG003.FixmedinsName = miConfig.OrgName
  3927. cFYLJG003.FixmedinsCode = miConfig.Code
  3928. cFYLJG003.DrCode = doctor_info.DoctorNumber
  3929. cFYLJG003.PrscDrName = doctor_info.UserName
  3930. cFYLJG003.PharDeptName = dept.Name
  3931. cFYLJG003.PharDeptCode = dept.Number
  3932. cFYLJG003.PharCode = "HY440309002107"
  3933. cFYLJG003.PharCertType = "01"
  3934. cFYLJG003.PharCertno = "430482199408260023"
  3935. cFYLJG003.PharName = "彭斯遥"
  3936. cFYLJG003.PsnCertType = "01"
  3937. cFYLJG003.RxFile = flow.RxFile
  3938. cFYLJG003.SignDigest = flow.SignDigest
  3939. cFYLJG003.FixmedinsCode = miConfig.Code
  3940. cFYLJG003.PsnCertType = "01"
  3941. cFYLJG003.PharProfttlCodg = dept.Name
  3942. //inputData["pharProfttlCodg"] =dept.Name
  3943. tempTime2 := time.Unix(info.Ctime, 0)
  3944. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3945. cFYLJG003.PharChkTime = timeFormatTwo
  3946. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  3947. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  3948. var res ResultCFYLJG003
  3949. var respJSON2 map[string]interface{}
  3950. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3953. return
  3954. }
  3955. userJSONBytes2, _ := json.Marshal(respJSON2)
  3956. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3957. utils.ErrorLog("解析失败:%v", err)
  3958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3959. return
  3960. }
  3961. if res.Infcode == -1 {
  3962. c.ServeSuccessJSON(map[string]interface{}{
  3963. "failed_code": -10,
  3964. "msg": res.ErrMsg,
  3965. })
  3966. return
  3967. } else {
  3968. c.ServeSuccessJSON(map[string]interface{}{
  3969. "info": res.Output,
  3970. })
  3971. }
  3972. }
  3973. func (c *HisApiController) GetCFYLJG004() {
  3974. admin_user_id, _ := c.GetInt64("admin_user_id")
  3975. his_patient_id, _ := c.GetInt64("his_patient_id")
  3976. record_time := c.GetString("record_time")
  3977. admin_user_id = 3626
  3978. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3979. //id, _ := c.GetInt64("id")
  3980. admin_user_id = 3626
  3981. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3982. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3983. flow, _ := service.Getflowtwo(his.Number)
  3984. //id = 3
  3985. patient_id, _ := c.GetInt64("patient_id")
  3986. //patient_id = 23834
  3987. //record_time = "2023-09-18"
  3988. timeLayout := "2006-01-02"
  3989. loc, _ := time.LoadLocation("Local")
  3990. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3991. if err != nil {
  3992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3993. return
  3994. }
  3995. recordDateTime := theTime.Unix()
  3996. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3997. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3998. var cFYLJG004 models.CFYLJG004
  3999. cFYLJG004.HiRxno = flow.HiRxno
  4000. cFYLJG004.FixmedinsCode = miConfig.Code
  4001. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  4002. cFYLJG004.UndoDrCertType = "01"
  4003. cFYLJG004.UndoRea = "撤销处方"
  4004. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  4005. cFYLJG004.UndoDrName = doctor_info.UserName
  4006. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  4007. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  4008. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  4009. var res ResultCFYLJG004
  4010. var respJSON2 map[string]interface{}
  4011. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4014. return
  4015. }
  4016. userJSONBytes2, _ := json.Marshal(respJSON2)
  4017. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  4018. utils.ErrorLog("解析失败:%v", err)
  4019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4020. return
  4021. }
  4022. if res.Infcode == -1 {
  4023. c.ServeSuccessJSON(map[string]interface{}{
  4024. "failed_code": -10,
  4025. "msg": res.ErrMsg,
  4026. })
  4027. return
  4028. } else {
  4029. flow.Status = 0
  4030. service.Saveflow(flow)
  4031. c.ServeSuccessJSON(map[string]interface{}{
  4032. "msg": "撤销成功",
  4033. })
  4034. return
  4035. }
  4036. }
  4037. func (c *HisApiController) GetCFYLJG005() {
  4038. admin_user_id, _ := c.GetInt64("admin_user_id")
  4039. his_patient_id, _ := c.GetInt64("his_patient_id")
  4040. //record_time := c.GetString("record_time")
  4041. admin_user_id = 3626
  4042. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4043. //id, _ := c.GetInt64("id")
  4044. admin_user_id = 3626
  4045. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4046. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4047. flow, _ := service.Getflowtwo(his.Number)
  4048. //id = 3
  4049. var cFYLJG005 models.CFYLJG005
  4050. //patient_id, _ := c.GetInt64("patient_id")
  4051. cFYLJG005.HiRxno = flow.HiRxno
  4052. cFYLJG005.MdtrtID = flow.MID
  4053. cFYLJG005.EcToken = ""
  4054. cFYLJG005.PsnName = his.Name
  4055. cFYLJG005.PsnCertType = "01"
  4056. cFYLJG005.Certno = his.IdCardNo
  4057. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  4058. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  4059. var res ResultCFYLJG005
  4060. var respJSON2 map[string]interface{}
  4061. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4064. return
  4065. }
  4066. userJSONBytes2, _ := json.Marshal(respJSON2)
  4067. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  4068. utils.ErrorLog("解析失败:%v", err)
  4069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4070. return
  4071. }
  4072. if res.Infcode == -1 {
  4073. c.ServeSuccessJSON(map[string]interface{}{
  4074. "failed_code": -10,
  4075. "msg": res.ErrMsg,
  4076. })
  4077. return
  4078. } else {
  4079. c.ServeSuccessJSON(map[string]interface{}{
  4080. "info": res.Output,
  4081. })
  4082. return
  4083. }
  4084. }
  4085. func (c *HisApiController) GetCFYLJG006() {
  4086. admin_user_id, _ := c.GetInt64("admin_user_id")
  4087. his_patient_id, _ := c.GetInt64("his_patient_id")
  4088. admin_user_id = 3626
  4089. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4090. //id, _ := c.GetInt64("id")
  4091. admin_user_id = 3626
  4092. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4093. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4094. flow, _ := service.Getflowtwo(his.Number)
  4095. //id = 3
  4096. patient_id, _ := c.GetInt64("patient_id")
  4097. var cFYLJG006 models.CFYLJG006
  4098. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  4099. cFYLJG006.HiRxno = flow.HiRxno
  4100. cFYLJG006.MdtrtID = flow.MID
  4101. cFYLJG006.PsnName = patient.Name
  4102. cFYLJG006.PsnCertType = "01"
  4103. cFYLJG006.Certno = patient.IdCardNo
  4104. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  4105. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  4106. var res ResultCFYLJG006
  4107. var respJSON2 map[string]interface{}
  4108. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4111. return
  4112. }
  4113. userJSONBytes2, _ := json.Marshal(respJSON2)
  4114. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  4115. utils.ErrorLog("解析失败:%v", err)
  4116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4117. return
  4118. }
  4119. if res.Infcode == -1 {
  4120. c.ServeSuccessJSON(map[string]interface{}{
  4121. "failed_code": -10,
  4122. "msg": res.ErrMsg,
  4123. })
  4124. return
  4125. } else {
  4126. c.ServeSuccessJSON(map[string]interface{}{
  4127. "info": res.Output,
  4128. })
  4129. return
  4130. }
  4131. }
  4132. func (c *HisApiController) GetCFYLJG007() {
  4133. admin_user_id, _ := c.GetInt64("admin_user_id")
  4134. his_patient_id, _ := c.GetInt64("his_patient_id")
  4135. admin_user_id = 3626
  4136. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4137. //id, _ := c.GetInt64("id")
  4138. admin_user_id = 3626
  4139. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4140. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4141. flow, _ := service.Getflowtwo(his.Number)
  4142. //id = 3
  4143. patient_id, _ := c.GetInt64("patient_id")
  4144. var cFYLJG007 models.CFYLJG007
  4145. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  4146. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  4147. cFYLJG007.HiRxno = flow.HiRxno
  4148. cFYLJG007.MdtrtID = flow.MID
  4149. cFYLJG007.PsnNo = his.PsnNo
  4150. cFYLJG007.PsnCertType = "01"
  4151. cFYLJG007.Certno = patient.IdCardNo
  4152. cFYLJG007.PsnName = patient.Name
  4153. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  4154. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  4155. var res ResultCFYLJG007
  4156. var respJSON2 map[string]interface{}
  4157. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4160. return
  4161. }
  4162. userJSONBytes2, _ := json.Marshal(respJSON2)
  4163. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  4164. utils.ErrorLog("解析失败:%v", err)
  4165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4166. return
  4167. }
  4168. if res.Infcode == -1 {
  4169. c.ServeSuccessJSON(map[string]interface{}{
  4170. "failed_code": -10,
  4171. "msg": res.ErrMsg,
  4172. })
  4173. return
  4174. } else {
  4175. c.ServeSuccessJSON(map[string]interface{}{
  4176. "info": res,
  4177. })
  4178. return
  4179. }
  4180. }
  4181. func (c *HisApiController) GetCFYLJG008() {
  4182. admin_user_id, _ := c.GetInt64("admin_user_id")
  4183. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4184. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4185. var cFYLJG008 models.CFYLJG008
  4186. //id, _ := c.GetInt64("id")
  4187. patient_id, _ := c.GetInt64("patient_id")
  4188. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  4189. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  4190. //id = 3
  4191. //flow, _ := service.Getflow(id)
  4192. //his, _ := service.GetHisPatientByNumber(flow.MID)
  4193. //
  4194. //admin_user_id, _ := c.GetInt64("admin_user_id")
  4195. //patient_id, _ := c.GetInt64("patient_id")
  4196. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4197. record_time := c.GetString("record_time")
  4198. admin_user_id = 3626
  4199. patient_id = 19424
  4200. //his_patient_id = 263947
  4201. record_time = "2023-08-29"
  4202. timeLayout := "2006-01-02"
  4203. loc, _ := time.LoadLocation("Local")
  4204. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4205. if err != nil {
  4206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4207. return
  4208. }
  4209. recordDateTime := theTime.Unix()
  4210. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  4211. cFYLJG008.FixmedinsName = ""
  4212. cFYLJG008.Lat = ""
  4213. cFYLJG008.Lng = ""
  4214. cFYLJG008.OrderType = "1"
  4215. cFYLJG008.PoolareaNo = ""
  4216. cFYLJG008.Lng = ""
  4217. cFYLJG008.PageNum = 1
  4218. cFYLJG008.PageSize = 10
  4219. var MPI models.MedinsProdInvChgDDTO
  4220. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  4221. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  4222. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  4223. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  4224. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  4225. var res ResultCFYLJG008
  4226. var respJSON2 map[string]interface{}
  4227. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4230. return
  4231. }
  4232. userJSONBytes2, _ := json.Marshal(respJSON2)
  4233. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  4234. utils.ErrorLog("解析失败:%v", err)
  4235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4236. return
  4237. }
  4238. if res.Infcode == -1 {
  4239. c.ServeSuccessJSON(map[string]interface{}{
  4240. "failed_code": -10,
  4241. "msg": res.ErrMsg,
  4242. })
  4243. return
  4244. } else {
  4245. c.ServeSuccessJSON(map[string]interface{}{
  4246. "info": res.Output,
  4247. })
  4248. return
  4249. }
  4250. }
  4251. func (c *HisApiController) GetBL4201A() {
  4252. order_id, _ := c.GetInt64("order_id")
  4253. admin_user_id, _ := c.GetInt64("admin_user_id")
  4254. order, _ := service.GetHisOrderByIDTwo(order_id)
  4255. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4256. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  4257. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  4258. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4259. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4260. department, _ := service.GetDepartMentDetail(his.Departments)
  4261. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4262. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4263. if order.ID == 0 {
  4264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4265. return
  4266. }
  4267. var struct4201A models.Struct4201A
  4268. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4269. for _, items := range order_info {
  4270. memo := make(map[string]interface{})
  4271. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4272. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4273. fsiOPFLD.MedType = "14"
  4274. fsiOPFLD.BkkpSn = items.FeedetlSn
  4275. fsiOPFLD.FixmedinsCode = miConfig.Code
  4276. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4277. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4278. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4279. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4280. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4281. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4282. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4283. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4284. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4285. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4286. fsiOPFLD.BilgDeptName = department.Name
  4287. fsiOPFLD.BilgDeptCodg = department.Number
  4288. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4289. fsiOPFLD.BilgDrName = doctor.UserName
  4290. fsiOPFLD.MedChrgitmType = "09"
  4291. memo["hosp_appr_flag"] = "1"
  4292. memo["invoice_no"] = order.MdtrtId
  4293. memo["memo"] = "自费"
  4294. bytesData, _ := json.Marshal(memo)
  4295. fsiOPFLD.Memo = string(bytesData)
  4296. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4297. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4298. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4299. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4300. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4301. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4302. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4303. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4304. fsiOPFLD.BilgDeptName = department.Name
  4305. fsiOPFLD.BilgDeptCodg = department.Number
  4306. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4307. fsiOPFLD.BilgDrName = doctor.UserName
  4308. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4309. case 0:
  4310. break
  4311. case 1:
  4312. fsiOPFLD.MedChrgitmType = "14"
  4313. break
  4314. case 2:
  4315. fsiOPFLD.MedChrgitmType = "05"
  4316. break
  4317. case 3:
  4318. fsiOPFLD.MedChrgitmType = "03"
  4319. break
  4320. case 4:
  4321. fsiOPFLD.MedChrgitmType = "03"
  4322. break
  4323. case 5:
  4324. fsiOPFLD.MedChrgitmType = "08"
  4325. break
  4326. case 6:
  4327. fsiOPFLD.MedChrgitmType = "14"
  4328. break
  4329. case 7:
  4330. fsiOPFLD.MedChrgitmType = "14"
  4331. break
  4332. case 8:
  4333. fsiOPFLD.MedChrgitmType = "03"
  4334. break
  4335. case 9:
  4336. fsiOPFLD.MedChrgitmType = "14"
  4337. break
  4338. case 10:
  4339. fsiOPFLD.MedChrgitmType = "14"
  4340. break
  4341. case 11:
  4342. fsiOPFLD.MedChrgitmType = "06"
  4343. break
  4344. case 12:
  4345. fsiOPFLD.MedChrgitmType = "12"
  4346. break
  4347. case 13:
  4348. fsiOPFLD.MedChrgitmType = "01"
  4349. break
  4350. case 14:
  4351. fsiOPFLD.MedChrgitmType = "04"
  4352. break
  4353. case 15:
  4354. fsiOPFLD.MedChrgitmType = "14"
  4355. break
  4356. }
  4357. memo["hosp_appr_flag"] = "1"
  4358. memo["invoice_no"] = order.MdtrtId
  4359. memo["memo"] = "自费"
  4360. bytesData, _ := json.Marshal(memo)
  4361. fsiOPFLD.Memo = string(bytesData)
  4362. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4363. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4364. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4365. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4366. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4367. fsiOPFLD.BilgDeptName = department.Name
  4368. fsiOPFLD.BilgDeptCodg = department.Number
  4369. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4370. fsiOPFLD.BilgDrName = doctor.UserName
  4371. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4372. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4373. fsiOPFLD.MedChrgitmType = "08"
  4374. memo["hosp_appr_flag"] = "1"
  4375. memo["invoice_no"] = order.MdtrtId
  4376. memo["memo"] = "自费"
  4377. bytesData, _ := json.Marshal(memo)
  4378. fsiOPFLD.Memo = string(bytesData)
  4379. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4380. }
  4381. }
  4382. }
  4383. for _, items := range order_info_two {
  4384. memo := make(map[string]interface{})
  4385. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4386. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4387. fsiOPFLD.MedType = "14"
  4388. fsiOPFLD.BkkpSn = items.FeedetlSn
  4389. fsiOPFLD.FixmedinsCode = miConfig.Code
  4390. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4391. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4392. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4393. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4394. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4395. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4396. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4397. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4398. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4399. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4400. fsiOPFLD.BilgDeptName = department.Name
  4401. fsiOPFLD.BilgDeptCodg = department.Number
  4402. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4403. fsiOPFLD.BilgDrName = doctor.UserName
  4404. fsiOPFLD.MedChrgitmType = "09"
  4405. memo["hosp_appr_flag"] = "1"
  4406. memo["invoice_no"] = order.MdtrtId
  4407. memo["memo"] = "自费"
  4408. bytesData, _ := json.Marshal(memo)
  4409. fsiOPFLD.Memo = string(bytesData)
  4410. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4411. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4412. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4413. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4414. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4415. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4416. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4417. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4418. fsiOPFLD.BilgDeptName = department.Name
  4419. fsiOPFLD.BilgDeptCodg = department.Number
  4420. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4421. fsiOPFLD.BilgDrName = doctor.UserName
  4422. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4423. case 0:
  4424. break
  4425. case 1:
  4426. fsiOPFLD.MedChrgitmType = "14"
  4427. break
  4428. case 2:
  4429. fsiOPFLD.MedChrgitmType = "05"
  4430. break
  4431. case 3:
  4432. fsiOPFLD.MedChrgitmType = "03"
  4433. break
  4434. case 4:
  4435. fsiOPFLD.MedChrgitmType = "03"
  4436. break
  4437. case 5:
  4438. fsiOPFLD.MedChrgitmType = "08"
  4439. break
  4440. case 6:
  4441. fsiOPFLD.MedChrgitmType = "14"
  4442. break
  4443. case 7:
  4444. fsiOPFLD.MedChrgitmType = "14"
  4445. break
  4446. case 8:
  4447. fsiOPFLD.MedChrgitmType = "03"
  4448. break
  4449. case 9:
  4450. fsiOPFLD.MedChrgitmType = "14"
  4451. break
  4452. case 10:
  4453. fsiOPFLD.MedChrgitmType = "14"
  4454. break
  4455. case 11:
  4456. fsiOPFLD.MedChrgitmType = "06"
  4457. break
  4458. case 12:
  4459. fsiOPFLD.MedChrgitmType = "12"
  4460. break
  4461. case 13:
  4462. fsiOPFLD.MedChrgitmType = "01"
  4463. break
  4464. case 14:
  4465. fsiOPFLD.MedChrgitmType = "04"
  4466. break
  4467. case 15:
  4468. fsiOPFLD.MedChrgitmType = "14"
  4469. break
  4470. }
  4471. memo["hosp_appr_flag"] = "1"
  4472. memo["invoice_no"] = order.MdtrtId
  4473. memo["memo"] = "自费"
  4474. bytesData, _ := json.Marshal(memo)
  4475. fsiOPFLD.Memo = string(bytesData)
  4476. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4477. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4478. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4479. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4480. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4481. fsiOPFLD.BilgDeptName = department.Name
  4482. fsiOPFLD.BilgDeptCodg = department.Number
  4483. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4484. fsiOPFLD.BilgDrName = doctor.UserName
  4485. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4486. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4487. fsiOPFLD.MedChrgitmType = "08"
  4488. memo["hosp_appr_flag"] = "1"
  4489. memo["invoice_no"] = order.MdtrtId
  4490. memo["memo"] = "自费"
  4491. bytesData, _ := json.Marshal(memo)
  4492. fsiOPFLD.Memo = string(bytesData)
  4493. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4494. }
  4495. }
  4496. }
  4497. fmt.Println(fsiOPFLDs)
  4498. struct4201A.Fopfd = fsiOPFLDs
  4499. fmt.Println(struct4201A.Fopfd)
  4500. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  4501. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  4502. var res2 ResultSix
  4503. var respJSON2 map[string]interface{}
  4504. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4507. return
  4508. }
  4509. userJSONBytes2, _ := json.Marshal(respJSON2)
  4510. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4511. utils.ErrorLog("解析失败:%v", err)
  4512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4513. return
  4514. }
  4515. if res2.Infcode != 0 {
  4516. c.ServeSuccessJSON(map[string]interface{}{
  4517. "failed_code": -10,
  4518. "msg": res2.ErrMsg,
  4519. })
  4520. return
  4521. } else {
  4522. order.IsUploadOrderInfo = 1
  4523. service.UpdateOrder(order)
  4524. c.ServeSuccessJSON(map[string]interface{}{
  4525. "msg": "上传成功",
  4526. })
  4527. }
  4528. }
  4529. func (c *HisApiController) Get2505() {
  4530. admin_user_id, _ := c.GetInt64("admin_user_id")
  4531. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  4532. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4533. 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)
  4534. }
  4535. func (c *HisApiController) Get4201A() {
  4536. order_id, _ := c.GetInt64("order_id")
  4537. admin_user_id, _ := c.GetInt64("admin_user_id")
  4538. order, _ := service.GetHisOrderByIDTwo(order_id)
  4539. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4540. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  4541. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  4542. //order_info = append(order_info, order_info_two...)
  4543. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4544. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4545. department, _ := service.GetDepartMentDetail(his.Departments)
  4546. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4547. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4548. if order.ID == 0 {
  4549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4550. return
  4551. }
  4552. var struct4201A models.Struct4201A
  4553. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4554. for _, items := range order_info {
  4555. memo := make(map[string]interface{})
  4556. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4557. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4558. fsiOPFLD.MedType = "14"
  4559. fsiOPFLD.BkkpSn = items.FeedetlSn
  4560. fsiOPFLD.FixmedinsCode = miConfig.Code
  4561. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4562. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4563. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4564. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4565. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4566. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4567. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4568. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4569. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4570. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4571. fsiOPFLD.BilgDeptName = department.Name
  4572. fsiOPFLD.BilgDeptCodg = department.Number
  4573. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4574. fsiOPFLD.BilgDrName = doctor.UserName
  4575. fsiOPFLD.MedChrgitmType = "09"
  4576. memo["hosp_appr_flag"] = "1"
  4577. memo["invoice_no"] = order.MdtrtId
  4578. memo["memo"] = "自费"
  4579. bytesData, _ := json.Marshal(memo)
  4580. fsiOPFLD.Memo = string(bytesData)
  4581. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4582. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4583. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4584. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4585. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4586. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4587. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4588. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4589. fsiOPFLD.BilgDeptName = department.Name
  4590. fsiOPFLD.BilgDeptCodg = department.Number
  4591. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4592. fsiOPFLD.BilgDrName = doctor.UserName
  4593. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4594. case 0:
  4595. break
  4596. case 1:
  4597. fsiOPFLD.MedChrgitmType = "14"
  4598. break
  4599. case 2:
  4600. fsiOPFLD.MedChrgitmType = "05"
  4601. break
  4602. case 3:
  4603. fsiOPFLD.MedChrgitmType = "03"
  4604. break
  4605. case 4:
  4606. fsiOPFLD.MedChrgitmType = "03"
  4607. break
  4608. case 5:
  4609. fsiOPFLD.MedChrgitmType = "08"
  4610. break
  4611. case 6:
  4612. fsiOPFLD.MedChrgitmType = "14"
  4613. break
  4614. case 7:
  4615. fsiOPFLD.MedChrgitmType = "14"
  4616. break
  4617. case 8:
  4618. fsiOPFLD.MedChrgitmType = "03"
  4619. break
  4620. case 9:
  4621. fsiOPFLD.MedChrgitmType = "14"
  4622. break
  4623. case 10:
  4624. fsiOPFLD.MedChrgitmType = "14"
  4625. break
  4626. case 11:
  4627. fsiOPFLD.MedChrgitmType = "06"
  4628. break
  4629. case 12:
  4630. fsiOPFLD.MedChrgitmType = "12"
  4631. break
  4632. case 13:
  4633. fsiOPFLD.MedChrgitmType = "01"
  4634. break
  4635. case 14:
  4636. fsiOPFLD.MedChrgitmType = "04"
  4637. break
  4638. case 15:
  4639. fsiOPFLD.MedChrgitmType = "14"
  4640. break
  4641. }
  4642. memo["hosp_appr_flag"] = "1"
  4643. memo["invoice_no"] = order.MdtrtId
  4644. memo["memo"] = "自费"
  4645. bytesData, _ := json.Marshal(memo)
  4646. fsiOPFLD.Memo = string(bytesData)
  4647. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4648. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4649. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4650. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4651. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4652. fsiOPFLD.BilgDeptName = department.Name
  4653. fsiOPFLD.BilgDeptCodg = department.Number
  4654. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4655. fsiOPFLD.BilgDrName = doctor.UserName
  4656. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4657. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4658. fsiOPFLD.MedChrgitmType = "08"
  4659. memo["hosp_appr_flag"] = "1"
  4660. memo["invoice_no"] = order.MdtrtId
  4661. memo["memo"] = "自费"
  4662. bytesData, _ := json.Marshal(memo)
  4663. fsiOPFLD.Memo = string(bytesData)
  4664. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4665. }
  4666. }
  4667. }
  4668. for _, items := range order_info_two {
  4669. memo := make(map[string]interface{})
  4670. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4671. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4672. fsiOPFLD.MedType = "14"
  4673. fsiOPFLD.BkkpSn = items.FeedetlSn
  4674. fsiOPFLD.FixmedinsCode = miConfig.Code
  4675. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4676. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4677. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4678. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4679. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4680. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4681. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4682. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4683. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4684. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4685. fsiOPFLD.BilgDeptName = department.Name
  4686. fsiOPFLD.BilgDeptCodg = department.Number
  4687. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4688. fsiOPFLD.BilgDrName = doctor.UserName
  4689. fsiOPFLD.MedChrgitmType = "09"
  4690. memo["hosp_appr_flag"] = "1"
  4691. memo["invoice_no"] = order.MdtrtId
  4692. memo["memo"] = "自费"
  4693. bytesData, _ := json.Marshal(memo)
  4694. fsiOPFLD.Memo = string(bytesData)
  4695. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4696. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4697. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4698. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4699. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4700. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4701. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4702. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4703. fsiOPFLD.BilgDeptName = department.Name
  4704. fsiOPFLD.BilgDeptCodg = department.Number
  4705. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4706. fsiOPFLD.BilgDrName = doctor.UserName
  4707. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4708. case 0:
  4709. break
  4710. case 1:
  4711. fsiOPFLD.MedChrgitmType = "14"
  4712. break
  4713. case 2:
  4714. fsiOPFLD.MedChrgitmType = "05"
  4715. break
  4716. case 3:
  4717. fsiOPFLD.MedChrgitmType = "03"
  4718. break
  4719. case 4:
  4720. fsiOPFLD.MedChrgitmType = "03"
  4721. break
  4722. case 5:
  4723. fsiOPFLD.MedChrgitmType = "08"
  4724. break
  4725. case 6:
  4726. fsiOPFLD.MedChrgitmType = "14"
  4727. break
  4728. case 7:
  4729. fsiOPFLD.MedChrgitmType = "14"
  4730. break
  4731. case 8:
  4732. fsiOPFLD.MedChrgitmType = "03"
  4733. break
  4734. case 9:
  4735. fsiOPFLD.MedChrgitmType = "14"
  4736. break
  4737. case 10:
  4738. fsiOPFLD.MedChrgitmType = "14"
  4739. break
  4740. case 11:
  4741. fsiOPFLD.MedChrgitmType = "06"
  4742. break
  4743. case 12:
  4744. fsiOPFLD.MedChrgitmType = "12"
  4745. break
  4746. case 13:
  4747. fsiOPFLD.MedChrgitmType = "01"
  4748. break
  4749. case 14:
  4750. fsiOPFLD.MedChrgitmType = "04"
  4751. break
  4752. case 15:
  4753. fsiOPFLD.MedChrgitmType = "14"
  4754. break
  4755. }
  4756. memo["hosp_appr_flag"] = "1"
  4757. memo["invoice_no"] = order.MdtrtId
  4758. memo["memo"] = "自费"
  4759. bytesData, _ := json.Marshal(memo)
  4760. fsiOPFLD.Memo = string(bytesData)
  4761. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4762. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4763. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4764. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4765. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4766. fsiOPFLD.BilgDeptName = department.Name
  4767. fsiOPFLD.BilgDeptCodg = department.Number
  4768. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4769. fsiOPFLD.BilgDrName = doctor.UserName
  4770. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4771. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4772. fsiOPFLD.MedChrgitmType = "08"
  4773. memo["hosp_appr_flag"] = "1"
  4774. memo["invoice_no"] = order.MdtrtId
  4775. memo["memo"] = "自费"
  4776. bytesData, _ := json.Marshal(memo)
  4777. fsiOPFLD.Memo = string(bytesData)
  4778. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4779. }
  4780. }
  4781. }
  4782. fmt.Println(fsiOPFLDs)
  4783. struct4201A.Fopfd = fsiOPFLDs
  4784. fmt.Println(struct4201A.Fopfd)
  4785. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  4786. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  4787. var res2 ResultSix
  4788. var respJSON2 map[string]interface{}
  4789. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4792. return
  4793. }
  4794. userJSONBytes2, _ := json.Marshal(respJSON2)
  4795. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4796. utils.ErrorLog("解析失败:%v", err)
  4797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4798. return
  4799. }
  4800. if res2.Infcode != 0 {
  4801. c.ServeSuccessJSON(map[string]interface{}{
  4802. "failed_code": -10,
  4803. "msg": res2.ErrMsg,
  4804. })
  4805. return
  4806. } else {
  4807. order.IsUploadOrderInfo = 1
  4808. service.UpdateOrder(order)
  4809. c.ServeSuccessJSON(map[string]interface{}{
  4810. "msg": "上传成功",
  4811. })
  4812. }
  4813. }
  4814. func (c *HisApiController) Get4202() {
  4815. order_id, _ := c.GetInt64("order_id")
  4816. admin_user_id, _ := c.GetInt64("admin_user_id")
  4817. order, _ := service.GetHisOrderByIDTwo(order_id)
  4818. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4819. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4820. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4821. if order.ID == 0 {
  4822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4823. return
  4824. }
  4825. var struct4202 models.Struct4202
  4826. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4827. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4828. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4829. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4830. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4831. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4832. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  4833. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  4834. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4835. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4836. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4837. var config []*models.HisXtDiagnoseConfig
  4838. for _, item := range diagnosis_ids {
  4839. id, _ := strconv.ParseInt(item, 10, 64)
  4840. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4841. config = append(config, &diagnosisConfig)
  4842. }
  4843. var tempDiaginfos []models.OwnPayPatnDiagListD
  4844. for index, item := range config {
  4845. if index == 0 {
  4846. var tempDiaginfo models.OwnPayPatnDiagListD
  4847. tempDiaginfo.InoutDiagType = "1"
  4848. tempDiaginfo.DiagCode = item.CountryCode
  4849. tempDiaginfo.DiagName = item.CountryContentName
  4850. tempDiaginfo.DiagType = "1"
  4851. tempDiaginfo.DiagSrtNo = "1"
  4852. tempDiaginfo.MaindiagFlag = "1"
  4853. tempDiaginfo.ValiFlag = "1"
  4854. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4855. } else {
  4856. var tempDiaginfo models.OwnPayPatnDiagListD
  4857. tempDiaginfo.DiagCode = item.CountryCode
  4858. tempDiaginfo.DiagName = item.CountryContentName
  4859. tempDiaginfo.DiagType = "2"
  4860. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4861. tempDiaginfo.MaindiagFlag = "0"
  4862. tempDiaginfo.ValiFlag = "1"
  4863. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4864. }
  4865. }
  4866. struct4202.ODiagListD = tempDiaginfos
  4867. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  4868. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  4869. var res2 ResultSix
  4870. var respJSON2 map[string]interface{}
  4871. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4874. return
  4875. }
  4876. userJSONBytes2, _ := json.Marshal(respJSON2)
  4877. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4878. utils.ErrorLog("解析失败:%v", err)
  4879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4880. return
  4881. }
  4882. if res2.Infcode != 0 {
  4883. c.ServeSuccessJSON(map[string]interface{}{
  4884. "failed_code": -10,
  4885. "msg": res2.ErrMsg,
  4886. })
  4887. return
  4888. } else {
  4889. order.IsUploadDiagnose = 1
  4890. service.UpdateOrder(order)
  4891. c.ServeSuccessJSON(map[string]interface{}{
  4892. "msg": "上传成功",
  4893. })
  4894. }
  4895. }
  4896. func (c *HisApiController) Get4203() {
  4897. admin_user_id, _ := c.GetInt64("admin_user_id")
  4898. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4899. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4900. order_id, _ := c.GetInt64("order_id")
  4901. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4902. number := ""
  4903. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4904. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4905. if his.ID == 0 {
  4906. number = hospital.Number
  4907. } else {
  4908. number = his.Number
  4909. }
  4910. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  4911. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  4912. var res2 ResultSix
  4913. var respJSON2 map[string]interface{}
  4914. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4917. return
  4918. }
  4919. userJSONBytes2, _ := json.Marshal(respJSON2)
  4920. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4921. utils.ErrorLog("解析失败:%v", err)
  4922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4923. return
  4924. }
  4925. if res2.Infcode != 0 {
  4926. c.ServeSuccessJSON(map[string]interface{}{
  4927. "failed_code": -10,
  4928. "msg": res2.ErrMsg,
  4929. })
  4930. return
  4931. } else {
  4932. order.IsUploadSuccess = 1
  4933. service.UpdateOrderTwo(order)
  4934. c.ServeSuccessJSON(map[string]interface{}{
  4935. "msg": "上传成功",
  4936. })
  4937. }
  4938. }
  4939. func (c *HisApiController) Get4205() {
  4940. order_id, _ := c.GetInt64("order_id")
  4941. admin_user_id, _ := c.GetInt64("admin_user_id")
  4942. fapiao_code := c.GetString("fapiao_code")
  4943. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4944. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4945. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4946. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4947. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  4948. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4949. //order_info = append(order_info, order_info_two...)
  4950. department, _ := service.GetDepartMentDetail(his.Departments)
  4951. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4952. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4953. if order.ID == 0 {
  4954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4955. return
  4956. }
  4957. var struct4201A models.Struct4201A
  4958. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4959. for _, items := range order_info {
  4960. memo := make(map[string]interface{})
  4961. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4962. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4963. fsiOPFLD.MedType = pre.MedType
  4964. fsiOPFLD.FixmedinsCode = miConfig.Code
  4965. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4966. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4967. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4968. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4969. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4970. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4971. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4972. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  4973. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4974. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4975. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4976. fsiOPFLD.BilgDeptName = department.Name
  4977. fsiOPFLD.BilgDeptCodg = department.Number
  4978. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4979. fsiOPFLD.BilgDrName = doctor.UserName
  4980. fsiOPFLD.MedChrgitmType = "09"
  4981. memo["hosp_appr_flag"] = "1"
  4982. memo["invoice_no"] = fapiao_code
  4983. memo["memo"] = "自费"
  4984. bytesData, _ := json.Marshal(memo)
  4985. fsiOPFLD.Memo = string(bytesData)
  4986. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4987. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4988. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4989. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4990. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4991. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4992. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4993. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4994. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4995. fsiOPFLD.BilgDeptName = department.Name
  4996. fsiOPFLD.BilgDeptCodg = department.Number
  4997. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4998. fsiOPFLD.BilgDrName = doctor.UserName
  4999. switch items.HisPrescriptionProject.HisProject.CostClassify {
  5000. case 0:
  5001. break
  5002. case 1:
  5003. fsiOPFLD.MedChrgitmType = "14"
  5004. break
  5005. case 2:
  5006. fsiOPFLD.MedChrgitmType = "05"
  5007. break
  5008. case 3:
  5009. fsiOPFLD.MedChrgitmType = "03"
  5010. break
  5011. case 4:
  5012. fsiOPFLD.MedChrgitmType = "03"
  5013. break
  5014. case 5:
  5015. fsiOPFLD.MedChrgitmType = "08"
  5016. break
  5017. case 6:
  5018. fsiOPFLD.MedChrgitmType = "14"
  5019. break
  5020. case 7:
  5021. fsiOPFLD.MedChrgitmType = "14"
  5022. break
  5023. case 8:
  5024. fsiOPFLD.MedChrgitmType = "03"
  5025. break
  5026. case 9:
  5027. fsiOPFLD.MedChrgitmType = "14"
  5028. break
  5029. case 10:
  5030. fsiOPFLD.MedChrgitmType = "14"
  5031. break
  5032. case 11:
  5033. fsiOPFLD.MedChrgitmType = "06"
  5034. break
  5035. case 12:
  5036. fsiOPFLD.MedChrgitmType = "12"
  5037. break
  5038. case 13:
  5039. fsiOPFLD.MedChrgitmType = "01"
  5040. break
  5041. case 14:
  5042. fsiOPFLD.MedChrgitmType = "04"
  5043. break
  5044. case 15:
  5045. fsiOPFLD.MedChrgitmType = "14"
  5046. break
  5047. }
  5048. memo["hosp_appr_flag"] = "1"
  5049. memo["invoice_no"] = fapiao_code
  5050. memo["memo"] = "自费"
  5051. bytesData, _ := json.Marshal(memo)
  5052. fsiOPFLD.Memo = string(bytesData)
  5053. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  5054. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  5055. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  5056. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  5057. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  5058. fsiOPFLD.BilgDeptName = department.Name
  5059. fsiOPFLD.BilgDeptCodg = department.Number
  5060. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  5061. fsiOPFLD.BilgDrName = doctor.UserName
  5062. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  5063. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  5064. fsiOPFLD.MedChrgitmType = "08"
  5065. memo["hosp_appr_flag"] = "1"
  5066. memo["invoice_no"] = fapiao_code
  5067. memo["memo"] = "自费"
  5068. bytesData, _ := json.Marshal(memo)
  5069. fsiOPFLD.Memo = string(bytesData)
  5070. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  5071. }
  5072. }
  5073. }
  5074. for _, items := range order_info_two {
  5075. memo := make(map[string]interface{})
  5076. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  5077. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  5078. fsiOPFLD.MedType = pre.MedType
  5079. fsiOPFLD.BkkpSn = items.FeedetlSn
  5080. fsiOPFLD.FixmedinsCode = miConfig.Code
  5081. fsiOPFLD.FixmedinsName = miConfig.OrgName
  5082. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  5083. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  5084. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  5085. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5086. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5087. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5088. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5089. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5090. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5091. fsiOPFLD.BilgDeptName = department.Name
  5092. fsiOPFLD.BilgDeptCodg = department.Number
  5093. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  5094. fsiOPFLD.BilgDrName = doctor.UserName
  5095. fsiOPFLD.MedChrgitmType = "09"
  5096. memo["hosp_appr_flag"] = "1"
  5097. memo["invoice_no"] = fapiao_code
  5098. memo["memo"] = "自费"
  5099. bytesData, _ := json.Marshal(memo)
  5100. fsiOPFLD.Memo = string(bytesData)
  5101. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  5102. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  5103. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  5104. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  5105. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  5106. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  5107. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  5108. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  5109. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  5110. fsiOPFLD.BilgDeptName = department.Name
  5111. fsiOPFLD.BilgDeptCodg = department.Number
  5112. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  5113. fsiOPFLD.BilgDrName = doctor.UserName
  5114. switch items.HisPrescriptionProject.HisProject.CostClassify {
  5115. case 0:
  5116. break
  5117. case 1:
  5118. fsiOPFLD.MedChrgitmType = "14"
  5119. break
  5120. case 2:
  5121. fsiOPFLD.MedChrgitmType = "05"
  5122. break
  5123. case 3:
  5124. fsiOPFLD.MedChrgitmType = "03"
  5125. break
  5126. case 4:
  5127. fsiOPFLD.MedChrgitmType = "03"
  5128. break
  5129. case 5:
  5130. fsiOPFLD.MedChrgitmType = "08"
  5131. break
  5132. case 6:
  5133. fsiOPFLD.MedChrgitmType = "14"
  5134. break
  5135. case 7:
  5136. fsiOPFLD.MedChrgitmType = "14"
  5137. break
  5138. case 8:
  5139. fsiOPFLD.MedChrgitmType = "03"
  5140. break
  5141. case 9:
  5142. fsiOPFLD.MedChrgitmType = "14"
  5143. break
  5144. case 10:
  5145. fsiOPFLD.MedChrgitmType = "14"
  5146. break
  5147. case 11:
  5148. fsiOPFLD.MedChrgitmType = "06"
  5149. break
  5150. case 12:
  5151. fsiOPFLD.MedChrgitmType = "12"
  5152. break
  5153. case 13:
  5154. fsiOPFLD.MedChrgitmType = "01"
  5155. break
  5156. case 14:
  5157. fsiOPFLD.MedChrgitmType = "04"
  5158. break
  5159. case 15:
  5160. fsiOPFLD.MedChrgitmType = "14"
  5161. break
  5162. }
  5163. memo["hosp_appr_flag"] = "1"
  5164. memo["invoice_no"] = fapiao_code
  5165. memo["memo"] = "自费"
  5166. bytesData, _ := json.Marshal(memo)
  5167. fsiOPFLD.Memo = string(bytesData)
  5168. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  5169. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  5170. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  5171. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  5172. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  5173. fsiOPFLD.BilgDeptName = department.Name
  5174. fsiOPFLD.BilgDeptCodg = department.Number
  5175. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  5176. fsiOPFLD.BilgDrName = doctor.UserName
  5177. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  5178. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  5179. fsiOPFLD.MedChrgitmType = "08"
  5180. memo["hosp_appr_flag"] = "1"
  5181. memo["invoice_no"] = fapiao_code
  5182. memo["memo"] = "自费"
  5183. bytesData, _ := json.Marshal(memo)
  5184. fsiOPFLD.Memo = string(bytesData)
  5185. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  5186. }
  5187. }
  5188. }
  5189. fmt.Println(fsiOPFLDs)
  5190. struct4201A.Fopfd = fsiOPFLDs
  5191. fmt.Println(struct4201A.Fopfd)
  5192. var struct4202 models.Struct4202
  5193. timeLayout := "2006-01-02 15:04:05"
  5194. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  5195. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  5196. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  5197. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  5198. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  5199. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  5200. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  5201. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  5202. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  5203. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  5204. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5205. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5206. var config []*models.HisXtDiagnoseConfig
  5207. for _, item := range diagnosis_ids {
  5208. id, _ := strconv.ParseInt(item, 10, 64)
  5209. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5210. config = append(config, &diagnosisConfig)
  5211. }
  5212. var tempDiaginfos []models.OwnPayPatnDiagListD
  5213. for index, item := range config {
  5214. if index == 0 {
  5215. var tempDiaginfo models.OwnPayPatnDiagListD
  5216. tempDiaginfo.InoutDiagType = "1"
  5217. tempDiaginfo.DiagCode = item.CountryCode
  5218. tempDiaginfo.DiagName = item.CountryContentName
  5219. tempDiaginfo.DiagType = "1"
  5220. tempDiaginfo.DiagSrtNo = "1"
  5221. tempDiaginfo.MaindiagFlag = "1"
  5222. tempDiaginfo.ValiFlag = "1"
  5223. tempDiaginfo.DiagDrName = doctor.UserName
  5224. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  5225. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  5226. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5227. } else {
  5228. var tempDiaginfo models.OwnPayPatnDiagListD
  5229. tempDiaginfo.DiagCode = item.CountryCode
  5230. tempDiaginfo.DiagName = item.CountryContentName
  5231. tempDiaginfo.DiagType = "2"
  5232. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  5233. tempDiaginfo.MaindiagFlag = "0"
  5234. tempDiaginfo.ValiFlag = "1"
  5235. tempDiaginfo.DiagDrName = doctor.UserName
  5236. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  5237. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  5238. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5239. }
  5240. }
  5241. struct4202.ODiagListD = tempDiaginfos
  5242. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  5243. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  5244. var res2 ResultSix
  5245. var respJSON2 map[string]interface{}
  5246. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5249. return
  5250. }
  5251. userJSONBytes2, _ := json.Marshal(respJSON2)
  5252. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5253. utils.ErrorLog("解析失败:%v", err)
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5255. return
  5256. }
  5257. if res2.Infcode != 0 {
  5258. c.ServeSuccessJSON(map[string]interface{}{
  5259. "failed_code": -10,
  5260. "msg": res2.ErrMsg,
  5261. })
  5262. return
  5263. } else {
  5264. order.IsUploadDiagnose = 1
  5265. order.IsUploadOrderInfo = 1
  5266. service.UpdateOrderTwo(order)
  5267. c.ServeSuccessJSON(map[string]interface{}{
  5268. "msg": "上传成功",
  5269. })
  5270. }
  5271. }
  5272. func (c *HisApiController) Get4207() {
  5273. admin_user_id, _ := c.GetInt64("admin_user_id")
  5274. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5275. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5276. order_id, _ := c.GetInt64("order_id")
  5277. order, _ := service.GetHisOrderByIDTwo(order_id)
  5278. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5279. var struct4207 models.Struct4207
  5280. struct4207.PageNum = "1"
  5281. struct4207.PageSize = "1000"
  5282. struct4207.FixmedinsCode = miConfig.Code
  5283. struct4207.FixmedinsMdtrtID = order.Number
  5284. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  5285. saveLog(result, requestLog, "4207", "查询")
  5286. var res2 ResultSix
  5287. var respJSON2 map[string]interface{}
  5288. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5291. return
  5292. }
  5293. userJSONBytes2, _ := json.Marshal(respJSON2)
  5294. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5295. utils.ErrorLog("解析失败:%v", err)
  5296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5297. return
  5298. }
  5299. if res2.Infcode != 0 {
  5300. c.ServeSuccessJSON(map[string]interface{}{
  5301. "failed_code": -10,
  5302. "msg": res2.ErrMsg,
  5303. })
  5304. return
  5305. } else {
  5306. c.ServeSuccessJSON(map[string]interface{}{
  5307. "msg": "查询成功",
  5308. })
  5309. }
  5310. }
  5311. func (c *HisApiController) Get4208() {
  5312. admin_user_id, _ := c.GetInt64("admin_user_id")
  5313. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5314. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5315. order_id, _ := c.GetInt64("order_id")
  5316. order, _ := service.GetHisOrderByIDTwo(order_id)
  5317. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5318. var struct4208 models.Struct4208
  5319. struct4208.PageNum = "1"
  5320. struct4208.PageSize = "1000"
  5321. struct4208.PsnCertType = "01"
  5322. struct4208.Certno = his.Certno
  5323. struct4208.MedType = order.MedType
  5324. struct4208.PsnName = his.Name
  5325. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  5326. saveLog(result, requestLog, "4208", "查询")
  5327. var res2 ResultSix
  5328. var respJSON2 map[string]interface{}
  5329. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5332. return
  5333. }
  5334. userJSONBytes2, _ := json.Marshal(respJSON2)
  5335. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5336. utils.ErrorLog("解析失败:%v", err)
  5337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5338. return
  5339. }
  5340. if res2.Infcode != 0 {
  5341. c.ServeSuccessJSON(map[string]interface{}{
  5342. "failed_code": -10,
  5343. "msg": res2.ErrMsg,
  5344. })
  5345. return
  5346. } else {
  5347. c.ServeSuccessJSON(map[string]interface{}{
  5348. "msg": "查询成功",
  5349. })
  5350. }
  5351. }
  5352. func (c *HisApiController) Get4209() {
  5353. admin_user_id, _ := c.GetInt64("admin_user_id")
  5354. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5355. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5356. order_id, _ := c.GetInt64("order_id")
  5357. order, _ := service.GetHisOrderByIDTwo(order_id)
  5358. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5359. var struct4209 models.Struct4209
  5360. struct4209.FixmedinsMdtrtID = order.Number
  5361. struct4209.FixmedinsCode = miConfig.Code
  5362. struct4209.PageSize = "1000"
  5363. struct4209.PageNum = "1"
  5364. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  5365. saveLog(result, requestLog, "4209", "查询")
  5366. var res2 ResultSix
  5367. var respJSON2 map[string]interface{}
  5368. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5371. return
  5372. }
  5373. userJSONBytes2, _ := json.Marshal(respJSON2)
  5374. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5375. utils.ErrorLog("解析失败:%v", err)
  5376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5377. return
  5378. }
  5379. if res2.Infcode != 0 {
  5380. c.ServeSuccessJSON(map[string]interface{}{
  5381. "failed_code": -10,
  5382. "msg": res2.ErrMsg,
  5383. })
  5384. return
  5385. } else {
  5386. c.ServeSuccessJSON(map[string]interface{}{
  5387. "msg": "查询成功",
  5388. })
  5389. }
  5390. }
  5391. type Result3101 struct {
  5392. Infcode string `json:"infcode"`
  5393. InfRefmsgid string `json:"inf_refmsgid"`
  5394. RefmsgTime string `json:"refmsg_time"`
  5395. RespondTime string `json:"respond_time"`
  5396. Enctype string `json:"enctype"`
  5397. Signtype string `json:"signtype"`
  5398. ErrMsg string `json:"err_msg"`
  5399. Output struct {
  5400. Result []struct {
  5401. JudgeResultDetailDtos []struct {
  5402. VolaItemType string `json:"vola_item_type"`
  5403. MdtrtID string `json:"mdtrt_id"`
  5404. JrdID string `json:"jrd_id"`
  5405. PatnID string `json:"patn_id"`
  5406. RxID string `json:"rx_id"`
  5407. VolaAmt interface{} `json:"vola_amt"`
  5408. } `json:"judge_result_detail_dtos"`
  5409. RuleID string `json:"rule_id"`
  5410. VolaEvid string `json:"vola_evid"`
  5411. MdtrtID string `json:"mdtrt_id"`
  5412. RuleName string `json:"rule_name"`
  5413. VolaAmtStas string `json:"vola_amt_stas"`
  5414. JrID string `json:"jr_id"`
  5415. PatnID string `json:"patn_id"`
  5416. SevDeg string `json:"sev_deg"`
  5417. VolaAmt float64 `json:"vola_amt"`
  5418. VolaBhvrType string `json:"vola_bhvr_type"`
  5419. VolaCont string `json:"vola_cont"`
  5420. } `json:"result"`
  5421. } `json:"output"`
  5422. }
  5423. type Resultgd3101 struct {
  5424. Infcode int64 `json:"infcode"`
  5425. InfRefmsgid string `json:"inf_refmsgid"`
  5426. RefmsgTime string `json:"refmsg_time"`
  5427. RespondTime string `json:"respond_time"`
  5428. Enctype string `json:"enctype"`
  5429. Signtype string `json:"signtype"`
  5430. ErrMsg string `json:"err_msg"`
  5431. Output struct {
  5432. Result []struct {
  5433. JudgeResultDetailDtos []struct {
  5434. VolaItemType string `json:"vola_item_type"`
  5435. MdtrtID string `json:"mdtrt_id"`
  5436. JrdID string `json:"jrd_id"`
  5437. PatnID string `json:"patn_id"`
  5438. RxID string `json:"rx_id"`
  5439. VolaAmt interface{} `json:"vola_amt"`
  5440. } `json:"judge_result_detail_dtos"`
  5441. RuleID string `json:"rule_id"`
  5442. VolaEvid string `json:"vola_evid"`
  5443. MdtrtID string `json:"mdtrt_id"`
  5444. RuleName string `json:"rule_name"`
  5445. VolaAmtStas string `json:"vola_amt_stas"`
  5446. JrID string `json:"jr_id"`
  5447. PatnID string `json:"patn_id"`
  5448. SevDeg string `json:"sev_deg"`
  5449. VolaAmt float64 `json:"vola_amt"`
  5450. VolaBhvrType string `json:"vola_bhvr_type"`
  5451. VolaCont string `json:"vola_cont"`
  5452. } `json:"result"`
  5453. } `json:"output"`
  5454. }
  5455. func (c *HisApiController) ReadEleToken() {
  5456. admin_user_id, _ := c.GetInt64("admin_user_id")
  5457. his_patient_id, _ := c.GetInt64("his_patient_id")
  5458. adminUser := c.GetAdminUserInfo()
  5459. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5460. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5461. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5462. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5463. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  5464. if len(tokens) > 0 {
  5465. c.ServeSuccessJSON(map[string]interface{}{
  5466. "msg": "读取成功",
  5467. })
  5468. } else {
  5469. c.ServeSuccessJSON(map[string]interface{}{
  5470. "failed_code": -10,
  5471. "msg": "读取失败",
  5472. })
  5473. }
  5474. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5475. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  5476. if len(tokens) > 0 {
  5477. c.ServeSuccessJSON(map[string]interface{}{
  5478. "msg": "读取成功",
  5479. })
  5480. } else {
  5481. c.ServeSuccessJSON(map[string]interface{}{
  5482. "failed_code": -10,
  5483. "msg": "读取失败",
  5484. })
  5485. }
  5486. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5487. var api string
  5488. 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 +
  5489. "&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"
  5490. resp, requestErr := http.Get(api)
  5491. if requestErr != nil {
  5492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5493. }
  5494. body, ioErr := ioutil.ReadAll(resp.Body)
  5495. if ioErr != nil {
  5496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5498. }
  5499. var respJSON map[string]interface{}
  5500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5503. return
  5504. }
  5505. var status string
  5506. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5507. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5508. var token string
  5509. var res ResultTwo //1101结果
  5510. var res10265 ResultTwo10265 //1101结果
  5511. if status == "0" { //读卡成功
  5512. var card_info string //卡信息
  5513. var busi_card_info string
  5514. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5515. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5516. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5517. fmt.Println(card_info)
  5518. fmt.Println(busi_card_info)
  5519. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5520. result, _ := json.Marshal(respJSON)
  5521. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5522. utils.ErrorLog("解析失败:%v", err)
  5523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5524. return
  5525. }
  5526. res.ErrMsg = res10265.ErrMsg
  5527. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5528. res.Infcode = infocode
  5529. res.Output = res10265.Output
  5530. res.InfRefmsgid = res10265.InfRefmsgid
  5531. if res.Infcode == 0 {
  5532. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5533. if err == gorm.ErrRecordNotFound {
  5534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5535. return
  5536. } else if err != nil {
  5537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5538. return
  5539. } else {
  5540. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5541. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5542. infoStr := string(Iinfos)
  5543. idetinfoStr := string(Idetinfos)
  5544. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  5545. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  5546. psn := &models.HisPsn{
  5547. PsnNo: res.Output.Baseinfo.PsnNo,
  5548. PatientId: patient.ID,
  5549. Certno: res.Output.Baseinfo.Certno,
  5550. Gend: res.Output.Baseinfo.Gend,
  5551. Naty: res.Output.Baseinfo.Naty,
  5552. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5553. PsnName: res.Output.Baseinfo.PsnName,
  5554. Age: float64(age),
  5555. Brdy: b,
  5556. Idetinfo: idetinfoStr,
  5557. Insuinfo: infoStr,
  5558. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5559. CardInfo: card_info,
  5560. VerifyNumber: token,
  5561. IdCardType: 4,
  5562. }
  5563. var rf []*ResultFive
  5564. json.Unmarshal([]byte(infoStr), &rf)
  5565. var insutypes []*ResultFive
  5566. var insutype string
  5567. var is390 int = 0
  5568. var is310 int = 0
  5569. for _, item := range rf {
  5570. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5571. insutypes = append(insutypes, item)
  5572. }
  5573. }
  5574. if len(insutypes) == 1 {
  5575. insutype = insutypes[0].Insutype
  5576. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5577. } else {
  5578. for _, i := range insutypes {
  5579. if i.Insutype == "390" {
  5580. is390 = 1
  5581. }
  5582. if i.Insutype == "310" {
  5583. is310 = 1
  5584. }
  5585. }
  5586. }
  5587. if is390 == 1 {
  5588. insutype = "390"
  5589. }
  5590. if is310 == 1 {
  5591. insutype = "310"
  5592. }
  5593. if len(insutypes) == 0 {
  5594. insutype = "310"
  5595. }
  5596. service.CreateHisPsn(psn)
  5597. c.ServeSuccessJSON(map[string]interface{}{
  5598. "patient": patient,
  5599. "number": token,
  5600. "insutype": insutype,
  5601. })
  5602. }
  5603. } else {
  5604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5605. return
  5606. }
  5607. } else { //读卡失败
  5608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5609. return
  5610. }
  5611. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5612. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  5613. if len(errMsg) == 0 {
  5614. type ELeData struct {
  5615. Data struct {
  5616. IdNo string `json:"idNo"`
  5617. IdType string `json:"idType"`
  5618. UserName string `json:"userName"`
  5619. EcToken string `json:"ecToken"`
  5620. InsuOrg string `json:"insuOrg"`
  5621. Gender string `json:"gender"`
  5622. Birthday string `json:"birthday"`
  5623. Nationality string `json:"nationality"`
  5624. Email string `json:"email"`
  5625. Extra string `json:"extra"`
  5626. } `json:"data"`
  5627. Code int `json:"code"`
  5628. Message string `json:"message"`
  5629. }
  5630. var ele ELeData
  5631. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5632. if err != nil {
  5633. utils.ErrorLog("解析失败:%v", err)
  5634. }
  5635. token := ele.Data.EcToken
  5636. if len(token) > 0 {
  5637. psn := &models.HisPsn{
  5638. PsnNo: his.PsnNo,
  5639. Age: 0,
  5640. PatientId: his.PatientId,
  5641. Certno: his.Certno,
  5642. Brdy: his.Brdy,
  5643. Gend: his.Gend,
  5644. Naty: his.Naty,
  5645. PsnCertType: his.PsnCertType,
  5646. PsnName: his.PsnName,
  5647. Idetinfo: his.Idetinfo,
  5648. Insuinfo: his.Iinfo,
  5649. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5650. CardInfo: outPutInfo,
  5651. VerifyNumber: token,
  5652. }
  5653. service.CreateHisPsn(psn)
  5654. }
  5655. if len(token) > 0 {
  5656. c.ServeSuccessJSON(map[string]interface{}{
  5657. "msg": "读取成功",
  5658. })
  5659. } else {
  5660. c.ServeSuccessJSON(map[string]interface{}{
  5661. "failed_code": -10,
  5662. "msg": "读取失败",
  5663. })
  5664. }
  5665. }
  5666. } else if miConfig.MdtrtareaAdmvs == "360302" {
  5667. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  5668. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  5669. type ELeData struct {
  5670. Data struct {
  5671. IdNo string `json:"idNo"`
  5672. IdType string `json:"idType"`
  5673. UserName string `json:"userName"`
  5674. EcToken string `json:"ecToken"`
  5675. InsuOrg string `json:"insuOrg"`
  5676. Gender string `json:"gender"`
  5677. Birthday string `json:"birthday"`
  5678. Nationality string `json:"nationality"`
  5679. Email string `json:"email"`
  5680. Extra string `json:"extra"`
  5681. } `json:"data"`
  5682. Code int `json:"code"`
  5683. Message string `json:"message"`
  5684. }
  5685. var ele ELeData
  5686. err := json.Unmarshal([]byte(result), &ele)
  5687. if err != nil {
  5688. utils.ErrorLog("解析失败:%v", err)
  5689. }
  5690. token := ele.Data.EcToken
  5691. token = Remove0000(token)
  5692. fmt.Println(ele.Data.UserName)
  5693. 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)
  5694. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5695. var res ResultTwo
  5696. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5697. utils.ErrorLog("解析失败:%v", err)
  5698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5699. return
  5700. }
  5701. if res.Infcode == 0 {
  5702. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5703. if err == gorm.ErrRecordNotFound {
  5704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5705. return
  5706. } else if err != nil {
  5707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5708. return
  5709. } else {
  5710. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5711. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5712. infoStr := string(Iinfos)
  5713. idetinfoStr := string(Idetinfos)
  5714. psn := &models.HisPsn{
  5715. PsnNo: res.Output.Baseinfo.PsnNo,
  5716. PatientId: patient.ID,
  5717. Certno: res.Output.Baseinfo.Certno,
  5718. Gend: res.Output.Baseinfo.Gend,
  5719. Naty: res.Output.Baseinfo.Naty,
  5720. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5721. PsnName: res.Output.Baseinfo.PsnName,
  5722. Idetinfo: idetinfoStr,
  5723. Insuinfo: infoStr,
  5724. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5725. CardInfo: "",
  5726. VerifyNumber: token,
  5727. }
  5728. service.CreateHisPsn(psn)
  5729. c.ServeSuccessJSON(map[string]interface{}{
  5730. "patient": patient,
  5731. "number": token,
  5732. })
  5733. }
  5734. } else {
  5735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5736. return
  5737. }
  5738. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5739. idNo := c.GetString("idNo")
  5740. userName := c.GetString("userName")
  5741. ecToken := c.GetString("ecToken")
  5742. insuOrg := c.GetString("insuOrg")
  5743. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  5744. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5745. var res ResultTwo
  5746. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5747. utils.ErrorLog("解析失败:%v", err)
  5748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5749. return
  5750. }
  5751. if res.Infcode == 0 {
  5752. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5753. if err == gorm.ErrRecordNotFound {
  5754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5755. return
  5756. } else if err != nil {
  5757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5758. return
  5759. } else {
  5760. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5761. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5762. infoStr := string(Iinfos)
  5763. idetinfoStr := string(Idetinfos)
  5764. psn := &models.HisPsn{
  5765. PsnNo: res.Output.Baseinfo.PsnNo,
  5766. PatientId: patient.ID,
  5767. Certno: res.Output.Baseinfo.Certno,
  5768. Gend: res.Output.Baseinfo.Gend,
  5769. Naty: res.Output.Baseinfo.Naty,
  5770. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5771. PsnName: res.Output.Baseinfo.PsnName,
  5772. Idetinfo: idetinfoStr,
  5773. Insuinfo: infoStr,
  5774. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5775. CardInfo: "",
  5776. VerifyNumber: ecToken,
  5777. InsuplcAdmdvs: insuOrg,
  5778. }
  5779. service.CreateHisPsn(psn)
  5780. c.ServeSuccessJSON(map[string]interface{}{
  5781. "patient": patient,
  5782. "number": ecToken,
  5783. })
  5784. }
  5785. } else {
  5786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5787. return
  5788. }
  5789. } else if miConfig.MdtrtareaAdmvs == "450721" {
  5790. res := c.GetoleInfo()
  5791. if res.Infcode == 0 {
  5792. var result string
  5793. if res.Output.MdtrtCertType == "01" {
  5794. 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)
  5795. } else if res.Output.MdtrtCertType == "02" {
  5796. 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)
  5797. } else if res.Output.MdtrtCertType == "03" {
  5798. 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)
  5799. }
  5800. var dat map[string]interface{}
  5801. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5802. fmt.Println(dat)
  5803. } else {
  5804. fmt.Println(err)
  5805. }
  5806. userJSONBytes, _ := json.Marshal(dat)
  5807. var res2 ResultTwo
  5808. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5809. utils.ErrorLog("解析失败:%v", err)
  5810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5811. return
  5812. }
  5813. if res2.Infcode == 0 {
  5814. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  5815. if err == gorm.ErrRecordNotFound {
  5816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5817. return
  5818. } else if err != nil {
  5819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5820. return
  5821. } else {
  5822. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  5823. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  5824. infoStr := string(Iinfos)
  5825. idetinfoStr := string(Idetinfos)
  5826. var rf []*ResultFive
  5827. json.Unmarshal([]byte(infoStr), &rf)
  5828. var insutypes []*ResultFive
  5829. var insutype string
  5830. var is390 int = 0
  5831. var is310 int = 0
  5832. //var insuplc_admdvs string
  5833. for _, item := range rf {
  5834. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5835. insutypes = append(insutypes, item)
  5836. }
  5837. }
  5838. if len(insutypes) == 1 {
  5839. insutype = insutypes[0].Insutype
  5840. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5841. } else {
  5842. for _, i := range insutypes {
  5843. if i.Insutype == "390" {
  5844. is390 = 1
  5845. }
  5846. if i.Insutype == "310" {
  5847. is310 = 1
  5848. }
  5849. }
  5850. }
  5851. if is390 == 1 {
  5852. insutype = "390"
  5853. }
  5854. if is310 == 1 {
  5855. insutype = "310"
  5856. }
  5857. if len(insutypes) == 0 {
  5858. insutype = "310"
  5859. }
  5860. psn := &models.HisPsn{
  5861. PsnNo: res2.Output.Baseinfo.PsnNo,
  5862. PatientId: patient.ID,
  5863. Certno: res2.Output.Baseinfo.Certno,
  5864. Gend: res2.Output.Baseinfo.Gend,
  5865. Naty: res2.Output.Baseinfo.Naty,
  5866. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  5867. PsnName: res2.Output.Baseinfo.PsnName,
  5868. Idetinfo: idetinfoStr,
  5869. Insuinfo: infoStr,
  5870. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5871. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  5872. VerifyNumber: res.Output.EcToken,
  5873. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  5874. }
  5875. service.CreateHisPsn(psn)
  5876. c.ServeSuccessJSON(map[string]interface{}{
  5877. "patient": patient,
  5878. "number": res.Output.CardNo,
  5879. "insutype": insutype,
  5880. })
  5881. }
  5882. } else {
  5883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5884. return
  5885. }
  5886. } else {
  5887. c.ServeSuccessJSON(map[string]interface{}{
  5888. "failed_code": -10,
  5889. "msg": res.ErrMsg,
  5890. })
  5891. }
  5892. } else {
  5893. //if initFlag == 0 {
  5894. // c.TestGetBasBaseInit()
  5895. //}
  5896. //token := c.GetEleBaseInfo()
  5897. //token = Remove0000(token)
  5898. type ELeData struct {
  5899. Code string `json:"code"`
  5900. Data struct {
  5901. Aac002 string `json:"aac002"`
  5902. Aaz500 string `json:"aaz500"`
  5903. ActCardNo string `json:"actCardNo"`
  5904. Bab520 string `json:"bab520"`
  5905. Bkz543 string `json:"bkz543"`
  5906. BusinessType string `json:"businessType"`
  5907. CertfCodg string `json:"certfCodg"`
  5908. EcIndexNo string `json:"ecIndexNo"`
  5909. EcToken string `json:"ecToken"`
  5910. ID0000 string `json:"id0000"`
  5911. IDNo string `json:"idNo"`
  5912. IDType string `json:"idType"`
  5913. Idcode string `json:"idcode"`
  5914. IdentityToken string `json:"identity_token"`
  5915. InsuOrg string `json:"insuOrg"`
  5916. OfficeID string `json:"officeId"`
  5917. OfficeName string `json:"officeName"`
  5918. OperatorID string `json:"operatorId"`
  5919. OperatorName string `json:"operatorName"`
  5920. OrgID string `json:"orgId"`
  5921. UserName string `json:"userName"`
  5922. } `json:"data"`
  5923. Infno interface{} `json:"infno"`
  5924. Message string `json:"message"`
  5925. OrgID string `json:"orgId"`
  5926. TransType string `json:"transType"`
  5927. }
  5928. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  5929. fmt.Println(result)
  5930. outPutInfo := Remove0000(result)
  5931. fmt.Println(outPutInfo)
  5932. var ele ELeData
  5933. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5934. if err != nil {
  5935. utils.ErrorLog("解析失败:%v", err)
  5936. }
  5937. token := ele.Data.EcToken
  5938. var result2 string
  5939. var requestLog2 string
  5940. if len(token) > 0 {
  5941. if strings.Contains(ele.Data.IDNo, "HKG") {
  5942. 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)
  5943. } else {
  5944. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5945. }
  5946. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5947. var res ResultTwo
  5948. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5949. utils.ErrorLog("解析失败:%v", err)
  5950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5951. return
  5952. }
  5953. if res.Infcode == 0 {
  5954. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5955. if err == gorm.ErrRecordNotFound {
  5956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5957. return
  5958. } else if err != nil {
  5959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5960. return
  5961. } else {
  5962. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5963. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5964. infoStr := string(Iinfos)
  5965. idetinfoStr := string(Idetinfos)
  5966. psn := &models.HisPsn{
  5967. PsnNo: res.Output.Baseinfo.PsnNo,
  5968. PatientId: patient.ID,
  5969. Certno: res.Output.Baseinfo.Certno,
  5970. Gend: res.Output.Baseinfo.Gend,
  5971. Naty: res.Output.Baseinfo.Naty,
  5972. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5973. PsnName: res.Output.Baseinfo.PsnName,
  5974. Idetinfo: idetinfoStr,
  5975. Insuinfo: infoStr,
  5976. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5977. CardInfo: "",
  5978. VerifyNumber: token,
  5979. }
  5980. service.CreateHisPsn(psn)
  5981. c.ServeSuccessJSON(map[string]interface{}{
  5982. "msg": "读取成功",
  5983. })
  5984. }
  5985. } else {
  5986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5987. return
  5988. }
  5989. } else {
  5990. c.ServeSuccessJSON(map[string]interface{}{
  5991. "failed_code": -10,
  5992. "msg": "读取失败",
  5993. })
  5994. }
  5995. }
  5996. }
  5997. func (c *HisApiController) ReadEleFace() {
  5998. admin_user_id, _ := c.GetInt64("admin_user_id")
  5999. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6000. adminUser := c.GetAdminUserInfo()
  6001. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6002. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6003. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6004. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6005. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  6006. if len(tokens) > 0 {
  6007. c.ServeSuccessJSON(map[string]interface{}{
  6008. "msg": "读取成功",
  6009. })
  6010. } else {
  6011. c.ServeSuccessJSON(map[string]interface{}{
  6012. "failed_code": -10,
  6013. "msg": "读取失败",
  6014. })
  6015. }
  6016. }
  6017. }
  6018. func (c *HisApiController) Get9001() {
  6019. adminUser := c.GetAdminUserInfo()
  6020. admin_user_id, _ := c.GetInt64("admin_user_id")
  6021. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6022. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6023. if miConfig.MdtrtareaAdmvs == "350500" {
  6024. service.GetFjAuthorizationInfo(miConfig.Code)
  6025. } else if miConfig.MdtrtareaAdmvs == "131023" {
  6026. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  6027. var dat map[string]interface{}
  6028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6029. fmt.Println(dat)
  6030. } else {
  6031. fmt.Println(err)
  6032. }
  6033. userJSONBytes, _ := json.Marshal(dat)
  6034. var res models.Result9001
  6035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6036. utils.ErrorLog("解析失败:%v", err)
  6037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6038. return
  6039. }
  6040. } else if miConfig.MdtrtareaAdmvs == "341203" {
  6041. fmt.Println(miConfig.SecretKey)
  6042. var res models.Result9001Two
  6043. 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 +
  6044. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  6045. resp, requestErr := http.Get(api)
  6046. if requestErr != nil {
  6047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6048. return
  6049. }
  6050. body, ioErr := ioutil.ReadAll(resp.Body)
  6051. if ioErr != nil {
  6052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6054. return
  6055. }
  6056. var respJSON map[string]interface{}
  6057. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6060. return
  6061. }
  6062. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6063. if status == "0" {
  6064. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6065. c.ServeSuccessJSON(map[string]interface{}{
  6066. "failed_code": -10,
  6067. "msg": err_msg,
  6068. })
  6069. return
  6070. }
  6071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6072. result, _ := json.Marshal(respJSON)
  6073. fmt.Println("log")
  6074. fmt.Println(string(result))
  6075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6076. utils.ErrorLog("解析失败:%v", err)
  6077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6078. return
  6079. }
  6080. if res.Infcode == 0 {
  6081. sign := models.HisSignIn{
  6082. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6083. SignNo: res.Output.Signinoutb.SignNo,
  6084. SignTime: "",
  6085. Ctime: time.Now().Unix(),
  6086. Mtime: time.Now().Unix(),
  6087. Status: 1,
  6088. InputLog: "",
  6089. OutputLog: "",
  6090. FixmedinsCode: miConfig.Code,
  6091. }
  6092. err := service.CreateSignIn(&sign)
  6093. if err == nil {
  6094. c.ServeSuccessJSON(map[string]interface{}{
  6095. "msg": "签到成功",
  6096. })
  6097. }
  6098. } else {
  6099. c.ServeSuccessJSON(map[string]interface{}{
  6100. "failed_code": -10,
  6101. "msg": res.ErrMsg,
  6102. })
  6103. return
  6104. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6105. //return
  6106. }
  6107. } else {
  6108. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6109. var dat map[string]interface{}
  6110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6111. fmt.Println(dat)
  6112. } else {
  6113. fmt.Println(err)
  6114. }
  6115. userJSONBytes, _ := json.Marshal(dat)
  6116. var res models.Result9001
  6117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6118. utils.ErrorLog("解析失败:%v", err)
  6119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6120. return
  6121. }
  6122. if res.Infcode == 0 {
  6123. sign := models.HisSignIn{
  6124. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6125. SignNo: res.Output.Signinoutb.SignNo,
  6126. SignTime: res.Output.Signinoutb.SignTime,
  6127. Ctime: time.Now().Unix(),
  6128. Mtime: time.Now().Unix(),
  6129. Status: 1,
  6130. InputLog: "",
  6131. OutputLog: "",
  6132. FixmedinsCode: miConfig.Code,
  6133. }
  6134. err := service.CreateSignIn(&sign)
  6135. if err == nil {
  6136. c.ServeSuccessJSON(map[string]interface{}{
  6137. "msg": "签到成功",
  6138. })
  6139. }
  6140. }
  6141. }
  6142. }
  6143. 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) {
  6144. var res Result3101
  6145. adminUser := c.GetAdminUserInfo()
  6146. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6147. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6148. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6149. //record_time := c.GetString("record_time")
  6150. //trig_scen := c.GetString("trig_scen")
  6151. timeLayout := "2006-01-02"
  6152. loc, _ := time.LoadLocation("Local")
  6153. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6154. if err != nil {
  6155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6156. return res
  6157. }
  6158. recordDateTime := theTime.Unix()
  6159. var patientPrescription models.HisPrescriptionInfo
  6160. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6161. //if patientPrescription.ID == 0 {
  6162. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6163. //}
  6164. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6165. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6166. //
  6167. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6168. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6169. var pp models.PublicParams
  6170. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6171. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6172. pp.FixmedinsName = miConfig.OrgName
  6173. pp.FixmedinsCode = miConfig.Code
  6174. pp.RequestUrl = miConfig.Url
  6175. pp.Cainfo = miConfig.Cainfo
  6176. pp.SecretKey = miConfig.SecretKey
  6177. pp.AccessKey = miConfig.AccessKey
  6178. pp.OpterName = roles.UserName
  6179. var config []*models.HisXtDiagnoseConfig
  6180. for _, item := range diagnosis_ids {
  6181. id, _ := strconv.ParseInt(item, 10, 64)
  6182. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6183. config = append(config, &diagnosisConfig)
  6184. }
  6185. var pd models.PatientDtos
  6186. pd.PatnID = his.PsnNo
  6187. pd.PatnName = his.Name
  6188. pd.Gend = his.Gend
  6189. pd.Brdy = his.Brdy
  6190. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6191. pd.CurrMdtrtID = his.Number
  6192. var fed models.FsiEncounterDtos
  6193. fed.MdtrtID = his.Number
  6194. fed.MedinsID = miConfig.Code
  6195. fed.MedinsName = miConfig.OrgName
  6196. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6197. fed.MedMdtrtType = "1"
  6198. fed.MedinsType = "1"
  6199. fed.MedinsLv = "11"
  6200. tm := time.Unix(his.RecordDate, 0)
  6201. s_tm := tm.Format("2006-01-02 15:04:05")
  6202. fed.AdmDate = s_tm
  6203. fed.DscgDate = s_tm
  6204. fed.DscgMainDiseCodg = config[0].CountryCode
  6205. fed.DscgMainDiseName = config[0].CountryContentName
  6206. //诊断信息
  6207. var fdds []*models.FsiDiagnoseDtos
  6208. for index, item := range config {
  6209. if index == 0 {
  6210. var fdd models.FsiDiagnoseDtos
  6211. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6212. fdd.InoutDiseType = "1"
  6213. fdd.MaindiseFlag = "1"
  6214. fdd.DiseDate = s_tm
  6215. fdd.DiasSrtNo = "1"
  6216. fdd.DiseName = item.CountryContentName
  6217. fdd.DiseCodg = item.CountryCode
  6218. fdds = append(fdds, &fdd)
  6219. } else {
  6220. var fdd models.FsiDiagnoseDtos
  6221. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6222. fdd.InoutDiseType = "1"
  6223. fdd.MaindiseFlag = "1"
  6224. fdd.DiseDate = s_tm
  6225. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6226. fdd.DiseName = item.CountryContentName
  6227. fdd.DiseCodg = item.CountryCode
  6228. fdds = append(fdds, &fdd)
  6229. }
  6230. }
  6231. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6232. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6233. fed.AdmDeptName = department.Name
  6234. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6235. fed.DscgDeptName = department.Name
  6236. fed.MedMdtrtType = "1"
  6237. fed.MedType = "11"
  6238. //if his.Insutype == "390" {
  6239. // fed.MedType = "1402"
  6240. //} else {
  6241. // fed.MedType = "9933"
  6242. //}
  6243. var orders []*models.FsiOrderDtos
  6244. if trig_scen == "2" {
  6245. //处方医嘱信息
  6246. for _, item := range prescriptions {
  6247. for _, subItem := range item.HisDoctorAdviceInfo {
  6248. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6249. var order models.FsiOrderDtos
  6250. order.RxID = strconv.FormatInt(item.ID, 10)
  6251. order.Rxno = strconv.FormatInt(item.ID, 10)
  6252. order.LongDrordFlag = "0"
  6253. order.HilistType = "1"
  6254. order.ChrgType = "1"
  6255. order.DrordBhvr = "-"
  6256. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6257. order.HosplistName = subItem.BaseDrugLib.DrugName
  6258. order.HilistLv = "1"
  6259. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6260. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6261. order.HosplistName = subItem.BaseDrugLib.DrugName
  6262. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6263. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6264. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6265. order.OwnpayAmt = ""
  6266. order.SelfpayAmt = ""
  6267. order.Spec = ""
  6268. order.SpecUnt = ""
  6269. order.DrordBegnDate = s_tm
  6270. order.DrordStopDate = ""
  6271. order.DrordDrCodg = doctor_info.DoctorNumber
  6272. order.DrordDeptName = department.Name
  6273. order.DrordDeptCodg = department.Number
  6274. order.DrordDrName = doctor_info.UserName
  6275. order.DrordDrProfttl = "234"
  6276. order.CurrDrordFlag = "1"
  6277. orders = append(orders, &order)
  6278. }
  6279. }
  6280. for _, subItem := range item.HisPrescriptionProject {
  6281. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6282. var order models.FsiOrderDtos
  6283. order.RxID = strconv.FormatInt(item.ID, 10)
  6284. order.Rxno = strconv.FormatInt(item.ID, 10)
  6285. order.LongDrordFlag = "0"
  6286. order.HilistType = "1"
  6287. order.ChrgType = "1"
  6288. order.DrordBhvr = "-"
  6289. order.HilistCode = subItem.HisProject.MedicalCode
  6290. order.HosplistName = subItem.HisProject.ProjectName
  6291. order.HilistLv = "1"
  6292. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6293. order.HosplistCode = subItem.HisProject.MedicalCode
  6294. order.HosplistName = subItem.HisProject.ProjectName
  6295. order.Cnt = subItem.Count
  6296. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6297. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6298. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6299. order.OwnpayAmt = ""
  6300. order.SelfpayAmt = ""
  6301. order.Spec = ""
  6302. order.SpecUnt = ""
  6303. order.DrordBegnDate = s_tm
  6304. order.DrordStopDate = ""
  6305. order.DrordDrCodg = doctor_info.DoctorNumber
  6306. order.DrordDeptName = department.Name
  6307. order.DrordDeptCodg = department.Number
  6308. order.DrordDrName = doctor_info.UserName
  6309. order.DrordDrProfttl = "234"
  6310. order.CurrDrordFlag = "1"
  6311. orders = append(orders, &order)
  6312. }
  6313. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6314. var order models.FsiOrderDtos
  6315. order.RxID = strconv.FormatInt(item.ID, 10)
  6316. order.Rxno = strconv.FormatInt(item.ID, 10)
  6317. order.LongDrordFlag = "0"
  6318. order.HilistType = "1"
  6319. order.ChrgType = "1"
  6320. order.DrordBhvr = "-"
  6321. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6322. order.HosplistName = subItem.GoodInfo.GoodName
  6323. order.HilistLv = "1"
  6324. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6325. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6326. order.HosplistName = subItem.GoodInfo.GoodName
  6327. order.Cnt = subItem.Count
  6328. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6329. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6330. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6331. order.OwnpayAmt = ""
  6332. order.SelfpayAmt = ""
  6333. order.Spec = ""
  6334. order.SpecUnt = ""
  6335. order.DrordBegnDate = s_tm
  6336. order.DrordStopDate = ""
  6337. order.DrordDrCodg = doctor_info.DoctorNumber
  6338. order.DrordDeptName = department.Name
  6339. order.DrordDeptCodg = department.Number
  6340. order.DrordDrName = doctor_info.UserName
  6341. order.DrordDrProfttl = "234"
  6342. order.CurrDrordFlag = "1"
  6343. orders = append(orders, &order)
  6344. }
  6345. }
  6346. }
  6347. //处方医嘱信息
  6348. }
  6349. fed.MatnStas = "0"
  6350. fed.MedfeeSumamt = "0"
  6351. fed.OwnpayAmt = "0"
  6352. fed.SelfpayAmt = "0"
  6353. fed.AcctPayamt = "0"
  6354. fed.MaAmt = "0"
  6355. fed.HifpPayamt = "0"
  6356. fed.SetlTotlnum = "1"
  6357. fed.Insutype = his.Insutype
  6358. fed.ReimFlag = "0"
  6359. fed.OutSetlFlag = "0"
  6360. var fopd []*models.FsiOperationDtosData
  6361. data := make(map[string]interface{})
  6362. data["fed"] = fed
  6363. data["fdd"] = fdds
  6364. data["fod"] = orders
  6365. data["pd"] = pd
  6366. data["pp"] = pp
  6367. data["fopd"] = fopd
  6368. data["trig_scen"] = trig_scen
  6369. fmt.Println(data)
  6370. fmt.Println(fed)
  6371. fmt.Println(fdds)
  6372. fmt.Println(orders)
  6373. fmt.Println(pd)
  6374. fmt.Println(pp)
  6375. fmt.Println(fopd)
  6376. client := &http.Client{}
  6377. bytesData, _ := json.Marshal(data)
  6378. var req *http.Request
  6379. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6380. if miConfig.MdtrtareaAdmvs == "320921" {
  6381. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6382. } else {
  6383. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6384. }
  6385. resp, _ := client.Do(req)
  6386. defer resp.Body.Close()
  6387. body, ioErr := ioutil.ReadAll(resp.Body)
  6388. if ioErr != nil {
  6389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6391. return res
  6392. }
  6393. var respJSON map[string]interface{}
  6394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6397. return res
  6398. }
  6399. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6400. fmt.Println(respJSON)
  6401. result, _ := json.Marshal(respJSON)
  6402. fmt.Println(result)
  6403. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6404. utils.ErrorLog("解析失败:%v", err)
  6405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6406. return res
  6407. }
  6408. return res
  6409. } else {
  6410. //if miConfig.MdtrtareaAdmvs == "441202" {
  6411. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6412. saveLog(output, input, "3101", "事前")
  6413. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6414. utils.ErrorLog("解析失败:%v", err)
  6415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6416. return
  6417. }
  6418. return res
  6419. //}
  6420. }
  6421. }
  6422. 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) {
  6423. adminUser := c.GetAdminUserInfo()
  6424. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6425. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6426. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6427. //record_time := c.GetString("record_time")
  6428. //trig_scen := c.GetString("trig_scen")
  6429. timeLayout := "2006-01-02"
  6430. loc, _ := time.LoadLocation("Local")
  6431. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6432. if err != nil {
  6433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6434. return res
  6435. }
  6436. recordDateTime := theTime.Unix()
  6437. var patientPrescription models.HisPrescriptionInfo
  6438. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6439. if patientPrescription.ID == 0 {
  6440. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6441. }
  6442. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6443. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6444. //
  6445. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6446. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6447. var pp models.PublicParams
  6448. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6449. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6450. pp.FixmedinsName = miConfig.OrgName
  6451. pp.FixmedinsCode = miConfig.Code
  6452. pp.RequestUrl = miConfig.Url
  6453. pp.Cainfo = miConfig.Cainfo
  6454. pp.SecretKey = miConfig.SecretKey
  6455. pp.AccessKey = miConfig.AccessKey
  6456. pp.OpterName = roles.UserName
  6457. var config []*models.HisXtDiagnoseConfig
  6458. for _, item := range diagnosis_ids {
  6459. id, _ := strconv.ParseInt(item, 10, 64)
  6460. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6461. config = append(config, &diagnosisConfig)
  6462. }
  6463. var pd models.PatientDtos
  6464. pd.PatnID = his.PsnNo
  6465. pd.PatnName = his.Name
  6466. pd.Gend = his.Gend
  6467. pd.Brdy = his.Brdy
  6468. pd.Poolarea = his.InsuplcAdmdvs
  6469. pd.CurrMdtrtID = his.Number
  6470. var fed models.FsiEncounterDtos
  6471. fed.MdtrtID = his.Number
  6472. fed.MedinsID = miConfig.Code
  6473. fed.MedinsName = miConfig.OrgName
  6474. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6475. fed.MedMdtrtType = "1"
  6476. fed.MedinsType = "1"
  6477. fed.MedinsLv = "11"
  6478. tm := time.Unix(his.RecordDate, 0)
  6479. s_tm := tm.Format("2006-01-02 15:04:05")
  6480. fed.AdmDate = s_tm
  6481. fed.DscgDate = s_tm
  6482. fed.DscgMainDiseCodg = config[0].CountryCode
  6483. fed.DscgMainDiseName = config[0].CountryContentName
  6484. //诊断信息
  6485. var fdds []*models.FsiDiagnoseDtos
  6486. for index, item := range config {
  6487. if index == 0 {
  6488. var fdd models.FsiDiagnoseDtos
  6489. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6490. fdd.InoutDiseType = "1"
  6491. fdd.MaindiseFlag = "1"
  6492. fdd.DiseDate = s_tm
  6493. fdd.DiasSrtNo = "1"
  6494. fdd.DiseName = item.CountryContentName
  6495. fdd.DiseCodg = item.CountryCode
  6496. fdds = append(fdds, &fdd)
  6497. } else {
  6498. var fdd models.FsiDiagnoseDtos
  6499. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6500. fdd.InoutDiseType = "1"
  6501. fdd.MaindiseFlag = "1"
  6502. fdd.DiseDate = s_tm
  6503. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6504. fdd.DiseName = item.CountryContentName
  6505. fdd.DiseCodg = item.CountryCode
  6506. fdds = append(fdds, &fdd)
  6507. }
  6508. }
  6509. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6510. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6511. fed.AdmDeptName = department.Name
  6512. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6513. fed.DscgDeptName = department.Name
  6514. fed.MedMdtrtType = "1"
  6515. fed.MedType = "11"
  6516. //if his.Insutype == "390" {
  6517. // fed.MedType = "1402"
  6518. //} else {
  6519. // fed.MedType = "9933"
  6520. //}
  6521. var orders []*models.FsiOrderDtos
  6522. if trig_scen == "2" {
  6523. //处方医嘱信息
  6524. for _, item := range prescriptions {
  6525. for _, subItem := range item.HisDoctorAdviceInfo {
  6526. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6527. var order models.FsiOrderDtos
  6528. order.RxID = strconv.FormatInt(item.ID, 10)
  6529. order.Rxno = strconv.FormatInt(item.ID, 10)
  6530. order.LongDrordFlag = "0"
  6531. order.HilistType = "1"
  6532. order.ChrgType = "1"
  6533. order.DrordBhvr = "-"
  6534. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6535. order.HosplistName = subItem.BaseDrugLib.DrugName
  6536. order.HilistLv = "1"
  6537. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6538. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6539. order.HosplistName = subItem.BaseDrugLib.DrugName
  6540. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6541. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6542. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6543. order.OwnpayAmt = ""
  6544. order.SelfpayAmt = ""
  6545. order.Spec = ""
  6546. order.SpecUnt = ""
  6547. order.DrordBegnDate = s_tm
  6548. order.DrordStopDate = ""
  6549. order.DrordDrCodg = doctor_info.DoctorNumber
  6550. order.DrordDeptName = department.Name
  6551. order.DrordDeptCodg = department.Number
  6552. order.DrordDrName = doctor_info.UserName
  6553. order.DrordDrProfttl = "234"
  6554. order.CurrDrordFlag = "1"
  6555. orders = append(orders, &order)
  6556. }
  6557. }
  6558. for _, subItem := range item.HisPrescriptionProject {
  6559. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6560. var order models.FsiOrderDtos
  6561. order.RxID = strconv.FormatInt(item.ID, 10)
  6562. order.Rxno = strconv.FormatInt(item.ID, 10)
  6563. order.LongDrordFlag = "0"
  6564. order.HilistType = "1"
  6565. order.ChrgType = "1"
  6566. order.DrordBhvr = "-"
  6567. order.HilistCode = subItem.HisProject.MedicalCode
  6568. order.HosplistName = subItem.HisProject.ProjectName
  6569. order.HilistLv = "1"
  6570. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6571. order.HosplistCode = subItem.HisProject.MedicalCode
  6572. order.HosplistName = subItem.HisProject.ProjectName
  6573. order.Cnt = subItem.Count
  6574. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6575. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6576. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6577. order.OwnpayAmt = ""
  6578. order.SelfpayAmt = ""
  6579. order.Spec = ""
  6580. order.SpecUnt = ""
  6581. order.DrordBegnDate = s_tm
  6582. order.DrordStopDate = ""
  6583. order.DrordDrCodg = doctor_info.DoctorNumber
  6584. order.DrordDeptName = department.Name
  6585. order.DrordDeptCodg = department.Number
  6586. order.DrordDrName = doctor_info.UserName
  6587. order.DrordDrProfttl = "234"
  6588. order.CurrDrordFlag = "1"
  6589. orders = append(orders, &order)
  6590. }
  6591. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6592. var order models.FsiOrderDtos
  6593. order.RxID = strconv.FormatInt(item.ID, 10)
  6594. order.Rxno = strconv.FormatInt(item.ID, 10)
  6595. order.LongDrordFlag = "0"
  6596. order.HilistType = "1"
  6597. order.ChrgType = "1"
  6598. order.DrordBhvr = "-"
  6599. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6600. order.HosplistName = subItem.GoodInfo.GoodName
  6601. order.HilistLv = "1"
  6602. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6603. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6604. order.HosplistName = subItem.GoodInfo.GoodName
  6605. order.Cnt = subItem.Count
  6606. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6607. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6608. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6609. order.OwnpayAmt = ""
  6610. order.SelfpayAmt = ""
  6611. order.Spec = ""
  6612. order.SpecUnt = ""
  6613. order.DrordBegnDate = s_tm
  6614. order.DrordStopDate = ""
  6615. order.DrordDrCodg = doctor_info.DoctorNumber
  6616. order.DrordDeptName = department.Name
  6617. order.DrordDeptCodg = department.Number
  6618. order.DrordDrName = doctor_info.UserName
  6619. order.DrordDrProfttl = "234"
  6620. order.CurrDrordFlag = "1"
  6621. orders = append(orders, &order)
  6622. }
  6623. }
  6624. }
  6625. //处方医嘱信息
  6626. }
  6627. fed.MatnStas = "0"
  6628. fed.MedfeeSumamt = "0"
  6629. fed.OwnpayAmt = "0"
  6630. fed.SelfpayAmt = "0"
  6631. fed.AcctPayamt = "0"
  6632. fed.MaAmt = "0"
  6633. fed.HifpPayamt = "0"
  6634. fed.SetlTotlnum = "1"
  6635. fed.Insutype = his.Insutype
  6636. fed.ReimFlag = "0"
  6637. fed.OutSetlFlag = "0"
  6638. var fopd []*models.FsiOperationDtosData
  6639. data := make(map[string]interface{})
  6640. data["fed"] = fed
  6641. data["fdd"] = fdds
  6642. data["fod"] = orders
  6643. data["pd"] = pd
  6644. data["pp"] = pp
  6645. data["fopd"] = fopd
  6646. data["trig_scen"] = trig_scen
  6647. fmt.Println(data)
  6648. fmt.Println(fed)
  6649. fmt.Println(fdds)
  6650. fmt.Println(orders)
  6651. fmt.Println(pd)
  6652. fmt.Println(pp)
  6653. fmt.Println(fopd)
  6654. client := &http.Client{}
  6655. bytesData, _ := json.Marshal(data)
  6656. var req *http.Request
  6657. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6658. if miConfig.MdtrtareaAdmvs == "320921" {
  6659. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6660. } else {
  6661. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6662. }
  6663. resp, _ := client.Do(req)
  6664. defer resp.Body.Close()
  6665. body, ioErr := ioutil.ReadAll(resp.Body)
  6666. if ioErr != nil {
  6667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6669. return res
  6670. }
  6671. var respJSON map[string]interface{}
  6672. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6675. return res
  6676. }
  6677. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6678. fmt.Println(respJSON)
  6679. result, _ := json.Marshal(respJSON)
  6680. fmt.Println(result)
  6681. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6682. utils.ErrorLog("解析失败:%v", err)
  6683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6684. return res
  6685. }
  6686. return res
  6687. } else {
  6688. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6689. saveLog(output, input, "3101", "事前")
  6690. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6691. utils.ErrorLog("解析失败:%v", err)
  6692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6693. return
  6694. }
  6695. return res
  6696. }
  6697. return res
  6698. }
  6699. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  6700. ////patient_id, _ := c.GetInt64("patient_id")
  6701. //order_id, _ := c.GetInt64("order_id")
  6702. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6703. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6704. //trig_scen := c.GetString("trig_scen")
  6705. adminUser := c.GetAdminUserInfo()
  6706. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6707. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6708. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6709. record_time := c.GetString("record_time")
  6710. order, _ := service.GetHisOrderByID(order_id)
  6711. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6712. timeLayout := "2006-01-02"
  6713. loc, _ := time.LoadLocation("Local")
  6714. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6715. if err != nil {
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6717. return
  6718. }
  6719. recordDateTime := theTime.Unix()
  6720. var patientPrescription models.HisPrescriptionInfo
  6721. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6722. if patientPrescription.ID == 0 {
  6723. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6724. }
  6725. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6726. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6727. //
  6728. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6729. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6730. var pp models.PublicParams
  6731. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6732. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6733. pp.FixmedinsName = miConfig.OrgName
  6734. pp.FixmedinsCode = miConfig.Code
  6735. pp.RequestUrl = miConfig.Url
  6736. pp.Cainfo = miConfig.Cainfo
  6737. pp.SecretKey = miConfig.SecretKey
  6738. pp.AccessKey = miConfig.AccessKey
  6739. pp.OpterName = roles.UserName
  6740. var config []*models.HisXtDiagnoseConfig
  6741. for _, item := range diagnosis_ids {
  6742. id, _ := strconv.ParseInt(item, 10, 64)
  6743. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6744. config = append(config, &diagnosisConfig)
  6745. }
  6746. var pd models.PatientDtos
  6747. pd.PatnID = his.PsnNo
  6748. pd.PatnName = his.Name
  6749. pd.Gend = his.Gend
  6750. pd.Brdy = psn_info.Brdy
  6751. pd.Poolarea = his.InsuplcAdmdvs
  6752. pd.CurrMdtrtID = his.Number
  6753. var fed models.FsiEncounterDtos
  6754. fed.MdtrtID = his.Number
  6755. fed.MedinsID = miConfig.Code
  6756. fed.MedinsName = miConfig.OrgName
  6757. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6758. fed.MedMdtrtType = "1"
  6759. fed.MedinsType = "1"
  6760. fed.MedinsLv = "11"
  6761. tm := time.Unix(his.RecordDate, 0)
  6762. s_tm := tm.Format("2006-01-02 15:04:05")
  6763. fed.AdmDate = s_tm
  6764. fed.DscgDate = s_tm
  6765. fed.DscgMainDiseCodg = config[0].CountryCode
  6766. fed.DscgMainDiseName = config[0].CountryContentName
  6767. //诊断信息
  6768. var fdds []*models.FsiDiagnoseDtos
  6769. for index, item := range config {
  6770. if index == 0 {
  6771. var fdd models.FsiDiagnoseDtos
  6772. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6773. fdd.InoutDiseType = "1"
  6774. fdd.MaindiseFlag = "1"
  6775. fdd.DiseDate = s_tm
  6776. fdd.DiasSrtNo = "1"
  6777. fdd.DiseName = item.CountryContentName
  6778. fdd.DiseCodg = item.CountryCode
  6779. fdds = append(fdds, &fdd)
  6780. } else {
  6781. var fdd models.FsiDiagnoseDtos
  6782. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6783. fdd.InoutDiseType = "1"
  6784. fdd.MaindiseFlag = "1"
  6785. fdd.DiseDate = s_tm
  6786. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6787. fdd.DiseName = item.CountryContentName
  6788. fdd.DiseCodg = item.CountryCode
  6789. fdds = append(fdds, &fdd)
  6790. }
  6791. }
  6792. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6793. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6794. fed.AdmDeptName = department.Name
  6795. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6796. fed.DscgDeptName = department.Name
  6797. fed.MedType = order.MedType
  6798. //处方医嘱信息
  6799. var orders []*models.FsiOrderDtos
  6800. //for _, item := range prescriptions {
  6801. // for _, subItem := range item.HisDoctorAdviceInfo {
  6802. // var order models.FsiOrderDtos
  6803. // order.RxID = strconv.FormatInt(item.ID, 10)
  6804. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6805. // order.LongDrordFlag = "0"
  6806. // order.HilistType = "1"
  6807. // order.ChrgType = "1"
  6808. // order.DrordBhvr = "-"
  6809. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6810. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6811. // order.HilistLv = "1"
  6812. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6813. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6814. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6815. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6816. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6817. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6818. // order.OwnpayAmt = ""
  6819. // order.SelfpayAmt = ""
  6820. // order.Spec = ""
  6821. // order.SpecUnt = ""
  6822. // order.DrordBegnDate = s_tm
  6823. // order.DrordStopDate = ""
  6824. // order.DrordDrCodg = "1"
  6825. // order.DrordDeptName = department.Name
  6826. // order.DrordDrCodg = "1"
  6827. // order.DrordDrName = doctor_info.UserName
  6828. // order.DrordDrProfttl = ""
  6829. // order.CurrDrordFlag = "1"
  6830. // orders = append(orders, &order)
  6831. // }
  6832. // for _, subItem := range item.HisPrescriptionProject {
  6833. // if subItem.Type == 2 {
  6834. // var order models.FsiOrderDtos
  6835. // order.RxID = strconv.FormatInt(item.ID, 10)
  6836. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6837. // order.LongDrordFlag = "0"
  6838. // order.HilistType = "1"
  6839. // order.ChrgType = "1"
  6840. // order.DrordBhvr = "-"
  6841. // order.HilistCode = subItem.HisProject.MedicalCode
  6842. // order.HosplistName = subItem.HisProject.ProjectName
  6843. // order.HilistLv = "1"
  6844. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6845. // order.HosplistCode = subItem.HisProject.MedicalCode
  6846. // order.HosplistName = subItem.HisProject.ProjectName
  6847. // order.Cnt = subItem.Count
  6848. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6849. //
  6850. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6851. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6852. // order.OwnpayAmt = ""
  6853. // order.SelfpayAmt = ""
  6854. // order.Spec = ""
  6855. // order.SpecUnt = ""
  6856. // order.DrordBegnDate = s_tm
  6857. // order.DrordStopDate = ""
  6858. // order.DrordDrCodg = "1"
  6859. // order.DrordDeptName = department.Name
  6860. // order.DrordDrCodg = "1"
  6861. // order.DrordDrName = doctor_info.UserName
  6862. // order.DrordDrProfttl = ""
  6863. // order.CurrDrordFlag = "1"
  6864. // orders = append(orders, &order)
  6865. //
  6866. // }
  6867. // if subItem.Type == 3 {
  6868. //
  6869. // var order models.FsiOrderDtos
  6870. // order.RxID = strconv.FormatInt(item.ID, 10)
  6871. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6872. // order.LongDrordFlag = "0"
  6873. // order.HilistType = "1"
  6874. // order.ChrgType = "1"
  6875. // order.DrordBhvr = "-"
  6876. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6877. // order.HosplistName = subItem.GoodInfo.GoodName
  6878. // order.HilistLv = "1"
  6879. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6880. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6881. // order.HosplistName = subItem.GoodInfo.GoodName
  6882. // order.Cnt = subItem.Count
  6883. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6884. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6885. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6886. // order.OwnpayAmt = ""
  6887. // order.SelfpayAmt = ""
  6888. // order.Spec = ""
  6889. // order.SpecUnt = ""
  6890. // order.DrordBegnDate = s_tm
  6891. // order.DrordStopDate = ""
  6892. // order.DrordDrCodg = "1"
  6893. // order.DrordDeptName = department.Name
  6894. // order.DrordDrCodg = "1"
  6895. // order.DrordDrName = doctor_info.UserName
  6896. // order.DrordDrProfttl = ""
  6897. // order.CurrDrordFlag = "1"
  6898. // orders = append(orders, &order)
  6899. //
  6900. // }
  6901. // }
  6902. //}
  6903. for _, item := range prescriptions {
  6904. for _, subItem := range item.HisDoctorAdviceInfo {
  6905. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6906. var order models.FsiOrderDtos
  6907. order.RxID = strconv.FormatInt(item.ID, 10)
  6908. order.Rxno = strconv.FormatInt(item.ID, 10)
  6909. order.LongDrordFlag = "0"
  6910. order.HilistType = "1"
  6911. order.ChrgType = "1"
  6912. order.DrordBhvr = "-"
  6913. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6914. order.HosplistName = subItem.BaseDrugLib.DrugName
  6915. order.HilistLv = "1"
  6916. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6917. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6918. order.HosplistName = subItem.BaseDrugLib.DrugName
  6919. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6920. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6921. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6922. order.OwnpayAmt = ""
  6923. order.SelfpayAmt = ""
  6924. order.Spec = ""
  6925. order.SpecUnt = ""
  6926. order.DrordBegnDate = s_tm
  6927. order.DrordStopDate = ""
  6928. order.DrordDrCodg = doctor_info.DoctorNumber
  6929. order.DrordDeptName = department.Name
  6930. order.DrordDeptCodg = department.Number
  6931. order.DrordDrName = doctor_info.UserName
  6932. order.DrordDrProfttl = "234"
  6933. order.CurrDrordFlag = "1"
  6934. orders = append(orders, &order)
  6935. }
  6936. }
  6937. for _, subItem := range item.HisPrescriptionProject {
  6938. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6939. var order models.FsiOrderDtos
  6940. order.RxID = strconv.FormatInt(item.ID, 10)
  6941. order.Rxno = strconv.FormatInt(item.ID, 10)
  6942. order.LongDrordFlag = "0"
  6943. order.HilistType = "1"
  6944. order.ChrgType = "1"
  6945. order.DrordBhvr = "-"
  6946. order.HilistCode = subItem.HisProject.MedicalCode
  6947. order.HosplistName = subItem.HisProject.ProjectName
  6948. order.HilistLv = "1"
  6949. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6950. order.HosplistCode = subItem.HisProject.MedicalCode
  6951. order.HosplistName = subItem.HisProject.ProjectName
  6952. order.Cnt = subItem.Count
  6953. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6954. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6955. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6956. order.OwnpayAmt = ""
  6957. order.SelfpayAmt = ""
  6958. order.Spec = ""
  6959. order.SpecUnt = ""
  6960. order.DrordBegnDate = s_tm
  6961. order.DrordStopDate = ""
  6962. order.DrordDrCodg = doctor_info.DoctorNumber
  6963. order.DrordDeptName = department.Name
  6964. order.DrordDeptCodg = department.Number
  6965. order.DrordDrName = doctor_info.UserName
  6966. order.DrordDrProfttl = "234"
  6967. order.CurrDrordFlag = "1"
  6968. orders = append(orders, &order)
  6969. }
  6970. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6971. var order models.FsiOrderDtos
  6972. order.RxID = strconv.FormatInt(item.ID, 10)
  6973. order.Rxno = strconv.FormatInt(item.ID, 10)
  6974. order.LongDrordFlag = "0"
  6975. order.HilistType = "1"
  6976. order.ChrgType = "1"
  6977. order.DrordBhvr = "0"
  6978. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6979. order.HosplistName = subItem.GoodInfo.GoodName
  6980. order.HilistLv = "1"
  6981. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6982. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6983. order.HosplistName = subItem.GoodInfo.GoodName
  6984. order.Cnt = subItem.Count
  6985. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6986. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6987. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6988. order.OwnpayAmt = ""
  6989. order.SelfpayAmt = ""
  6990. order.Spec = ""
  6991. order.SpecUnt = ""
  6992. order.DrordBegnDate = s_tm
  6993. order.DrordStopDate = ""
  6994. order.DrordDrCodg = doctor_info.DoctorNumber
  6995. order.DrordDeptName = department.Name
  6996. order.DrordDeptCodg = department.Number
  6997. order.DrordDrName = doctor_info.UserName
  6998. order.DrordDrProfttl = "234"
  6999. order.CurrDrordFlag = "1"
  7000. orders = append(orders, &order)
  7001. }
  7002. }
  7003. }
  7004. //处方医嘱信息
  7005. fed.MatnStas = "0"
  7006. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7007. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  7008. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  7009. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  7010. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  7011. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  7012. fed.SetlTotlnum = "1"
  7013. fed.Insutype = his.Insutype
  7014. fed.ReimFlag = "0"
  7015. fed.OutSetlFlag = "0"
  7016. var fopd []*models.FsiOperationDtosData
  7017. data := make(map[string]interface{})
  7018. data["fed"] = fed
  7019. data["fdd"] = fdds
  7020. data["fod"] = orders
  7021. data["pd"] = pd
  7022. data["pp"] = pp
  7023. data["fopd"] = fopd
  7024. data["trig_scen"] = trig_scen
  7025. client := &http.Client{}
  7026. bytesData, _ := json.Marshal(data)
  7027. var req *http.Request
  7028. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7029. if miConfig.MdtrtareaAdmvs == "320921" {
  7030. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7031. } else {
  7032. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7033. }
  7034. resp, _ := client.Do(req)
  7035. defer resp.Body.Close()
  7036. body, ioErr := ioutil.ReadAll(resp.Body)
  7037. if ioErr != nil {
  7038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7040. return res
  7041. }
  7042. var respJSON map[string]interface{}
  7043. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7046. return res
  7047. }
  7048. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7049. result, _ := json.Marshal(respJSON)
  7050. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7051. utils.ErrorLog("解析失败:%v", err)
  7052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7053. return res
  7054. }
  7055. return res
  7056. } else {
  7057. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7058. saveLog(output, input, "3102", "事中")
  7059. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7060. utils.ErrorLog("解析失败:%v", err)
  7061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7062. return
  7063. }
  7064. return res
  7065. }
  7066. return res
  7067. }
  7068. 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) {
  7069. var res Resultgd3101
  7070. adminUser := c.GetAdminUserInfo()
  7071. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7072. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7073. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7074. //record_time := c.GetString("record_time")
  7075. //trig_scen := c.GetString("trig_scen")
  7076. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7077. timeLayout := "2006-01-02"
  7078. loc, _ := time.LoadLocation("Local")
  7079. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7080. if err != nil {
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7082. return res
  7083. }
  7084. recordDateTime := theTime.Unix()
  7085. var patientPrescription models.HisPrescriptionInfo
  7086. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7087. //if patientPrescription.ID == 0 {
  7088. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7089. //}
  7090. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7091. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7092. //
  7093. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  7094. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7095. var pp models.PublicParams
  7096. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7097. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7098. pp.FixmedinsName = miConfig.OrgName
  7099. pp.FixmedinsCode = miConfig.Code
  7100. pp.RequestUrl = miConfig.Url
  7101. pp.Cainfo = miConfig.Cainfo
  7102. pp.SecretKey = miConfig.SecretKey
  7103. pp.AccessKey = miConfig.AccessKey
  7104. pp.OpterName = roles.UserName
  7105. var config []*models.HisXtDiagnoseConfig
  7106. for _, item := range diagnosis_ids {
  7107. id, _ := strconv.ParseInt(item, 10, 64)
  7108. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7109. config = append(config, &diagnosisConfig)
  7110. }
  7111. var pd models.PatientDtos
  7112. pd.PatnID = his.PsnNo
  7113. pd.PatnName = his.Name
  7114. pd.Gend = his.Gend
  7115. pd.Brdy = psn_info.Brdy
  7116. pd.Poolarea = miConfig.MdtrtareaAdmvs
  7117. pd.CurrMdtrtID = his.Number
  7118. var fed models.FsiEncounterDtos
  7119. fed.MdtrtID = his.Number
  7120. fed.MedinsID = miConfig.Code
  7121. fed.MedinsName = miConfig.OrgName
  7122. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  7123. fed.MedMdtrtType = "1"
  7124. fed.MedinsType = "1"
  7125. fed.MedinsLv = "11"
  7126. tm := time.Unix(his.RecordDate, 0)
  7127. s_tm := tm.Format("2006-01-02 15:04:05")
  7128. fed.AdmDate = s_tm
  7129. fed.DscgDate = s_tm
  7130. fed.DscgMainDiseCodg = config[0].CountryCode
  7131. fed.DscgMainDiseName = config[0].CountryContentName
  7132. //诊断信息
  7133. var fdds []*models.FsiDiagnoseDtos
  7134. for index, item := range config {
  7135. if index == 0 {
  7136. var fdd models.FsiDiagnoseDtos
  7137. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7138. fdd.InoutDiseType = "1"
  7139. fdd.MaindiseFlag = "1"
  7140. fdd.DiseDate = s_tm
  7141. fdd.DiasSrtNo = "1"
  7142. fdd.DiseName = item.CountryContentName
  7143. fdd.DiseCodg = item.CountryCode
  7144. fdds = append(fdds, &fdd)
  7145. } else {
  7146. var fdd models.FsiDiagnoseDtos
  7147. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7148. fdd.InoutDiseType = "1"
  7149. fdd.MaindiseFlag = "1"
  7150. fdd.DiseDate = s_tm
  7151. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  7152. fdd.DiseName = item.CountryContentName
  7153. fdd.DiseCodg = item.CountryCode
  7154. fdds = append(fdds, &fdd)
  7155. }
  7156. }
  7157. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  7158. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  7159. fed.AdmDeptName = department.Name
  7160. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  7161. fed.DscgDeptName = department.Name
  7162. fed.MedMdtrtType = "1"
  7163. fed.MedType = "11"
  7164. //if his.Insutype == "390" {
  7165. // fed.MedType = "1402"
  7166. //} else {
  7167. // fed.MedType = "9933"
  7168. //}
  7169. var orders []*models.FsiOrderDtos
  7170. if trig_scen == "2" {
  7171. //处方医嘱信息
  7172. for _, item := range prescriptions {
  7173. for _, subItem := range item.HisDoctorAdviceInfo {
  7174. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7175. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7176. var order models.FsiOrderDtos
  7177. order.RxID = strconv.FormatInt(item.ID, 10)
  7178. order.Rxno = strconv.FormatInt(item.ID, 10)
  7179. order.LongDrordFlag = "0"
  7180. order.HilistType = "1"
  7181. order.ChrgType = "1"
  7182. order.DrordBhvr = "0"
  7183. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7184. order.HosplistName = subItem.BaseDrugLib.DrugName
  7185. order.HilistLv = "1"
  7186. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7187. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7188. order.HosplistName = subItem.BaseDrugLib.DrugName
  7189. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7190. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7191. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  7192. order.OwnpayAmt = ""
  7193. order.SelfpayAmt = ""
  7194. order.Spec = spec
  7195. order.SpecUnt = subItem.PrescribingNumberUnit
  7196. order.DrordBegnDate = s_tm
  7197. order.DrordStopDate = ""
  7198. order.DrordDrCodg = doctor_info.DoctorNumber
  7199. order.DrordDeptName = department.Name
  7200. order.DrordDeptCodg = department.Number
  7201. order.DrordDrName = doctor_info.UserName
  7202. order.DrordDrProfttl = "234"
  7203. order.CurrDrordFlag = "1"
  7204. orders = append(orders, &order)
  7205. }
  7206. }
  7207. for _, subItem := range item.HisPrescriptionProject {
  7208. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  7209. var order models.FsiOrderDtos
  7210. order.RxID = strconv.FormatInt(item.ID, 10)
  7211. order.Rxno = strconv.FormatInt(item.ID, 10)
  7212. order.LongDrordFlag = "0"
  7213. order.HilistType = "1"
  7214. order.ChrgType = "1"
  7215. order.DrordBhvr = "0"
  7216. order.HilistCode = subItem.HisProject.MedicalCode
  7217. order.HosplistName = subItem.HisProject.ProjectName
  7218. order.HilistLv = "1"
  7219. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7220. order.HosplistCode = subItem.HisProject.MedicalCode
  7221. order.HosplistName = subItem.HisProject.ProjectName
  7222. order.Cnt = subItem.Count
  7223. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7224. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7225. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7226. order.OwnpayAmt = ""
  7227. order.SelfpayAmt = ""
  7228. order.Spec = subItem.Unit
  7229. order.SpecUnt = subItem.Unit
  7230. order.DrordBegnDate = s_tm
  7231. order.DrordStopDate = ""
  7232. order.DrordDrCodg = doctor_info.DoctorNumber
  7233. order.DrordDeptName = department.Name
  7234. order.DrordDeptCodg = department.Number
  7235. order.DrordDrName = doctor_info.UserName
  7236. order.DrordDrProfttl = "234"
  7237. order.CurrDrordFlag = "1"
  7238. orders = append(orders, &order)
  7239. }
  7240. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7241. var order models.FsiOrderDtos
  7242. order.RxID = strconv.FormatInt(item.ID, 10)
  7243. order.Rxno = strconv.FormatInt(item.ID, 10)
  7244. order.LongDrordFlag = "0"
  7245. order.HilistType = "1"
  7246. order.ChrgType = "1"
  7247. order.DrordBhvr = "0"
  7248. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7249. order.HosplistName = subItem.GoodInfo.GoodName
  7250. order.HilistLv = "1"
  7251. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7252. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7253. order.HosplistName = subItem.GoodInfo.GoodName
  7254. order.Cnt = subItem.Count
  7255. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7256. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7257. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7258. order.OwnpayAmt = ""
  7259. order.SelfpayAmt = ""
  7260. order.Spec = subItem.GoodInfo.SpecificationName
  7261. order.SpecUnt = subItem.Unit
  7262. order.DrordBegnDate = s_tm
  7263. order.DrordStopDate = ""
  7264. order.DrordDrCodg = doctor_info.DoctorNumber
  7265. order.DrordDeptName = department.Name
  7266. order.DrordDeptCodg = department.Number
  7267. order.DrordDrName = doctor_info.UserName
  7268. order.DrordDrProfttl = "234"
  7269. order.CurrDrordFlag = "1"
  7270. orders = append(orders, &order)
  7271. }
  7272. }
  7273. }
  7274. //处方医嘱信息
  7275. }
  7276. fed.MatnStas = "0"
  7277. fed.MedfeeSumamt = "0"
  7278. fed.OwnpayAmt = "0"
  7279. fed.SelfpayAmt = "0"
  7280. fed.AcctPayamt = "0"
  7281. fed.MaAmt = "0"
  7282. fed.HifpPayamt = "0"
  7283. fed.SetlTotlnum = "1"
  7284. fed.Insutype = his.Insutype
  7285. fed.ReimFlag = "0"
  7286. fed.OutSetlFlag = "0"
  7287. var fopd []*models.FsiOperationDtosData
  7288. data := make(map[string]interface{})
  7289. data["fed"] = fed
  7290. data["fdd"] = fdds
  7291. data["fod"] = orders
  7292. data["pd"] = pd
  7293. data["pp"] = pp
  7294. data["fopd"] = fopd
  7295. data["trig_scen"] = trig_scen
  7296. fmt.Println(data)
  7297. fmt.Println(fed)
  7298. fmt.Println(fdds)
  7299. fmt.Println(orders)
  7300. fmt.Println(pd)
  7301. fmt.Println(pp)
  7302. fmt.Println(fopd)
  7303. client := &http.Client{}
  7304. bytesData, _ := json.Marshal(data)
  7305. var req *http.Request
  7306. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7307. if miConfig.MdtrtareaAdmvs == "320921" {
  7308. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  7309. } else {
  7310. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  7311. }
  7312. resp, _ := client.Do(req)
  7313. defer resp.Body.Close()
  7314. body, ioErr := ioutil.ReadAll(resp.Body)
  7315. if ioErr != nil {
  7316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7318. return res
  7319. }
  7320. var respJSON map[string]interface{}
  7321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7324. return res
  7325. }
  7326. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7327. fmt.Println(respJSON)
  7328. result, _ := json.Marshal(respJSON)
  7329. fmt.Println(result)
  7330. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7331. utils.ErrorLog("解析失败:%v", err)
  7332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7333. return res
  7334. }
  7335. return res
  7336. } else {
  7337. //if miConfig.MdtrtareaAdmvs == "441202" {
  7338. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7339. saveLog(output, input, "3101", "事前")
  7340. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7341. utils.ErrorLog("解析失败:%v", err)
  7342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7343. return
  7344. }
  7345. return res
  7346. //}
  7347. }
  7348. }
  7349. 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) {
  7350. adminUser := c.GetAdminUserInfo()
  7351. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7352. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7353. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7354. //record_time := c.GetString("record_time")
  7355. //trig_scen := c.GetString("trig_scen")
  7356. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7357. timeLayout := "2006-01-02"
  7358. loc, _ := time.LoadLocation("Local")
  7359. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7360. if err != nil {
  7361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7362. return res
  7363. }
  7364. recordDateTime := theTime.Unix()
  7365. var patientPrescription models.HisPrescriptionInfo
  7366. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7367. if patientPrescription.ID == 0 {
  7368. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7369. }
  7370. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7371. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7372. //
  7373. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  7374. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7375. var pp models.PublicParams
  7376. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7377. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7378. pp.FixmedinsName = miConfig.OrgName
  7379. pp.FixmedinsCode = miConfig.Code
  7380. pp.RequestUrl = miConfig.Url
  7381. pp.Cainfo = miConfig.Cainfo
  7382. pp.SecretKey = miConfig.SecretKey
  7383. pp.AccessKey = miConfig.AccessKey
  7384. pp.OpterName = roles.UserName
  7385. var config []*models.HisXtDiagnoseConfig
  7386. for _, item := range diagnosis_ids {
  7387. id, _ := strconv.ParseInt(item, 10, 64)
  7388. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7389. config = append(config, &diagnosisConfig)
  7390. }
  7391. var pd models.PatientDtos
  7392. pd.PatnID = his.PsnNo
  7393. pd.PatnName = his.Name
  7394. pd.Gend = his.Gend
  7395. pd.Brdy = psn_info.Brdy
  7396. pd.Poolarea = his.InsuplcAdmdvs
  7397. pd.CurrMdtrtID = his.Number
  7398. var fed models.FsiEncounterDtos
  7399. fed.MdtrtID = his.Number
  7400. fed.MedinsID = miConfig.Code
  7401. fed.MedinsName = miConfig.OrgName
  7402. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  7403. fed.MedMdtrtType = "1"
  7404. fed.MedinsType = "1"
  7405. fed.MedinsLv = "11"
  7406. tm := time.Unix(his.RecordDate, 0)
  7407. s_tm := tm.Format("2006-01-02 15:04:05")
  7408. fed.AdmDate = s_tm
  7409. fed.DscgDate = s_tm
  7410. fed.DscgMainDiseCodg = config[0].CountryCode
  7411. fed.DscgMainDiseName = config[0].CountryContentName
  7412. //诊断信息
  7413. var fdds []*models.FsiDiagnoseDtos
  7414. for index, item := range config {
  7415. if index == 0 {
  7416. var fdd models.FsiDiagnoseDtos
  7417. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7418. fdd.InoutDiseType = "1"
  7419. fdd.MaindiseFlag = "1"
  7420. fdd.DiseDate = s_tm
  7421. fdd.DiasSrtNo = "1"
  7422. fdd.DiseName = item.CountryContentName
  7423. fdd.DiseCodg = item.CountryCode
  7424. fdds = append(fdds, &fdd)
  7425. } else {
  7426. var fdd models.FsiDiagnoseDtos
  7427. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7428. fdd.InoutDiseType = "1"
  7429. fdd.MaindiseFlag = "1"
  7430. fdd.DiseDate = s_tm
  7431. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  7432. fdd.DiseName = item.CountryContentName
  7433. fdd.DiseCodg = item.CountryCode
  7434. fdds = append(fdds, &fdd)
  7435. }
  7436. }
  7437. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  7438. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  7439. fed.AdmDeptName = department.Name
  7440. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  7441. fed.DscgDeptName = department.Name
  7442. fed.MedMdtrtType = "1"
  7443. fed.MedType = "11"
  7444. //if his.Insutype == "390" {
  7445. // fed.MedType = "1402"
  7446. //} else {
  7447. // fed.MedType = "9933"
  7448. //}
  7449. var orders []*models.FsiOrderDtos
  7450. if trig_scen == "2" {
  7451. //处方医嘱信息
  7452. for _, item := range prescriptions {
  7453. for _, subItem := range item.HisDoctorAdviceInfo {
  7454. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7455. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7456. var order models.FsiOrderDtos
  7457. order.RxID = strconv.FormatInt(item.ID, 10)
  7458. order.Rxno = strconv.FormatInt(item.ID, 10)
  7459. order.LongDrordFlag = "0"
  7460. order.HilistType = "1"
  7461. order.ChrgType = "1"
  7462. order.DrordBhvr = "0"
  7463. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7464. order.HosplistName = subItem.BaseDrugLib.DrugName
  7465. order.HilistLv = "1"
  7466. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7467. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7468. order.HosplistName = subItem.BaseDrugLib.DrugName
  7469. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7470. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7471. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  7472. order.OwnpayAmt = ""
  7473. order.SelfpayAmt = ""
  7474. order.Spec = spec
  7475. order.SpecUnt = subItem.PrescribingNumberUnit
  7476. order.DrordBegnDate = s_tm
  7477. order.DrordStopDate = ""
  7478. order.DrordDrCodg = doctor_info.DoctorNumber
  7479. order.DrordDeptName = department.Name
  7480. order.DrordDeptCodg = department.Number
  7481. order.DrordDrName = doctor_info.UserName
  7482. order.DrordDrProfttl = "234"
  7483. order.CurrDrordFlag = "1"
  7484. orders = append(orders, &order)
  7485. }
  7486. }
  7487. for _, subItem := range item.HisPrescriptionProject {
  7488. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  7489. var order models.FsiOrderDtos
  7490. order.RxID = strconv.FormatInt(item.ID, 10)
  7491. order.Rxno = strconv.FormatInt(item.ID, 10)
  7492. order.LongDrordFlag = "0"
  7493. order.HilistType = "1"
  7494. order.ChrgType = "1"
  7495. order.DrordBhvr = "0"
  7496. order.HilistCode = subItem.HisProject.MedicalCode
  7497. order.HosplistName = subItem.HisProject.ProjectName
  7498. order.HilistLv = "1"
  7499. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7500. order.HosplistCode = subItem.HisProject.MedicalCode
  7501. order.HosplistName = subItem.HisProject.ProjectName
  7502. order.Cnt = subItem.Count
  7503. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7504. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7505. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7506. order.OwnpayAmt = ""
  7507. order.SelfpayAmt = ""
  7508. order.Spec = subItem.Unit
  7509. order.SpecUnt = subItem.Unit
  7510. order.DrordBegnDate = s_tm
  7511. order.DrordStopDate = ""
  7512. order.DrordDrCodg = doctor_info.DoctorNumber
  7513. order.DrordDeptName = department.Name
  7514. order.DrordDeptCodg = department.Number
  7515. order.DrordDrName = doctor_info.UserName
  7516. order.DrordDrProfttl = "234"
  7517. order.CurrDrordFlag = "1"
  7518. orders = append(orders, &order)
  7519. }
  7520. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7521. var order models.FsiOrderDtos
  7522. order.RxID = strconv.FormatInt(item.ID, 10)
  7523. order.Rxno = strconv.FormatInt(item.ID, 10)
  7524. order.LongDrordFlag = "0"
  7525. order.HilistType = "1"
  7526. order.ChrgType = "1"
  7527. order.DrordBhvr = "0"
  7528. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7529. order.HosplistName = subItem.GoodInfo.GoodName
  7530. order.HilistLv = "1"
  7531. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7532. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7533. order.HosplistName = subItem.GoodInfo.GoodName
  7534. order.Cnt = subItem.Count
  7535. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7536. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7537. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7538. order.OwnpayAmt = ""
  7539. order.SelfpayAmt = ""
  7540. order.Spec = subItem.GoodInfo.SpecificationName
  7541. order.SpecUnt = subItem.Unit
  7542. order.DrordBegnDate = s_tm
  7543. order.DrordStopDate = ""
  7544. order.DrordDrCodg = doctor_info.DoctorNumber
  7545. order.DrordDeptName = department.Name
  7546. order.DrordDeptCodg = department.Number
  7547. order.DrordDrName = doctor_info.UserName
  7548. order.DrordDrProfttl = "234"
  7549. order.CurrDrordFlag = "1"
  7550. orders = append(orders, &order)
  7551. }
  7552. }
  7553. }
  7554. //处方医嘱信息
  7555. }
  7556. fed.MatnStas = "0"
  7557. fed.MedfeeSumamt = "0"
  7558. fed.OwnpayAmt = "0"
  7559. fed.SelfpayAmt = "0"
  7560. fed.AcctPayamt = "0"
  7561. fed.MaAmt = "0"
  7562. fed.HifpPayamt = "0"
  7563. fed.SetlTotlnum = "1"
  7564. fed.Insutype = his.Insutype
  7565. fed.ReimFlag = "0"
  7566. fed.OutSetlFlag = "0"
  7567. var fopd []*models.FsiOperationDtosData
  7568. data := make(map[string]interface{})
  7569. data["fed"] = fed
  7570. data["fdd"] = fdds
  7571. data["fod"] = orders
  7572. data["pd"] = pd
  7573. data["pp"] = pp
  7574. data["fopd"] = fopd
  7575. data["trig_scen"] = trig_scen
  7576. fmt.Println(data)
  7577. fmt.Println(fed)
  7578. fmt.Println(fdds)
  7579. fmt.Println(orders)
  7580. fmt.Println(pd)
  7581. fmt.Println(pp)
  7582. fmt.Println(fopd)
  7583. client := &http.Client{}
  7584. bytesData, _ := json.Marshal(data)
  7585. var req *http.Request
  7586. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7587. if miConfig.MdtrtareaAdmvs == "320921" {
  7588. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  7589. } else {
  7590. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  7591. }
  7592. resp, _ := client.Do(req)
  7593. defer resp.Body.Close()
  7594. body, ioErr := ioutil.ReadAll(resp.Body)
  7595. if ioErr != nil {
  7596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7598. return res
  7599. }
  7600. var respJSON map[string]interface{}
  7601. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7604. return res
  7605. }
  7606. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7607. fmt.Println(respJSON)
  7608. result, _ := json.Marshal(respJSON)
  7609. fmt.Println(result)
  7610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7611. utils.ErrorLog("解析失败:%v", err)
  7612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7613. return res
  7614. }
  7615. return res
  7616. } else {
  7617. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7618. saveLog(output, input, "3101", "事前")
  7619. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7620. utils.ErrorLog("解析失败:%v", err)
  7621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7622. return
  7623. }
  7624. return res
  7625. }
  7626. return res
  7627. }
  7628. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  7629. ////patient_id, _ := c.GetInt64("patient_id")
  7630. //order_id, _ := c.GetInt64("order_id")
  7631. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  7632. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  7633. //trig_scen := c.GetString("trig_scen")
  7634. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7635. utils.ErrorLog("解析失败:%v", psn_info)
  7636. adminUser := c.GetAdminUserInfo()
  7637. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7638. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7639. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7640. record_time := c.GetString("record_time")
  7641. order, _ := service.GetHisOrderByID(order_id)
  7642. timeLayout := "2006-01-02"
  7643. loc, _ := time.LoadLocation("Local")
  7644. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7645. if err != nil {
  7646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7647. return
  7648. }
  7649. recordDateTime := theTime.Unix()
  7650. var patientPrescription models.HisPrescriptionInfo
  7651. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7652. if patientPrescription.ID == 0 {
  7653. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7654. }
  7655. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7656. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7657. //
  7658. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7659. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7660. var pp models.PublicParams
  7661. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7662. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7663. pp.FixmedinsName = miConfig.OrgName
  7664. pp.FixmedinsCode = miConfig.Code
  7665. pp.RequestUrl = miConfig.Url
  7666. pp.Cainfo = miConfig.Cainfo
  7667. pp.SecretKey = miConfig.SecretKey
  7668. pp.AccessKey = miConfig.AccessKey
  7669. pp.OpterName = roles.UserName
  7670. var config []*models.HisXtDiagnoseConfig
  7671. for _, item := range diagnosis_ids {
  7672. id, _ := strconv.ParseInt(item, 10, 64)
  7673. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7674. config = append(config, &diagnosisConfig)
  7675. }
  7676. var pd models.PatientDtos
  7677. pd.PatnID = his.PsnNo
  7678. pd.PatnName = his.Name
  7679. pd.Gend = his.Gend
  7680. pd.Brdy = psn_info.Brdy
  7681. pd.Poolarea = his.InsuplcAdmdvs
  7682. pd.CurrMdtrtID = his.Number
  7683. var fed models.FsiEncounterDtos
  7684. fed.MdtrtID = his.Number
  7685. fed.MedinsID = miConfig.Code
  7686. fed.MedinsName = miConfig.OrgName
  7687. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  7688. fed.MedMdtrtType = "1"
  7689. fed.MedinsType = "1"
  7690. fed.MedinsLv = "11"
  7691. tm := time.Unix(his.RecordDate, 0)
  7692. s_tm := tm.Format("2006-01-02 15:04:05")
  7693. fed.AdmDate = s_tm
  7694. fed.DscgDate = s_tm
  7695. fed.DscgMainDiseCodg = config[0].CountryCode
  7696. fed.DscgMainDiseName = config[0].CountryContentName
  7697. //诊断信息
  7698. var fdds []*models.FsiDiagnoseDtos
  7699. for index, item := range config {
  7700. if index == 0 {
  7701. var fdd models.FsiDiagnoseDtos
  7702. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7703. fdd.InoutDiseType = "1"
  7704. fdd.MaindiseFlag = "1"
  7705. fdd.DiseDate = s_tm
  7706. fdd.DiasSrtNo = "1"
  7707. fdd.DiseName = item.CountryContentName
  7708. fdd.DiseCodg = item.CountryCode
  7709. fdds = append(fdds, &fdd)
  7710. } else {
  7711. var fdd models.FsiDiagnoseDtos
  7712. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7713. fdd.InoutDiseType = "1"
  7714. fdd.MaindiseFlag = "1"
  7715. fdd.DiseDate = s_tm
  7716. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  7717. fdd.DiseName = item.CountryContentName
  7718. fdd.DiseCodg = item.CountryCode
  7719. fdds = append(fdds, &fdd)
  7720. }
  7721. }
  7722. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  7723. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  7724. fed.AdmDeptName = department.Name
  7725. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  7726. fed.DscgDeptName = department.Name
  7727. fed.MedType = order.MedType
  7728. //处方医嘱信息
  7729. var orders []*models.FsiOrderDtos
  7730. //for _, item := range prescriptions {
  7731. // for _, subItem := range item.HisDoctorAdviceInfo {
  7732. // var order models.FsiOrderDtos
  7733. // order.RxID = strconv.FormatInt(item.ID, 10)
  7734. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7735. // order.LongDrordFlag = "0"
  7736. // order.HilistType = "1"
  7737. // order.ChrgType = "1"
  7738. // order.DrordBhvr = "-"
  7739. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7740. // order.HosplistName = subItem.BaseDrugLib.DrugName
  7741. // order.HilistLv = "1"
  7742. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7743. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7744. // order.HosplistName = subItem.BaseDrugLib.DrugName
  7745. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  7746. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7747. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  7748. // order.OwnpayAmt = ""
  7749. // order.SelfpayAmt = ""
  7750. // order.Spec = ""
  7751. // order.SpecUnt = ""
  7752. // order.DrordBegnDate = s_tm
  7753. // order.DrordStopDate = ""
  7754. // order.DrordDrCodg = "1"
  7755. // order.DrordDeptName = department.Name
  7756. // order.DrordDrCodg = "1"
  7757. // order.DrordDrName = doctor_info.UserName
  7758. // order.DrordDrProfttl = ""
  7759. // order.CurrDrordFlag = "1"
  7760. // orders = append(orders, &order)
  7761. // }
  7762. // for _, subItem := range item.HisPrescriptionProject {
  7763. // if subItem.Type == 2 {
  7764. // var order models.FsiOrderDtos
  7765. // order.RxID = strconv.FormatInt(item.ID, 10)
  7766. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7767. // order.LongDrordFlag = "0"
  7768. // order.HilistType = "1"
  7769. // order.ChrgType = "1"
  7770. // order.DrordBhvr = "-"
  7771. // order.HilistCode = subItem.HisProject.MedicalCode
  7772. // order.HosplistName = subItem.HisProject.ProjectName
  7773. // order.HilistLv = "1"
  7774. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7775. // order.HosplistCode = subItem.HisProject.MedicalCode
  7776. // order.HosplistName = subItem.HisProject.ProjectName
  7777. // order.Cnt = subItem.Count
  7778. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7779. //
  7780. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7781. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  7782. // order.OwnpayAmt = ""
  7783. // order.SelfpayAmt = ""
  7784. // order.Spec = ""
  7785. // order.SpecUnt = ""
  7786. // order.DrordBegnDate = s_tm
  7787. // order.DrordStopDate = ""
  7788. // order.DrordDrCodg = "1"
  7789. // order.DrordDeptName = department.Name
  7790. // order.DrordDrCodg = "1"
  7791. // order.DrordDrName = doctor_info.UserName
  7792. // order.DrordDrProfttl = ""
  7793. // order.CurrDrordFlag = "1"
  7794. // orders = append(orders, &order)
  7795. //
  7796. // }
  7797. // if subItem.Type == 3 {
  7798. //
  7799. // var order models.FsiOrderDtos
  7800. // order.RxID = strconv.FormatInt(item.ID, 10)
  7801. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7802. // order.LongDrordFlag = "0"
  7803. // order.HilistType = "1"
  7804. // order.ChrgType = "1"
  7805. // order.DrordBhvr = "-"
  7806. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7807. // order.HosplistName = subItem.GoodInfo.GoodName
  7808. // order.HilistLv = "1"
  7809. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7810. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7811. // order.HosplistName = subItem.GoodInfo.GoodName
  7812. // order.Cnt = subItem.Count
  7813. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7814. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7815. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  7816. // order.OwnpayAmt = ""
  7817. // order.SelfpayAmt = ""
  7818. // order.Spec = ""
  7819. // order.SpecUnt = ""
  7820. // order.DrordBegnDate = s_tm
  7821. // order.DrordStopDate = ""
  7822. // order.DrordDrCodg = "1"
  7823. // order.DrordDeptName = department.Name
  7824. // order.DrordDrCodg = "1"
  7825. // order.DrordDrName = doctor_info.UserName
  7826. // order.DrordDrProfttl = ""
  7827. // order.CurrDrordFlag = "1"
  7828. // orders = append(orders, &order)
  7829. //
  7830. // }
  7831. // }
  7832. //}
  7833. for _, item := range prescriptions {
  7834. for _, subItem := range item.HisDoctorAdviceInfo {
  7835. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7836. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7837. var order models.FsiOrderDtos
  7838. order.RxID = strconv.FormatInt(item.ID, 10)
  7839. order.Rxno = strconv.FormatInt(item.ID, 10)
  7840. order.LongDrordFlag = "0"
  7841. order.HilistType = "1"
  7842. order.ChrgType = "1"
  7843. order.DrordBhvr = "0"
  7844. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7845. order.HosplistName = subItem.BaseDrugLib.DrugName
  7846. order.HilistLv = "1"
  7847. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7848. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7849. order.HosplistName = subItem.BaseDrugLib.DrugName
  7850. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7851. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7852. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  7853. order.OwnpayAmt = ""
  7854. order.SelfpayAmt = ""
  7855. order.Spec = spec
  7856. order.SpecUnt = subItem.PrescribingNumberUnit
  7857. order.DrordBegnDate = s_tm
  7858. order.DrordStopDate = ""
  7859. order.DrordDrCodg = doctor_info.DoctorNumber
  7860. order.DrordDeptName = department.Name
  7861. order.DrordDeptCodg = department.Number
  7862. order.DrordDrName = doctor_info.UserName
  7863. order.DrordDrProfttl = "234"
  7864. order.CurrDrordFlag = "1"
  7865. orders = append(orders, &order)
  7866. }
  7867. }
  7868. for _, subItem := range item.HisPrescriptionProject {
  7869. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  7870. var order models.FsiOrderDtos
  7871. order.RxID = strconv.FormatInt(item.ID, 10)
  7872. order.Rxno = strconv.FormatInt(item.ID, 10)
  7873. order.LongDrordFlag = "0"
  7874. order.HilistType = "1"
  7875. order.ChrgType = "1"
  7876. order.DrordBhvr = "0"
  7877. order.HilistCode = subItem.HisProject.MedicalCode
  7878. order.HosplistName = subItem.HisProject.ProjectName
  7879. order.HilistLv = "1"
  7880. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7881. order.HosplistCode = subItem.HisProject.MedicalCode
  7882. order.HosplistName = subItem.HisProject.ProjectName
  7883. order.Cnt = subItem.Count
  7884. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7885. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7886. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7887. order.OwnpayAmt = ""
  7888. order.SelfpayAmt = ""
  7889. order.Spec = subItem.Unit
  7890. order.SpecUnt = subItem.Unit
  7891. order.DrordBegnDate = s_tm
  7892. order.DrordStopDate = ""
  7893. order.DrordDrCodg = doctor_info.DoctorNumber
  7894. order.DrordDeptName = department.Name
  7895. order.DrordDeptCodg = department.Number
  7896. order.DrordDrName = doctor_info.UserName
  7897. order.DrordDrProfttl = "234"
  7898. order.CurrDrordFlag = "1"
  7899. orders = append(orders, &order)
  7900. }
  7901. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7902. var order models.FsiOrderDtos
  7903. order.RxID = strconv.FormatInt(item.ID, 10)
  7904. order.Rxno = strconv.FormatInt(item.ID, 10)
  7905. order.LongDrordFlag = "0"
  7906. order.HilistType = "1"
  7907. order.ChrgType = "1"
  7908. order.DrordBhvr = "0"
  7909. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7910. order.HosplistName = subItem.GoodInfo.GoodName
  7911. order.HilistLv = "1"
  7912. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7913. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7914. order.HosplistName = subItem.GoodInfo.GoodName
  7915. order.Cnt = subItem.Count
  7916. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7917. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7918. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7919. order.OwnpayAmt = ""
  7920. order.SelfpayAmt = ""
  7921. order.Spec = subItem.GoodInfo.SpecificationName
  7922. order.SpecUnt = subItem.Unit
  7923. order.DrordBegnDate = s_tm
  7924. order.DrordStopDate = ""
  7925. order.DrordDrCodg = doctor_info.DoctorNumber
  7926. order.DrordDeptName = department.Name
  7927. order.DrordDeptCodg = department.Number
  7928. order.DrordDrName = doctor_info.UserName
  7929. order.DrordDrProfttl = "234"
  7930. order.CurrDrordFlag = "1"
  7931. orders = append(orders, &order)
  7932. }
  7933. }
  7934. }
  7935. //处方医嘱信息
  7936. fed.MatnStas = "0"
  7937. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7938. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  7939. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  7940. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  7941. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  7942. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  7943. fed.SetlTotlnum = "1"
  7944. fed.Insutype = his.Insutype
  7945. fed.ReimFlag = "0"
  7946. fed.OutSetlFlag = "0"
  7947. var fopd []*models.FsiOperationDtosData
  7948. data := make(map[string]interface{})
  7949. data["fed"] = fed
  7950. data["fdd"] = fdds
  7951. data["fod"] = orders
  7952. data["pd"] = pd
  7953. data["pp"] = pp
  7954. data["fopd"] = fopd
  7955. data["trig_scen"] = trig_scen
  7956. client := &http.Client{}
  7957. bytesData, _ := json.Marshal(data)
  7958. var req *http.Request
  7959. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7960. if miConfig.MdtrtareaAdmvs == "320921" {
  7961. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7962. } else {
  7963. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7964. }
  7965. resp, _ := client.Do(req)
  7966. defer resp.Body.Close()
  7967. body, ioErr := ioutil.ReadAll(resp.Body)
  7968. if ioErr != nil {
  7969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7971. return res
  7972. }
  7973. var respJSON map[string]interface{}
  7974. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7977. return res
  7978. }
  7979. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7980. result, _ := json.Marshal(respJSON)
  7981. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7982. utils.ErrorLog("解析失败:%v", err)
  7983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7984. return res
  7985. }
  7986. return res
  7987. } else {
  7988. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7989. saveLog(output, input, "3102", "事中")
  7990. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7991. utils.ErrorLog("解析失败:%v", err)
  7992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7993. return
  7994. }
  7995. return res
  7996. }
  7997. return res
  7998. }
  7999. func (c *HisApiController) Check() {
  8000. psn_no := c.GetString("psn_no")
  8001. in := c.GetString("in")
  8002. mt := c.GetString("mt")
  8003. baseParams := models.BaseParams{
  8004. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  8005. FixmedinsCode: "H15049901371",
  8006. InsuplcAdmdvs: "150499",
  8007. MdtrtareaAdmvs: "150499",
  8008. OrgName: "赤峰费森血液透析中心",
  8009. Doctor: "1111",
  8010. }
  8011. service.Gdyb2001(baseParams, psn_no, in, mt)
  8012. }
  8013. func (c *HisApiController) GetPsnNcdsInfo() {
  8014. admin_user_id, _ := c.GetInt64("admin_user_id")
  8015. patient_id, _ := c.GetInt64("patient_id")
  8016. //id, _ := c.GetInt64("id")
  8017. adminUser := c.GetAdminUserInfo()
  8018. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8019. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8020. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8021. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8022. //psn_record, _ := service.GetP(id)
  8023. psn_info, _ := service.GetPsnByPatientId(patient_id)
  8024. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  8025. //
  8026. //if psn_record.ID == 0 {
  8027. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8028. // return
  8029. //}
  8030. var res Result5301
  8031. var res10265 Result5301For10265
  8032. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8033. psn_info, _ := service.GetPsnByPatientId(patient_id)
  8034. var api string
  8035. if miConfig.MdtrtareaAdmvs == "320921" {
  8036. 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 +
  8037. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  8038. } else {
  8039. 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 +
  8040. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  8041. }
  8042. resp, requestErr := http.Get(api)
  8043. if requestErr != nil {
  8044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8045. return
  8046. }
  8047. body, ioErr := ioutil.ReadAll(resp.Body)
  8048. if ioErr != nil {
  8049. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8051. return
  8052. }
  8053. var respJSON map[string]interface{}
  8054. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8057. return
  8058. }
  8059. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8060. result, _ := json.Marshal(respJSON)
  8061. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8062. utils.ErrorLog("解析失败:%v", err)
  8063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8064. return
  8065. }
  8066. res.ErrMsg = res10265.ErrMsg
  8067. res.Output = res10265.Output
  8068. res.InfRefmsgid = res10265.InfRefmsgid
  8069. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8070. res.Infcode = infocode
  8071. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8072. psn_info, _ := service.GetPsnByPatientId(patient_id)
  8073. var api string
  8074. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  8075. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  8076. resp, requestErr := http.Get(api)
  8077. if requestErr != nil {
  8078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8079. return
  8080. }
  8081. body, ioErr := ioutil.ReadAll(resp.Body)
  8082. if ioErr != nil {
  8083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8085. return
  8086. }
  8087. var respJSON map[string]interface{}
  8088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8091. return
  8092. }
  8093. status := respJSON["data"].(map[string]interface{})["status"].(string)
  8094. if status == "0" {
  8095. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  8096. c.ServeSuccessJSON(map[string]interface{}{
  8097. "failed_code": -10,
  8098. "msg": err_msg,
  8099. })
  8100. return
  8101. }
  8102. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8103. result, _ := json.Marshal(respJSON)
  8104. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8105. utils.ErrorLog("解析失败:%v", err)
  8106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8107. return
  8108. }
  8109. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8110. p, _ := service.GetHisPatientById(patient_id)
  8111. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  8112. var dat map[string]interface{}
  8113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8114. fmt.Println(dat)
  8115. } else {
  8116. fmt.Println(err)
  8117. }
  8118. userJSONBytes, _ := json.Marshal(dat)
  8119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8120. utils.ErrorLog("解析失败:%v", err)
  8121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8122. return
  8123. }
  8124. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8125. p, _ := service.GetHisPatientById(patient_id)
  8126. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  8127. var dat map[string]interface{}
  8128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8129. fmt.Println(dat)
  8130. } else {
  8131. fmt.Println(err)
  8132. }
  8133. userJSONBytes, _ := json.Marshal(dat)
  8134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8135. utils.ErrorLog("解析失败:%v", err)
  8136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8137. return
  8138. }
  8139. } else if miConfig.MdtrtareaAdmvs == "420200" {
  8140. p, _ := service.GetHisPatientById(patient_id)
  8141. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  8142. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8143. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8144. resp, requestErr := http.Get(api)
  8145. if requestErr != nil {
  8146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8147. return
  8148. }
  8149. body, ioErr := ioutil.ReadAll(resp.Body)
  8150. if ioErr != nil {
  8151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8153. return
  8154. }
  8155. var respJSON map[string]interface{}
  8156. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8159. return
  8160. }
  8161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8162. result, _ := json.Marshal(respJSON)
  8163. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8164. utils.ErrorLog("解析失败:%v", err)
  8165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8166. return
  8167. }
  8168. } else if miConfig.MdtrtareaAdmvs == "420902" {
  8169. p, _ := service.GetHisPatientById(patient_id)
  8170. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  8171. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8172. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8173. resp, requestErr := http.Get(api)
  8174. if requestErr != nil {
  8175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8176. return
  8177. }
  8178. body, ioErr := ioutil.ReadAll(resp.Body)
  8179. if ioErr != nil {
  8180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8182. return
  8183. }
  8184. var respJSON map[string]interface{}
  8185. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8188. return
  8189. }
  8190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8191. result, _ := json.Marshal(respJSON)
  8192. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8193. utils.ErrorLog("解析失败:%v", err)
  8194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8195. return
  8196. }
  8197. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8198. p, _ := service.GetHisPatientById(patient_id)
  8199. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  8200. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8201. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8202. resp, requestErr := http.Get(api)
  8203. if requestErr != nil {
  8204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8205. return
  8206. }
  8207. body, ioErr := ioutil.ReadAll(resp.Body)
  8208. if ioErr != nil {
  8209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8211. return
  8212. }
  8213. var respJSON map[string]interface{}
  8214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8217. return
  8218. }
  8219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8220. result, _ := json.Marshal(respJSON)
  8221. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8222. utils.ErrorLog("解析失败:%v", err)
  8223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8224. return
  8225. }
  8226. } else if miConfig.MdtrtareaAdmvs == "420902" {
  8227. p, _ := service.GetHisPatientById(patient_id)
  8228. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  8229. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8230. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8231. resp, requestErr := http.Get(api)
  8232. if requestErr != nil {
  8233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8234. return
  8235. }
  8236. body, ioErr := ioutil.ReadAll(resp.Body)
  8237. if ioErr != nil {
  8238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8240. return
  8241. }
  8242. var respJSON map[string]interface{}
  8243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8246. return
  8247. }
  8248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8249. result, _ := json.Marshal(respJSON)
  8250. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8251. utils.ErrorLog("解析失败:%v", err)
  8252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8253. return
  8254. }
  8255. } else if miConfig.MdtrtareaAdmvs == "421300" {
  8256. p, _ := service.GetHisPatientById(patient_id)
  8257. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  8258. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8259. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8260. resp, requestErr := http.Get(api)
  8261. if requestErr != nil {
  8262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8263. return
  8264. }
  8265. body, ioErr := ioutil.ReadAll(resp.Body)
  8266. if ioErr != nil {
  8267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8269. return
  8270. }
  8271. var respJSON map[string]interface{}
  8272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8275. return
  8276. }
  8277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8278. result, _ := json.Marshal(respJSON)
  8279. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8280. utils.ErrorLog("解析失败:%v", err)
  8281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8282. return
  8283. }
  8284. } else if miConfig.MdtrtareaAdmvs == "441799" {
  8285. p, _ := service.GetHisPatientById(patient_id)
  8286. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  8287. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8288. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8289. resp, requestErr := http.Get(api)
  8290. if requestErr != nil {
  8291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8292. return
  8293. }
  8294. body, ioErr := ioutil.ReadAll(resp.Body)
  8295. if ioErr != nil {
  8296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8298. return
  8299. }
  8300. var respJSON map[string]interface{}
  8301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8304. return
  8305. }
  8306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8307. result, _ := json.Marshal(respJSON)
  8308. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8309. utils.ErrorLog("解析失败:%v", err)
  8310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8311. return
  8312. }
  8313. } else {
  8314. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  8315. var dat map[string]interface{}
  8316. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8317. fmt.Println(dat)
  8318. } else {
  8319. fmt.Println(err)
  8320. }
  8321. userJSONBytes, _ := json.Marshal(dat)
  8322. if miConfig.Code == "H15049901371" {
  8323. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8324. utils.ErrorLog("解析失败:%v", err)
  8325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8326. return
  8327. }
  8328. res.InfRefmsgid = res10265.InfRefmsgid
  8329. res.Output = res10265.Output
  8330. res.ErrMsg = res10265.ErrMsg
  8331. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8332. res.Infcode = infocode
  8333. } else {
  8334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8335. utils.ErrorLog("解析失败:%v", err)
  8336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8337. return
  8338. }
  8339. }
  8340. }
  8341. if res.Infcode == 0 {
  8342. c.ServeSuccessJSON(map[string]interface{}{
  8343. "result": res.Output.Result,
  8344. })
  8345. }
  8346. }
  8347. func (c *HisApiController) CheckInsutype() {
  8348. his_patient_id, _ := c.GetInt64("his_patient_id")
  8349. admin_user_id, _ := c.GetInt64("admin_user_id")
  8350. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8351. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8352. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8353. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8354. var dat map[string]interface{}
  8355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8356. fmt.Println(dat)
  8357. } else {
  8358. fmt.Println(err)
  8359. }
  8360. userJSONBytes, _ := json.Marshal(dat)
  8361. var res Result90100
  8362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8363. utils.ErrorLog("解析失败:%v", err)
  8364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8365. return
  8366. }
  8367. if res.Infcode != 0 {
  8368. c.ServeSuccessJSON(map[string]interface{}{
  8369. "failed_code": -10,
  8370. "msg": res.ErrMsg,
  8371. })
  8372. return
  8373. } else {
  8374. fmt.Println(res)
  8375. }
  8376. }
  8377. func (c *HisApiController) CheckCardPWD() {
  8378. card_pwd := c.GetString("card_pwd")
  8379. his_patient_id, _ := c.GetInt64("his_patient_id")
  8380. admin_user_id, _ := c.GetInt64("admin_user_id")
  8381. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8382. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8383. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8384. psn, _ := service.GetPsnByPatientId(his.PatientId)
  8385. bas := strings.Split(psn.CardInfo, "|")
  8386. basNumber := bas[2]
  8387. if psn.InsuplcAdmdvs[:4] == "4403" {
  8388. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  8389. var dat map[string]interface{}
  8390. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8391. fmt.Println(dat)
  8392. } else {
  8393. fmt.Println(err)
  8394. }
  8395. userJSONBytes, _ := json.Marshal(dat)
  8396. var res Result90991
  8397. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8398. utils.ErrorLog("解析失败:%v", err)
  8399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8400. return
  8401. }
  8402. if res.Infcode != 0 {
  8403. c.ServeSuccessJSON(map[string]interface{}{
  8404. "failed_code": -10,
  8405. "msg": res.ErrMsg,
  8406. })
  8407. return
  8408. } else {
  8409. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  8410. var msg string
  8411. switch res.Output.Result.CardStat {
  8412. case "00":
  8413. msg = "未激活"
  8414. break
  8415. case "10":
  8416. msg = "激活"
  8417. break
  8418. case "20":
  8419. msg = "窗口挂失"
  8420. break
  8421. case "21":
  8422. msg = "电话挂失"
  8423. break
  8424. case "22":
  8425. msg = "单位网上申报挂失"
  8426. break
  8427. case "23":
  8428. msg = "保健办挂失"
  8429. break
  8430. case "24":
  8431. msg = "个人网上挂失"
  8432. break
  8433. case "25":
  8434. msg = "网上服务大厅挂失"
  8435. break
  8436. case "30":
  8437. msg = "注销"
  8438. break
  8439. case "40":
  8440. msg = "回收"
  8441. break
  8442. case "99":
  8443. msg = "制卡中(无效卡)"
  8444. break
  8445. }
  8446. c.ServeSuccessJSON(map[string]interface{}{
  8447. "failed_code": -10,
  8448. "msg": msg,
  8449. })
  8450. return
  8451. } else {
  8452. c.ServeSuccessJSON(map[string]interface{}{
  8453. "msg": "校验成功",
  8454. })
  8455. return
  8456. }
  8457. }
  8458. } else {
  8459. c.ServeSuccessJSON(map[string]interface{}{
  8460. "msg": "校验成功",
  8461. })
  8462. return
  8463. }
  8464. }
  8465. func (c *HisApiController) CheckCardPWDTwo() {
  8466. //card_pwd := c.GetString("card_pwd")
  8467. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8468. admin_user_id, _ := c.GetInt64("admin_user_id")
  8469. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8470. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8471. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  8472. var dat map[string]interface{}
  8473. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8474. fmt.Println(dat)
  8475. } else {
  8476. fmt.Println(err)
  8477. }
  8478. userJSONBytes, _ := json.Marshal(dat)
  8479. var res Result90991
  8480. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8481. utils.ErrorLog("解析失败:%v", err)
  8482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8483. return
  8484. }
  8485. if res.Infcode != 0 {
  8486. c.ServeSuccessJSON(map[string]interface{}{
  8487. "failed_code": -10,
  8488. "msg": res.ErrMsg,
  8489. })
  8490. return
  8491. } else {
  8492. if res.Output.Result.SscnoCheckStat == "0" {
  8493. var msg string
  8494. switch res.Output.Result.CardStat {
  8495. case "00":
  8496. msg = "未激活"
  8497. break
  8498. case "10":
  8499. msg = "激活"
  8500. break
  8501. case "20":
  8502. msg = "窗口挂失"
  8503. break
  8504. case "21":
  8505. msg = "电话挂失"
  8506. break
  8507. case "22":
  8508. msg = "单位网上申报挂失"
  8509. break
  8510. case "23":
  8511. msg = "保健办挂失"
  8512. break
  8513. case "24":
  8514. msg = "个人网上挂失"
  8515. break
  8516. case "25":
  8517. msg = "网上服务大厅挂失"
  8518. break
  8519. case "30":
  8520. msg = "注销"
  8521. break
  8522. case "40":
  8523. msg = "回收"
  8524. break
  8525. case "99":
  8526. msg = "制卡中(无效卡)"
  8527. break
  8528. }
  8529. c.ServeSuccessJSON(map[string]interface{}{
  8530. "failed_code": -10,
  8531. "msg": msg,
  8532. })
  8533. return
  8534. } else {
  8535. c.ServeSuccessJSON(map[string]interface{}{
  8536. "msg": "校验成功",
  8537. })
  8538. return
  8539. }
  8540. }
  8541. }
  8542. type ELeCertData struct {
  8543. Data struct {
  8544. Extra string `json:"extra"`
  8545. IDNo string `json:"idNo"`
  8546. IDType string `json:"idType"`
  8547. EcToken string `json:"ecToken"`
  8548. InsuOrg string `json:"insuOrg"`
  8549. UserName string `json:"userName"`
  8550. EcIndexNo string `json:"ecIndexNo"`
  8551. Gender string `json:"gender"`
  8552. Birthday string `json:"birthday"`
  8553. Nationality string `json:"nationality"`
  8554. Email string `json:"email"`
  8555. } `json:"OutData"`
  8556. }
  8557. func (c *HisApiController) ReadCard() {
  8558. id_card_type, _ := c.GetInt64("id_card_type")
  8559. admin_user_id, _ := c.GetInt64("admin_user_id")
  8560. certificates, _ := c.GetInt64("certificates")
  8561. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  8562. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8564. switch id_card_type {
  8565. case 1:
  8566. if miConfig.MdtrtareaAdmvs == "421300" {
  8567. var res ResultTwo
  8568. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8569. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8570. "&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)
  8571. resp, requestErr := http.Get(api)
  8572. if requestErr != nil {
  8573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8574. return
  8575. }
  8576. body, ioErr := ioutil.ReadAll(resp.Body)
  8577. if ioErr != nil {
  8578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8580. return
  8581. }
  8582. var respJSON map[string]interface{}
  8583. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8586. return
  8587. }
  8588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8589. result, _ := json.Marshal(respJSON)
  8590. fmt.Println("log")
  8591. fmt.Println(string(result))
  8592. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8593. utils.ErrorLog("解析失败:%v", err)
  8594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8595. return
  8596. }
  8597. if res.Infcode == 0 {
  8598. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8599. if err == gorm.ErrRecordNotFound {
  8600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8601. return
  8602. } else if err != nil {
  8603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8604. return
  8605. } else {
  8606. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8607. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8608. infoStr := string(Iinfos)
  8609. idetinfoStr := string(Idetinfos)
  8610. var rf []*ResultFive
  8611. json.Unmarshal([]byte(infoStr), &rf)
  8612. var insutypes []*ResultFive
  8613. var insutype string
  8614. var is390 int = 0
  8615. var is310 int = 0
  8616. for _, item := range rf {
  8617. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8618. insutypes = append(insutypes, item)
  8619. }
  8620. }
  8621. if len(insutypes) == 1 {
  8622. insutype = insutypes[0].Insutype
  8623. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8624. } else {
  8625. for _, i := range insutypes {
  8626. if i.Insutype == "390" {
  8627. is390 = 1
  8628. }
  8629. if i.Insutype == "310" {
  8630. is310 = 1
  8631. }
  8632. }
  8633. }
  8634. if is390 == 1 {
  8635. insutype = "390"
  8636. }
  8637. if is310 == 1 {
  8638. insutype = "310"
  8639. }
  8640. if len(insutypes) == 0 {
  8641. insutype = "390"
  8642. }
  8643. var insuplc_admdvs string
  8644. for _, item := range rf {
  8645. if item.Insutype == insutype {
  8646. insuplc_admdvs = item.InsuplcAdmdvs
  8647. }
  8648. }
  8649. if strings.Contains(insuplc_admdvs, "4213") {
  8650. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  8651. }
  8652. psn := &models.HisPsn{
  8653. PsnNo: res.Output.Baseinfo.PsnNo,
  8654. PatientId: patient.ID,
  8655. Certno: res.Output.Baseinfo.Certno,
  8656. Gend: res.Output.Baseinfo.Gend,
  8657. Naty: res.Output.Baseinfo.Naty,
  8658. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8659. PsnName: res.Output.Baseinfo.PsnName,
  8660. Idetinfo: idetinfoStr,
  8661. Insuinfo: infoStr,
  8662. InsuplcAdmdvs: insuplc_admdvs,
  8663. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8664. }
  8665. service.CreateHisPsn(psn)
  8666. c.ServeSuccessJSON(map[string]interface{}{
  8667. "patient": patient,
  8668. "number": res.Output.Baseinfo.Certno,
  8669. })
  8670. }
  8671. } else {
  8672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8673. return
  8674. }
  8675. } else if miConfig.MdtrtareaAdmvs == "420200" {
  8676. var res ResultTwo
  8677. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  8678. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8679. "&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)
  8680. resp, requestErr := http.Get(api)
  8681. if requestErr != nil {
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8683. return
  8684. }
  8685. body, ioErr := ioutil.ReadAll(resp.Body)
  8686. if ioErr != nil {
  8687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8689. return
  8690. }
  8691. var respJSON map[string]interface{}
  8692. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8695. return
  8696. }
  8697. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8698. result, _ := json.Marshal(respJSON)
  8699. fmt.Println("log")
  8700. fmt.Println(string(result))
  8701. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8702. utils.ErrorLog("解析失败:%v", err)
  8703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8704. return
  8705. }
  8706. if res.Infcode == 0 {
  8707. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8708. if err == gorm.ErrRecordNotFound {
  8709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8710. return
  8711. } else if err != nil {
  8712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8713. return
  8714. } else {
  8715. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8716. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8717. infoStr := string(Iinfos)
  8718. idetinfoStr := string(Idetinfos)
  8719. psn := &models.HisPsn{
  8720. PsnNo: res.Output.Baseinfo.PsnNo,
  8721. PatientId: patient.ID,
  8722. Certno: res.Output.Baseinfo.Certno,
  8723. Gend: res.Output.Baseinfo.Gend,
  8724. Naty: res.Output.Baseinfo.Naty,
  8725. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8726. PsnName: res.Output.Baseinfo.PsnName,
  8727. Idetinfo: idetinfoStr,
  8728. Insuinfo: infoStr,
  8729. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8730. }
  8731. service.CreateHisPsn(psn)
  8732. var rf []*ResultFive
  8733. json.Unmarshal([]byte(infoStr), &rf)
  8734. var insutypes []*ResultFive
  8735. var insutype string
  8736. var is390 int = 0
  8737. var is310 int = 0
  8738. for _, item := range rf {
  8739. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8740. insutypes = append(insutypes, item)
  8741. }
  8742. }
  8743. if len(insutypes) == 1 {
  8744. insutype = insutypes[0].Insutype
  8745. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8746. } else {
  8747. for _, i := range insutypes {
  8748. if i.Insutype == "390" {
  8749. is390 = 1
  8750. }
  8751. if i.Insutype == "310" {
  8752. is310 = 1
  8753. }
  8754. }
  8755. }
  8756. if is390 == 1 {
  8757. insutype = "390"
  8758. }
  8759. if is310 == 1 {
  8760. insutype = "310"
  8761. }
  8762. if len(insutypes) == 0 {
  8763. insutype = "310"
  8764. }
  8765. c.ServeSuccessJSON(map[string]interface{}{
  8766. "patient": patient,
  8767. "number": res.Output.Baseinfo.Certno,
  8768. "insutype": insutype,
  8769. })
  8770. }
  8771. } else {
  8772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8773. return
  8774. }
  8775. } else if miConfig.MdtrtareaAdmvs == "420902" {
  8776. var res ResultTwo
  8777. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  8778. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8779. "&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)
  8780. resp, requestErr := http.Get(api)
  8781. if requestErr != nil {
  8782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8783. return
  8784. }
  8785. body, ioErr := ioutil.ReadAll(resp.Body)
  8786. if ioErr != nil {
  8787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8789. return
  8790. }
  8791. var respJSON map[string]interface{}
  8792. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8795. return
  8796. }
  8797. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8798. result, _ := json.Marshal(respJSON)
  8799. fmt.Println("log")
  8800. fmt.Println(string(result))
  8801. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8802. utils.ErrorLog("解析失败:%v", err)
  8803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8804. return
  8805. }
  8806. if res.Infcode == 0 {
  8807. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8808. if err == gorm.ErrRecordNotFound {
  8809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8810. return
  8811. } else if err != nil {
  8812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8813. return
  8814. } else {
  8815. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8816. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8817. infoStr := string(Iinfos)
  8818. idetinfoStr := string(Idetinfos)
  8819. var rf []*ResultFive
  8820. json.Unmarshal([]byte(infoStr), &rf)
  8821. var insutypes []*ResultFive
  8822. var insutype string
  8823. var is390 int = 0
  8824. var is310 int = 0
  8825. for _, item := range rf {
  8826. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8827. insutypes = append(insutypes, item)
  8828. }
  8829. }
  8830. if len(insutypes) == 1 {
  8831. insutype = insutypes[0].Insutype
  8832. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8833. } else {
  8834. for _, i := range insutypes {
  8835. if i.Insutype == "390" {
  8836. is390 = 1
  8837. }
  8838. if i.Insutype == "310" {
  8839. is310 = 1
  8840. }
  8841. }
  8842. }
  8843. if is390 == 1 {
  8844. insutype = "390"
  8845. }
  8846. if is310 == 1 {
  8847. insutype = "310"
  8848. }
  8849. if len(insutypes) == 0 {
  8850. insutype = "390"
  8851. }
  8852. var insuplc_admdvs string
  8853. for _, item := range rf {
  8854. if item.Insutype == insutype {
  8855. insuplc_admdvs = item.InsuplcAdmdvs
  8856. }
  8857. }
  8858. psn := &models.HisPsn{
  8859. PsnNo: res.Output.Baseinfo.PsnNo,
  8860. PatientId: patient.ID,
  8861. Certno: res.Output.Baseinfo.Certno,
  8862. Gend: res.Output.Baseinfo.Gend,
  8863. Naty: res.Output.Baseinfo.Naty,
  8864. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8865. PsnName: res.Output.Baseinfo.PsnName,
  8866. Idetinfo: idetinfoStr,
  8867. Insuinfo: infoStr,
  8868. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8869. InsuplcAdmdvs: insuplc_admdvs,
  8870. }
  8871. service.CreateHisPsn(psn)
  8872. for _, item := range rf {
  8873. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8874. insutypes = append(insutypes, item)
  8875. }
  8876. }
  8877. if len(insutypes) == 1 {
  8878. insutype = insutypes[0].Insutype
  8879. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8880. } else {
  8881. for _, i := range insutypes {
  8882. if i.Insutype == "390" {
  8883. is390 = 1
  8884. }
  8885. if i.Insutype == "310" {
  8886. is310 = 1
  8887. }
  8888. }
  8889. }
  8890. if is390 == 1 {
  8891. insutype = "390"
  8892. }
  8893. if is310 == 1 {
  8894. insutype = "310"
  8895. }
  8896. if len(insutypes) == 0 {
  8897. insutype = "310"
  8898. }
  8899. c.ServeSuccessJSON(map[string]interface{}{
  8900. "patient": patient,
  8901. "number": res.Output.Baseinfo.Certno,
  8902. "insutype": insutype,
  8903. })
  8904. }
  8905. } else {
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8907. return
  8908. }
  8909. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8910. var res ResultTwo
  8911. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  8912. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8913. "&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)
  8914. resp, requestErr := http.Get(api)
  8915. if requestErr != nil {
  8916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8917. return
  8918. }
  8919. body, ioErr := ioutil.ReadAll(resp.Body)
  8920. if ioErr != nil {
  8921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8923. return
  8924. }
  8925. var respJSON map[string]interface{}
  8926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8929. return
  8930. }
  8931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8932. result, _ := json.Marshal(respJSON)
  8933. fmt.Println("log")
  8934. fmt.Println(string(result))
  8935. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8936. utils.ErrorLog("解析失败:%v", err)
  8937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8938. return
  8939. }
  8940. if res.Infcode == 0 {
  8941. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8942. if err == gorm.ErrRecordNotFound {
  8943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8944. return
  8945. } else if err != nil {
  8946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8947. return
  8948. } else {
  8949. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8950. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8951. infoStr := string(Iinfos)
  8952. idetinfoStr := string(Idetinfos)
  8953. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8954. psn := &models.HisPsn{
  8955. PsnNo: res.Output.Baseinfo.PsnNo,
  8956. PatientId: patient.ID,
  8957. Certno: res.Output.Baseinfo.Certno,
  8958. Brdy: b,
  8959. Age: float64(age),
  8960. Gend: res.Output.Baseinfo.Gend,
  8961. Naty: res.Output.Baseinfo.Naty,
  8962. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8963. PsnName: res.Output.Baseinfo.PsnName,
  8964. Idetinfo: idetinfoStr,
  8965. Insuinfo: infoStr,
  8966. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8967. }
  8968. service.CreateHisPsn(psn)
  8969. var rf []*ResultFive
  8970. json.Unmarshal([]byte(infoStr), &rf)
  8971. var insutypes []*ResultFive
  8972. var insutype string
  8973. var is390 int = 0
  8974. var is310 int = 0
  8975. for _, item := range rf {
  8976. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8977. insutypes = append(insutypes, item)
  8978. }
  8979. }
  8980. if len(insutypes) == 1 {
  8981. insutype = insutypes[0].Insutype
  8982. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8983. } else {
  8984. for _, i := range insutypes {
  8985. if i.Insutype == "390" {
  8986. is390 = 1
  8987. }
  8988. if i.Insutype == "310" {
  8989. is310 = 1
  8990. }
  8991. }
  8992. }
  8993. if is390 == 1 {
  8994. insutype = "390"
  8995. }
  8996. if is310 == 1 {
  8997. insutype = "310"
  8998. }
  8999. if len(insutypes) == 0 {
  9000. insutype = "310"
  9001. }
  9002. c.ServeSuccessJSON(map[string]interface{}{
  9003. "patient": patient,
  9004. "number": res.Output.Baseinfo.Certno,
  9005. "insutype": insutype,
  9006. })
  9007. }
  9008. } else {
  9009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9010. return
  9011. }
  9012. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9013. var api string
  9014. if miConfig.MdtrtareaAdmvs == "320921" {
  9015. 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 +
  9016. "&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
  9017. fmt.Println(api)
  9018. } else {
  9019. 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 +
  9020. "&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)
  9021. }
  9022. resp, requestErr := http.Get(api)
  9023. if requestErr != nil {
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9025. return
  9026. }
  9027. body, ioErr := ioutil.ReadAll(resp.Body)
  9028. if ioErr != nil {
  9029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9031. return
  9032. }
  9033. var respJSON map[string]interface{}
  9034. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9037. return
  9038. }
  9039. var status string
  9040. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9041. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9042. //console.log()
  9043. fmt.Println("type===")
  9044. fmt.Println(card_type)
  9045. var token string
  9046. var res ResultTwo //1101结果
  9047. var res10265 ResultTwo10265 //1101结果
  9048. var card_info string //卡信息
  9049. var busi_card_info string
  9050. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9051. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9052. if status == "0" { //读卡成功
  9053. if card_type == "1" {
  9054. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9055. result, _ := json.Marshal(respJSON)
  9056. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9057. utils.ErrorLog("解析失败:%v", err)
  9058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9059. return
  9060. }
  9061. res.ErrMsg = res10265.ErrMsg
  9062. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9063. res.Infcode = infocode
  9064. res.Output = res10265.Output
  9065. res.InfRefmsgid = res10265.InfRefmsgid
  9066. } else {
  9067. //var card_info string //卡信息
  9068. //var busi_card_info string
  9069. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9070. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9071. //fmt.Println(card_info)
  9072. //fmt.Println(busi_card_info)
  9073. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9074. result, _ := json.Marshal(respJSON)
  9075. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9076. utils.ErrorLog("解析失败:%v", err)
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. res.ErrMsg = res10265.ErrMsg
  9081. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9082. res.Infcode = infocode
  9083. res.Output = res10265.Output
  9084. res.InfRefmsgid = res10265.InfRefmsgid
  9085. }
  9086. if res.Infcode == 0 {
  9087. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9088. if err == gorm.ErrRecordNotFound {
  9089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9090. return
  9091. } else if err != nil {
  9092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9093. return
  9094. } else {
  9095. if card_type == "1" {
  9096. bas := strings.Split(card_info, "|")
  9097. basNumber := bas[2]
  9098. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9099. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9100. infoStr := string(Iinfos)
  9101. idetinfoStr := string(Idetinfos)
  9102. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9103. psn := &models.HisPsn{
  9104. PsnNo: res.Output.Baseinfo.PsnNo,
  9105. PatientId: patient.ID,
  9106. Certno: res.Output.Baseinfo.Certno,
  9107. Brdy: b,
  9108. Age: float64(age),
  9109. Gend: res.Output.Baseinfo.Gend,
  9110. Naty: res.Output.Baseinfo.Naty,
  9111. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9112. PsnName: res.Output.Baseinfo.PsnName,
  9113. Idetinfo: idetinfoStr,
  9114. Insuinfo: infoStr,
  9115. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9116. CardInfo: card_info,
  9117. VerifyNumber: busi_card_info,
  9118. }
  9119. service.CreateHisPsn(psn)
  9120. var rf []*ResultFive
  9121. json.Unmarshal([]byte(infoStr), &rf)
  9122. var insutypes []*ResultFive
  9123. var insutype string
  9124. var is390 int = 0
  9125. var is310 int = 0
  9126. for _, item := range rf {
  9127. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9128. insutypes = append(insutypes, item)
  9129. }
  9130. }
  9131. if len(insutypes) == 1 {
  9132. insutype = insutypes[0].Insutype
  9133. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9134. } else {
  9135. for _, i := range insutypes {
  9136. if i.Insutype == "390" {
  9137. is390 = 1
  9138. }
  9139. if i.Insutype == "310" {
  9140. is310 = 1
  9141. }
  9142. }
  9143. }
  9144. if is390 == 1 {
  9145. insutype = "390"
  9146. }
  9147. if is310 == 1 {
  9148. insutype = "310"
  9149. }
  9150. if len(insutypes) == 0 {
  9151. insutype = "310"
  9152. }
  9153. c.ServeSuccessJSON(map[string]interface{}{
  9154. "patient": patient,
  9155. "number": basNumber,
  9156. "insutype": insutype,
  9157. })
  9158. } else {
  9159. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9160. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9161. infoStr := string(Iinfos)
  9162. idetinfoStr := string(Idetinfos)
  9163. psn := &models.HisPsn{
  9164. PsnNo: res.Output.Baseinfo.PsnNo,
  9165. PatientId: patient.ID,
  9166. Certno: res.Output.Baseinfo.Certno,
  9167. Gend: res.Output.Baseinfo.Gend,
  9168. Naty: res.Output.Baseinfo.Naty,
  9169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9170. PsnName: res.Output.Baseinfo.PsnName,
  9171. Idetinfo: idetinfoStr,
  9172. Insuinfo: infoStr,
  9173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9174. CardInfo: card_info,
  9175. VerifyNumber: token,
  9176. }
  9177. service.CreateHisPsn(psn)
  9178. c.ServeSuccessJSON(map[string]interface{}{
  9179. "patient": patient,
  9180. "number": token,
  9181. })
  9182. }
  9183. }
  9184. } else {
  9185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9186. return
  9187. }
  9188. } else { //读卡失败
  9189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9190. return
  9191. }
  9192. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9193. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  9194. cardnum = DeleteExtraSpaceTwo(cardnum)
  9195. cardCode = DeleteExtraSpaceTwo(cardCode)
  9196. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  9197. name = DeleteExtraSpaceTwo(name)
  9198. errmsg = DeleteExtraSpaceTwo(errmsg)
  9199. cardnum = Remove0000(cardnum)
  9200. cardCode = Remove0000(cardCode)
  9201. id_card_no = Remove0000(id_card_no)
  9202. name = Remove0000(name)
  9203. errmsg = Remove0000(errmsg)
  9204. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  9205. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  9206. //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)
  9207. //fmt.Println(result2)
  9208. //fmt.Println(requestLog2)
  9209. //fmt.Println(errMsgLog2)
  9210. 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)
  9211. saveLog(result, requestLog, "1101", "获取人员信息")
  9212. fmt.Println(errMsgLog)
  9213. if len(errMsgLog) > 0 {
  9214. } else {
  9215. var dat map[string]interface{}
  9216. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9217. fmt.Println(dat)
  9218. } else {
  9219. fmt.Println(err)
  9220. }
  9221. userJSONBytes, _ := json.Marshal(dat)
  9222. var res ResultTwo
  9223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9224. utils.ErrorLog("解析失败:%v", err)
  9225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9226. return
  9227. }
  9228. res.ErrMsg = errMsgLog
  9229. if res.Infcode == 0 {
  9230. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9231. if err == gorm.ErrRecordNotFound {
  9232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9233. return
  9234. } else if err != nil {
  9235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9236. return
  9237. } else {
  9238. fmt.Println(res)
  9239. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9240. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9241. infoStr := string(Iinfos)
  9242. idetinfoStr := string(Idetinfos)
  9243. var rf []*ResultFive
  9244. json.Unmarshal([]byte(infoStr), &rf)
  9245. var insutypes []*ResultFive
  9246. var insutype string
  9247. var is390 int = 0
  9248. var is310 int = 0
  9249. for _, item := range rf {
  9250. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9251. insutypes = append(insutypes, item)
  9252. }
  9253. }
  9254. if len(insutypes) == 1 {
  9255. insutype = insutypes[0].Insutype
  9256. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9257. } else {
  9258. for _, i := range insutypes {
  9259. if i.Insutype == "390" {
  9260. is390 = 1
  9261. }
  9262. if i.Insutype == "310" {
  9263. is310 = 1
  9264. }
  9265. }
  9266. }
  9267. if is390 == 1 {
  9268. insutype = "390"
  9269. }
  9270. if is310 == 1 {
  9271. insutype = "310"
  9272. }
  9273. if len(insutypes) == 0 {
  9274. insutype = "390"
  9275. }
  9276. var insuplc_admdvs string
  9277. for _, item := range rf {
  9278. if item.Insutype == insutype {
  9279. insuplc_admdvs = item.InsuplcAdmdvs
  9280. }
  9281. }
  9282. psn := &models.HisPsn{
  9283. PsnNo: res.Output.Baseinfo.PsnNo,
  9284. PatientId: patient.ID,
  9285. Certno: res.Output.Baseinfo.Certno,
  9286. Gend: res.Output.Baseinfo.Gend,
  9287. Naty: res.Output.Baseinfo.Naty,
  9288. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9289. PsnName: res.Output.Baseinfo.PsnName,
  9290. Idetinfo: idetinfoStr,
  9291. Insuinfo: infoStr,
  9292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9293. CardInfo: basStr,
  9294. VerifyNumber: "",
  9295. InsuplcAdmdvs: insuplc_admdvs,
  9296. }
  9297. service.CreateHisPsn(psn)
  9298. c.ServeSuccessJSON(map[string]interface{}{
  9299. "patient": patient,
  9300. "number": cardnum,
  9301. "insutype": insutype,
  9302. })
  9303. }
  9304. } else {
  9305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9306. return
  9307. }
  9308. }
  9309. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9310. fmt.Println(initFlag)
  9311. fmt.Println("initFlag")
  9312. if initFlag == 0 {
  9313. c.TestGetJiangXiBasBaseInit()
  9314. }
  9315. basStr := c.GetBasBaseInfo()
  9316. if len(basStr) == 0 {
  9317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9318. return
  9319. }
  9320. fmt.Println(basStr)
  9321. bas := strings.Split(basStr, "|")
  9322. basNumber := bas[1]
  9323. fmt.Println(basNumber)
  9324. card_sn := bas[3]
  9325. fmt.Println(card_sn)
  9326. 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, "")
  9327. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  9328. var dat map[string]interface{}
  9329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9330. fmt.Println(dat)
  9331. } else {
  9332. fmt.Println(err)
  9333. }
  9334. userJSONBytes, _ := json.Marshal(dat)
  9335. var res ResultTwo
  9336. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9337. utils.ErrorLog("解析失败:%v", err)
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9339. return
  9340. }
  9341. if res.Infcode == 0 {
  9342. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9343. if err == gorm.ErrRecordNotFound {
  9344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9345. return
  9346. } else if err != nil {
  9347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9348. return
  9349. } else {
  9350. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9351. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9352. infoStr := string(Iinfos)
  9353. idetinfoStr := string(Idetinfos)
  9354. var rf []*ResultFive
  9355. json.Unmarshal([]byte(infoStr), &rf)
  9356. var insutypes []*ResultFive
  9357. var insutype string
  9358. var is390 int = 0
  9359. var is310 int = 0
  9360. var insuplc_admdvs string
  9361. for _, item := range rf {
  9362. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9363. insutypes = append(insutypes, item)
  9364. }
  9365. }
  9366. if len(insutypes) == 1 {
  9367. insutype = insutypes[0].Insutype
  9368. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9369. } else {
  9370. for _, i := range insutypes {
  9371. if i.Insutype == "390" {
  9372. is390 = 1
  9373. }
  9374. if i.Insutype == "310" {
  9375. is310 = 1
  9376. }
  9377. }
  9378. }
  9379. if is390 == 1 {
  9380. insutype = "390"
  9381. }
  9382. if is310 == 1 {
  9383. insutype = "310"
  9384. }
  9385. if len(insutypes) == 0 {
  9386. insutype = "310"
  9387. }
  9388. for _, item := range rf {
  9389. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  9390. insuplc_admdvs = item.InsuplcAdmdvs
  9391. }
  9392. }
  9393. psn := &models.HisPsn{
  9394. PsnNo: res.Output.Baseinfo.PsnNo,
  9395. PatientId: patient.ID,
  9396. Certno: res.Output.Baseinfo.Certno,
  9397. Gend: res.Output.Baseinfo.Gend,
  9398. Naty: res.Output.Baseinfo.Naty,
  9399. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9400. PsnName: res.Output.Baseinfo.PsnName,
  9401. Idetinfo: idetinfoStr,
  9402. Insuinfo: infoStr,
  9403. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9404. CardInfo: basStr,
  9405. InsuplcAdmdvs: insuplc_admdvs,
  9406. VerifyNumber: "",
  9407. }
  9408. service.CreateHisPsn(psn)
  9409. c.ServeSuccessJSON(map[string]interface{}{
  9410. "patient": patient,
  9411. "number": basNumber,
  9412. "insutype": insutype,
  9413. })
  9414. }
  9415. } else {
  9416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9417. return
  9418. }
  9419. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9420. fmt.Println(initFlag)
  9421. fmt.Println("initFlag")
  9422. if initFlag == 0 {
  9423. c.TestGetHnBasBaseInit()
  9424. }
  9425. basStr := c.GetBasBaseInfo()
  9426. if len(basStr) == 0 {
  9427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9428. return
  9429. }
  9430. fmt.Println(basStr)
  9431. bas := strings.Split(basStr, "|")
  9432. basNumber := bas[1]
  9433. fmt.Println(basNumber)
  9434. card_sn := bas[3]
  9435. card_no := bas[2]
  9436. fmt.Println(card_sn)
  9437. name := bas[4]
  9438. name = ConvertToString(name, "gbk", "utf-8")
  9439. 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)
  9440. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  9441. var dat map[string]interface{}
  9442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9443. fmt.Println(dat)
  9444. } else {
  9445. fmt.Println(err)
  9446. }
  9447. userJSONBytes, _ := json.Marshal(dat)
  9448. var res ResultTwo
  9449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9450. utils.ErrorLog("解析失败:%v", err)
  9451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9452. return
  9453. }
  9454. if res.Infcode == 0 {
  9455. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9456. if err == gorm.ErrRecordNotFound {
  9457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9458. return
  9459. } else if err != nil {
  9460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9461. return
  9462. } else {
  9463. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9464. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9465. infoStr := string(Iinfos)
  9466. idetinfoStr := string(Idetinfos)
  9467. psn := &models.HisPsn{
  9468. PsnNo: res.Output.Baseinfo.PsnNo,
  9469. PatientId: patient.ID,
  9470. Certno: res.Output.Baseinfo.Certno,
  9471. Gend: res.Output.Baseinfo.Gend,
  9472. Naty: res.Output.Baseinfo.Naty,
  9473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9474. PsnName: res.Output.Baseinfo.PsnName,
  9475. Idetinfo: idetinfoStr,
  9476. Insuinfo: infoStr,
  9477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9478. CardInfo: basStr,
  9479. VerifyNumber: "",
  9480. }
  9481. service.CreateHisPsn(psn)
  9482. var rf []*ResultFive
  9483. json.Unmarshal([]byte(infoStr), &rf)
  9484. var insutypes []*ResultFive
  9485. var insutype string
  9486. var is390 int = 0
  9487. var is310 int = 0
  9488. for _, item := range rf {
  9489. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9490. insutypes = append(insutypes, item)
  9491. }
  9492. }
  9493. if len(insutypes) == 1 {
  9494. insutype = insutypes[0].Insutype
  9495. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9496. } else {
  9497. for _, i := range insutypes {
  9498. if i.Insutype == "390" {
  9499. is390 = 1
  9500. }
  9501. if i.Insutype == "310" {
  9502. is310 = 1
  9503. }
  9504. }
  9505. }
  9506. if is390 == 1 {
  9507. insutype = "390"
  9508. }
  9509. if is310 == 1 {
  9510. insutype = "310"
  9511. }
  9512. if len(insutypes) == 0 {
  9513. insutype = "310"
  9514. }
  9515. c.ServeSuccessJSON(map[string]interface{}{
  9516. "patient": patient,
  9517. "number": basNumber,
  9518. "insutype": insutype,
  9519. })
  9520. }
  9521. } else {
  9522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9523. return
  9524. }
  9525. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9526. var api string
  9527. 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 +
  9528. "&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
  9529. fmt.Println(api)
  9530. resp, requestErr := http.Get(api)
  9531. if requestErr != nil {
  9532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9533. return
  9534. }
  9535. body, ioErr := ioutil.ReadAll(resp.Body)
  9536. if ioErr != nil {
  9537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9539. return
  9540. }
  9541. var respJSON map[string]interface{}
  9542. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9545. return
  9546. }
  9547. var res ResultTwo //1101结果
  9548. var res10265 ResultTwo10265 //1101结果
  9549. var card_info string //卡信息
  9550. token := respJSON["data"].(map[string]interface{})["token"].(string)
  9551. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9552. result, _ := json.Marshal(respJSON)
  9553. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9554. utils.ErrorLog("解析失败:%v", err)
  9555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9556. return
  9557. }
  9558. res.ErrMsg = res10265.ErrMsg
  9559. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9560. res.Infcode = infocode
  9561. res.Output = res10265.Output
  9562. res.InfRefmsgid = res10265.InfRefmsgid
  9563. if res.Infcode == 0 {
  9564. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9565. if err == gorm.ErrRecordNotFound {
  9566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9567. return
  9568. } else if err != nil {
  9569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9570. return
  9571. } else {
  9572. bas := strings.Split(card_info, "|")
  9573. basNumber := bas[2]
  9574. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9575. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9576. infoStr := string(Iinfos)
  9577. idetinfoStr := string(Idetinfos)
  9578. psn := &models.HisPsn{
  9579. PsnNo: res.Output.Baseinfo.PsnNo,
  9580. PatientId: patient.ID,
  9581. Certno: res.Output.Baseinfo.Certno,
  9582. Gend: res.Output.Baseinfo.Gend,
  9583. Naty: res.Output.Baseinfo.Naty,
  9584. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9585. PsnName: res.Output.Baseinfo.PsnName,
  9586. Idetinfo: idetinfoStr,
  9587. Insuinfo: infoStr,
  9588. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9589. CardInfo: card_info,
  9590. VerifyNumber: token,
  9591. }
  9592. service.CreateHisPsn(psn)
  9593. var rf []*ResultFive
  9594. json.Unmarshal([]byte(infoStr), &rf)
  9595. var insutypes []*ResultFive
  9596. var insutype string
  9597. var is390 int = 0
  9598. var is310 int = 0
  9599. for _, item := range rf {
  9600. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9601. insutypes = append(insutypes, item)
  9602. }
  9603. }
  9604. if len(insutypes) == 1 {
  9605. insutype = insutypes[0].Insutype
  9606. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9607. } else {
  9608. for _, i := range insutypes {
  9609. if i.Insutype == "390" {
  9610. is390 = 1
  9611. }
  9612. if i.Insutype == "310" {
  9613. is310 = 1
  9614. }
  9615. }
  9616. }
  9617. if is390 == 1 {
  9618. insutype = "390"
  9619. }
  9620. if is310 == 1 {
  9621. insutype = "310"
  9622. }
  9623. if len(insutypes) == 0 {
  9624. insutype = "310"
  9625. }
  9626. c.ServeSuccessJSON(map[string]interface{}{
  9627. "patient": patient,
  9628. "number": basNumber,
  9629. "insutype": insutype,
  9630. })
  9631. }
  9632. } else {
  9633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9634. return
  9635. }
  9636. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9637. res := c.GetoleInfo()
  9638. if res.Infcode == 0 {
  9639. var result string
  9640. if res.Output.MdtrtCertType == "01" {
  9641. 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)
  9642. } else if res.Output.MdtrtCertType == "02" {
  9643. 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)
  9644. } else if res.Output.MdtrtCertType == "03" {
  9645. 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)
  9646. }
  9647. var dat map[string]interface{}
  9648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9649. fmt.Println(dat)
  9650. } else {
  9651. fmt.Println(err)
  9652. }
  9653. userJSONBytes, _ := json.Marshal(dat)
  9654. var res2 ResultTwo
  9655. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9656. utils.ErrorLog("解析失败:%v", err)
  9657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9658. return
  9659. }
  9660. if res2.Infcode == 0 {
  9661. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9662. if err == gorm.ErrRecordNotFound {
  9663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9664. return
  9665. } else if err != nil {
  9666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9667. return
  9668. } else {
  9669. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9670. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9671. infoStr := string(Iinfos)
  9672. idetinfoStr := string(Idetinfos)
  9673. var rf []*ResultFive
  9674. json.Unmarshal([]byte(infoStr), &rf)
  9675. var insutypes []*ResultFive
  9676. var insutype string
  9677. var is390 int = 0
  9678. var is310 int = 0
  9679. //var insuplc_admdvs string
  9680. for _, item := range rf {
  9681. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9682. insutypes = append(insutypes, item)
  9683. }
  9684. }
  9685. if len(insutypes) == 1 {
  9686. insutype = insutypes[0].Insutype
  9687. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9688. } else {
  9689. for _, i := range insutypes {
  9690. if i.Insutype == "390" {
  9691. is390 = 1
  9692. }
  9693. if i.Insutype == "310" {
  9694. is310 = 1
  9695. }
  9696. }
  9697. }
  9698. if is390 == 1 {
  9699. insutype = "390"
  9700. }
  9701. if is310 == 1 {
  9702. insutype = "310"
  9703. }
  9704. if len(insutypes) == 0 {
  9705. insutype = "310"
  9706. }
  9707. psn := &models.HisPsn{
  9708. PsnNo: res2.Output.Baseinfo.PsnNo,
  9709. PatientId: patient.ID,
  9710. Certno: res2.Output.Baseinfo.Certno,
  9711. Gend: res2.Output.Baseinfo.Gend,
  9712. Naty: res2.Output.Baseinfo.Naty,
  9713. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9714. PsnName: res2.Output.Baseinfo.PsnName,
  9715. Idetinfo: idetinfoStr,
  9716. Insuinfo: infoStr,
  9717. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9718. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9719. VerifyNumber: res.Output.EcToken,
  9720. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9721. }
  9722. if res.Output.MdtrtCertType == "01" {
  9723. psn.VerifyNumber = res.Output.EcToken
  9724. //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)
  9725. } else if res.Output.MdtrtCertType == "02" {
  9726. psn.VerifyNumber = res.Output.MdtrtCertNo
  9727. //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)
  9728. } else if res.Output.MdtrtCertType == "03" {
  9729. psn.VerifyNumber = res.Output.MdtrtCertNo
  9730. //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)
  9731. }
  9732. var balc float64
  9733. for _, item := range rf {
  9734. if item.Insutype == insutype {
  9735. balc = item.Balc
  9736. }
  9737. }
  9738. service.CreateHisPsn(psn)
  9739. c.ServeSuccessJSON(map[string]interface{}{
  9740. "patient": patient,
  9741. "number": res.Output.CardNo,
  9742. "insutype": insutype,
  9743. "blac": balc,
  9744. "desc": idetinfoStr,
  9745. })
  9746. }
  9747. } else {
  9748. c.ServeSuccessJSON(map[string]interface{}{
  9749. "failed_code": -10,
  9750. "msg": res2.ErrMsg,
  9751. })
  9752. }
  9753. } else {
  9754. c.ServeSuccessJSON(map[string]interface{}{
  9755. "failed_code": -10,
  9756. "msg": res.ErrMsg,
  9757. })
  9758. }
  9759. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9760. var api string
  9761. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9762. "&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
  9763. fmt.Println(api)
  9764. resp, requestErr := http.Get(api)
  9765. if requestErr != nil {
  9766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9767. return
  9768. }
  9769. body, ioErr := ioutil.ReadAll(resp.Body)
  9770. if ioErr != nil {
  9771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9773. return
  9774. }
  9775. var respJSON map[string]interface{}
  9776. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9779. return
  9780. }
  9781. var status string
  9782. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9783. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9784. //console.log()
  9785. fmt.Println("type===")
  9786. fmt.Println(card_type)
  9787. var token string
  9788. var res ResultTwo //1101结果
  9789. //var res10265 ResultTwoesultTwo10265 //1101结果
  9790. var card_info string //卡信息
  9791. var busi_card_info string
  9792. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9793. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9794. if status == "0" { //读卡成功
  9795. if card_type == "1" {
  9796. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9797. result, _ := json.Marshal(respJSON)
  9798. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9799. utils.ErrorLog("解析失败:%v", err)
  9800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9801. return
  9802. }
  9803. } else {
  9804. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9805. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9806. result, _ := json.Marshal(respJSON)
  9807. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9808. utils.ErrorLog("解析失败:%v", err)
  9809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9810. return
  9811. }
  9812. }
  9813. if res.Infcode == 0 {
  9814. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9815. if err == gorm.ErrRecordNotFound {
  9816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9817. return
  9818. } else if err != nil {
  9819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9820. return
  9821. } else {
  9822. if card_type == "1" {
  9823. bas := strings.Split(card_info, "|")
  9824. basNumber := bas[2]
  9825. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9826. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9827. infoStr := string(Iinfos)
  9828. idetinfoStr := string(Idetinfos)
  9829. psn := &models.HisPsn{
  9830. PsnNo: res.Output.Baseinfo.PsnNo,
  9831. PatientId: patient.ID,
  9832. Certno: res.Output.Baseinfo.Certno,
  9833. Gend: res.Output.Baseinfo.Gend,
  9834. Naty: res.Output.Baseinfo.Naty,
  9835. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9836. PsnName: res.Output.Baseinfo.PsnName,
  9837. Idetinfo: idetinfoStr,
  9838. Insuinfo: infoStr,
  9839. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9840. CardInfo: card_info,
  9841. VerifyNumber: busi_card_info,
  9842. }
  9843. service.CreateHisPsn(psn)
  9844. var rf []*ResultFive
  9845. json.Unmarshal([]byte(infoStr), &rf)
  9846. var insutypes []*ResultFive
  9847. var insutype string
  9848. var is390 int = 0
  9849. var is310 int = 0
  9850. for _, item := range rf {
  9851. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9852. insutypes = append(insutypes, item)
  9853. }
  9854. }
  9855. if len(insutypes) == 1 {
  9856. insutype = insutypes[0].Insutype
  9857. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9858. } else {
  9859. for _, i := range insutypes {
  9860. if i.Insutype == "390" {
  9861. is390 = 1
  9862. }
  9863. if i.Insutype == "310" {
  9864. is310 = 1
  9865. }
  9866. }
  9867. }
  9868. if is390 == 1 {
  9869. insutype = "390"
  9870. }
  9871. if is310 == 1 {
  9872. insutype = "310"
  9873. }
  9874. if len(insutypes) == 0 {
  9875. insutype = "310"
  9876. }
  9877. c.ServeSuccessJSON(map[string]interface{}{
  9878. "patient": patient,
  9879. "number": basNumber,
  9880. "insutype": insutype,
  9881. })
  9882. } else {
  9883. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9884. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9885. infoStr := string(Iinfos)
  9886. idetinfoStr := string(Idetinfos)
  9887. psn := &models.HisPsn{
  9888. PsnNo: res.Output.Baseinfo.PsnNo,
  9889. PatientId: patient.ID,
  9890. Certno: res.Output.Baseinfo.Certno,
  9891. Gend: res.Output.Baseinfo.Gend,
  9892. Naty: res.Output.Baseinfo.Naty,
  9893. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9894. PsnName: res.Output.Baseinfo.PsnName,
  9895. Idetinfo: idetinfoStr,
  9896. Insuinfo: infoStr,
  9897. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9898. CardInfo: card_info,
  9899. VerifyNumber: token,
  9900. }
  9901. service.CreateHisPsn(psn)
  9902. c.ServeSuccessJSON(map[string]interface{}{
  9903. "patient": patient,
  9904. "number": token,
  9905. })
  9906. }
  9907. }
  9908. } else {
  9909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9910. return
  9911. }
  9912. } else { //读卡失败
  9913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9914. return
  9915. }
  9916. } else {
  9917. if initFlag == 0 {
  9918. c.TestGetBasBaseInit()
  9919. }
  9920. basStr := c.GetBasBaseInfo()
  9921. if len(basStr) == 0 {
  9922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9923. return
  9924. }
  9925. fmt.Println(basStr)
  9926. bas := strings.Split(basStr, "|")
  9927. basNumber := bas[1]
  9928. fmt.Println(basNumber)
  9929. card_sn := bas[3]
  9930. fmt.Println(card_sn)
  9931. cardNumber := bas[2]
  9932. fmt.Println(cardNumber)
  9933. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  9934. var result string
  9935. if bas[0][:2] == "44" {
  9936. 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)
  9937. } else {
  9938. 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)
  9939. }
  9940. var dat map[string]interface{}
  9941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9942. fmt.Println(dat)
  9943. } else {
  9944. fmt.Println(err)
  9945. }
  9946. userJSONBytes, _ := json.Marshal(dat)
  9947. var res ResultTwo
  9948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9949. utils.ErrorLog("解析失败:%v", err)
  9950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9951. return
  9952. }
  9953. if res.Infcode == 0 {
  9954. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9955. if err == gorm.ErrRecordNotFound {
  9956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9957. return
  9958. } else if err != nil {
  9959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9960. return
  9961. } else {
  9962. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9963. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9964. infoStr := string(Iinfos)
  9965. idetinfoStr := string(Idetinfos)
  9966. var rf []*ResultFive
  9967. json.Unmarshal([]byte(infoStr), &rf)
  9968. var insutypes []*ResultFive
  9969. var insutype string
  9970. var is390 int = 0
  9971. var is310 int = 0
  9972. var insuplc_admdvs string
  9973. for _, item := range rf {
  9974. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9975. insutypes = append(insutypes, item)
  9976. }
  9977. }
  9978. if len(insutypes) == 1 {
  9979. insutype = insutypes[0].Insutype
  9980. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9981. } else {
  9982. for _, i := range insutypes {
  9983. if i.Insutype == "390" {
  9984. is390 = 1
  9985. }
  9986. if i.Insutype == "310" {
  9987. is310 = 1
  9988. }
  9989. }
  9990. }
  9991. if is390 == 1 {
  9992. insutype = "390"
  9993. }
  9994. if is310 == 1 {
  9995. insutype = "310"
  9996. }
  9997. if len(insutypes) == 0 {
  9998. insutype = "310"
  9999. }
  10000. for _, item := range rf {
  10001. if item.Insutype == insutype {
  10002. insuplc_admdvs = item.InsuplcAdmdvs
  10003. }
  10004. }
  10005. psn := &models.HisPsn{
  10006. PsnNo: res.Output.Baseinfo.PsnNo,
  10007. PatientId: patient.ID,
  10008. Certno: res.Output.Baseinfo.Certno,
  10009. Gend: res.Output.Baseinfo.Gend,
  10010. Naty: res.Output.Baseinfo.Naty,
  10011. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10012. PsnName: res.Output.Baseinfo.PsnName,
  10013. Idetinfo: idetinfoStr,
  10014. Insuinfo: infoStr,
  10015. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10016. CardInfo: basStr,
  10017. VerifyNumber: "",
  10018. InsuplcAdmdvs: insuplc_admdvs,
  10019. }
  10020. service.CreateHisPsn(psn)
  10021. c.ServeSuccessJSON(map[string]interface{}{
  10022. "patient": patient,
  10023. "number": basNumber,
  10024. })
  10025. }
  10026. } else {
  10027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10028. return
  10029. }
  10030. break
  10031. }
  10032. case 2:
  10033. if miConfig.MdtrtareaAdmvs == "430800" {
  10034. if initFlag == 0 {
  10035. c.TestGetHnBasBaseInit()
  10036. }
  10037. SFZStr := c.GetSFZBaseInfo()
  10038. if len(SFZStr) == 0 {
  10039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10040. return
  10041. }
  10042. fmt.Println(SFZStr)
  10043. id_card_str := strings.Split(SFZStr, "^")
  10044. card_no := id_card_str[0]
  10045. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  10046. //name := id_card_str[1]
  10047. //name = ConvertToString(name, "gbk", "utf-8")
  10048. 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)
  10049. var dat map[string]interface{}
  10050. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10051. fmt.Println(dat)
  10052. } else {
  10053. fmt.Println(err)
  10054. }
  10055. userJSONBytes, _ := json.Marshal(dat)
  10056. var res ResultTwo
  10057. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10058. utils.ErrorLog("解析失败:%v", err)
  10059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10060. return
  10061. }
  10062. if res.Infcode == 0 {
  10063. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  10064. if err == gorm.ErrRecordNotFound {
  10065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10066. return
  10067. } else if err != nil {
  10068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10069. return
  10070. } else {
  10071. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10072. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10073. infoStr := string(Iinfos)
  10074. idetinfoStr := string(Idetinfos)
  10075. var rf []*ResultFive
  10076. json.Unmarshal([]byte(infoStr), &rf)
  10077. var insutypes []*ResultFive
  10078. var insutype string
  10079. var is390 int = 0
  10080. var is310 int = 0
  10081. for _, item := range rf {
  10082. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10083. insutypes = append(insutypes, item)
  10084. }
  10085. }
  10086. if len(insutypes) == 1 {
  10087. insutype = insutypes[0].Insutype
  10088. } else {
  10089. for _, i := range insutypes {
  10090. if i.Insutype == "390" {
  10091. is390 = 1
  10092. }
  10093. if i.Insutype == "310" {
  10094. is310 = 1
  10095. }
  10096. }
  10097. }
  10098. if is390 == 1 {
  10099. insutype = "390"
  10100. }
  10101. if is310 == 1 {
  10102. insutype = "310"
  10103. }
  10104. if len(insutypes) == 0 {
  10105. insutype = "310"
  10106. }
  10107. var InsuplcAdmdvs string
  10108. for _, item := range rf {
  10109. if item.Insutype == insutype {
  10110. InsuplcAdmdvs = item.InsuplcAdmdvs
  10111. }
  10112. }
  10113. psn := &models.HisPsn{
  10114. PsnNo: res.Output.Baseinfo.PsnNo,
  10115. PatientId: patient.ID,
  10116. Certno: res.Output.Baseinfo.Certno,
  10117. Gend: res.Output.Baseinfo.Gend,
  10118. Naty: res.Output.Baseinfo.Naty,
  10119. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10120. PsnName: res.Output.Baseinfo.PsnName,
  10121. Idetinfo: idetinfoStr,
  10122. Insuinfo: infoStr,
  10123. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10124. CardInfo: SFZStr,
  10125. VerifyNumber: "",
  10126. InsuplcAdmdvs: InsuplcAdmdvs,
  10127. }
  10128. service.CreateHisPsn(psn)
  10129. c.ServeSuccessJSON(map[string]interface{}{
  10130. "patient": patient,
  10131. "number": card_no,
  10132. "insutype": insutype,
  10133. })
  10134. }
  10135. } else {
  10136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10137. return
  10138. }
  10139. } else if miConfig.MdtrtareaAdmvs == "420200" {
  10140. var res ResultTwo
  10141. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  10142. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10143. "&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)
  10144. resp, requestErr := http.Get(api)
  10145. if requestErr != nil {
  10146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10147. return
  10148. }
  10149. body, ioErr := ioutil.ReadAll(resp.Body)
  10150. if ioErr != nil {
  10151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10153. return
  10154. }
  10155. var respJSON map[string]interface{}
  10156. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10159. return
  10160. }
  10161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10162. result, _ := json.Marshal(respJSON)
  10163. fmt.Println("log")
  10164. fmt.Println(string(result))
  10165. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10166. utils.ErrorLog("解析失败:%v", err)
  10167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10168. return
  10169. }
  10170. if res.Infcode == 0 {
  10171. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10172. if err == gorm.ErrRecordNotFound {
  10173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10174. return
  10175. } else if err != nil {
  10176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10177. return
  10178. } else {
  10179. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10180. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10181. infoStr := string(Iinfos)
  10182. idetinfoStr := string(Idetinfos)
  10183. psn := &models.HisPsn{
  10184. PsnNo: res.Output.Baseinfo.PsnNo,
  10185. PatientId: patient.ID,
  10186. Certno: res.Output.Baseinfo.Certno,
  10187. Gend: res.Output.Baseinfo.Gend,
  10188. Naty: res.Output.Baseinfo.Naty,
  10189. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10190. PsnName: res.Output.Baseinfo.PsnName,
  10191. Idetinfo: idetinfoStr,
  10192. Insuinfo: infoStr,
  10193. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10194. }
  10195. service.CreateHisPsn(psn)
  10196. c.ServeSuccessJSON(map[string]interface{}{
  10197. "patient": patient,
  10198. "number": res.Output.Baseinfo.Certno,
  10199. })
  10200. }
  10201. } else {
  10202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10203. return
  10204. }
  10205. } else if miConfig.MdtrtareaAdmvs == "421182" {
  10206. var res ResultTwo
  10207. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10208. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10209. "&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)
  10210. resp, requestErr := http.Get(api)
  10211. if requestErr != nil {
  10212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10213. return
  10214. }
  10215. body, ioErr := ioutil.ReadAll(resp.Body)
  10216. if ioErr != nil {
  10217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10219. return
  10220. }
  10221. var respJSON map[string]interface{}
  10222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10225. return
  10226. }
  10227. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10228. result, _ := json.Marshal(respJSON)
  10229. fmt.Println("log")
  10230. fmt.Println(string(result))
  10231. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10232. utils.ErrorLog("解析失败:%v", err)
  10233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10234. return
  10235. }
  10236. if res.Infcode == 0 {
  10237. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10238. if err == gorm.ErrRecordNotFound {
  10239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10240. return
  10241. } else if err != nil {
  10242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10243. return
  10244. } else {
  10245. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10246. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10247. infoStr := string(Iinfos)
  10248. idetinfoStr := string(Idetinfos)
  10249. psn := &models.HisPsn{
  10250. PsnNo: res.Output.Baseinfo.PsnNo,
  10251. PatientId: patient.ID,
  10252. Certno: res.Output.Baseinfo.Certno,
  10253. Gend: res.Output.Baseinfo.Gend,
  10254. Naty: res.Output.Baseinfo.Naty,
  10255. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10256. PsnName: res.Output.Baseinfo.PsnName,
  10257. Idetinfo: idetinfoStr,
  10258. Insuinfo: infoStr,
  10259. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10260. }
  10261. service.CreateHisPsn(psn)
  10262. c.ServeSuccessJSON(map[string]interface{}{
  10263. "patient": patient,
  10264. "number": res.Output.Baseinfo.Certno,
  10265. })
  10266. }
  10267. } else {
  10268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10269. return
  10270. }
  10271. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10272. var res ResultTwo
  10273. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10274. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10275. "&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)
  10276. resp, requestErr := http.Get(api)
  10277. if requestErr != nil {
  10278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10279. return
  10280. }
  10281. body, ioErr := ioutil.ReadAll(resp.Body)
  10282. if ioErr != nil {
  10283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10285. return
  10286. }
  10287. var respJSON map[string]interface{}
  10288. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10291. return
  10292. }
  10293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10294. result, _ := json.Marshal(respJSON)
  10295. fmt.Println("log")
  10296. fmt.Println(string(result))
  10297. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10298. utils.ErrorLog("解析失败:%v", err)
  10299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10300. return
  10301. }
  10302. if res.Infcode == 0 {
  10303. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10304. if err == gorm.ErrRecordNotFound {
  10305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10306. return
  10307. } else if err != nil {
  10308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10309. return
  10310. } else {
  10311. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10312. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10313. infoStr := string(Iinfos)
  10314. idetinfoStr := string(Idetinfos)
  10315. var rf []*ResultFive
  10316. json.Unmarshal([]byte(infoStr), &rf)
  10317. var insutypes []*ResultFive
  10318. var insutype string
  10319. var is390 int = 0
  10320. var is310 int = 0
  10321. for _, item := range rf {
  10322. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10323. insutypes = append(insutypes, item)
  10324. }
  10325. }
  10326. if len(insutypes) == 1 {
  10327. insutype = insutypes[0].Insutype
  10328. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10329. } else {
  10330. for _, i := range insutypes {
  10331. if i.Insutype == "390" {
  10332. is390 = 1
  10333. }
  10334. if i.Insutype == "310" {
  10335. is310 = 1
  10336. }
  10337. }
  10338. }
  10339. if is390 == 1 {
  10340. insutype = "390"
  10341. }
  10342. if is310 == 1 {
  10343. insutype = "310"
  10344. }
  10345. if len(insutypes) == 0 {
  10346. insutype = "390"
  10347. }
  10348. var insuplc_admdvs string
  10349. for _, item := range rf {
  10350. if item.Insutype == insutype {
  10351. insuplc_admdvs = item.InsuplcAdmdvs
  10352. }
  10353. }
  10354. psn := &models.HisPsn{
  10355. PsnNo: res.Output.Baseinfo.PsnNo,
  10356. PatientId: patient.ID,
  10357. Certno: res.Output.Baseinfo.Certno,
  10358. Gend: res.Output.Baseinfo.Gend,
  10359. Naty: res.Output.Baseinfo.Naty,
  10360. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10361. PsnName: res.Output.Baseinfo.PsnName,
  10362. Idetinfo: idetinfoStr,
  10363. Insuinfo: infoStr,
  10364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10365. InsuplcAdmdvs: insuplc_admdvs,
  10366. }
  10367. service.CreateHisPsn(psn)
  10368. c.ServeSuccessJSON(map[string]interface{}{
  10369. "patient": patient,
  10370. "number": res.Output.Baseinfo.Certno,
  10371. })
  10372. }
  10373. } else {
  10374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10375. return
  10376. }
  10377. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10378. res := c.GetoleInfo()
  10379. if res.Infcode == 0 {
  10380. var result string
  10381. if res.Output.MdtrtCertType == "01" {
  10382. 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)
  10383. } else if res.Output.MdtrtCertType == "02" {
  10384. 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)
  10385. } else if res.Output.MdtrtCertType == "03" {
  10386. 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)
  10387. }
  10388. var dat map[string]interface{}
  10389. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10390. fmt.Println(dat)
  10391. } else {
  10392. fmt.Println(err)
  10393. }
  10394. userJSONBytes, _ := json.Marshal(dat)
  10395. var res2 ResultTwo
  10396. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10397. utils.ErrorLog("解析失败:%v", err)
  10398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10399. return
  10400. }
  10401. if res2.Infcode == 0 {
  10402. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10403. if err == gorm.ErrRecordNotFound {
  10404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10405. return
  10406. } else if err != nil {
  10407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10408. return
  10409. } else {
  10410. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10411. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10412. infoStr := string(Iinfos)
  10413. idetinfoStr := string(Idetinfos)
  10414. var rf []*ResultFive
  10415. json.Unmarshal([]byte(infoStr), &rf)
  10416. var insutypes []*ResultFive
  10417. var insutype string
  10418. var is390 int = 0
  10419. var is310 int = 0
  10420. //var insuplc_admdvs string
  10421. for _, item := range rf {
  10422. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10423. insutypes = append(insutypes, item)
  10424. }
  10425. }
  10426. if len(insutypes) == 1 {
  10427. insutype = insutypes[0].Insutype
  10428. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10429. } else {
  10430. for _, i := range insutypes {
  10431. if i.Insutype == "390" {
  10432. is390 = 1
  10433. }
  10434. if i.Insutype == "310" {
  10435. is310 = 1
  10436. }
  10437. }
  10438. }
  10439. if is390 == 1 {
  10440. insutype = "390"
  10441. }
  10442. if is310 == 1 {
  10443. insutype = "310"
  10444. }
  10445. if len(insutypes) == 0 {
  10446. insutype = "310"
  10447. }
  10448. psn := &models.HisPsn{
  10449. PsnNo: res2.Output.Baseinfo.PsnNo,
  10450. PatientId: patient.ID,
  10451. //Brdy: res2.Output.Baseinfo.Brdy,
  10452. Certno: res2.Output.Baseinfo.Certno,
  10453. Gend: res2.Output.Baseinfo.Gend,
  10454. Naty: res2.Output.Baseinfo.Naty,
  10455. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10456. PsnName: res2.Output.Baseinfo.PsnName,
  10457. Idetinfo: idetinfoStr,
  10458. Insuinfo: infoStr,
  10459. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10460. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10461. VerifyNumber: res.Output.EcToken,
  10462. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10463. }
  10464. service.CreateHisPsn(psn)
  10465. var balc float64
  10466. for _, item := range rf {
  10467. if item.Insutype == insutype {
  10468. balc = item.Balc
  10469. }
  10470. }
  10471. c.ServeSuccessJSON(map[string]interface{}{
  10472. "patient": patient,
  10473. "number": res.Output.CardNo,
  10474. "insutype": insutype,
  10475. "blac": balc,
  10476. "desc": idetinfoStr,
  10477. })
  10478. }
  10479. } else {
  10480. c.ServeSuccessJSON(map[string]interface{}{
  10481. "failed_code": -10,
  10482. "msg": res2.ErrMsg,
  10483. })
  10484. }
  10485. } else {
  10486. c.ServeSuccessJSON(map[string]interface{}{
  10487. "failed_code": -10,
  10488. "msg": res.ErrMsg,
  10489. })
  10490. }
  10491. } else {
  10492. SFZStr := c.GetSFZBaseInfo()
  10493. id_card_str := strings.Split(SFZStr, "^")
  10494. id_card_number := id_card_str[0]
  10495. card_sn := ""
  10496. 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)
  10497. var dat map[string]interface{}
  10498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10499. fmt.Println(dat)
  10500. } else {
  10501. fmt.Println(err)
  10502. }
  10503. userJSONBytes, _ := json.Marshal(dat)
  10504. var res ResultTwo
  10505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10506. utils.ErrorLog("解析失败:%v", err)
  10507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10508. return
  10509. }
  10510. if res.Infcode == 0 {
  10511. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  10512. if err == gorm.ErrRecordNotFound {
  10513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10514. return
  10515. } else if err != nil {
  10516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10517. return
  10518. } else {
  10519. c.ServeSuccessJSON(map[string]interface{}{
  10520. "patient": patient,
  10521. "number": id_card_number,
  10522. })
  10523. }
  10524. } else {
  10525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10526. return
  10527. }
  10528. }
  10529. break
  10530. case 3:
  10531. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10532. var api string
  10533. if miConfig.MdtrtareaAdmvs == "320921" {
  10534. 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 +
  10535. "&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
  10536. fmt.Println(api)
  10537. } else {
  10538. 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 +
  10539. "&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)
  10540. }
  10541. resp, requestErr := http.Get(api)
  10542. if requestErr != nil {
  10543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10544. return
  10545. }
  10546. body, ioErr := ioutil.ReadAll(resp.Body)
  10547. if ioErr != nil {
  10548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10550. return
  10551. }
  10552. var respJSON map[string]interface{}
  10553. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10556. return
  10557. }
  10558. var status string
  10559. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10560. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10561. var token string
  10562. var res ResultTwo //1101结果
  10563. var res10265 ResultTwo10265 //1101结果
  10564. var card_info string //卡信息
  10565. var busi_card_info string
  10566. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10567. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10568. if status == "0" { //读卡成功
  10569. if card_type == "1" {
  10570. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10571. result, _ := json.Marshal(respJSON)
  10572. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10573. utils.ErrorLog("解析失败:%v", err)
  10574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10575. return
  10576. }
  10577. res.ErrMsg = res10265.ErrMsg
  10578. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10579. res.Infcode = infocode
  10580. res.Output = res10265.Output
  10581. res.InfRefmsgid = res10265.InfRefmsgid
  10582. } else {
  10583. //var card_info string //卡信息
  10584. //var busi_card_info string
  10585. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10586. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10587. //fmt.Println(card_info)
  10588. //fmt.Println(busi_card_info)
  10589. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10590. result, _ := json.Marshal(respJSON)
  10591. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10592. utils.ErrorLog("解析失败:%v", err)
  10593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10594. return
  10595. }
  10596. res.ErrMsg = res10265.ErrMsg
  10597. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10598. res.Infcode = infocode
  10599. res.Output = res10265.Output
  10600. res.InfRefmsgid = res10265.InfRefmsgid
  10601. }
  10602. if res.Infcode == 0 {
  10603. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10604. if err == gorm.ErrRecordNotFound {
  10605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10606. return
  10607. } else if err != nil {
  10608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10609. return
  10610. } else {
  10611. if card_type == "1" {
  10612. bas := strings.Split(card_info, "|")
  10613. basNumber := bas[2]
  10614. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10615. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10616. infoStr := string(Iinfos)
  10617. idetinfoStr := string(Idetinfos)
  10618. psn := &models.HisPsn{
  10619. PsnNo: res.Output.Baseinfo.PsnNo,
  10620. PatientId: patient.ID,
  10621. Certno: res.Output.Baseinfo.Certno,
  10622. //Brdy: res.Output.Baseinfo.Brdy,
  10623. Gend: res.Output.Baseinfo.Gend,
  10624. Naty: res.Output.Baseinfo.Naty,
  10625. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10626. PsnName: res.Output.Baseinfo.PsnName,
  10627. Idetinfo: idetinfoStr,
  10628. Insuinfo: infoStr,
  10629. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10630. CardInfo: card_info,
  10631. VerifyNumber: busi_card_info,
  10632. }
  10633. service.CreateHisPsn(psn)
  10634. c.ServeSuccessJSON(map[string]interface{}{
  10635. "patient": patient,
  10636. "number": basNumber,
  10637. })
  10638. } else {
  10639. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10640. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10641. infoStr := string(Iinfos)
  10642. idetinfoStr := string(Idetinfos)
  10643. psn := &models.HisPsn{
  10644. PsnNo: res.Output.Baseinfo.PsnNo,
  10645. PatientId: patient.ID,
  10646. Certno: res.Output.Baseinfo.Certno,
  10647. Gend: res.Output.Baseinfo.Gend,
  10648. Naty: res.Output.Baseinfo.Naty,
  10649. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10650. PsnName: res.Output.Baseinfo.PsnName,
  10651. Idetinfo: idetinfoStr,
  10652. Insuinfo: infoStr,
  10653. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10654. CardInfo: card_info,
  10655. VerifyNumber: token,
  10656. }
  10657. service.CreateHisPsn(psn)
  10658. var rf []*ResultFive
  10659. json.Unmarshal([]byte(infoStr), &rf)
  10660. var insutypes []*ResultFive
  10661. var insutype string
  10662. var is390 int = 0
  10663. var is310 int = 0
  10664. for _, item := range rf {
  10665. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10666. insutypes = append(insutypes, item)
  10667. }
  10668. }
  10669. if len(insutypes) == 1 {
  10670. insutype = insutypes[0].Insutype
  10671. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10672. } else {
  10673. for _, i := range insutypes {
  10674. if i.Insutype == "390" {
  10675. is390 = 1
  10676. }
  10677. if i.Insutype == "310" {
  10678. is310 = 1
  10679. }
  10680. }
  10681. }
  10682. if is390 == 1 {
  10683. insutype = "390"
  10684. }
  10685. if is310 == 1 {
  10686. insutype = "310"
  10687. }
  10688. if len(insutypes) == 0 {
  10689. insutype = "310"
  10690. }
  10691. c.ServeSuccessJSON(map[string]interface{}{
  10692. "patient": patient,
  10693. "number": token,
  10694. "insutype": insutype,
  10695. })
  10696. }
  10697. }
  10698. } else {
  10699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10700. return
  10701. }
  10702. } else { //读卡失败
  10703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10704. return
  10705. }
  10706. }
  10707. break
  10708. case 4:
  10709. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10710. var api string
  10711. if miConfig.MdtrtareaAdmvs == "320921" {
  10712. 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 +
  10713. "&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
  10714. fmt.Println(api)
  10715. } else {
  10716. 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 +
  10717. "&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)
  10718. }
  10719. resp, requestErr := http.Get(api)
  10720. if requestErr != nil {
  10721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10722. return
  10723. }
  10724. body, ioErr := ioutil.ReadAll(resp.Body)
  10725. if ioErr != nil {
  10726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10728. return
  10729. }
  10730. var respJSON map[string]interface{}
  10731. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10734. return
  10735. }
  10736. var status string
  10737. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10738. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10739. var token string
  10740. var res ResultTwo //1101结果
  10741. var res10265 ResultTwo10265 //1101结果
  10742. if status == "0" { //读卡成功
  10743. var card_info string //卡信息
  10744. var busi_card_info string
  10745. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10746. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10747. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10748. fmt.Println(card_info)
  10749. fmt.Println(busi_card_info)
  10750. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10751. result, _ := json.Marshal(respJSON)
  10752. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10753. utils.ErrorLog("解析失败:%v", err)
  10754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10755. return
  10756. }
  10757. res.ErrMsg = res10265.ErrMsg
  10758. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10759. res.Infcode = infocode
  10760. res.Output = res10265.Output
  10761. res.InfRefmsgid = res10265.InfRefmsgid
  10762. if res.Infcode == 0 {
  10763. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10764. if err == gorm.ErrRecordNotFound {
  10765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10766. return
  10767. } else if err != nil {
  10768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10769. return
  10770. } else {
  10771. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10772. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10773. infoStr := string(Iinfos)
  10774. idetinfoStr := string(Idetinfos)
  10775. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10776. psn := &models.HisPsn{
  10777. PsnNo: res.Output.Baseinfo.PsnNo,
  10778. PatientId: patient.ID,
  10779. Certno: res.Output.Baseinfo.Certno,
  10780. Brdy: b,
  10781. Age: float64(age),
  10782. //Brdy: res.Output.Baseinfo.Brdy,
  10783. Gend: res.Output.Baseinfo.Gend,
  10784. Naty: res.Output.Baseinfo.Naty,
  10785. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10786. PsnName: res.Output.Baseinfo.PsnName,
  10787. Idetinfo: idetinfoStr,
  10788. Insuinfo: infoStr,
  10789. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10790. CardInfo: card_info,
  10791. VerifyNumber: token,
  10792. }
  10793. var rf []*ResultFive
  10794. json.Unmarshal([]byte(infoStr), &rf)
  10795. var insutypes []*ResultFive
  10796. var insutype string
  10797. var is390 int = 0
  10798. var is310 int = 0
  10799. for _, item := range rf {
  10800. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10801. insutypes = append(insutypes, item)
  10802. }
  10803. }
  10804. if len(insutypes) == 1 {
  10805. insutype = insutypes[0].Insutype
  10806. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10807. } else {
  10808. for _, i := range insutypes {
  10809. if i.Insutype == "390" {
  10810. is390 = 1
  10811. }
  10812. if i.Insutype == "310" {
  10813. is310 = 1
  10814. }
  10815. }
  10816. }
  10817. if is390 == 1 {
  10818. insutype = "390"
  10819. }
  10820. if is310 == 1 {
  10821. insutype = "310"
  10822. }
  10823. if len(insutypes) == 0 {
  10824. insutype = "310"
  10825. }
  10826. service.CreateHisPsn(psn)
  10827. c.ServeSuccessJSON(map[string]interface{}{
  10828. "patient": patient,
  10829. "number": token,
  10830. "insutype": insutype,
  10831. })
  10832. }
  10833. } else {
  10834. c.ServeSuccessJSON(map[string]interface{}{
  10835. "failed_code": -10,
  10836. "msg": res.ErrMsg,
  10837. })
  10838. }
  10839. } else { //读卡失败
  10840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10841. return
  10842. }
  10843. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10844. var api string
  10845. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10846. "&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
  10847. resp, requestErr := http.Get(api)
  10848. if requestErr != nil {
  10849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10850. return
  10851. }
  10852. body, ioErr := ioutil.ReadAll(resp.Body)
  10853. if ioErr != nil {
  10854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10856. return
  10857. }
  10858. var respJSON map[string]interface{}
  10859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10862. return
  10863. }
  10864. var status string
  10865. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10866. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10867. var token string
  10868. var res ResultTwo //1101结果
  10869. if status == "1" { //读卡成功
  10870. var card_info string //卡信息
  10871. var busi_card_info string
  10872. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10873. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10874. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10875. fmt.Println(card_info)
  10876. fmt.Println(busi_card_info)
  10877. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10878. result, _ := json.Marshal(respJSON)
  10879. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10880. utils.ErrorLog("解析失败:%v", err)
  10881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10882. return
  10883. }
  10884. if res.Infcode == 0 {
  10885. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10886. if err == gorm.ErrRecordNotFound {
  10887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10888. return
  10889. } else if err != nil {
  10890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10891. return
  10892. } else {
  10893. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10894. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10895. infoStr := string(Iinfos)
  10896. idetinfoStr := string(Idetinfos)
  10897. psn := &models.HisPsn{
  10898. PsnNo: res.Output.Baseinfo.PsnNo,
  10899. PatientId: patient.ID,
  10900. Certno: res.Output.Baseinfo.Certno,
  10901. Gend: res.Output.Baseinfo.Gend,
  10902. Naty: res.Output.Baseinfo.Naty,
  10903. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10904. PsnName: res.Output.Baseinfo.PsnName,
  10905. Idetinfo: idetinfoStr,
  10906. Insuinfo: infoStr,
  10907. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10908. CardInfo: card_info,
  10909. VerifyNumber: token,
  10910. }
  10911. var rf []*ResultFive
  10912. json.Unmarshal([]byte(infoStr), &rf)
  10913. var insutypes []*ResultFive
  10914. var insutype string
  10915. var is390 int = 0
  10916. var is310 int = 0
  10917. for _, item := range rf {
  10918. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10919. insutypes = append(insutypes, item)
  10920. }
  10921. }
  10922. if len(insutypes) == 1 {
  10923. insutype = insutypes[0].Insutype
  10924. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10925. } else {
  10926. for _, i := range insutypes {
  10927. if i.Insutype == "390" {
  10928. is390 = 1
  10929. }
  10930. if i.Insutype == "310" {
  10931. is310 = 1
  10932. }
  10933. }
  10934. }
  10935. if is390 == 1 {
  10936. insutype = "390"
  10937. }
  10938. if is310 == 1 {
  10939. insutype = "310"
  10940. }
  10941. if len(insutypes) == 0 {
  10942. insutype = "310"
  10943. }
  10944. service.CreateHisPsn(psn)
  10945. c.ServeSuccessJSON(map[string]interface{}{
  10946. "patient": patient,
  10947. "number": token,
  10948. "insutype": insutype,
  10949. })
  10950. }
  10951. } else {
  10952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10953. return
  10954. }
  10955. } else { //读卡失败
  10956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10957. return
  10958. }
  10959. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10960. idNo := c.GetString("idNo")
  10961. userName := c.GetString("userName")
  10962. ecToken := c.GetString("ecToken")
  10963. insuOrg := c.GetString("insuOrg")
  10964. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10965. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10966. var res ResultTwo
  10967. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10968. utils.ErrorLog("解析失败:%v", err)
  10969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10970. return
  10971. }
  10972. if res.Infcode == 0 {
  10973. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10974. if err == gorm.ErrRecordNotFound {
  10975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10976. return
  10977. } else if err != nil {
  10978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10979. return
  10980. } else {
  10981. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10982. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10983. infoStr := string(Iinfos)
  10984. idetinfoStr := string(Idetinfos)
  10985. psn := &models.HisPsn{
  10986. PsnNo: res.Output.Baseinfo.PsnNo,
  10987. PatientId: patient.ID,
  10988. Certno: res.Output.Baseinfo.Certno,
  10989. Gend: res.Output.Baseinfo.Gend,
  10990. Naty: res.Output.Baseinfo.Naty,
  10991. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10992. PsnName: res.Output.Baseinfo.PsnName,
  10993. Idetinfo: idetinfoStr,
  10994. Insuinfo: infoStr,
  10995. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10996. CardInfo: "",
  10997. Stage: "1",
  10998. VerifyNumber: ecToken,
  10999. InsuplcAdmdvs: insuOrg,
  11000. }
  11001. service.CreateHisPsn(psn)
  11002. var rf []*ResultFive
  11003. json.Unmarshal([]byte(infoStr), &rf)
  11004. var insutypes []*ResultFive
  11005. var insutype string
  11006. var is390 int = 0
  11007. var is310 int = 0
  11008. for _, item := range rf {
  11009. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11010. insutypes = append(insutypes, item)
  11011. }
  11012. }
  11013. if len(insutypes) == 1 {
  11014. insutype = insutypes[0].Insutype
  11015. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11016. } else {
  11017. for _, i := range insutypes {
  11018. if i.Insutype == "390" {
  11019. is390 = 1
  11020. }
  11021. if i.Insutype == "310" {
  11022. is310 = 1
  11023. }
  11024. }
  11025. }
  11026. if is390 == 1 {
  11027. insutype = "390"
  11028. }
  11029. if is310 == 1 {
  11030. insutype = "310"
  11031. }
  11032. if len(insutypes) == 0 {
  11033. insutype = "310"
  11034. }
  11035. c.ServeSuccessJSON(map[string]interface{}{
  11036. "patient": patient,
  11037. "number": ecToken,
  11038. "insutype": insutype,
  11039. })
  11040. }
  11041. } else {
  11042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11043. return
  11044. }
  11045. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11046. //if initFlag == 0 {
  11047. //c.TestGetJiangXiBasBaseInit()
  11048. //}
  11049. //if initEleFlag == 0 {
  11050. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  11051. //}
  11052. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  11053. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  11054. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  11055. type ELeData struct {
  11056. Data struct {
  11057. IdNo string `json:"idNo"`
  11058. IdType string `json:"idType"`
  11059. UserName string `json:"userName"`
  11060. EcToken string `json:"ecToken"`
  11061. InsuOrg string `json:"insuOrg"`
  11062. Gender string `json:"gender"`
  11063. Birthday string `json:"birthday"`
  11064. Nationality string `json:"nationality"`
  11065. Email string `json:"email"`
  11066. Extra string `json:"extra"`
  11067. } `json:"data"`
  11068. Code int `json:"code"`
  11069. Message string `json:"message"`
  11070. }
  11071. var ele ELeData
  11072. err := json.Unmarshal([]byte(result), &ele)
  11073. if err != nil {
  11074. utils.ErrorLog("解析失败:%v", err)
  11075. }
  11076. token := ele.Data.EcToken
  11077. token = Remove0000(token)
  11078. 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)
  11079. saveLog(result2, requestLog2, "1101", "获取人员信息")
  11080. var res ResultTwo
  11081. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11082. utils.ErrorLog("解析失败:%v", err)
  11083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11084. return
  11085. }
  11086. if res.Infcode == 0 {
  11087. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11088. if err == gorm.ErrRecordNotFound {
  11089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11090. return
  11091. } else if err != nil {
  11092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11093. return
  11094. } else {
  11095. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11096. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11097. infoStr := string(Iinfos)
  11098. idetinfoStr := string(Idetinfos)
  11099. psn := &models.HisPsn{
  11100. PsnNo: res.Output.Baseinfo.PsnNo,
  11101. PatientId: patient.ID,
  11102. Certno: res.Output.Baseinfo.Certno,
  11103. Gend: res.Output.Baseinfo.Gend,
  11104. Naty: res.Output.Baseinfo.Naty,
  11105. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11106. PsnName: res.Output.Baseinfo.PsnName,
  11107. Idetinfo: idetinfoStr,
  11108. Insuinfo: infoStr,
  11109. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11110. CardInfo: "",
  11111. VerifyNumber: token,
  11112. }
  11113. service.CreateHisPsn(psn)
  11114. var rf []*ResultFive
  11115. json.Unmarshal([]byte(infoStr), &rf)
  11116. var insutypes []*ResultFive
  11117. var insutype string
  11118. var is390 int = 0
  11119. var is310 int = 0
  11120. for _, item := range rf {
  11121. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11122. insutypes = append(insutypes, item)
  11123. }
  11124. }
  11125. if len(insutypes) == 1 {
  11126. insutype = insutypes[0].Insutype
  11127. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11128. } else {
  11129. for _, i := range insutypes {
  11130. if i.Insutype == "390" {
  11131. is390 = 1
  11132. }
  11133. if i.Insutype == "310" {
  11134. is310 = 1
  11135. }
  11136. }
  11137. }
  11138. if is390 == 1 {
  11139. insutype = "390"
  11140. }
  11141. if is310 == 1 {
  11142. insutype = "310"
  11143. }
  11144. if len(insutypes) == 0 {
  11145. insutype = "310"
  11146. }
  11147. c.ServeSuccessJSON(map[string]interface{}{
  11148. "patient": patient,
  11149. "number": token,
  11150. "insutype": insutype,
  11151. })
  11152. }
  11153. } else {
  11154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11155. return
  11156. }
  11157. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11158. //if initFlag == 0 {
  11159. c.TestGetJiangXiBasBaseInit()
  11160. //}
  11161. //if initEleFlag == 0 {
  11162. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  11163. //}
  11164. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  11165. type ELeData struct {
  11166. Data struct {
  11167. IdNo string `json:"idNo"`
  11168. IdType string `json:"idType"`
  11169. UserName string `json:"userName"`
  11170. EcToken string `json:"ecToken"`
  11171. InsuOrg string `json:"insuOrg"`
  11172. Gender string `json:"gender"`
  11173. Birthday string `json:"birthday"`
  11174. Nationality string `json:"nationality"`
  11175. Email string `json:"email"`
  11176. Extra string `json:"extra"`
  11177. } `json:"data"`
  11178. Code int `json:"code"`
  11179. Message string `json:"message"`
  11180. }
  11181. var ele ELeData
  11182. err := json.Unmarshal([]byte(json_result), &ele)
  11183. if err != nil {
  11184. utils.ErrorLog("解析失败:%v", err)
  11185. }
  11186. token := ele.Data.EcToken
  11187. token = Remove0000(token)
  11188. 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)
  11189. saveLog(result2, requestLog2, "1101", "获取人员信息")
  11190. var res ResultTwo
  11191. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11192. utils.ErrorLog("解析失败:%v", err)
  11193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11194. return
  11195. }
  11196. if res.Infcode == 0 {
  11197. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11198. if err == gorm.ErrRecordNotFound {
  11199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11200. return
  11201. } else if err != nil {
  11202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11203. return
  11204. } else {
  11205. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11206. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11207. infoStr := string(Iinfos)
  11208. idetinfoStr := string(Idetinfos)
  11209. psn := &models.HisPsn{
  11210. PsnNo: res.Output.Baseinfo.PsnNo,
  11211. PatientId: patient.ID,
  11212. Certno: res.Output.Baseinfo.Certno,
  11213. Gend: res.Output.Baseinfo.Gend,
  11214. Naty: res.Output.Baseinfo.Naty,
  11215. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11216. PsnName: res.Output.Baseinfo.PsnName,
  11217. Idetinfo: idetinfoStr,
  11218. Insuinfo: infoStr,
  11219. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11220. CardInfo: "",
  11221. VerifyNumber: token,
  11222. }
  11223. service.CreateHisPsn(psn)
  11224. var rf []*ResultFive
  11225. json.Unmarshal([]byte(infoStr), &rf)
  11226. var insutypes []*ResultFive
  11227. var insutype string
  11228. var is390 int = 0
  11229. var is310 int = 0
  11230. for _, item := range rf {
  11231. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11232. insutypes = append(insutypes, item)
  11233. }
  11234. }
  11235. if len(insutypes) == 1 {
  11236. insutype = insutypes[0].Insutype
  11237. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11238. } else {
  11239. for _, i := range insutypes {
  11240. if i.Insutype == "390" {
  11241. is390 = 1
  11242. }
  11243. if i.Insutype == "310" {
  11244. is310 = 1
  11245. }
  11246. }
  11247. }
  11248. if is390 == 1 {
  11249. insutype = "390"
  11250. }
  11251. if is310 == 1 {
  11252. insutype = "310"
  11253. }
  11254. if len(insutypes) == 0 {
  11255. insutype = "310"
  11256. }
  11257. c.ServeSuccessJSON(map[string]interface{}{
  11258. "patient": patient,
  11259. "number": token,
  11260. "insutype": insutype,
  11261. })
  11262. }
  11263. } else {
  11264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11265. return
  11266. }
  11267. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11268. type ELeData struct {
  11269. Code string `json:"code"`
  11270. Data struct {
  11271. Aac002 string `json:"aac002"`
  11272. Aaz500 string `json:"aaz500"`
  11273. ActCardNo string `json:"actCardNo"`
  11274. Bab520 string `json:"bab520"`
  11275. Bkz543 string `json:"bkz543"`
  11276. BusinessType string `json:"businessType"`
  11277. CertfCodg string `json:"certfCodg"`
  11278. EcIndexNo string `json:"ecIndexNo"`
  11279. EcToken string `json:"ecToken"`
  11280. ID0000 string `json:"id0000"`
  11281. IDNo string `json:"idNo"`
  11282. IDType string `json:"idType"`
  11283. Idcode string `json:"idcode"`
  11284. IdentityToken string `json:"identity_token"`
  11285. InsuOrg string `json:"insuOrg"`
  11286. OfficeID string `json:"officeId"`
  11287. OfficeName string `json:"officeName"`
  11288. OperatorID string `json:"operatorId"`
  11289. OperatorName string `json:"operatorName"`
  11290. OrgID string `json:"orgId"`
  11291. UserName string `json:"userName"`
  11292. } `json:"data"`
  11293. Infno interface{} `json:"infno"`
  11294. Message string `json:"message"`
  11295. OrgID string `json:"orgId"`
  11296. TransType string `json:"transType"`
  11297. }
  11298. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  11299. outPutInfo = Remove0000(outPutInfo)
  11300. if len(outPutInfo) > 0 {
  11301. var ele ELeData
  11302. err := json.Unmarshal([]byte(outPutInfo), &ele)
  11303. if err != nil {
  11304. utils.ErrorLog("解析失败:%v", err)
  11305. }
  11306. token := ele.Data.EcToken
  11307. fmt.Println(inputInfo)
  11308. fmt.Println(outPutInfo)
  11309. 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)
  11310. saveLog(result, requestLog, "1101", "获取人员信息")
  11311. var dat map[string]interface{}
  11312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11313. fmt.Println(dat)
  11314. } else {
  11315. fmt.Println(err)
  11316. }
  11317. userJSONBytes, _ := json.Marshal(dat)
  11318. var res ResultTwo
  11319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11320. utils.ErrorLog("解析失败:%v", err)
  11321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11322. return
  11323. }
  11324. res.ErrMsg = errMsgLog
  11325. if res.Infcode == 0 {
  11326. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  11327. if err == gorm.ErrRecordNotFound {
  11328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11329. return
  11330. } else if err != nil {
  11331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11332. return
  11333. } else {
  11334. fmt.Println(res)
  11335. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11336. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11337. infoStr := string(Iinfos)
  11338. idetinfoStr := string(Idetinfos)
  11339. psn := &models.HisPsn{
  11340. PsnNo: res.Output.Baseinfo.PsnNo,
  11341. PatientId: patient.ID,
  11342. Certno: res.Output.Baseinfo.Certno,
  11343. Gend: res.Output.Baseinfo.Gend,
  11344. Naty: res.Output.Baseinfo.Naty,
  11345. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11346. PsnName: res.Output.Baseinfo.PsnName,
  11347. Idetinfo: idetinfoStr,
  11348. Insuinfo: infoStr,
  11349. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11350. CardInfo: outPutInfo,
  11351. VerifyNumber: token,
  11352. InsuplcAdmdvs: ele.Data.InsuOrg,
  11353. }
  11354. service.CreateHisPsn(psn)
  11355. var rf []*ResultFive
  11356. json.Unmarshal([]byte(infoStr), &rf)
  11357. var insutypes []*ResultFive
  11358. var insutype string
  11359. var is390 int = 0
  11360. var is310 int = 0
  11361. for _, item := range rf {
  11362. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  11363. insutypes = append(insutypes, item)
  11364. }
  11365. }
  11366. if len(insutypes) == 1 {
  11367. insutype = insutypes[0].Insutype
  11368. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11369. } else {
  11370. for _, i := range insutypes {
  11371. if i.Insutype == "390" {
  11372. is390 = 1
  11373. }
  11374. if i.Insutype == "310" {
  11375. is310 = 1
  11376. }
  11377. }
  11378. }
  11379. if is390 == 1 {
  11380. insutype = "390"
  11381. }
  11382. if is310 == 1 {
  11383. insutype = "310"
  11384. }
  11385. if len(insutypes) == 0 {
  11386. insutype = "310"
  11387. }
  11388. c.ServeSuccessJSON(map[string]interface{}{
  11389. "patient": patient,
  11390. "number": token,
  11391. "insutype": insutype,
  11392. })
  11393. }
  11394. } else {
  11395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11396. return
  11397. }
  11398. }
  11399. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11400. var api string
  11401. 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 +
  11402. "&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
  11403. resp, requestErr := http.Get(api)
  11404. if requestErr != nil {
  11405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11406. return
  11407. }
  11408. body, ioErr := ioutil.ReadAll(resp.Body)
  11409. if ioErr != nil {
  11410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11412. return
  11413. }
  11414. var respJSON map[string]interface{}
  11415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11418. return
  11419. }
  11420. var status string
  11421. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11422. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11423. var token string
  11424. var res ResultTwo //1101结果
  11425. var res10265 ResultTwo10265 //1101结果
  11426. if status == "0" { //读卡成功
  11427. var card_info string //卡信息
  11428. var busi_card_info string
  11429. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11430. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11431. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11432. fmt.Println(card_info)
  11433. fmt.Println(busi_card_info)
  11434. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11435. result, _ := json.Marshal(respJSON)
  11436. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11437. utils.ErrorLog("解析失败:%v", err)
  11438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11439. return
  11440. }
  11441. res.ErrMsg = res10265.ErrMsg
  11442. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11443. res.Infcode = infocode
  11444. res.Output = res10265.Output
  11445. res.InfRefmsgid = res10265.InfRefmsgid
  11446. if res.Infcode == 0 {
  11447. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11448. if err == gorm.ErrRecordNotFound {
  11449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11450. return
  11451. } else if err != nil {
  11452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11453. return
  11454. } else {
  11455. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11456. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11457. infoStr := string(Iinfos)
  11458. idetinfoStr := string(Idetinfos)
  11459. psn := &models.HisPsn{
  11460. PsnNo: res.Output.Baseinfo.PsnNo,
  11461. PatientId: patient.ID,
  11462. Certno: res.Output.Baseinfo.Certno,
  11463. Gend: res.Output.Baseinfo.Gend,
  11464. Naty: res.Output.Baseinfo.Naty,
  11465. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11466. PsnName: res.Output.Baseinfo.PsnName,
  11467. Idetinfo: idetinfoStr,
  11468. Insuinfo: infoStr,
  11469. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11470. CardInfo: card_info,
  11471. VerifyNumber: token,
  11472. }
  11473. var rf []*ResultFive
  11474. json.Unmarshal([]byte(infoStr), &rf)
  11475. var insutypes []*ResultFive
  11476. var insutype string
  11477. var is390 int = 0
  11478. var is310 int = 0
  11479. for _, item := range rf {
  11480. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11481. insutypes = append(insutypes, item)
  11482. }
  11483. }
  11484. if len(insutypes) == 1 {
  11485. insutype = insutypes[0].Insutype
  11486. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11487. } else {
  11488. for _, i := range insutypes {
  11489. if i.Insutype == "390" {
  11490. is390 = 1
  11491. }
  11492. if i.Insutype == "310" {
  11493. is310 = 1
  11494. }
  11495. }
  11496. }
  11497. if is390 == 1 {
  11498. insutype = "390"
  11499. }
  11500. if is310 == 1 {
  11501. insutype = "310"
  11502. }
  11503. if len(insutypes) == 0 {
  11504. insutype = "310"
  11505. }
  11506. service.CreateHisPsn(psn)
  11507. c.ServeSuccessJSON(map[string]interface{}{
  11508. "patient": patient,
  11509. "number": token,
  11510. "insutype": insutype,
  11511. })
  11512. }
  11513. } else {
  11514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11515. return
  11516. }
  11517. } else { //读卡失败
  11518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11519. return
  11520. }
  11521. } else if miConfig.MdtrtareaAdmvs == "450721" {
  11522. res := c.GetoleInfo()
  11523. if res.Infcode == 0 {
  11524. var result string
  11525. if res.Output.MdtrtCertType == "01" {
  11526. 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)
  11527. } else if res.Output.MdtrtCertType == "02" {
  11528. 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)
  11529. } else if res.Output.MdtrtCertType == "03" {
  11530. 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)
  11531. }
  11532. var dat map[string]interface{}
  11533. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11534. fmt.Println(dat)
  11535. } else {
  11536. fmt.Println(err)
  11537. }
  11538. userJSONBytes, _ := json.Marshal(dat)
  11539. var res2 ResultTwo
  11540. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11541. utils.ErrorLog("解析失败:%v", err)
  11542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11543. return
  11544. }
  11545. if res2.Infcode == 0 {
  11546. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  11547. if err == gorm.ErrRecordNotFound {
  11548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11549. return
  11550. } else if err != nil {
  11551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11552. return
  11553. } else {
  11554. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  11555. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  11556. infoStr := string(Iinfos)
  11557. idetinfoStr := string(Idetinfos)
  11558. var rf []*ResultFive
  11559. json.Unmarshal([]byte(infoStr), &rf)
  11560. var insutypes []*ResultFive
  11561. var insutype string
  11562. var is390 int = 0
  11563. var is310 int = 0
  11564. //var insuplc_admdvs string
  11565. for _, item := range rf {
  11566. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11567. insutypes = append(insutypes, item)
  11568. }
  11569. }
  11570. if len(insutypes) == 1 {
  11571. insutype = insutypes[0].Insutype
  11572. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11573. } else {
  11574. for _, i := range insutypes {
  11575. if i.Insutype == "390" {
  11576. is390 = 1
  11577. }
  11578. if i.Insutype == "310" {
  11579. is310 = 1
  11580. }
  11581. }
  11582. }
  11583. if is390 == 1 {
  11584. insutype = "390"
  11585. }
  11586. if is310 == 1 {
  11587. insutype = "310"
  11588. }
  11589. if len(insutypes) == 0 {
  11590. insutype = "310"
  11591. }
  11592. psn := &models.HisPsn{
  11593. PsnNo: res2.Output.Baseinfo.PsnNo,
  11594. PatientId: patient.ID,
  11595. Certno: res2.Output.Baseinfo.Certno,
  11596. Gend: res2.Output.Baseinfo.Gend,
  11597. Naty: res2.Output.Baseinfo.Naty,
  11598. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  11599. PsnName: res2.Output.Baseinfo.PsnName,
  11600. Idetinfo: idetinfoStr,
  11601. Insuinfo: infoStr,
  11602. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11603. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  11604. VerifyNumber: res.Output.EcToken,
  11605. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  11606. }
  11607. if res.Output.MdtrtCertType == "01" {
  11608. psn.VerifyNumber = res.Output.EcToken
  11609. //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)
  11610. } else if res.Output.MdtrtCertType == "02" {
  11611. psn.VerifyNumber = res.Output.CardNo
  11612. //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)
  11613. } else if res.Output.MdtrtCertType == "03" {
  11614. psn.VerifyNumber = res.Output.MdtrtCertNo
  11615. //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)
  11616. }
  11617. service.CreateHisPsn(psn)
  11618. var balc float64
  11619. for _, item := range rf {
  11620. if item.Insutype == insutype {
  11621. balc = item.Balc
  11622. }
  11623. }
  11624. c.ServeSuccessJSON(map[string]interface{}{
  11625. "patient": patient,
  11626. "number": res.Output.CardNo,
  11627. "insutype": insutype,
  11628. "blac": balc,
  11629. "desc": idetinfoStr,
  11630. })
  11631. }
  11632. } else {
  11633. c.ServeSuccessJSON(map[string]interface{}{
  11634. "failed_code": -10,
  11635. "msg": res2.ErrMsg,
  11636. })
  11637. }
  11638. } else {
  11639. c.ServeSuccessJSON(map[string]interface{}{
  11640. "failed_code": -10,
  11641. "msg": res.ErrMsg,
  11642. })
  11643. }
  11644. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11645. var res ResultTwo
  11646. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  11647. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11648. "&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)
  11649. resp, requestErr := http.Get(api)
  11650. if requestErr != nil {
  11651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11652. return
  11653. }
  11654. body, ioErr := ioutil.ReadAll(resp.Body)
  11655. if ioErr != nil {
  11656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11658. return
  11659. }
  11660. var respJSON map[string]interface{}
  11661. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11664. return
  11665. }
  11666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11667. result, _ := json.Marshal(respJSON)
  11668. fmt.Println("log")
  11669. fmt.Println(string(result))
  11670. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11671. utils.ErrorLog("解析失败:%v", err)
  11672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11673. return
  11674. }
  11675. if res.Infcode == 0 {
  11676. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11677. if err == gorm.ErrRecordNotFound {
  11678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11679. return
  11680. } else if err != nil {
  11681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11682. return
  11683. } else {
  11684. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11685. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11686. infoStr := string(Iinfos)
  11687. idetinfoStr := string(Idetinfos)
  11688. var rf []*ResultFive
  11689. json.Unmarshal([]byte(infoStr), &rf)
  11690. var insutypes []*ResultFive
  11691. var insutype string
  11692. var is390 int = 0
  11693. var is310 int = 0
  11694. for _, item := range rf {
  11695. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  11696. insutypes = append(insutypes, item)
  11697. }
  11698. }
  11699. if len(insutypes) == 1 {
  11700. insutype = insutypes[0].Insutype
  11701. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11702. } else {
  11703. for _, i := range insutypes {
  11704. if i.Insutype == "390" {
  11705. is390 = 1
  11706. }
  11707. if i.Insutype == "310" {
  11708. is310 = 1
  11709. }
  11710. }
  11711. }
  11712. if is390 == 1 {
  11713. insutype = "390"
  11714. }
  11715. if is310 == 1 {
  11716. insutype = "310"
  11717. }
  11718. if len(insutypes) == 0 {
  11719. insutype = "390"
  11720. }
  11721. var insuplc_admdvs string
  11722. for _, item := range rf {
  11723. if item.Insutype == insutype {
  11724. insuplc_admdvs = item.InsuplcAdmdvs
  11725. }
  11726. }
  11727. psn := &models.HisPsn{
  11728. PsnNo: res.Output.Baseinfo.PsnNo,
  11729. PatientId: patient.ID,
  11730. Certno: res.Output.Baseinfo.Certno,
  11731. Gend: res.Output.Baseinfo.Gend,
  11732. Naty: res.Output.Baseinfo.Naty,
  11733. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11734. PsnName: res.Output.Baseinfo.PsnName,
  11735. Idetinfo: idetinfoStr,
  11736. Insuinfo: infoStr,
  11737. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11738. InsuplcAdmdvs: insuplc_admdvs,
  11739. }
  11740. service.CreateHisPsn(psn)
  11741. c.ServeSuccessJSON(map[string]interface{}{
  11742. "patient": patient,
  11743. "number": res.Output.Baseinfo.Certno,
  11744. })
  11745. }
  11746. } else {
  11747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11748. return
  11749. }
  11750. } else {
  11751. type ELeData struct {
  11752. Code string `json:"code"`
  11753. Data struct {
  11754. Aac002 string `json:"aac002"`
  11755. Aaz500 string `json:"aaz500"`
  11756. ActCardNo string `json:"actCardNo"`
  11757. Bab520 string `json:"bab520"`
  11758. Bkz543 string `json:"bkz543"`
  11759. BusinessType string `json:"businessType"`
  11760. CertfCodg string `json:"certfCodg"`
  11761. EcIndexNo string `json:"ecIndexNo"`
  11762. EcToken string `json:"ecToken"`
  11763. ID0000 string `json:"id0000"`
  11764. IDNo string `json:"idNo"`
  11765. IDType string `json:"idType"`
  11766. Idcode string `json:"idcode"`
  11767. IdentityToken string `json:"identity_token"`
  11768. InsuOrg string `json:"insuOrg"`
  11769. OfficeID string `json:"officeId"`
  11770. OfficeName string `json:"officeName"`
  11771. OperatorID string `json:"operatorId"`
  11772. OperatorName string `json:"operatorName"`
  11773. OrgID string `json:"orgId"`
  11774. UserName string `json:"userName"`
  11775. } `json:"data"`
  11776. Infno interface{} `json:"infno"`
  11777. Message string `json:"message"`
  11778. OrgID string `json:"orgId"`
  11779. TransType string `json:"transType"`
  11780. }
  11781. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  11782. fmt.Println(result)
  11783. outPutInfo := Remove0000(result)
  11784. fmt.Println(outPutInfo)
  11785. if len(outPutInfo) > 0 {
  11786. var ele ELeData
  11787. err := json.Unmarshal([]byte(outPutInfo), &ele)
  11788. if err != nil {
  11789. utils.ErrorLog("解析失败:%v", err)
  11790. }
  11791. token := ele.Data.EcToken
  11792. fmt.Println(outPutInfo)
  11793. 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)
  11794. saveLog(result, requestLog, "1101", "获取人员信息")
  11795. var dat map[string]interface{}
  11796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11797. fmt.Println(dat)
  11798. } else {
  11799. fmt.Println(err)
  11800. }
  11801. userJSONBytes, _ := json.Marshal(dat)
  11802. var res ResultTwo
  11803. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11804. utils.ErrorLog("解析失败:%v", err)
  11805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11806. return
  11807. }
  11808. if res.Infcode == 0 {
  11809. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  11810. if err == gorm.ErrRecordNotFound {
  11811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11812. return
  11813. } else if err != nil {
  11814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11815. return
  11816. } else {
  11817. fmt.Println(res)
  11818. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11819. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11820. infoStr := string(Iinfos)
  11821. idetinfoStr := string(Idetinfos)
  11822. psn := &models.HisPsn{
  11823. PsnNo: res.Output.Baseinfo.PsnNo,
  11824. PatientId: patient.ID,
  11825. Certno: res.Output.Baseinfo.Certno,
  11826. Gend: res.Output.Baseinfo.Gend,
  11827. Naty: res.Output.Baseinfo.Naty,
  11828. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11829. PsnName: res.Output.Baseinfo.PsnName,
  11830. Idetinfo: idetinfoStr,
  11831. Insuinfo: infoStr,
  11832. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11833. CardInfo: outPutInfo,
  11834. VerifyNumber: token,
  11835. InsuplcAdmdvs: ele.Data.InsuOrg,
  11836. }
  11837. service.CreateHisPsn(psn)
  11838. var rf []*ResultFive
  11839. json.Unmarshal([]byte(infoStr), &rf)
  11840. var insutypes []*ResultFive
  11841. var insutype string
  11842. var is390 int = 0
  11843. var is310 int = 0
  11844. for _, item := range rf {
  11845. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11846. insutypes = append(insutypes, item)
  11847. }
  11848. }
  11849. if len(insutypes) == 1 {
  11850. insutype = insutypes[0].Insutype
  11851. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11852. } else {
  11853. for _, i := range insutypes {
  11854. if i.Insutype == "390" {
  11855. is390 = 1
  11856. }
  11857. if i.Insutype == "310" {
  11858. is310 = 1
  11859. }
  11860. }
  11861. }
  11862. if is390 == 1 {
  11863. insutype = "390"
  11864. }
  11865. if is310 == 1 {
  11866. insutype = "310"
  11867. }
  11868. if len(insutypes) == 0 {
  11869. insutype = "310"
  11870. }
  11871. c.ServeSuccessJSON(map[string]interface{}{
  11872. "patient": patient,
  11873. "number": token,
  11874. "insutype": insutype,
  11875. })
  11876. }
  11877. } else {
  11878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11879. return
  11880. }
  11881. }
  11882. //fmt.Println(result)
  11883. //
  11884. //if initFlag == 0 {
  11885. // c.TestGetBasBaseInit()
  11886. //}
  11887. //token := c.GetEleBaseInfo()
  11888. //
  11889. //token = Remove0000(token)
  11890. //
  11891. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  11892. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  11893. ////
  11894. //var res ResultTwo
  11895. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11896. // utils.ErrorLog("解析失败:%v", err)
  11897. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11898. // return
  11899. //}
  11900. //
  11901. //if res.Infcode == 0 {
  11902. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11903. // if err == gorm.ErrRecordNotFound {
  11904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11905. // return
  11906. // } else if err != nil {
  11907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11908. // return
  11909. //
  11910. // } else {
  11911. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11912. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11913. // infoStr := string(Iinfos)
  11914. // idetinfoStr := string(Idetinfos)
  11915. //
  11916. //
  11917. //
  11918. //
  11919. // var rf []*ResultFive
  11920. // json.Unmarshal([]byte(infoStr), &rf)
  11921. //
  11922. // var insutypes []*ResultFive
  11923. // var insutype string
  11924. // var is390 int = 0
  11925. // var is310 int = 0
  11926. // var insuplc_admdvs string
  11927. //
  11928. // for _, item := range rf {
  11929. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11930. // insutypes = append(insutypes, item)
  11931. // }
  11932. // }
  11933. //
  11934. // if len(insutypes) == 1 {
  11935. // insutype = insutypes[0].Insutype
  11936. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11937. // } else {
  11938. // for _, i := range insutypes {
  11939. // if i.Insutype == "390" {
  11940. // is390 = 1
  11941. // }
  11942. //
  11943. // if i.Insutype == "310" {
  11944. // is310 = 1
  11945. // }
  11946. // }
  11947. // }
  11948. // if is390 == 1 {
  11949. // insutype = "390"
  11950. // }
  11951. //
  11952. // if is310 == 1 {
  11953. // insutype = "310"
  11954. // }
  11955. // if len(insutypes) == 0 {
  11956. // insutype = "310"
  11957. // }
  11958. // for _, item := range rf {
  11959. // if item.Insutype == insutype {
  11960. // insuplc_admdvs = item.InsuplcAdmdvs
  11961. // }
  11962. // }
  11963. // psn := &models.HisPsn{
  11964. // PsnNo: res.Output.Baseinfo.PsnNo,
  11965. // Age: res.Output.Baseinfo.Age,
  11966. // PatientId: patient.ID,
  11967. // Certno: res.Output.Baseinfo.Certno,
  11968. // Brdy: res.Output.Baseinfo.Brdy,
  11969. // Gend: res.Output.Baseinfo.Gend,
  11970. // Naty: res.Output.Baseinfo.Naty,
  11971. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  11972. // PsnName: res.Output.Baseinfo.PsnName,
  11973. // Idetinfo: idetinfoStr,
  11974. // Insuinfo: infoStr,
  11975. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11976. // CardInfo: "",
  11977. // VerifyNumber: token,
  11978. // InsuplcAdmdvs: insuplc_admdvs,
  11979. // }
  11980. // service.CreateHisPsn(psn)
  11981. //
  11982. // c.ServeSuccessJSON(map[string]interface{}{
  11983. // "patient": patient,
  11984. // "number": token,
  11985. // })
  11986. // }
  11987. //} else {
  11988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11989. // return
  11990. //}
  11991. }
  11992. break
  11993. case 5:
  11994. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11995. var api string
  11996. if miConfig.MdtrtareaAdmvs == "320921" {
  11997. 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 +
  11998. "&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
  11999. fmt.Println(api)
  12000. } else {
  12001. 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 +
  12002. "&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)
  12003. }
  12004. resp, requestErr := http.Get(api)
  12005. if requestErr != nil {
  12006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12007. return
  12008. }
  12009. body, ioErr := ioutil.ReadAll(resp.Body)
  12010. if ioErr != nil {
  12011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12013. return
  12014. }
  12015. var respJSON map[string]interface{}
  12016. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12019. return
  12020. }
  12021. var status string
  12022. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12023. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12024. var token string
  12025. var res ResultTwo //1101结果
  12026. var res10265 ResultTwo10265 //1101结果
  12027. if status == "0" { //读卡成功
  12028. var card_info string //卡信息
  12029. //var busi_card_info string
  12030. var auth_info string
  12031. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12032. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12033. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12034. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  12035. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12036. result, _ := json.Marshal(respJSON)
  12037. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12038. utils.ErrorLog("解析失败:%v", err)
  12039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12040. return
  12041. }
  12042. res.ErrMsg = res10265.ErrMsg
  12043. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12044. res.Infcode = infocode
  12045. res.Output = res10265.Output
  12046. res.InfRefmsgid = res10265.InfRefmsgid
  12047. if res.Infcode == 0 {
  12048. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12049. if err == gorm.ErrRecordNotFound {
  12050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12051. return
  12052. } else if err != nil {
  12053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12054. return
  12055. } else {
  12056. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12057. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12058. infoStr := string(Iinfos)
  12059. idetinfoStr := string(Idetinfos)
  12060. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12061. psn := &models.HisPsn{
  12062. PsnNo: res.Output.Baseinfo.PsnNo,
  12063. PatientId: patient.ID,
  12064. Certno: res.Output.Baseinfo.Certno,
  12065. Gend: res.Output.Baseinfo.Gend,
  12066. Brdy: b,
  12067. Age: float64(age),
  12068. Naty: res.Output.Baseinfo.Naty,
  12069. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12070. PsnName: res.Output.Baseinfo.PsnName,
  12071. Idetinfo: idetinfoStr,
  12072. Insuinfo: infoStr,
  12073. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12074. CardInfo: card_info,
  12075. VerifyNumber: token,
  12076. AuthInfo: auth_info,
  12077. }
  12078. var rf []*ResultFive
  12079. json.Unmarshal([]byte(infoStr), &rf)
  12080. var insutypes []*ResultFive
  12081. var insutype string
  12082. var is390 int = 0
  12083. var is310 int = 0
  12084. for _, item := range rf {
  12085. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12086. insutypes = append(insutypes, item)
  12087. }
  12088. }
  12089. if len(insutypes) == 1 {
  12090. insutype = insutypes[0].Insutype
  12091. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12092. } else {
  12093. for _, i := range insutypes {
  12094. if i.Insutype == "390" {
  12095. is390 = 1
  12096. }
  12097. if i.Insutype == "310" {
  12098. is310 = 1
  12099. }
  12100. }
  12101. }
  12102. if is390 == 1 {
  12103. insutype = "390"
  12104. }
  12105. if is310 == 1 {
  12106. insutype = "310"
  12107. }
  12108. if len(insutypes) == 0 {
  12109. insutype = "310"
  12110. }
  12111. service.CreateHisPsn(psn)
  12112. c.ServeSuccessJSON(map[string]interface{}{
  12113. "patient": patient,
  12114. "number": token,
  12115. "insutype": insutype,
  12116. })
  12117. }
  12118. } else {
  12119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12120. return
  12121. }
  12122. } else { //读卡失败
  12123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12124. return
  12125. }
  12126. }
  12127. break
  12128. }
  12129. }
  12130. var initFlag int64 = 0
  12131. var initEleFlag int64 = 0
  12132. func (c *HisApiController) TestGetBasBaseInit() {
  12133. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12134. Iinit := DllDef.MustFindProc("Init")
  12135. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12136. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  12137. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  12138. if ret != 0 {
  12139. fmt.Println("SSCard的报错原因:", err)
  12140. fmt.Println("SSCard的运算结果为:", ret)
  12141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12142. return
  12143. }
  12144. result := int(ret)
  12145. fmt.Println("SSCard的运算结果为1:", result)
  12146. initFlag = 1
  12147. return
  12148. }
  12149. func (c *HisApiController) HandleJiangXiReadCard() {
  12150. fmt.Println("~~~~~~")
  12151. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12152. admin_user_id, _ := c.GetInt64("admin_user_id")
  12153. id_card_type, _ := c.GetInt64("id_card_type")
  12154. //certificates, _ := c.GetInt64("certificates")
  12155. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12156. if initFlag == 0 {
  12157. c.TestGetJiangXiBasBaseInit()
  12158. }
  12159. basStr := c.GetBasBaseInfo()
  12160. if len(basStr) == 0 {
  12161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12162. return
  12163. }
  12164. fmt.Println(basStr)
  12165. bas := strings.Split(basStr, "|")
  12166. basNumber := bas[1]
  12167. fmt.Println(basNumber)
  12168. card_sn := bas[3]
  12169. fmt.Println(card_sn)
  12170. 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, "")
  12171. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12172. var dat map[string]interface{}
  12173. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12174. fmt.Println(dat)
  12175. } else {
  12176. fmt.Println(err)
  12177. }
  12178. userJSONBytes, _ := json.Marshal(dat)
  12179. var res ResultTwo
  12180. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12181. utils.ErrorLog("解析失败:%v", err)
  12182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12183. return
  12184. }
  12185. if res.Infcode == 0 {
  12186. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12187. if err == gorm.ErrRecordNotFound {
  12188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12189. return
  12190. } else if err != nil {
  12191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12192. return
  12193. } else {
  12194. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12195. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12196. infoStr := string(Iinfos)
  12197. idetinfoStr := string(Idetinfos)
  12198. psn := &models.HisPsn{
  12199. PsnNo: res.Output.Baseinfo.PsnNo,
  12200. PatientId: patient.ID,
  12201. Certno: res.Output.Baseinfo.Certno,
  12202. Gend: res.Output.Baseinfo.Gend,
  12203. Naty: res.Output.Baseinfo.Naty,
  12204. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12205. PsnName: res.Output.Baseinfo.PsnName,
  12206. Idetinfo: idetinfoStr,
  12207. Insuinfo: infoStr,
  12208. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12209. CardInfo: basStr,
  12210. VerifyNumber: "",
  12211. }
  12212. service.CreateHisPsn(psn)
  12213. c.ServeSuccessJSON(map[string]interface{}{
  12214. "patient": patient,
  12215. "number": basNumber,
  12216. })
  12217. }
  12218. } else {
  12219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12220. return
  12221. }
  12222. }
  12223. func (c *HisApiController) TestGetHnBasBaseInit() {
  12224. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12225. Iinit := DllDef.MustFindProc("Init")
  12226. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12227. //http://10.77.211.236/CSB/hsa-fsi-1303
  12228. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  12229. if ret != 0 {
  12230. fmt.Println("SSCard的报错原因:", err)
  12231. fmt.Println("SSCard的运算结果为:", ret)
  12232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12233. return
  12234. }
  12235. result := int(ret)
  12236. fmt.Println("SSCard的运算结果为1:", result)
  12237. initFlag = 1
  12238. return
  12239. }
  12240. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  12241. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12242. Iinit := DllDef.MustFindProc("Init")
  12243. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12244. //http://10.77.211.236/CSB/hsa-fsi-1303
  12245. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  12246. if ret != 0 {
  12247. fmt.Println("SSCard的报错原因:", err)
  12248. fmt.Println("SSCard的运算结果为:", ret)
  12249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12250. return
  12251. }
  12252. result := int(ret)
  12253. fmt.Println("SSCard的运算结果为1:", result)
  12254. initFlag = 1
  12255. return
  12256. }
  12257. func (c *HisApiController) GetSFZBaseInfo() string {
  12258. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12259. readCard := DllDef.MustFindProc("ReadSFZ")
  12260. if readCard == nil {
  12261. fmt.Println("readcard is nil")
  12262. readCard = DllDef.MustFindProc("ReadSFZ")
  12263. }
  12264. str := make([]byte, 8096)
  12265. str1 := make([]byte, 8096)
  12266. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  12267. fmt.Println(r)
  12268. return Remove0000(string(str))
  12269. }
  12270. func (c *HisApiController) GetEleBaseInfo() string {
  12271. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12272. readCard := DllDef.MustFindProc("GetQRBase")
  12273. fmt.Println(readCard)
  12274. if readCard == nil {
  12275. fmt.Println("readcard is nil")
  12276. readCard = DllDef.MustFindProc("GetQRBase")
  12277. }
  12278. str := make([]byte, 1024)
  12279. str1 := make([]byte, 1024)
  12280. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  12281. fmt.Println(ret2)
  12282. fmt.Println(string(str1))
  12283. fmt.Println(string(str))
  12284. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12285. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  12286. if ret2 != 0 {
  12287. return ""
  12288. }
  12289. return string(str)
  12290. }
  12291. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  12292. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  12293. readCard := DllDef.MustFindProc("NationEcTrans")
  12294. fmt.Println(readCard)
  12295. fmt.Println("!!!!!")
  12296. pBusiCardInfo := make([]byte, 2048)
  12297. input := make(map[string]interface{})
  12298. inputData := make(map[string]interface{})
  12299. inputData["orgId"] = code
  12300. inputData["businessType"] = "01101"
  12301. inputData["operatorId"] = "1"
  12302. inputData["operatorName"] = "admin"
  12303. inputData["officeId"] = "001"
  12304. inputData["officeName"] = "血透室"
  12305. inputData["deviceType"] = ""
  12306. input["data"] = inputData
  12307. input["orgId"] = code
  12308. input["transType"] = "ec.query"
  12309. bytesData, _ := json.Marshal(input)
  12310. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  12311. fmt.Println(ret2)
  12312. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  12313. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  12314. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  12315. }
  12316. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  12317. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  12318. readCard := DllDef.MustFindProc("NationEcTrans")
  12319. fmt.Println(readCard)
  12320. fmt.Println("!!!!!")
  12321. pBusiCardInfo := make([]byte, 2048)
  12322. input := make(map[string]interface{})
  12323. inputData := make(map[string]interface{})
  12324. inputData["orgId"] = code
  12325. inputData["businessType"] = "01101"
  12326. inputData["operatorId"] = "9"
  12327. inputData["operatorName"] = "admin"
  12328. inputData["officeId"] = "001"
  12329. inputData["officeName"] = "血透室"
  12330. inputData["deviceType"] = ""
  12331. input["data"] = inputData
  12332. input["orgId"] = code
  12333. input["transType"] = "ec.query"
  12334. bytesData, _ := json.Marshal(input)
  12335. 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])))
  12336. fmt.Println(ret2)
  12337. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  12338. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  12339. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  12340. }
  12341. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  12342. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  12343. readCard := DllDef.MustFindProc("NationEcTrans")
  12344. fmt.Println(readCard)
  12345. fmt.Println("!!!!!")
  12346. pBusiCardInfo := make([]byte, 2048)
  12347. input := make(map[string]interface{})
  12348. inputData := make(map[string]interface{})
  12349. inputData["orgId"] = code
  12350. inputData["businessType"] = "01301"
  12351. inputData["operatorId"] = "9"
  12352. inputData["operatorName"] = "admin"
  12353. inputData["officeId"] = "001"
  12354. inputData["officeName"] = "血透室"
  12355. inputData["deviceType"] = ""
  12356. input["data"] = inputData
  12357. input["orgId"] = code
  12358. input["transType"] = "ec.query"
  12359. bytesData, _ := json.Marshal(input)
  12360. 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])))
  12361. fmt.Println(ret2)
  12362. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  12363. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  12364. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  12365. }
  12366. func GetJxEleBaseInfo(org_id int64) string {
  12367. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12368. readCard := DllDef.MustFindProc("NationEcTrans")
  12369. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  12370. if readCard == nil {
  12371. fmt.Println("readcard is nil")
  12372. readCard = DllDef.MustFindProc("NationEcTrans")
  12373. }
  12374. str1 := make([]byte, 1024)
  12375. data := make(map[string]interface{})
  12376. inputData := make(map[string]interface{})
  12377. inputData["orgId"] = miConfig.Code
  12378. inputData["businessType"] = "01101"
  12379. inputData["operatorId"] = "test001"
  12380. inputData["operatorName"] = "cn"
  12381. inputData["officeId"] = "32760"
  12382. inputData["officeName"] = "waike"
  12383. inputData["deviceType"] = ""
  12384. data["data"] = inputData
  12385. data["transType"] = "ec.query"
  12386. data["extra "] = ""
  12387. data["orgId"] = miConfig.Code
  12388. bytesData, _ := json.Marshal(data)
  12389. //bytesData, _ := json.Marshal(data)
  12390. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  12391. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  12392. fmt.Println(ret2)
  12393. fmt.Println(string(str1))
  12394. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12395. if ret2 != 0 {
  12396. return ""
  12397. }
  12398. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  12399. }
  12400. func GetJxEleBaseInitInfo(org_id int64) string {
  12401. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12402. readCard := DllDef.MustFindProc("NationEcTrans")
  12403. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  12404. if readCard == nil {
  12405. fmt.Println("readcard is nil")
  12406. readCard = DllDef.MustFindProc("NationEcTrans")
  12407. }
  12408. str1 := make([]byte, 2048)
  12409. data := make(map[string]interface{})
  12410. inputData := make(map[string]interface{})
  12411. inputData["orgId"] = miConfig.Code
  12412. inputData["businessType"] = "01101"
  12413. inputData["operatorId"] = "1"
  12414. inputData["operatorName"] = "huangchuang"
  12415. inputData["officeId"] = "101"
  12416. inputData["officeName"] = "xuetou"
  12417. inputData["deviceType"] = ""
  12418. data["data"] = inputData
  12419. data["transType"] = "ec.query"
  12420. data["orgId"] = miConfig.Code
  12421. bytesData, _ := json.Marshal(data)
  12422. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  12423. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  12424. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  12425. fmt.Println(ret2)
  12426. fmt.Println(string(str1))
  12427. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12428. if ret2 != 0 {
  12429. return ""
  12430. }
  12431. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  12432. initEleFlag = 1
  12433. }
  12434. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  12435. }
  12436. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  12437. // // 构建命令
  12438. // cmd := exec.Command("python", "b.py")
  12439. //
  12440. // // 执行命令并等待完成
  12441. // output, err := cmd.CombinedOutput()
  12442. // if err != nil {
  12443. // fmt.Println("Error executing Python script:", err)
  12444. // return
  12445. // }
  12446. //
  12447. // // 打印Python脚本的输出
  12448. // fmt.Println(string(output))
  12449. //}
  12450. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  12451. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  12452. readCard := DllDef.MustFindProc("gxyb_call")
  12453. if readCard == nil {
  12454. fmt.Println("readcard is nil")
  12455. readCard = DllDef.MustFindProc("gxyb_call")
  12456. }
  12457. str := make([]byte, 1024)
  12458. str1 := make([]byte, 1024)
  12459. //data := make(map[string]interface{})
  12460. currentTime := time.Now()
  12461. // 格式化时间为 "YYYYMMDDHH24MISS"
  12462. formattedTime := currentTime.Format("20060102150405")
  12463. inputData := make(map[string]interface{})
  12464. inputData2 := make(map[string]interface{})
  12465. inputData["transNo"] = "1401"
  12466. inputData["transType"] = "passwordCheck"
  12467. inputData["timestamp"] = formattedTime
  12468. inputData2["fixmedinsCode"] = code
  12469. inputData2["psnNo"] = ""
  12470. inputData["data"] = inputData2
  12471. jsonBytes, err := json.Marshal(inputData)
  12472. if err != nil {
  12473. fmt.Println("Error encoding map to JSON:", err)
  12474. }
  12475. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  12476. fmt.Println(string(str1))
  12477. fmt.Println(string(str))
  12478. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12479. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  12480. if ret2 != 0 {
  12481. return ""
  12482. }
  12483. return string(str)
  12484. }
  12485. func (c *HisApiController) GetoleInfo() Response {
  12486. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  12487. defer ole.CoUninitialize()
  12488. // Replace with the ProgID or CLSID of your COM object
  12489. progID := "YinHai.XJ.Actual.Interface.New"
  12490. // Create COM object
  12491. unknown, err := oleutil.CreateObject(progID)
  12492. if err != nil {
  12493. fmt.Println("Unable to create COM object:", err)
  12494. }
  12495. defer unknown.Release()
  12496. // Query for the IDispatch interface
  12497. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  12498. if err != nil {
  12499. fmt.Println("Unable to get IDispatch interface:", err)
  12500. }
  12501. defer dispatch.Release()
  12502. // Prepare parameters
  12503. transNo := "1401"
  12504. transType := "passwordCheck"
  12505. timestamp := time.Now().Unix()
  12506. fixmedinsCode := "H45072101171"
  12507. psnNo := ""
  12508. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  12509. result2 := ""
  12510. // Call COM object's method using the IDispatch interface
  12511. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  12512. fmt.Println(resulr)
  12513. fmt.Println(result2)
  12514. if err != nil {
  12515. fmt.Println("调用COM对象方法失败:", err)
  12516. }
  12517. var response Response
  12518. err2 := json.Unmarshal([]byte(result2), &response)
  12519. if err2 != nil {
  12520. fmt.Println("解析JSON失败:", err)
  12521. }
  12522. return response
  12523. }
  12524. func (c *HisApiController) GetBasBaseInfo() string {
  12525. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12526. readCard := DllDef.MustFindProc("ReadCardBas")
  12527. if readCard == nil {
  12528. fmt.Println("readcard is nil")
  12529. readCard = DllDef.MustFindProc("ReadCardBas")
  12530. }
  12531. str := make([]byte, 1024)
  12532. str1 := make([]byte, 1024)
  12533. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  12534. fmt.Println(string(str1))
  12535. fmt.Println(string(str))
  12536. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12537. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  12538. if ret2 != 0 {
  12539. return ""
  12540. }
  12541. return string(str)
  12542. }
  12543. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  12544. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  12545. readCard := DllDef.MustFindProc("read_cardinfo")
  12546. if readCard == nil {
  12547. fmt.Println("readcard is nil")
  12548. readCard = DllDef.MustFindProc("read_cardinfo")
  12549. }
  12550. str := make([]byte, 1024) //卡号
  12551. str1 := make([]byte, 1024) //卡识别码
  12552. str2 := make([]byte, 1024) //身份证号
  12553. str3 := make([]byte, 1024) //姓名
  12554. str4 := make([]byte, 1024) //错误信息
  12555. 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])))
  12556. fmt.Println(string(str1))
  12557. fmt.Println(string(str))
  12558. fmt.Println(string(str2))
  12559. fmt.Println(string(str3))
  12560. fmt.Println(string(str4))
  12561. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12562. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  12563. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  12564. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  12565. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  12566. if ret2 != 0 {
  12567. return "", "", "", "", ""
  12568. }
  12569. return string(str), string(str1), string(str2), string(str3), string(str4)
  12570. }
  12571. type CustomFundPay struct {
  12572. FundPayType string `json:"fund_pay_type"`
  12573. FundPayamt float64 `json:"fund_payamt"`
  12574. InscpScpAmt float64 `json:"inscp_scp_amt"`
  12575. }
  12576. //func (c *HisApiController) GetBatchSettleList() {
  12577. // start_time_str := c.GetString("start_time")
  12578. // //end_time_str := c.GetString("end_time")
  12579. // admin_user_id, _ := c.GetInt64("admin_user_id")
  12580. //
  12581. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  12582. //
  12583. // for _, item := range orders {
  12584. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  12585. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12586. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12587. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12588. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12589. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12590. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12591. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12592. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12593. //
  12594. // if order.ID == 0 {
  12595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12596. // return
  12597. // }
  12598. //
  12599. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12600. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12601. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12602. // //fmt.Println(count)
  12603. // //var zero string
  12604. // //number := count + 1
  12605. // //if number >= 1000 {
  12606. // // zero = "0000" + strconv.FormatInt(number, 10)
  12607. // //} else if number >= 10000 {
  12608. // // zero = "000" + strconv.FormatInt(number, 10)
  12609. // //} else if number >= 100000 {
  12610. // // zero = "00" + strconv.FormatInt(number, 10)
  12611. // //} else if number >= 1000000 {
  12612. // // zero = "0" + strconv.FormatInt(number, 10)
  12613. // //} else {
  12614. // // zero = strconv.FormatInt(number, 10)
  12615. // //}
  12616. // //fmt.Println(zero)
  12617. //
  12618. // struct4101 := service.Struct4101{
  12619. // PsnNo: order.PsnNo,
  12620. // MdtrtId: order.MdtrtId,
  12621. // SetlId: order.SetlId,
  12622. // PsnName: order.PsnName,
  12623. // Gend: order.Gend,
  12624. // Brdy: his.Brdy,
  12625. // Age: his.Age,
  12626. // Naty: order.Naty,
  12627. // PatnCertType: "01",
  12628. // Certno: order.Certno,
  12629. // Prfs: "90",
  12630. // ConerName: roles[0].UserName,
  12631. // PatnRlts: "99",
  12632. // ConerAddr: miConfig.OrgName,
  12633. // ConerTel: admin.Mobile,
  12634. // HiType: order.Insutype,
  12635. // Insuplc: miConfig.InsuplcAdmdvs,
  12636. // MaindiagFlag: "1",
  12637. // BillCode: order.SetlId,
  12638. // BillNo: order.SetlId,
  12639. // BizSn: order.Number,
  12640. // PsnSelfPay: order.PsnPartAmt,
  12641. // PsnOwnPay: order.PsnPartAmt,
  12642. // AcctPay: order.AcctPay,
  12643. // PsnCashpay: order.PsnCashPay,
  12644. // HiPaymtd: "1",
  12645. // Hsorg: miConfig.InsuplcAdmdvs,
  12646. // HsorgOpter: miConfig.InsuplcAdmdvs,
  12647. // MedinsFillPsn: curRoles.UserName,
  12648. // MedinsFillDept: miConfig.OrgName,
  12649. // IptMedType: "2",
  12650. // }
  12651. // struct4101.SetlBegnDate = order.SetlTime
  12652. // struct4101.SetlEndDate = order.SetlTime
  12653. // time_arr := strings.Split(order.SetlTime, " ")
  12654. // struct4101.AdmTime = time_arr[0]
  12655. // struct4101.AdmEndTime = time_arr[0]
  12656. //
  12657. // var rf []CustomFundPay
  12658. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  12659. //
  12660. // var tempFunPays []service.CustomStruct
  12661. // for _, item := range rf {
  12662. // var tempFunPay service.CustomStruct
  12663. // tempFunPay.FundPayamt = item.FundPayamt
  12664. // tempFunPay.FundPayType = item.FundPayType
  12665. // tempFunPays = append(tempFunPays, tempFunPay)
  12666. // }
  12667. // struct4101.CustomStruct = tempFunPays
  12668. //
  12669. // var tempDiaginfos []service.DiaginfoStructTwo
  12670. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12671. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12672. //
  12673. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12674. // var config []*models.HisXtDiagnoseConfig
  12675. // for _, item := range diagnosis_ids {
  12676. // id, _ := strconv.ParseInt(item, 10, 64)
  12677. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  12678. // config = append(config, &diagnosisConfig)
  12679. // }
  12680. //
  12681. // for index, item := range config {
  12682. // if index == 0 {
  12683. // var tempDiaginfo service.DiaginfoStructTwo
  12684. // tempDiaginfo.DiagCode = item.CountryCode
  12685. // tempDiaginfo.DiagName = item.CountryContentName
  12686. // tempDiaginfo.DiagType = "1"
  12687. // tempDiaginfo.MaindiagFlag = "1"
  12688. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12689. // } else {
  12690. // var tempDiaginfo service.DiaginfoStructTwo
  12691. // tempDiaginfo.DiagCode = item.CountryCode
  12692. // tempDiaginfo.DiagName = item.CountryContentName
  12693. // tempDiaginfo.DiagType = "1"
  12694. // tempDiaginfo.MaindiagFlag = "0"
  12695. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12696. // }
  12697. // }
  12698. // struct4101.Diseinfo = tempDiaginfos
  12699. //
  12700. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  12701. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12702. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12703. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12704. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12705. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12706. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12707. //
  12708. // var iteminfo service.IteminfoStruct
  12709. //
  12710. // var bedCostTotal float64 = 0 //床位总费
  12711. // var bedCostSelfTotal float64 = 0 //床位自费
  12712. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12713. //
  12714. // var operationCostTotal float64 = 0 //手术费
  12715. // var operationCostSelfTotal float64 = 0 //手术费
  12716. // var operationCostPartSelfTotal float64 = 0 //手术费
  12717. //
  12718. // var otherCostTotal float64 = 0 //其他费用
  12719. // var otherCostSelfTotal float64 = 0 //其他费用
  12720. // var otherCostPartSelfTotal float64 = 0 //其他费用
  12721. //
  12722. // var materialCostTotal float64 = 0 //材料费
  12723. // var materialCostSelfTotal float64 = 0 //材料费
  12724. // var materialCostPartSelfTotal float64 = 0 //材料费
  12725. //
  12726. // var westernMedicineCostTotal float64 = 0 //西药费
  12727. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  12728. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12729. //
  12730. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12731. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12732. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12733. //
  12734. // var checkCostTotal float64 = 0 //检查费
  12735. // var checkCostSelfTotal float64 = 0 //检查费
  12736. // var checkCostPartSelfTotal float64 = 0 //检查费
  12737. //
  12738. // var laboratoryCostTotal float64 = 0 //化验费
  12739. // var laboratoryCostSelfTotal float64 = 0 //化验费
  12740. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12741. //
  12742. // var treatCostTotal float64 = 0 //治疗费用
  12743. // var treatCostSelfTotal float64 = 0 //治疗费用
  12744. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  12745. //
  12746. // decimal.DivisionPrecision = 2
  12747. //
  12748. // var bed_fulamt_ownpay_amt float64 = 0
  12749. // var operation_fulamt_ownpay_amt float64 = 0
  12750. // var other_fulamt_ownpay_amt float64 = 0
  12751. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  12752. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12753. // var check_fulamt_ownpay_amt float64 = 0
  12754. // var material_fulamt_ownpay_amt float64 = 0
  12755. // var laboratory_fulamt_ownpay_amt float64 = 0
  12756. // var treat_fulamt_ownpay_amt float64 = 0
  12757. //
  12758. // var bed_claa_sunmfee float64 = 0
  12759. // var bed_clab_amt float64 = 0
  12760. // var bed_other_amt float64 = 0
  12761. //
  12762. // var operation_claa_sunmfee float64 = 0
  12763. // var operation_clab_amt float64 = 0
  12764. // var operation_other_amt float64 = 0
  12765. //
  12766. // var other_claa_sunmfee float64 = 0
  12767. // var other_clab_amt float64 = 0
  12768. // var other_other_amt float64 = 0
  12769. //
  12770. // var westernMedicine_claa_sunmfee float64 = 0
  12771. // var westernMedicine_clab_amt float64 = 0
  12772. // var westernMedicine_other_amt float64 = 0
  12773. //
  12774. // var chineseTraditional_claa_sunmfee float64 = 0
  12775. // var chineseTraditional_clab_amt float64 = 0
  12776. // var chineseTraditional_other_amt float64 = 0
  12777. //
  12778. // var check_claa_sunmfee float64 = 0
  12779. // var check_clab_amt float64 = 0
  12780. // var check_other_amt float64 = 0
  12781. //
  12782. // var material_claa_sunmfee float64 = 0
  12783. // var material_clab_amt float64 = 0
  12784. // var material_other_amt float64 = 0
  12785. //
  12786. // var laboratory_claa_sunmfee float64 = 0
  12787. // var laboratory_clab_amt float64 = 0
  12788. // var laboratory_other_amt float64 = 0
  12789. //
  12790. // var treat_claa_sunmfee float64 = 0
  12791. // var treat_clab_amt float64 = 0
  12792. // var treat_other_amt float64 = 0
  12793. //
  12794. // for _, item := range order.HisOrderInfo {
  12795. // if item.MedChrgitmType == "01" { //床位费
  12796. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12797. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12798. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12799. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12800. // if item.ChrgitmLv == "1" {
  12801. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12802. // }
  12803. // if item.ChrgitmLv == "2" {
  12804. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12805. //
  12806. // }
  12807. // if item.ChrgitmLv == "3" {
  12808. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12809. // }
  12810. //
  12811. // }
  12812. //
  12813. // if item.MedChrgitmType == "03" { //检查费
  12814. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12815. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12816. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12817. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12818. // if item.ChrgitmLv == "1" {
  12819. //
  12820. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12821. //
  12822. // }
  12823. // if item.ChrgitmLv == "2" {
  12824. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12825. //
  12826. // }
  12827. // if item.ChrgitmLv == "3" {
  12828. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12829. // }
  12830. // }
  12831. //
  12832. // if item.MedChrgitmType == "04" { //化验费
  12833. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12834. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12835. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12836. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12837. // if item.ChrgitmLv == "1" {
  12838. //
  12839. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12840. //
  12841. // }
  12842. // if item.ChrgitmLv == "2" {
  12843. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12844. //
  12845. // }
  12846. // if item.ChrgitmLv == "3" {
  12847. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12848. // }
  12849. // }
  12850. //
  12851. // if item.MedChrgitmType == "05" { //治疗费
  12852. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12853. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12854. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12855. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12856. // if item.ChrgitmLv == "1" {
  12857. //
  12858. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12859. //
  12860. // }
  12861. // if item.ChrgitmLv == "2" {
  12862. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12863. //
  12864. // }
  12865. // if item.ChrgitmLv == "3" {
  12866. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12867. // }
  12868. // }
  12869. //
  12870. // if item.MedChrgitmType == "06" { //手术费
  12871. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12872. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12873. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12874. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12875. //
  12876. // if item.ChrgitmLv == "1" {
  12877. //
  12878. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12879. //
  12880. // }
  12881. // if item.ChrgitmLv == "2" {
  12882. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12883. //
  12884. // }
  12885. // if item.ChrgitmLv == "3" {
  12886. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12887. // }
  12888. // }
  12889. //
  12890. // if item.MedChrgitmType == "08" { //材料费
  12891. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12892. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12893. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12894. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12895. // if item.ChrgitmLv == "1" {
  12896. //
  12897. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12898. //
  12899. // }
  12900. // if item.ChrgitmLv == "2" {
  12901. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12902. //
  12903. // }
  12904. // if item.ChrgitmLv == "3" {
  12905. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12906. // }
  12907. // }
  12908. //
  12909. // if item.MedChrgitmType == "09" { //西药费
  12910. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12911. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12912. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12913. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12914. // if item.ChrgitmLv == "1" {
  12915. //
  12916. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12917. //
  12918. // }
  12919. // if item.ChrgitmLv == "2" {
  12920. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12921. //
  12922. // }
  12923. // if item.ChrgitmLv == "3" {
  12924. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12925. // }
  12926. // }
  12927. //
  12928. // if item.MedChrgitmType == "11" { //中成费
  12929. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12930. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12931. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12932. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12933. // if item.ChrgitmLv == "1" {
  12934. //
  12935. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12936. //
  12937. // }
  12938. // if item.ChrgitmLv == "2" {
  12939. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12940. //
  12941. // }
  12942. // if item.ChrgitmLv == "3" {
  12943. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12944. // }
  12945. // }
  12946. //
  12947. // if item.MedChrgitmType == "14" { //其他费
  12948. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12949. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12950. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12951. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12952. // if item.ChrgitmLv == "1" {
  12953. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12954. //
  12955. // }
  12956. // if item.ChrgitmLv == "2" {
  12957. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12958. //
  12959. // }
  12960. // if item.ChrgitmLv == "3" {
  12961. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12962. // }
  12963. // }
  12964. //
  12965. // }
  12966. //
  12967. // var iteminfoStructs []service.IteminfoStruct
  12968. //
  12969. // if bedCostTotal != 0 {
  12970. // iteminfo.MedChrgitm = "01"
  12971. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12972. // iteminfo.Amt = bedCostTotal
  12973. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  12974. // iteminfo.ClabAmt = bed_clab_amt
  12975. // iteminfo.OthAmt = bed_other_amt
  12976. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12977. // }
  12978. //
  12979. // if checkCostTotal != 0 {
  12980. // iteminfo.MedChrgitm = "03"
  12981. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12982. // iteminfo.Amt = checkCostTotal
  12983. // iteminfo.ClaaSumfee = check_claa_sunmfee
  12984. // iteminfo.ClabAmt = check_clab_amt
  12985. // iteminfo.OthAmt = check_other_amt
  12986. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12987. //
  12988. // }
  12989. //
  12990. // if laboratoryCostTotal != 0 {
  12991. // iteminfo.MedChrgitm = "04"
  12992. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12993. // iteminfo.Amt = laboratoryCostTotal
  12994. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12995. // iteminfo.ClabAmt = laboratory_clab_amt
  12996. // iteminfo.OthAmt = laboratory_other_amt
  12997. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12998. //
  12999. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13000. //
  13001. // }
  13002. //
  13003. // if treatCostTotal != 0 {
  13004. // iteminfo.MedChrgitm = "05"
  13005. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13006. // iteminfo.Amt = treatCostTotal
  13007. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  13008. // iteminfo.ClabAmt = treat_clab_amt
  13009. // iteminfo.OthAmt = treat_other_amt
  13010. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13011. // //(struct4101.IteminfoStruct, iteminfo)
  13012. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13013. // }
  13014. //
  13015. // if operationCostTotal != 0 {
  13016. // iteminfo.MedChrgitm = "06"
  13017. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13018. // iteminfo.Amt = operationCostTotal
  13019. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  13020. // iteminfo.ClabAmt = operation_clab_amt
  13021. // iteminfo.OthAmt = operation_other_amt
  13022. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13023. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13024. // }
  13025. //
  13026. // if materialCostTotal != 0 {
  13027. // iteminfo.MedChrgitm = "08"
  13028. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13029. // iteminfo.Amt = materialCostTotal
  13030. // iteminfo.ClaaSumfee = material_claa_sunmfee
  13031. // iteminfo.ClabAmt = material_clab_amt
  13032. // iteminfo.OthAmt = material_other_amt
  13033. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13034. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13035. // }
  13036. //
  13037. // if westernMedicineCostTotal != 0 {
  13038. // iteminfo.MedChrgitm = "09"
  13039. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13040. // iteminfo.Amt = westernMedicineCostTotal
  13041. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13042. // iteminfo.ClabAmt = westernMedicine_clab_amt
  13043. // iteminfo.OthAmt = westernMedicine_other_amt
  13044. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13045. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13046. //
  13047. // }
  13048. // if chineseTraditionalMedicineCostTotal != 0 {
  13049. // iteminfo.MedChrgitm = "11"
  13050. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13051. // iteminfo.Amt = westernMedicineCostTotal
  13052. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13053. // iteminfo.ClabAmt = westernMedicine_clab_amt
  13054. // iteminfo.OthAmt = westernMedicine_other_amt
  13055. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13056. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13057. //
  13058. // }
  13059. // if otherCostTotal != 0 {
  13060. // iteminfo.MedChrgitm = "14"
  13061. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13062. // iteminfo.Amt = otherCostTotal
  13063. // iteminfo.ClaaSumfee = other_claa_sunmfee
  13064. // iteminfo.ClabAmt = other_clab_amt
  13065. // iteminfo.OthAmt = other_other_amt
  13066. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13067. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13068. //
  13069. // }
  13070. // struct4101.IteminfoStruct = iteminfoStructs
  13071. // struct4101.Ntly = "中国"
  13072. // struct4101.AdmCaty = "A03.06"
  13073. //
  13074. // struct4101.DoctorName = doctor.UserName
  13075. // struct4101.DoctorCode = doctor.DoctorNumber
  13076. //
  13077. // var res ResultSeventeen
  13078. //
  13079. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13080. // struct4101.BillCode = order.Number
  13081. // struct4101.BillNo = order.SetlId
  13082. // var resOther ResultSeventeenOther
  13083. // var pp models.PublicParams
  13084. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13085. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13086. // pp.FixmedinsName = miConfig.OrgName
  13087. // pp.FixmedinsCode = miConfig.Code
  13088. // pp.RequestUrl = miConfig.Url
  13089. // pp.Cainfo = miConfig.Cainfo
  13090. // pp.SecretKey = miConfig.SecretKey
  13091. // pp.AccessKey = miConfig.AccessKey
  13092. // pp.OpterName = curRoles.UserName
  13093. //
  13094. // client := &http.Client{}
  13095. // var req *http.Request
  13096. // data := make(map[string]interface{})
  13097. // data["struct4101"] = struct4101
  13098. // data["pp"] = pp
  13099. // bytesData, _ := json.Marshal(data)
  13100. // if miConfig.MdtrtareaAdmvs == "320921" {
  13101. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13102. // } else {
  13103. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13104. // }
  13105. // resp, _ := client.Do(req)
  13106. // defer resp.Body.Close()
  13107. // body, ioErr := ioutil.ReadAll(resp.Body)
  13108. // if ioErr != nil {
  13109. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13111. // return
  13112. // }
  13113. // var respJSON map[string]interface{}
  13114. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13115. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13116. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13117. // return
  13118. // }
  13119. //
  13120. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13121. // userJSONBytes, _ := json.Marshal(respJSON)
  13122. // fmt.Println("log")
  13123. // fmt.Println(string(userJSONBytes))
  13124. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13125. // utils.ErrorLog("解析失败:%v", err)
  13126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13127. // return
  13128. // }
  13129. // res.InfRefmsgid = resOther.InfRefmsgid
  13130. // res.Output = resOther.Output
  13131. // res.ErrMsg = resOther.ErrMsg
  13132. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13133. // res.Infcode = infocode
  13134. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  13135. //
  13136. // var pp models.PublicParams
  13137. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13138. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13139. // pp.FixmedinsName = miConfig.OrgName
  13140. // pp.FixmedinsCode = miConfig.Code
  13141. // pp.RequestUrl = miConfig.Url
  13142. // pp.Cainfo = miConfig.Cainfo
  13143. // pp.SecretKey = miConfig.SecretKey
  13144. // pp.AccessKey = miConfig.AccessKey
  13145. // pp.OpterName = curRoles.UserName
  13146. // result, _ := service.Jxyb4101(struct4101, pp)
  13147. // var dat map[string]interface{}
  13148. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13149. // fmt.Println(dat)
  13150. // } else {
  13151. // fmt.Println(err)
  13152. // }
  13153. // userJSONBytes, _ := json.Marshal(dat)
  13154. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13155. // utils.ErrorLog("解析失败:%v", err)
  13156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13157. // return
  13158. // }
  13159. //
  13160. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  13161. // var pp models.PublicParams
  13162. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13163. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13164. // pp.FixmedinsName = miConfig.OrgName
  13165. // pp.FixmedinsCode = miConfig.Code
  13166. // pp.RequestUrl = miConfig.Url
  13167. // pp.Cainfo = miConfig.Cainfo
  13168. // pp.SecretKey = miConfig.SecretKey
  13169. // pp.AccessKey = miConfig.AccessKey
  13170. // pp.OpterName = curRoles.UserName
  13171. // result, _ := service.Hnyb4101(struct4101, pp)
  13172. // var dat map[string]interface{}
  13173. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13174. // fmt.Println(dat)
  13175. // } else {
  13176. // fmt.Println(err)
  13177. // }
  13178. // userJSONBytes, _ := json.Marshal(dat)
  13179. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13180. // utils.ErrorLog("解析失败:%v", err)
  13181. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13182. // return
  13183. // }
  13184. //
  13185. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  13186. // var resOther ResultSeventeenOther
  13187. //
  13188. // var pp models.PublicParams
  13189. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13190. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13191. // pp.FixmedinsName = miConfig.OrgName
  13192. // pp.FixmedinsCode = miConfig.Code
  13193. // pp.RequestUrl = miConfig.Url
  13194. // pp.Cainfo = miConfig.Cainfo
  13195. // pp.SecretKey = miConfig.SecretKey
  13196. // pp.AccessKey = miConfig.AccessKey
  13197. // pp.OpterName = curRoles.UserName
  13198. // client := &http.Client{}
  13199. // var req *http.Request
  13200. // data := make(map[string]interface{})
  13201. // data["struct4101"] = struct4101
  13202. // data["pp"] = pp
  13203. // bytesData, _ := json.Marshal(data)
  13204. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13205. // resp, _ := client.Do(req)
  13206. // defer resp.Body.Close()
  13207. // body, ioErr := ioutil.ReadAll(resp.Body)
  13208. // if ioErr != nil {
  13209. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13211. // return
  13212. // }
  13213. // var respJSON map[string]interface{}
  13214. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13215. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13217. // return
  13218. // }
  13219. //
  13220. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13221. // userJSONBytes, _ := json.Marshal(respJSON)
  13222. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13223. // utils.ErrorLog("解析失败:%v", err)
  13224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13225. // return
  13226. // }
  13227. // res.InfRefmsgid = resOther.InfRefmsgid
  13228. // res.Output = resOther.Output
  13229. // res.ErrMsg = resOther.ErrMsg
  13230. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13231. // res.Infcode = infocode
  13232. //
  13233. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  13234. // var pp models.PublicParams
  13235. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13236. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13237. // pp.FixmedinsName = miConfig.OrgName
  13238. // pp.FixmedinsCode = miConfig.Code
  13239. // pp.RequestUrl = miConfig.Url
  13240. // pp.Cainfo = miConfig.Cainfo
  13241. // pp.SecretKey = miConfig.SecretKey
  13242. // pp.AccessKey = miConfig.AccessKey
  13243. // pp.OpterName = curRoles.UserName
  13244. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13245. // fmt.Println(requestLog)
  13246. // fmt.Println(errMsgLog)
  13247. //
  13248. // saveLog(result, requestLog, "4101a", "上传清单")
  13249. //
  13250. // var dat map[string]interface{}
  13251. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13252. // fmt.Println(dat)
  13253. // } else {
  13254. // fmt.Println(err)
  13255. // }
  13256. // userJSONBytes, _ := json.Marshal(dat)
  13257. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13258. // utils.ErrorLog("解析失败:%v", err)
  13259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13260. // return
  13261. // }
  13262. //
  13263. // } else {
  13264. //
  13265. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  13266. // var dat map[string]interface{}
  13267. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13268. // fmt.Println(dat)
  13269. // } else {
  13270. // fmt.Println(err)
  13271. // }
  13272. // userJSONBytes, _ := json.Marshal(dat)
  13273. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13274. // utils.ErrorLog("解析失败:%v", err)
  13275. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13276. // return
  13277. // }
  13278. // }
  13279. //
  13280. // if res.Infcode != 0 {
  13281. // adminUser := c.GetAdminUserInfo()
  13282. // errlog := &models.HisOrderError{
  13283. // UserOrgId: adminUser.CurrentOrgId,
  13284. // Ctime: time.Now().Unix(),
  13285. // Mtime: time.Now().Unix(),
  13286. // ErrMsg: res.ErrMsg,
  13287. // Status: 1,
  13288. // PatientId: order.ID,
  13289. // Stage: 10265,
  13290. // }
  13291. // service.CreateErrMsgLog(errlog)
  13292. // continue
  13293. // } else {
  13294. // //order.FaPiaoNumber = zero
  13295. // //order.FaPiaoCode = last_order.FaPiaoCode
  13296. // //service.UpdateOrder(order)
  13297. // hisFundSettleListResult := &models.HisFundSettleListResult{
  13298. // Number: res.Output.SetlListId,
  13299. // Status: 1,
  13300. // Ctime: time.Now().Unix(),
  13301. // Mtime: time.Now().Unix(),
  13302. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13303. // IsUpload: 1,
  13304. // OrderId: order.ID,
  13305. // }
  13306. // service.CreateUploadRecord(hisFundSettleListResult)
  13307. // c.ServeSuccessJSON(map[string]interface{}{
  13308. // "msg": "上传成功",
  13309. // "result": hisFundSettleListResult,
  13310. // })
  13311. // continue
  13312. // }
  13313. // }
  13314. //}
  13315. func (c *HisApiController) GetbatchSettleList() {
  13316. //order_id, _ := c.GetInt64("order_id")
  13317. admin_user_id, _ := c.GetInt64("admin_user_id")
  13318. orders, _ := service.GetAllHisOrderTwo10485()
  13319. for _, item := range orders {
  13320. order, _ := service.GetHisOrderByIDTwo(item.ID)
  13321. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13322. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13323. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13324. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13325. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13326. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13327. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13328. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13329. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13330. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13331. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13332. //fmt.Println(count)
  13333. //var zero string
  13334. //number := count + 1
  13335. //if number >= 1000 {
  13336. // zero = "0000" + strconv.FormatInt(number, 10)
  13337. //} else if number >= 10000 {
  13338. // zero = "000" + strconv.FormatInt(number, 10)
  13339. //} else if number >= 100000 {
  13340. // zero = "00" + strconv.FormatInt(number, 10)
  13341. //} else if number >= 1000000 {
  13342. // zero = "0" + strconv.FormatInt(number, 10)
  13343. //} else {
  13344. // zero = strconv.FormatInt(number, 10)
  13345. //}
  13346. //fmt.Println(zero)
  13347. struct4101 := service.Struct4101{
  13348. PsnNo: order.PsnNo,
  13349. MdtrtId: order.MdtrtId,
  13350. SetlId: order.SetlId,
  13351. PsnName: order.PsnName,
  13352. Gend: order.Gend,
  13353. Brdy: his.Brdy,
  13354. Age: his.Age,
  13355. Naty: order.Naty,
  13356. PatnCertType: "01",
  13357. Certno: order.Certno,
  13358. Prfs: "90",
  13359. ConerName: roles[0].UserName,
  13360. PatnRlts: "99",
  13361. ConerAddr: miConfig.OrgName,
  13362. ConerTel: admin.Mobile,
  13363. HiType: order.Insutype,
  13364. Insuplc: miConfig.InsuplcAdmdvs,
  13365. MaindiagFlag: "1",
  13366. BillCode: order.SetlId,
  13367. BillNo: order.SetlId,
  13368. BizSn: order.Number,
  13369. PsnSelfPay: order.PsnPartAmt,
  13370. PsnOwnPay: order.PsnPartAmt,
  13371. AcctPay: order.AcctPay,
  13372. PsnCashpay: order.PsnCashPay,
  13373. HiPaymtd: "1",
  13374. Hsorg: miConfig.InsuplcAdmdvs,
  13375. HsorgOpter: miConfig.InsuplcAdmdvs,
  13376. MedinsFillPsn: curRoles.UserName,
  13377. MedinsFillDept: miConfig.OrgName,
  13378. IptMedType: "2",
  13379. }
  13380. struct4101.SetlBegnDate = order.SetlTime
  13381. struct4101.SetlEndDate = order.SetlTime
  13382. time_arr := strings.Split(order.SetlTime, " ")
  13383. struct4101.AdmTime = time_arr[0]
  13384. struct4101.AdmEndTime = time_arr[0]
  13385. //var rf []CustomFundPay
  13386. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13387. //
  13388. //var tempFunPays []service.CustomStruct
  13389. //for _, item := range rf {
  13390. // var tempFunPay service.CustomStruct
  13391. // tempFunPay.FundPayamt = item.FundPayamt
  13392. // tempFunPay.FundPayType = item.FundPayType
  13393. // tempFunPays = append(tempFunPays, tempFunPay)
  13394. //}
  13395. //struct4101.CustomStruct = tempFunPays
  13396. var tempDiaginfos []service.DiaginfoStructTwo
  13397. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13398. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13399. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13400. var config []*models.HisXtDiagnoseConfig
  13401. for _, item := range diagnosis_ids {
  13402. id, _ := strconv.ParseInt(item, 10, 64)
  13403. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13404. config = append(config, &diagnosisConfig)
  13405. }
  13406. for index, item := range config {
  13407. if index == 0 {
  13408. var tempDiaginfo service.DiaginfoStructTwo
  13409. tempDiaginfo.DiagCode = item.CountryCode
  13410. tempDiaginfo.DiagName = item.CountryContentName
  13411. tempDiaginfo.DiagType = "1"
  13412. tempDiaginfo.MaindiagFlag = "1"
  13413. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13414. } else {
  13415. var tempDiaginfo service.DiaginfoStructTwo
  13416. tempDiaginfo.DiagCode = item.CountryCode
  13417. tempDiaginfo.DiagName = item.CountryContentName
  13418. tempDiaginfo.DiagType = "1"
  13419. tempDiaginfo.MaindiagFlag = "0"
  13420. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13421. }
  13422. }
  13423. struct4101.Diseinfo = tempDiaginfos
  13424. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13425. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13426. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13427. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13428. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13429. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13430. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13431. var iteminfo service.IteminfoStruct
  13432. var bedCostTotal float64 = 0 //床位总费
  13433. var bedCostSelfTotal float64 = 0 //床位自费
  13434. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13435. var operationCostTotal float64 = 0 //手术费
  13436. var operationCostSelfTotal float64 = 0 //手术费
  13437. var operationCostPartSelfTotal float64 = 0 //手术费
  13438. var otherCostTotal float64 = 0 //其他费用
  13439. var otherCostSelfTotal float64 = 0 //其他费用
  13440. var otherCostPartSelfTotal float64 = 0 //其他费用
  13441. var materialCostTotal float64 = 0 //材料费
  13442. var materialCostSelfTotal float64 = 0 //材料费
  13443. var materialCostPartSelfTotal float64 = 0 //材料费
  13444. var westernMedicineCostTotal float64 = 0 //西药费
  13445. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13446. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13447. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13448. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13449. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13450. var checkCostTotal float64 = 0 //检查费
  13451. var checkCostSelfTotal float64 = 0 //检查费
  13452. var checkCostPartSelfTotal float64 = 0 //检查费
  13453. var laboratoryCostTotal float64 = 0 //化验费
  13454. var laboratoryCostSelfTotal float64 = 0 //化验费
  13455. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13456. var treatCostTotal float64 = 0 //治疗费用
  13457. var treatCostSelfTotal float64 = 0 //治疗费用
  13458. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13459. decimal.DivisionPrecision = 2
  13460. var bed_fulamt_ownpay_amt float64 = 0
  13461. var operation_fulamt_ownpay_amt float64 = 0
  13462. var other_fulamt_ownpay_amt float64 = 0
  13463. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13464. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13465. var check_fulamt_ownpay_amt float64 = 0
  13466. var material_fulamt_ownpay_amt float64 = 0
  13467. var laboratory_fulamt_ownpay_amt float64 = 0
  13468. var treat_fulamt_ownpay_amt float64 = 0
  13469. var bed_claa_sunmfee float64 = 0
  13470. var bed_clab_amt float64 = 0
  13471. var bed_other_amt float64 = 0
  13472. var operation_claa_sunmfee float64 = 0
  13473. var operation_clab_amt float64 = 0
  13474. var operation_other_amt float64 = 0
  13475. var other_claa_sunmfee float64 = 0
  13476. var other_clab_amt float64 = 0
  13477. var other_other_amt float64 = 0
  13478. var westernMedicine_claa_sunmfee float64 = 0
  13479. var westernMedicine_clab_amt float64 = 0
  13480. var westernMedicine_other_amt float64 = 0
  13481. var chineseTraditional_claa_sunmfee float64 = 0
  13482. var chineseTraditional_clab_amt float64 = 0
  13483. var chineseTraditional_other_amt float64 = 0
  13484. var check_claa_sunmfee float64 = 0
  13485. var check_clab_amt float64 = 0
  13486. var check_other_amt float64 = 0
  13487. var material_claa_sunmfee float64 = 0
  13488. var material_clab_amt float64 = 0
  13489. var material_other_amt float64 = 0
  13490. var laboratory_claa_sunmfee float64 = 0
  13491. var laboratory_clab_amt float64 = 0
  13492. var laboratory_other_amt float64 = 0
  13493. var treat_claa_sunmfee float64 = 0
  13494. var treat_clab_amt float64 = 0
  13495. var treat_other_amt float64 = 0
  13496. for _, item := range order.HisOrderInfo {
  13497. if item.MedChrgitmType == "01" { //床位费
  13498. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13499. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13500. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13501. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13502. if item.ChrgitmLv == "1" {
  13503. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13504. }
  13505. if item.ChrgitmLv == "2" {
  13506. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13507. }
  13508. if item.ChrgitmLv == "3" {
  13509. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13510. }
  13511. }
  13512. if item.MedChrgitmType == "03" { //检查费
  13513. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13514. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13515. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13516. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13517. if item.ChrgitmLv == "1" {
  13518. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13519. }
  13520. if item.ChrgitmLv == "2" {
  13521. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13522. }
  13523. if item.ChrgitmLv == "3" {
  13524. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13525. }
  13526. }
  13527. if item.MedChrgitmType == "04" { //化验费
  13528. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13529. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13530. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13531. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13532. if item.ChrgitmLv == "1" {
  13533. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13534. }
  13535. if item.ChrgitmLv == "2" {
  13536. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13537. }
  13538. if item.ChrgitmLv == "3" {
  13539. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13540. }
  13541. }
  13542. if item.MedChrgitmType == "05" { //治疗费
  13543. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13544. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13545. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13546. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13547. if item.ChrgitmLv == "1" {
  13548. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13549. }
  13550. if item.ChrgitmLv == "2" {
  13551. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13552. }
  13553. if item.ChrgitmLv == "3" {
  13554. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13555. }
  13556. }
  13557. if item.MedChrgitmType == "06" { //手术费
  13558. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13559. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13560. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13561. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13562. if item.ChrgitmLv == "1" {
  13563. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13564. }
  13565. if item.ChrgitmLv == "2" {
  13566. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13567. }
  13568. if item.ChrgitmLv == "3" {
  13569. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13570. }
  13571. }
  13572. if item.MedChrgitmType == "08" { //材料费
  13573. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13574. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13575. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13576. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13577. if item.ChrgitmLv == "1" {
  13578. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13579. }
  13580. if item.ChrgitmLv == "2" {
  13581. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13582. }
  13583. if item.ChrgitmLv == "3" {
  13584. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13585. }
  13586. }
  13587. if item.MedChrgitmType == "09" { //西药费
  13588. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13589. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13590. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13591. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13592. if item.ChrgitmLv == "1" {
  13593. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13594. }
  13595. if item.ChrgitmLv == "2" {
  13596. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13597. }
  13598. if item.ChrgitmLv == "3" {
  13599. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13600. }
  13601. }
  13602. if item.MedChrgitmType == "11" { //中成费
  13603. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13604. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13605. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13606. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13607. if item.ChrgitmLv == "1" {
  13608. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13609. }
  13610. if item.ChrgitmLv == "2" {
  13611. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13612. }
  13613. if item.ChrgitmLv == "3" {
  13614. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13615. }
  13616. }
  13617. if item.MedChrgitmType == "14" { //其他费
  13618. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13619. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13620. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13621. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13622. if item.ChrgitmLv == "1" {
  13623. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13624. }
  13625. if item.ChrgitmLv == "2" {
  13626. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13627. }
  13628. if item.ChrgitmLv == "3" {
  13629. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13630. }
  13631. }
  13632. }
  13633. var iteminfoStructs []service.IteminfoStruct
  13634. if bedCostTotal != 0 {
  13635. iteminfo.MedChrgitm = "01"
  13636. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13637. iteminfo.Amt = bedCostTotal
  13638. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13639. iteminfo.ClabAmt = bed_clab_amt
  13640. iteminfo.OthAmt = bed_other_amt
  13641. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13642. }
  13643. if checkCostTotal != 0 {
  13644. iteminfo.MedChrgitm = "03"
  13645. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13646. iteminfo.Amt = checkCostTotal
  13647. iteminfo.ClaaSumfee = check_claa_sunmfee
  13648. iteminfo.ClabAmt = check_clab_amt
  13649. iteminfo.OthAmt = check_other_amt
  13650. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13651. }
  13652. if laboratoryCostTotal != 0 {
  13653. iteminfo.MedChrgitm = "04"
  13654. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13655. iteminfo.Amt = laboratoryCostTotal
  13656. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13657. iteminfo.ClabAmt = laboratory_clab_amt
  13658. iteminfo.OthAmt = laboratory_other_amt
  13659. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13660. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13661. }
  13662. if treatCostTotal != 0 {
  13663. iteminfo.MedChrgitm = "05"
  13664. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13665. iteminfo.Amt = treatCostTotal
  13666. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13667. iteminfo.ClabAmt = treat_clab_amt
  13668. iteminfo.OthAmt = treat_other_amt
  13669. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13670. //(struct4101.IteminfoStruct, iteminfo)
  13671. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13672. }
  13673. if operationCostTotal != 0 {
  13674. iteminfo.MedChrgitm = "06"
  13675. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13676. iteminfo.Amt = operationCostTotal
  13677. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13678. iteminfo.ClabAmt = operation_clab_amt
  13679. iteminfo.OthAmt = operation_other_amt
  13680. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13681. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13682. }
  13683. if materialCostTotal != 0 {
  13684. iteminfo.MedChrgitm = "08"
  13685. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13686. iteminfo.Amt = materialCostTotal
  13687. iteminfo.ClaaSumfee = material_claa_sunmfee
  13688. iteminfo.ClabAmt = material_clab_amt
  13689. iteminfo.OthAmt = material_other_amt
  13690. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13691. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13692. }
  13693. if westernMedicineCostTotal != 0 {
  13694. iteminfo.MedChrgitm = "09"
  13695. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13696. iteminfo.Amt = westernMedicineCostTotal
  13697. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13698. iteminfo.ClabAmt = westernMedicine_clab_amt
  13699. iteminfo.OthAmt = westernMedicine_other_amt
  13700. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13701. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13702. }
  13703. if chineseTraditionalMedicineCostTotal != 0 {
  13704. iteminfo.MedChrgitm = "11"
  13705. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13706. iteminfo.Amt = westernMedicineCostTotal
  13707. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13708. iteminfo.ClabAmt = westernMedicine_clab_amt
  13709. iteminfo.OthAmt = westernMedicine_other_amt
  13710. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13711. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13712. }
  13713. if otherCostTotal != 0 {
  13714. iteminfo.MedChrgitm = "14"
  13715. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13716. iteminfo.Amt = otherCostTotal
  13717. iteminfo.ClaaSumfee = other_claa_sunmfee
  13718. iteminfo.ClabAmt = other_clab_amt
  13719. iteminfo.OthAmt = other_other_amt
  13720. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13721. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13722. }
  13723. struct4101.IteminfoStruct = iteminfoStructs
  13724. struct4101.Ntly = "中国"
  13725. struct4101.AdmCaty = "A03.06"
  13726. struct4101.DoctorName = doctor.UserName
  13727. struct4101.DoctorCode = doctor.DoctorNumber
  13728. var res ResultSeventeen
  13729. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13730. struct4101.BillCode = order.Number
  13731. struct4101.BillNo = order.SetlId
  13732. var resOther ResultSeventeenOther
  13733. var pp models.PublicParams
  13734. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13735. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13736. pp.FixmedinsName = miConfig.OrgName
  13737. pp.FixmedinsCode = miConfig.Code
  13738. pp.RequestUrl = miConfig.Url
  13739. pp.Cainfo = miConfig.Cainfo
  13740. pp.SecretKey = miConfig.SecretKey
  13741. pp.AccessKey = miConfig.AccessKey
  13742. pp.OpterName = curRoles.UserName
  13743. client := &http.Client{}
  13744. var req *http.Request
  13745. data := make(map[string]interface{})
  13746. data["struct4101"] = struct4101
  13747. data["pp"] = pp
  13748. bytesData, _ := json.Marshal(data)
  13749. if miConfig.MdtrtareaAdmvs == "320921" {
  13750. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13751. } else {
  13752. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13753. }
  13754. resp, _ := client.Do(req)
  13755. defer resp.Body.Close()
  13756. body, ioErr := ioutil.ReadAll(resp.Body)
  13757. if ioErr != nil {
  13758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13760. return
  13761. }
  13762. var respJSON map[string]interface{}
  13763. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13766. return
  13767. }
  13768. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13769. userJSONBytes, _ := json.Marshal(respJSON)
  13770. fmt.Println("log")
  13771. fmt.Println(string(userJSONBytes))
  13772. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13773. utils.ErrorLog("解析失败:%v", err)
  13774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13775. return
  13776. }
  13777. res.InfRefmsgid = resOther.InfRefmsgid
  13778. res.Output = resOther.Output
  13779. res.ErrMsg = resOther.ErrMsg
  13780. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13781. res.Infcode = infocode
  13782. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13783. var pp models.PublicParams
  13784. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13785. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13786. pp.FixmedinsName = miConfig.OrgName
  13787. pp.FixmedinsCode = miConfig.Code
  13788. pp.RequestUrl = miConfig.Url
  13789. pp.Cainfo = miConfig.Cainfo
  13790. pp.SecretKey = miConfig.SecretKey
  13791. pp.AccessKey = miConfig.AccessKey
  13792. pp.OpterName = curRoles.UserName
  13793. result, _ := service.Jxyb4101(struct4101, pp)
  13794. var dat map[string]interface{}
  13795. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13796. fmt.Println(dat)
  13797. } else {
  13798. fmt.Println(err)
  13799. }
  13800. userJSONBytes, _ := json.Marshal(dat)
  13801. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13802. utils.ErrorLog("解析失败:%v", err)
  13803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13804. return
  13805. }
  13806. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13807. var pp models.PublicParams
  13808. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13809. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13810. pp.FixmedinsName = miConfig.OrgName
  13811. pp.FixmedinsCode = miConfig.Code
  13812. pp.RequestUrl = miConfig.Url
  13813. pp.Cainfo = miConfig.Cainfo
  13814. pp.SecretKey = miConfig.SecretKey
  13815. pp.AccessKey = miConfig.AccessKey
  13816. pp.OpterName = curRoles.UserName
  13817. result, _ := service.Hnyb4101(struct4101, pp)
  13818. var dat map[string]interface{}
  13819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13820. fmt.Println(dat)
  13821. } else {
  13822. fmt.Println(err)
  13823. }
  13824. userJSONBytes, _ := json.Marshal(dat)
  13825. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13826. utils.ErrorLog("解析失败:%v", err)
  13827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13828. return
  13829. }
  13830. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13831. var resOther ResultSeventeenOther
  13832. var pp models.PublicParams
  13833. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13834. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13835. pp.FixmedinsName = miConfig.OrgName
  13836. pp.FixmedinsCode = miConfig.Code
  13837. pp.RequestUrl = miConfig.Url
  13838. pp.Cainfo = miConfig.Cainfo
  13839. pp.SecretKey = miConfig.SecretKey
  13840. pp.AccessKey = miConfig.AccessKey
  13841. pp.OpterName = curRoles.UserName
  13842. client := &http.Client{}
  13843. var req *http.Request
  13844. data := make(map[string]interface{})
  13845. data["struct4101"] = struct4101
  13846. data["pp"] = pp
  13847. bytesData, _ := json.Marshal(data)
  13848. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13849. resp, _ := client.Do(req)
  13850. defer resp.Body.Close()
  13851. body, ioErr := ioutil.ReadAll(resp.Body)
  13852. if ioErr != nil {
  13853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13855. return
  13856. }
  13857. var respJSON map[string]interface{}
  13858. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13861. return
  13862. }
  13863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13864. userJSONBytes, _ := json.Marshal(respJSON)
  13865. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13866. utils.ErrorLog("解析失败:%v", err)
  13867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13868. return
  13869. }
  13870. res.InfRefmsgid = resOther.InfRefmsgid
  13871. res.Output = resOther.Output
  13872. res.ErrMsg = resOther.ErrMsg
  13873. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13874. res.Infcode = infocode
  13875. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13876. var pp models.PublicParams
  13877. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13878. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13879. pp.FixmedinsName = miConfig.OrgName
  13880. pp.FixmedinsCode = miConfig.Code
  13881. pp.RequestUrl = miConfig.Url
  13882. pp.Cainfo = miConfig.Cainfo
  13883. pp.SecretKey = miConfig.SecretKey
  13884. pp.AccessKey = miConfig.AccessKey
  13885. pp.OpterName = curRoles.UserName
  13886. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13887. fmt.Println(requestLog)
  13888. fmt.Println(errMsgLog)
  13889. saveLog(result, requestLog, "4101a", "上传清单")
  13890. var dat map[string]interface{}
  13891. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13892. fmt.Println(dat)
  13893. } else {
  13894. fmt.Println(err)
  13895. }
  13896. userJSONBytes, _ := json.Marshal(dat)
  13897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13898. utils.ErrorLog("解析失败:%v", err)
  13899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13900. return
  13901. }
  13902. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13903. var pp models.PublicParams
  13904. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13905. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13906. pp.FixmedinsName = miConfig.OrgName
  13907. pp.FixmedinsCode = miConfig.Code
  13908. pp.RequestUrl = miConfig.Url
  13909. pp.Cainfo = miConfig.Cainfo
  13910. pp.SecretKey = miConfig.SecretKey
  13911. pp.AccessKey = miConfig.AccessKey
  13912. pp.OpterName = curRoles.UserName
  13913. client := &http.Client{}
  13914. var req *http.Request
  13915. data := make(map[string]interface{})
  13916. data["struct4101"] = struct4101
  13917. data["pp"] = pp
  13918. bytesData, _ := json.Marshal(data)
  13919. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13920. resp, _ := client.Do(req)
  13921. defer resp.Body.Close()
  13922. body, ioErr := ioutil.ReadAll(resp.Body)
  13923. if ioErr != nil {
  13924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13926. return
  13927. }
  13928. var respJSON map[string]interface{}
  13929. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13932. return
  13933. }
  13934. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13935. userJSONBytes, _ := json.Marshal(respJSON)
  13936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13937. utils.ErrorLog("解析失败:%v", err)
  13938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13939. return
  13940. }
  13941. } else {
  13942. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13943. var dat map[string]interface{}
  13944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13945. fmt.Println(dat)
  13946. } else {
  13947. fmt.Println(err)
  13948. }
  13949. userJSONBytes, _ := json.Marshal(dat)
  13950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13951. utils.ErrorLog("解析失败:%v", err)
  13952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13953. return
  13954. }
  13955. }
  13956. if res.Infcode != 0 {
  13957. errlog := &models.HisOrderError{
  13958. UserOrgId: order.UserOrgId,
  13959. Ctime: time.Now().Unix(),
  13960. Mtime: time.Now().Unix(),
  13961. ErrMsg: res.ErrMsg + "解析失败",
  13962. Status: 1,
  13963. PatientId: order.ID,
  13964. Stage: 10485,
  13965. }
  13966. service.CreateErrMsgLog(errlog)
  13967. continue
  13968. //c.ServeSuccessJSON(map[string]interface{}{
  13969. // "failed_code": -10,
  13970. // "msg": res.ErrMsg,
  13971. //})
  13972. } else {
  13973. //order.FaPiaoNumber = zero
  13974. //order.FaPiaoCode = last_order.FaPiaoCode
  13975. //service.UpdateOrder(order)
  13976. hisFundSettleListResult := &models.HisFundSettleListResult{
  13977. Number: res.Output.SetlListId,
  13978. Status: 1,
  13979. Ctime: time.Now().Unix(),
  13980. Mtime: time.Now().Unix(),
  13981. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13982. IsUpload: 1,
  13983. OrderId: order.ID,
  13984. }
  13985. service.CreateUploadRecord(hisFundSettleListResult)
  13986. continue
  13987. }
  13988. }
  13989. }
  13990. func (c *HisApiController) GetSettleList() {
  13991. order_id, _ := c.GetInt64("order_id")
  13992. admin_user_id, _ := c.GetInt64("admin_user_id")
  13993. order, _ := service.GetHisOrderByIDTwo(order_id)
  13994. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13995. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13996. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13997. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13998. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13999. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14000. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14001. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14002. if order.ID == 0 {
  14003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14004. return
  14005. }
  14006. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  14007. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  14008. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  14009. //fmt.Println(count)
  14010. //var zero string
  14011. //number := count + 1
  14012. //if number >= 1000 {
  14013. // zero = "0000" + strconv.FormatInt(number, 10)
  14014. //} else if number >= 10000 {
  14015. // zero = "000" + strconv.FormatInt(number, 10)
  14016. //} else if number >= 100000 {
  14017. // zero = "00" + strconv.FormatInt(number, 10)
  14018. //} else if number >= 1000000 {
  14019. // zero = "0" + strconv.FormatInt(number, 10)
  14020. //} else {
  14021. // zero = strconv.FormatInt(number, 10)
  14022. //}
  14023. //fmt.Println(zero)
  14024. struct4101 := service.Struct4101{
  14025. PsnNo: order.PsnNo,
  14026. MdtrtId: order.MdtrtId,
  14027. SetlId: order.SetlId,
  14028. PsnName: order.PsnName,
  14029. Gend: order.Gend,
  14030. Brdy: his.Brdy,
  14031. Age: his.Age,
  14032. Naty: order.Naty,
  14033. PatnCertType: "01",
  14034. Certno: order.Certno,
  14035. Prfs: "90",
  14036. ConerName: roles[0].UserName,
  14037. PatnRlts: "99",
  14038. ConerAddr: miConfig.OrgName,
  14039. ConerTel: admin.Mobile,
  14040. HiType: order.Insutype,
  14041. Insuplc: miConfig.InsuplcAdmdvs,
  14042. MaindiagFlag: "1",
  14043. BillCode: order.SetlId,
  14044. BillNo: order.SetlId,
  14045. BizSn: order.Number,
  14046. PsnSelfPay: order.PsnPartAmt,
  14047. PsnOwnPay: order.PsnPartAmt,
  14048. AcctPay: order.AcctPay,
  14049. PsnCashpay: order.PsnCashPay,
  14050. HiPaymtd: "1",
  14051. Hsorg: miConfig.InsuplcAdmdvs,
  14052. HsorgOpter: miConfig.InsuplcAdmdvs,
  14053. MedinsFillPsn: curRoles.UserName,
  14054. MedinsFillDept: miConfig.OrgName,
  14055. IptMedType: "2",
  14056. }
  14057. struct4101.SetlBegnDate = order.SetlTime
  14058. struct4101.SetlEndDate = order.SetlTime
  14059. time_arr := strings.Split(order.SetlTime, " ")
  14060. struct4101.AdmTime = time_arr[0]
  14061. struct4101.AdmEndTime = time_arr[0]
  14062. //
  14063. //var rf []CustomFundPay
  14064. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  14065. //
  14066. //var tempFunPays []service.CustomStruct
  14067. //for _, item := range rf {
  14068. // var tempFunPay service.CustomStruct
  14069. // tempFunPay.FundPayamt = item.FundPayamt
  14070. // tempFunPay.FundPayType = item.FundPayType
  14071. // tempFunPays = append(tempFunPays, tempFunPay)
  14072. //}
  14073. //struct4101.CustomStruct = tempFunPays
  14074. var tempDiaginfos []service.DiaginfoStructTwo
  14075. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14076. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14077. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  14078. var config []*models.HisXtDiagnoseConfig
  14079. for _, item := range diagnosis_ids {
  14080. id, _ := strconv.ParseInt(item, 10, 64)
  14081. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14082. config = append(config, &diagnosisConfig)
  14083. }
  14084. if miConfig.Code == "H15049901371" {
  14085. //for _, item := range config {
  14086. // if item.ID == 138 {
  14087. diagnosisConfig, _ := service.FindDiagnoseById(138)
  14088. var tempDiaginfo service.DiaginfoStructTwo
  14089. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  14090. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  14091. tempDiaginfo.DiagType = "1"
  14092. tempDiaginfo.MaindiagFlag = "1"
  14093. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14094. //}
  14095. //}
  14096. for _, item := range config {
  14097. if item.ID != 138 {
  14098. var tempDiaginfo service.DiaginfoStructTwo
  14099. tempDiaginfo.DiagCode = item.CountryCode
  14100. tempDiaginfo.DiagName = item.CountryContentName
  14101. tempDiaginfo.DiagType = "1"
  14102. tempDiaginfo.MaindiagFlag = "0"
  14103. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14104. }
  14105. }
  14106. } else {
  14107. for index, item := range config {
  14108. if index == 0 {
  14109. var tempDiaginfo service.DiaginfoStructTwo
  14110. tempDiaginfo.DiagCode = item.CountryCode
  14111. tempDiaginfo.DiagName = item.CountryContentName
  14112. tempDiaginfo.DiagType = "1"
  14113. tempDiaginfo.MaindiagFlag = "1"
  14114. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14115. } else {
  14116. var tempDiaginfo service.DiaginfoStructTwo
  14117. tempDiaginfo.DiagCode = item.CountryCode
  14118. tempDiaginfo.DiagName = item.CountryContentName
  14119. tempDiaginfo.DiagType = "1"
  14120. tempDiaginfo.MaindiagFlag = "0"
  14121. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14122. }
  14123. }
  14124. }
  14125. struct4101.Diseinfo = tempDiaginfos
  14126. sickConfigTwo, _ := service.FindSickById(his.SickType)
  14127. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14128. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14129. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  14130. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  14131. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14132. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14133. var iteminfo service.IteminfoStruct
  14134. var bedCostTotal float64 = 0 //床位总费
  14135. var bedCostSelfTotal float64 = 0 //床位自费
  14136. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14137. var operationCostTotal float64 = 0 //手术费
  14138. var operationCostSelfTotal float64 = 0 //手术费
  14139. var operationCostPartSelfTotal float64 = 0 //手术费
  14140. var otherCostTotal float64 = 0 //其他费用
  14141. var otherCostSelfTotal float64 = 0 //其他费用
  14142. var otherCostPartSelfTotal float64 = 0 //其他费用
  14143. var materialCostTotal float64 = 0 //材料费
  14144. var materialCostSelfTotal float64 = 0 //材料费
  14145. var materialCostPartSelfTotal float64 = 0 //材料费
  14146. var westernMedicineCostTotal float64 = 0 //西药费
  14147. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14148. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14149. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14150. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14151. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14152. var checkCostTotal float64 = 0 //检查费
  14153. var checkCostSelfTotal float64 = 0 //检查费
  14154. var checkCostPartSelfTotal float64 = 0 //检查费
  14155. var laboratoryCostTotal float64 = 0 //化验费
  14156. var laboratoryCostSelfTotal float64 = 0 //化验费
  14157. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14158. var treatCostTotal float64 = 0 //治疗费用
  14159. var treatCostSelfTotal float64 = 0 //治疗费用
  14160. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14161. decimal.DivisionPrecision = 2
  14162. var bed_fulamt_ownpay_amt float64 = 0
  14163. var operation_fulamt_ownpay_amt float64 = 0
  14164. var other_fulamt_ownpay_amt float64 = 0
  14165. var westernMedicine_fulamt_ownpay_amt float64 = 0
  14166. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14167. var check_fulamt_ownpay_amt float64 = 0
  14168. var material_fulamt_ownpay_amt float64 = 0
  14169. var laboratory_fulamt_ownpay_amt float64 = 0
  14170. var treat_fulamt_ownpay_amt float64 = 0
  14171. var bed_claa_sunmfee float64 = 0
  14172. var bed_clab_amt float64 = 0
  14173. var bed_other_amt float64 = 0
  14174. var operation_claa_sunmfee float64 = 0
  14175. var operation_clab_amt float64 = 0
  14176. var operation_other_amt float64 = 0
  14177. var other_claa_sunmfee float64 = 0
  14178. var other_clab_amt float64 = 0
  14179. var other_other_amt float64 = 0
  14180. var westernMedicine_claa_sunmfee float64 = 0
  14181. var westernMedicine_clab_amt float64 = 0
  14182. var westernMedicine_other_amt float64 = 0
  14183. var chineseTraditional_claa_sunmfee float64 = 0
  14184. var chineseTraditional_clab_amt float64 = 0
  14185. var chineseTraditional_other_amt float64 = 0
  14186. var check_claa_sunmfee float64 = 0
  14187. var check_clab_amt float64 = 0
  14188. var check_other_amt float64 = 0
  14189. var material_claa_sunmfee float64 = 0
  14190. var material_clab_amt float64 = 0
  14191. var material_other_amt float64 = 0
  14192. var laboratory_claa_sunmfee float64 = 0
  14193. var laboratory_clab_amt float64 = 0
  14194. var laboratory_other_amt float64 = 0
  14195. var treat_claa_sunmfee float64 = 0
  14196. var treat_clab_amt float64 = 0
  14197. var treat_other_amt float64 = 0
  14198. for _, item := range order.HisOrderInfo {
  14199. if item.MedChrgitmType == "01" { //床位费
  14200. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14201. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14202. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14203. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14204. if item.ChrgitmLv == "1" {
  14205. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14206. }
  14207. if item.ChrgitmLv == "2" {
  14208. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14209. }
  14210. if item.ChrgitmLv == "3" {
  14211. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14212. }
  14213. }
  14214. if item.MedChrgitmType == "03" { //检查费
  14215. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14216. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14217. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14218. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14219. if item.ChrgitmLv == "1" {
  14220. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14221. }
  14222. if item.ChrgitmLv == "2" {
  14223. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14224. }
  14225. if item.ChrgitmLv == "3" {
  14226. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14227. }
  14228. }
  14229. if item.MedChrgitmType == "04" { //化验费
  14230. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14231. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14232. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14233. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14234. if item.ChrgitmLv == "1" {
  14235. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14236. }
  14237. if item.ChrgitmLv == "2" {
  14238. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14239. }
  14240. if item.ChrgitmLv == "3" {
  14241. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14242. }
  14243. }
  14244. if item.MedChrgitmType == "05" { //治疗费
  14245. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14246. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14247. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14248. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14249. if item.ChrgitmLv == "1" {
  14250. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14251. }
  14252. if item.ChrgitmLv == "2" {
  14253. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14254. }
  14255. if item.ChrgitmLv == "3" {
  14256. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14257. }
  14258. }
  14259. if item.MedChrgitmType == "06" { //手术费
  14260. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14261. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14262. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14263. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14264. if item.ChrgitmLv == "1" {
  14265. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14266. }
  14267. if item.ChrgitmLv == "2" {
  14268. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14269. }
  14270. if item.ChrgitmLv == "3" {
  14271. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14272. }
  14273. }
  14274. if item.MedChrgitmType == "08" { //材料费
  14275. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14276. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14277. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14278. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14279. if item.ChrgitmLv == "1" {
  14280. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14281. }
  14282. if item.ChrgitmLv == "2" {
  14283. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14284. }
  14285. if item.ChrgitmLv == "3" {
  14286. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14287. }
  14288. }
  14289. if item.MedChrgitmType == "09" { //西药费
  14290. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14291. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14292. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14293. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14294. if item.ChrgitmLv == "1" {
  14295. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14296. }
  14297. if item.ChrgitmLv == "2" {
  14298. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14299. }
  14300. if item.ChrgitmLv == "3" {
  14301. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14302. }
  14303. }
  14304. if item.MedChrgitmType == "11" { //中成费
  14305. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14306. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14307. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14308. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14309. if item.ChrgitmLv == "1" {
  14310. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14311. }
  14312. if item.ChrgitmLv == "2" {
  14313. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14314. }
  14315. if item.ChrgitmLv == "3" {
  14316. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14317. }
  14318. }
  14319. if item.MedChrgitmType == "14" { //其他费
  14320. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14321. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14322. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14323. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14324. if item.ChrgitmLv == "1" {
  14325. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14326. }
  14327. if item.ChrgitmLv == "2" {
  14328. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14329. }
  14330. if item.ChrgitmLv == "3" {
  14331. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14332. }
  14333. }
  14334. }
  14335. var iteminfoStructs []service.IteminfoStruct
  14336. if bedCostTotal != 0 {
  14337. iteminfo.MedChrgitm = "01"
  14338. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14339. iteminfo.Amt = bedCostTotal
  14340. iteminfo.ClaaSumfee = bed_claa_sunmfee
  14341. iteminfo.ClabAmt = bed_clab_amt
  14342. iteminfo.OthAmt = bed_other_amt
  14343. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14344. }
  14345. if checkCostTotal != 0 {
  14346. iteminfo.MedChrgitm = "03"
  14347. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14348. iteminfo.Amt = checkCostTotal
  14349. iteminfo.ClaaSumfee = check_claa_sunmfee
  14350. iteminfo.ClabAmt = check_clab_amt
  14351. iteminfo.OthAmt = check_other_amt
  14352. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14353. }
  14354. if laboratoryCostTotal != 0 {
  14355. iteminfo.MedChrgitm = "04"
  14356. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14357. iteminfo.Amt = laboratoryCostTotal
  14358. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14359. iteminfo.ClabAmt = laboratory_clab_amt
  14360. iteminfo.OthAmt = laboratory_other_amt
  14361. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14362. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14363. }
  14364. if treatCostTotal != 0 {
  14365. iteminfo.MedChrgitm = "05"
  14366. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14367. iteminfo.Amt = treatCostTotal
  14368. iteminfo.ClaaSumfee = treat_claa_sunmfee
  14369. iteminfo.ClabAmt = treat_clab_amt
  14370. iteminfo.OthAmt = treat_other_amt
  14371. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14372. //(struct4101.IteminfoStruct, iteminfo)
  14373. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14374. }
  14375. if operationCostTotal != 0 {
  14376. iteminfo.MedChrgitm = "06"
  14377. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14378. iteminfo.Amt = operationCostTotal
  14379. iteminfo.ClaaSumfee = operation_claa_sunmfee
  14380. iteminfo.ClabAmt = operation_clab_amt
  14381. iteminfo.OthAmt = operation_other_amt
  14382. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14383. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14384. }
  14385. if materialCostTotal != 0 {
  14386. iteminfo.MedChrgitm = "08"
  14387. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14388. iteminfo.Amt = materialCostTotal
  14389. iteminfo.ClaaSumfee = material_claa_sunmfee
  14390. iteminfo.ClabAmt = material_clab_amt
  14391. iteminfo.OthAmt = material_other_amt
  14392. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14393. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14394. }
  14395. if westernMedicineCostTotal != 0 {
  14396. iteminfo.MedChrgitm = "09"
  14397. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14398. iteminfo.Amt = westernMedicineCostTotal
  14399. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14400. iteminfo.ClabAmt = westernMedicine_clab_amt
  14401. iteminfo.OthAmt = westernMedicine_other_amt
  14402. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14403. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14404. }
  14405. if chineseTraditionalMedicineCostTotal != 0 {
  14406. iteminfo.MedChrgitm = "11"
  14407. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14408. iteminfo.Amt = westernMedicineCostTotal
  14409. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14410. iteminfo.ClabAmt = westernMedicine_clab_amt
  14411. iteminfo.OthAmt = westernMedicine_other_amt
  14412. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14413. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14414. }
  14415. if otherCostTotal != 0 {
  14416. iteminfo.MedChrgitm = "14"
  14417. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14418. iteminfo.Amt = otherCostTotal
  14419. iteminfo.ClaaSumfee = other_claa_sunmfee
  14420. iteminfo.ClabAmt = other_clab_amt
  14421. iteminfo.OthAmt = other_other_amt
  14422. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14423. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14424. }
  14425. struct4101.IteminfoStruct = iteminfoStructs
  14426. struct4101.Ntly = "中国"
  14427. struct4101.AdmCaty = "A03.06"
  14428. struct4101.DoctorName = doctor.UserName
  14429. struct4101.DoctorCode = doctor.DoctorNumber
  14430. var res ResultSeventeen
  14431. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14432. struct4101.BillCode = order.Number
  14433. struct4101.BillNo = order.SetlId
  14434. var resOther ResultSeventeenOther
  14435. var pp models.PublicParams
  14436. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14437. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14438. pp.FixmedinsName = miConfig.OrgName
  14439. pp.FixmedinsCode = miConfig.Code
  14440. pp.RequestUrl = miConfig.Url
  14441. pp.Cainfo = miConfig.Cainfo
  14442. pp.SecretKey = miConfig.SecretKey
  14443. pp.AccessKey = miConfig.AccessKey
  14444. pp.OpterName = curRoles.UserName
  14445. client := &http.Client{}
  14446. var req *http.Request
  14447. data := make(map[string]interface{})
  14448. data["struct4101"] = struct4101
  14449. data["pp"] = pp
  14450. bytesData, _ := json.Marshal(data)
  14451. if miConfig.MdtrtareaAdmvs == "320921" {
  14452. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  14453. } else {
  14454. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  14455. }
  14456. resp, _ := client.Do(req)
  14457. defer resp.Body.Close()
  14458. body, ioErr := ioutil.ReadAll(resp.Body)
  14459. if ioErr != nil {
  14460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14462. return
  14463. }
  14464. var respJSON map[string]interface{}
  14465. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14468. return
  14469. }
  14470. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14471. userJSONBytes, _ := json.Marshal(respJSON)
  14472. fmt.Println("log")
  14473. fmt.Println(string(userJSONBytes))
  14474. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14475. utils.ErrorLog("解析失败:%v", err)
  14476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14477. return
  14478. }
  14479. res.InfRefmsgid = resOther.InfRefmsgid
  14480. res.Output = resOther.Output
  14481. res.ErrMsg = resOther.ErrMsg
  14482. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14483. res.Infcode = infocode
  14484. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14485. var pp models.PublicParams
  14486. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14487. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14488. pp.FixmedinsName = miConfig.OrgName
  14489. pp.FixmedinsCode = miConfig.Code
  14490. pp.RequestUrl = miConfig.Url
  14491. pp.Cainfo = miConfig.Cainfo
  14492. pp.SecretKey = miConfig.SecretKey
  14493. pp.AccessKey = miConfig.AccessKey
  14494. pp.OpterName = curRoles.UserName
  14495. result, _ := service.Jxyb4101(struct4101, pp)
  14496. var dat map[string]interface{}
  14497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14498. fmt.Println(dat)
  14499. } else {
  14500. fmt.Println(err)
  14501. }
  14502. userJSONBytes, _ := json.Marshal(dat)
  14503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14504. utils.ErrorLog("解析失败:%v", err)
  14505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14506. return
  14507. }
  14508. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14509. var pp models.PublicParams
  14510. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14511. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14512. pp.FixmedinsName = miConfig.OrgName
  14513. pp.FixmedinsCode = miConfig.Code
  14514. pp.RequestUrl = miConfig.Url
  14515. pp.Cainfo = miConfig.Cainfo
  14516. pp.SecretKey = miConfig.SecretKey
  14517. pp.AccessKey = miConfig.AccessKey
  14518. pp.OpterName = curRoles.UserName
  14519. result, _ := service.Hnyb4101(struct4101, pp)
  14520. var dat map[string]interface{}
  14521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14522. fmt.Println(dat)
  14523. } else {
  14524. fmt.Println(err)
  14525. }
  14526. userJSONBytes, _ := json.Marshal(dat)
  14527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14528. utils.ErrorLog("解析失败:%v", err)
  14529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14530. return
  14531. }
  14532. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14533. var resOther ResultSeventeenOther
  14534. var pp models.PublicParams
  14535. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14536. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14537. pp.FixmedinsName = miConfig.OrgName
  14538. pp.FixmedinsCode = miConfig.Code
  14539. pp.RequestUrl = miConfig.Url
  14540. pp.Cainfo = miConfig.Cainfo
  14541. pp.SecretKey = miConfig.SecretKey
  14542. pp.AccessKey = miConfig.AccessKey
  14543. pp.OpterName = curRoles.UserName
  14544. client := &http.Client{}
  14545. var req *http.Request
  14546. data := make(map[string]interface{})
  14547. data["struct4101"] = struct4101
  14548. data["pp"] = pp
  14549. bytesData, _ := json.Marshal(data)
  14550. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14551. resp, _ := client.Do(req)
  14552. defer resp.Body.Close()
  14553. body, ioErr := ioutil.ReadAll(resp.Body)
  14554. if ioErr != nil {
  14555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14557. return
  14558. }
  14559. var respJSON map[string]interface{}
  14560. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14563. return
  14564. }
  14565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14566. userJSONBytes, _ := json.Marshal(respJSON)
  14567. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14568. utils.ErrorLog("解析失败:%v", err)
  14569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14570. return
  14571. }
  14572. res.InfRefmsgid = resOther.InfRefmsgid
  14573. res.Output = resOther.Output
  14574. res.ErrMsg = resOther.ErrMsg
  14575. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14576. res.Infcode = infocode
  14577. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14578. var pp models.PublicParams
  14579. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14580. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14581. pp.FixmedinsName = miConfig.OrgName
  14582. pp.FixmedinsCode = miConfig.Code
  14583. pp.RequestUrl = miConfig.Url
  14584. pp.Cainfo = miConfig.Cainfo
  14585. pp.SecretKey = miConfig.SecretKey
  14586. pp.AccessKey = miConfig.AccessKey
  14587. pp.OpterName = curRoles.UserName
  14588. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  14589. fmt.Println(requestLog)
  14590. fmt.Println(errMsgLog)
  14591. saveLog(result, requestLog, "4101a", "上传清单")
  14592. var dat map[string]interface{}
  14593. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14594. fmt.Println(dat)
  14595. } else {
  14596. fmt.Println(err)
  14597. }
  14598. userJSONBytes, _ := json.Marshal(dat)
  14599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14600. utils.ErrorLog("解析失败:%v", err)
  14601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14602. return
  14603. }
  14604. } else if miConfig.MdtrtareaAdmvs == "441799" {
  14605. var pp models.PublicParams
  14606. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14607. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14608. pp.FixmedinsName = miConfig.OrgName
  14609. pp.FixmedinsCode = miConfig.Code
  14610. pp.RequestUrl = miConfig.Url
  14611. pp.Cainfo = miConfig.Cainfo
  14612. pp.SecretKey = miConfig.SecretKey
  14613. pp.AccessKey = miConfig.AccessKey
  14614. pp.OpterName = curRoles.UserName
  14615. client := &http.Client{}
  14616. var req *http.Request
  14617. data := make(map[string]interface{})
  14618. data["struct4101"] = struct4101
  14619. data["pp"] = pp
  14620. bytesData, _ := json.Marshal(data)
  14621. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  14622. resp, _ := client.Do(req)
  14623. defer resp.Body.Close()
  14624. body, ioErr := ioutil.ReadAll(resp.Body)
  14625. if ioErr != nil {
  14626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14628. return
  14629. }
  14630. var respJSON map[string]interface{}
  14631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14634. return
  14635. }
  14636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14637. userJSONBytes, _ := json.Marshal(respJSON)
  14638. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14639. utils.ErrorLog("解析失败:%v", err)
  14640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14641. return
  14642. }
  14643. } else {
  14644. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14645. var dat map[string]interface{}
  14646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14647. fmt.Println(dat)
  14648. } else {
  14649. fmt.Println(err)
  14650. }
  14651. userJSONBytes, _ := json.Marshal(dat)
  14652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14653. utils.ErrorLog("解析失败:%v", err)
  14654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14655. return
  14656. }
  14657. }
  14658. if res.Infcode != 0 {
  14659. c.ServeSuccessJSON(map[string]interface{}{
  14660. "failed_code": -10,
  14661. "msg": res.ErrMsg,
  14662. })
  14663. return
  14664. } else {
  14665. //order.FaPiaoNumber = zero
  14666. //order.FaPiaoCode = last_order.FaPiaoCode
  14667. //service.UpdateOrder(order)
  14668. hisFundSettleListResult := &models.HisFundSettleListResult{
  14669. Number: res.Output.SetlListId,
  14670. Status: 1,
  14671. Ctime: time.Now().Unix(),
  14672. Mtime: time.Now().Unix(),
  14673. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14674. IsUpload: 1,
  14675. OrderId: order_id,
  14676. }
  14677. service.CreateUploadRecord(hisFundSettleListResult)
  14678. c.ServeSuccessJSON(map[string]interface{}{
  14679. "msg": "上传成功",
  14680. "result": hisFundSettleListResult,
  14681. })
  14682. return
  14683. }
  14684. }
  14685. func (c *HisApiController) GetSettleListHospital() {
  14686. order_id, _ := c.GetInt64("order_id")
  14687. admin_user_id, _ := c.GetInt64("admin_user_id")
  14688. order, _ := service.GetHisOrderByIDTwo(order_id)
  14689. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14690. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  14691. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14692. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  14693. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14694. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14695. if order.ID == 0 {
  14696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14697. return
  14698. }
  14699. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  14700. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  14701. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  14702. fmt.Println(count)
  14703. var zero string
  14704. number := count + 1
  14705. if number >= 1000 {
  14706. zero = "0000" + strconv.FormatInt(number, 10)
  14707. } else if number >= 10000 {
  14708. zero = "000" + strconv.FormatInt(number, 10)
  14709. } else if number >= 100000 {
  14710. zero = "00" + strconv.FormatInt(number, 10)
  14711. } else if number >= 1000000 {
  14712. zero = "0" + strconv.FormatInt(number, 10)
  14713. } else {
  14714. zero = strconv.FormatInt(number, 10)
  14715. }
  14716. fmt.Println(zero)
  14717. struct4101 := service.Struct4101{
  14718. PsnNo: order.PsnNo,
  14719. MdtrtId: order.MdtrtId,
  14720. SetlId: order.SetlId,
  14721. PsnName: order.PsnName,
  14722. Gend: order.Gend,
  14723. Brdy: his.Brdy,
  14724. Age: int64(order.Age),
  14725. Naty: order.Naty,
  14726. PatnCertType: "01",
  14727. Certno: order.Certno,
  14728. Prfs: "90",
  14729. ConerName: roles[0].UserName,
  14730. PatnRlts: "99",
  14731. ConerAddr: miConfig.OrgName,
  14732. ConerTel: admin.Mobile,
  14733. HiType: order.Insutype,
  14734. Insuplc: miConfig.InsuplcAdmdvs,
  14735. MaindiagFlag: "1",
  14736. BillCode: order.SetlId,
  14737. BillNo: order.SetlId,
  14738. BizSn: order.Number,
  14739. PsnSelfPay: order.PsnPartAmt,
  14740. PsnOwnPay: order.PsnPartAmt,
  14741. AcctPay: order.AcctPay,
  14742. PsnCashpay: order.PsnCashPay,
  14743. HiPaymtd: "1",
  14744. Hsorg: miConfig.InsuplcAdmdvs,
  14745. HsorgOpter: miConfig.InsuplcAdmdvs,
  14746. MedinsFillPsn: curRoles.UserName,
  14747. MedinsFillDept: depart.Name,
  14748. IptMedType: "2",
  14749. AdmTime: his.InHosptialTime,
  14750. AdmEndTime: his.OutHosptialTime,
  14751. }
  14752. struct4101.SetlBegnDate = order.SetlTime
  14753. struct4101.SetlEndDate = order.SetlTime
  14754. //var rf []CustomFundPay
  14755. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  14756. //
  14757. //var tempFunPays []service.CustomStruct
  14758. //for _, item := range rf {
  14759. // var tempFunPay service.CustomStruct
  14760. // tempFunPay.FundPayamt = item.FundPayamt
  14761. // tempFunPay.FundPayType = item.FundPayType
  14762. // tempFunPays = append(tempFunPays, tempFunPay)
  14763. //}
  14764. //struct4101.CustomStruct = tempFunPays
  14765. var tempDiaginfos []service.DiaginfoStructTwo
  14766. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14767. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14768. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  14769. //for _, item := range infos {
  14770. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  14771. //}
  14772. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  14773. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  14774. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14775. fmt.Println(diagnosis_ids_arr)
  14776. if order.UserOrgId == 10210 {
  14777. var diagnosis_ids_arr_two []int64
  14778. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  14779. var config []*models.HisXtDiagnoseConfig
  14780. for _, id := range diagnosis_ids_arr_two {
  14781. //id, _ := strconv.ParseInt(item, 10, 64)
  14782. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14783. if diagnosisConfig.ID > 0 {
  14784. config = append(config, &diagnosisConfig)
  14785. }
  14786. }
  14787. for index, item := range config {
  14788. if item.ID > 0 {
  14789. if index == 0 {
  14790. var tempDiaginfo service.DiaginfoStructTwo
  14791. tempDiaginfo.DiagCode = item.CountryCode
  14792. tempDiaginfo.DiagName = item.CountryContentName
  14793. tempDiaginfo.DiagType = "1"
  14794. tempDiaginfo.MaindiagFlag = "1"
  14795. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14796. } else {
  14797. var tempDiaginfo service.DiaginfoStructTwo
  14798. tempDiaginfo.DiagCode = item.CountryCode
  14799. tempDiaginfo.DiagName = item.CountryContentName
  14800. tempDiaginfo.DiagType = "1"
  14801. tempDiaginfo.MaindiagFlag = "0"
  14802. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14803. }
  14804. }
  14805. }
  14806. struct4101.Diseinfo = tempDiaginfos
  14807. } else {
  14808. var config []*models.HisXtDiagnoseConfig
  14809. for _, item := range diagnosis_ids_arr {
  14810. id, _ := strconv.ParseInt(item, 10, 64)
  14811. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14812. if diagnosisConfig.ID > 0 {
  14813. config = append(config, &diagnosisConfig)
  14814. }
  14815. }
  14816. for index, item := range config {
  14817. if item.ID > 0 {
  14818. if index == 0 {
  14819. var tempDiaginfo service.DiaginfoStructTwo
  14820. tempDiaginfo.DiagCode = item.CountryCode
  14821. tempDiaginfo.DiagName = item.CountryContentName
  14822. tempDiaginfo.DiagType = "1"
  14823. tempDiaginfo.MaindiagFlag = "1"
  14824. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14825. } else {
  14826. var tempDiaginfo service.DiaginfoStructTwo
  14827. tempDiaginfo.DiagCode = item.CountryCode
  14828. tempDiaginfo.DiagName = item.CountryContentName
  14829. tempDiaginfo.DiagType = "1"
  14830. tempDiaginfo.MaindiagFlag = "0"
  14831. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14832. }
  14833. }
  14834. }
  14835. struct4101.Diseinfo = tempDiaginfos
  14836. }
  14837. sickConfigTwo, _ := service.FindSickById(his.SickType)
  14838. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14839. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14840. tempOpspdiseinfo2.OprnOprtCode = ""
  14841. tempOpspdiseinfo2.OprnOprtName = ""
  14842. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14843. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14844. var iteminfo service.IteminfoStruct
  14845. var bedCostTotal float64 = 0 //床位总费
  14846. var bedCostSelfTotal float64 = 0 //床位自费
  14847. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14848. var operationCostTotal float64 = 0 //手术费
  14849. var operationCostSelfTotal float64 = 0 //手术费
  14850. var operationCostPartSelfTotal float64 = 0 //手术费
  14851. var otherCostTotal float64 = 0 //其他费用
  14852. var otherCostSelfTotal float64 = 0 //其他费用
  14853. var otherCostPartSelfTotal float64 = 0 //其他费用
  14854. var materialCostTotal float64 = 0 //材料费
  14855. var materialCostSelfTotal float64 = 0 //材料费
  14856. var materialCostPartSelfTotal float64 = 0 //材料费
  14857. var westernMedicineCostTotal float64 = 0 //西药费
  14858. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14859. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14860. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14861. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14862. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14863. var checkCostTotal float64 = 0 //检查费
  14864. var checkCostSelfTotal float64 = 0 //检查费
  14865. var checkCostPartSelfTotal float64 = 0 //检查费
  14866. var laboratoryCostTotal float64 = 0 //化验费
  14867. var laboratoryCostSelfTotal float64 = 0 //化验费
  14868. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14869. var treatCostTotal float64 = 0 //治疗费用
  14870. var treatCostSelfTotal float64 = 0 //治疗费用
  14871. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14872. decimal.DivisionPrecision = 2
  14873. var bed_fulamt_ownpay_amt float64 = 0
  14874. var operation_fulamt_ownpay_amt float64 = 0
  14875. var other_fulamt_ownpay_amt float64 = 0
  14876. var westernMedicine_fulamt_ownpay_amt float64 = 0
  14877. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14878. var check_fulamt_ownpay_amt float64 = 0
  14879. var material_fulamt_ownpay_amt float64 = 0
  14880. var laboratory_fulamt_ownpay_amt float64 = 0
  14881. var treat_fulamt_ownpay_amt float64 = 0
  14882. var bed_claa_sunmfee float64 = 0
  14883. var bed_clab_amt float64 = 0
  14884. var bed_other_amt float64 = 0
  14885. var operation_claa_sunmfee float64 = 0
  14886. var operation_clab_amt float64 = 0
  14887. var operation_other_amt float64 = 0
  14888. var other_claa_sunmfee float64 = 0
  14889. var other_clab_amt float64 = 0
  14890. var other_other_amt float64 = 0
  14891. var westernMedicine_claa_sunmfee float64 = 0
  14892. var westernMedicine_clab_amt float64 = 0
  14893. var westernMedicine_other_amt float64 = 0
  14894. var chineseTraditional_claa_sunmfee float64 = 0
  14895. var chineseTraditional_clab_amt float64 = 0
  14896. var chineseTraditional_other_amt float64 = 0
  14897. var check_claa_sunmfee float64 = 0
  14898. var check_clab_amt float64 = 0
  14899. var check_other_amt float64 = 0
  14900. var material_claa_sunmfee float64 = 0
  14901. var material_clab_amt float64 = 0
  14902. var material_other_amt float64 = 0
  14903. var laboratory_claa_sunmfee float64 = 0
  14904. var laboratory_clab_amt float64 = 0
  14905. var laboratory_other_amt float64 = 0
  14906. var treat_claa_sunmfee float64 = 0
  14907. var treat_clab_amt float64 = 0
  14908. var treat_other_amt float64 = 0
  14909. for _, item := range order.HisOrderInfo {
  14910. if item.MedChrgitmType == "01" { //床位费
  14911. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14912. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14913. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14914. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14915. if item.ChrgitmLv == "1" {
  14916. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14917. }
  14918. if item.ChrgitmLv == "2" {
  14919. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14920. }
  14921. if item.ChrgitmLv == "3" {
  14922. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14923. }
  14924. }
  14925. if item.MedChrgitmType == "03" { //检查费
  14926. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14927. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14928. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14929. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14930. if item.ChrgitmLv == "1" {
  14931. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14932. }
  14933. if item.ChrgitmLv == "2" {
  14934. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14935. }
  14936. if item.ChrgitmLv == "3" {
  14937. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14938. }
  14939. }
  14940. if item.MedChrgitmType == "04" { //化验费
  14941. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14942. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14943. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14944. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14945. if item.ChrgitmLv == "1" {
  14946. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14947. }
  14948. if item.ChrgitmLv == "2" {
  14949. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14950. }
  14951. if item.ChrgitmLv == "3" {
  14952. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14953. }
  14954. }
  14955. if item.MedChrgitmType == "05" { //治疗费
  14956. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14957. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14958. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14959. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14960. if item.ChrgitmLv == "1" {
  14961. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14962. }
  14963. if item.ChrgitmLv == "2" {
  14964. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14965. }
  14966. if item.ChrgitmLv == "3" {
  14967. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14968. }
  14969. }
  14970. if item.MedChrgitmType == "06" { //手术费
  14971. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14972. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14973. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14974. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14975. if item.ChrgitmLv == "1" {
  14976. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14977. }
  14978. if item.ChrgitmLv == "2" {
  14979. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14980. }
  14981. if item.ChrgitmLv == "3" {
  14982. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14983. }
  14984. }
  14985. if item.MedChrgitmType == "08" { //材料费
  14986. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14987. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14988. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14989. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14990. if item.ChrgitmLv == "1" {
  14991. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14992. }
  14993. if item.ChrgitmLv == "2" {
  14994. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14995. }
  14996. if item.ChrgitmLv == "3" {
  14997. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14998. }
  14999. }
  15000. if item.MedChrgitmType == "09" { //西药费
  15001. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15002. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15003. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15004. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15005. if item.ChrgitmLv == "1" {
  15006. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15007. }
  15008. if item.ChrgitmLv == "2" {
  15009. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15010. }
  15011. if item.ChrgitmLv == "3" {
  15012. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15013. }
  15014. }
  15015. if item.MedChrgitmType == "11" { //中成费
  15016. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15017. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15018. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15019. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15020. if item.ChrgitmLv == "1" {
  15021. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15022. }
  15023. if item.ChrgitmLv == "2" {
  15024. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15025. }
  15026. if item.ChrgitmLv == "3" {
  15027. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15028. }
  15029. }
  15030. if item.MedChrgitmType == "14" { //其他费
  15031. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15032. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15033. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15034. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15035. if item.ChrgitmLv == "1" {
  15036. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15037. }
  15038. if item.ChrgitmLv == "2" {
  15039. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15040. }
  15041. if item.ChrgitmLv == "3" {
  15042. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15043. }
  15044. }
  15045. }
  15046. var iteminfoStructs []service.IteminfoStruct
  15047. if bedCostTotal != 0 {
  15048. iteminfo.MedChrgitm = "01"
  15049. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15050. iteminfo.Amt = bedCostTotal
  15051. iteminfo.ClaaSumfee = bed_claa_sunmfee
  15052. iteminfo.ClabAmt = bed_clab_amt
  15053. iteminfo.OthAmt = bed_other_amt
  15054. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15055. }
  15056. if checkCostTotal != 0 {
  15057. iteminfo.MedChrgitm = "03"
  15058. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  15059. iteminfo.Amt = checkCostTotal
  15060. iteminfo.ClaaSumfee = check_claa_sunmfee
  15061. iteminfo.ClabAmt = check_clab_amt
  15062. iteminfo.OthAmt = check_other_amt
  15063. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15064. }
  15065. if laboratoryCostTotal != 0 {
  15066. iteminfo.MedChrgitm = "04"
  15067. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  15068. iteminfo.Amt = laboratoryCostTotal
  15069. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  15070. iteminfo.ClabAmt = laboratory_clab_amt
  15071. iteminfo.OthAmt = laboratory_other_amt
  15072. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15073. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15074. }
  15075. if treatCostTotal != 0 {
  15076. iteminfo.MedChrgitm = "05"
  15077. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  15078. iteminfo.Amt = treatCostTotal
  15079. iteminfo.ClaaSumfee = treat_claa_sunmfee
  15080. iteminfo.ClabAmt = treat_clab_amt
  15081. iteminfo.OthAmt = treat_other_amt
  15082. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15083. //(struct4101.IteminfoStruct, iteminfo)
  15084. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15085. }
  15086. if operationCostTotal != 0 {
  15087. iteminfo.MedChrgitm = "06"
  15088. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15089. iteminfo.Amt = operationCostTotal
  15090. iteminfo.ClaaSumfee = operation_claa_sunmfee
  15091. iteminfo.ClabAmt = operation_clab_amt
  15092. iteminfo.OthAmt = operation_other_amt
  15093. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15094. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15095. }
  15096. if materialCostTotal != 0 {
  15097. iteminfo.MedChrgitm = "08"
  15098. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  15099. iteminfo.Amt = materialCostTotal
  15100. iteminfo.ClaaSumfee = material_claa_sunmfee
  15101. iteminfo.ClabAmt = material_clab_amt
  15102. iteminfo.OthAmt = material_other_amt
  15103. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15104. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15105. }
  15106. if westernMedicineCostTotal != 0 {
  15107. iteminfo.MedChrgitm = "09"
  15108. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15109. iteminfo.Amt = westernMedicineCostTotal
  15110. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15111. iteminfo.ClabAmt = westernMedicine_clab_amt
  15112. iteminfo.OthAmt = westernMedicine_other_amt
  15113. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15114. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15115. }
  15116. if chineseTraditionalMedicineCostTotal != 0 {
  15117. iteminfo.MedChrgitm = "11"
  15118. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15119. iteminfo.Amt = westernMedicineCostTotal
  15120. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15121. iteminfo.ClabAmt = westernMedicine_clab_amt
  15122. iteminfo.OthAmt = westernMedicine_other_amt
  15123. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15124. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15125. }
  15126. if otherCostTotal != 0 {
  15127. iteminfo.MedChrgitm = "14"
  15128. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15129. iteminfo.Amt = otherCostTotal
  15130. iteminfo.ClaaSumfee = other_claa_sunmfee
  15131. iteminfo.ClabAmt = other_clab_amt
  15132. iteminfo.OthAmt = other_other_amt
  15133. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15134. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15135. }
  15136. struct4101.IteminfoStruct = iteminfoStructs
  15137. struct4101.Ntly = "中国"
  15138. struct4101.AdmCaty = "A03.06"
  15139. var resOther ResultSeventeenOther
  15140. var res ResultSeventeen
  15141. if miConfig.MdtrtareaAdmvs == "150499" {
  15142. var pp models.PublicParams
  15143. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15144. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15145. pp.FixmedinsName = miConfig.OrgName
  15146. pp.FixmedinsCode = miConfig.Code
  15147. pp.RequestUrl = miConfig.Url
  15148. pp.Cainfo = miConfig.Cainfo
  15149. pp.SecretKey = miConfig.SecretKey
  15150. pp.AccessKey = miConfig.AccessKey
  15151. pp.OpterName = curRoles.UserName
  15152. client := &http.Client{}
  15153. var req *http.Request
  15154. data := make(map[string]interface{})
  15155. data["struct4101"] = struct4101
  15156. data["pp"] = pp
  15157. bytesData, _ := json.Marshal(data)
  15158. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  15159. resp, _ := client.Do(req)
  15160. defer resp.Body.Close()
  15161. body, ioErr := ioutil.ReadAll(resp.Body)
  15162. if ioErr != nil {
  15163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15165. return
  15166. }
  15167. var respJSON map[string]interface{}
  15168. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15171. return
  15172. }
  15173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15174. userJSONBytes, _ := json.Marshal(respJSON)
  15175. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  15176. utils.ErrorLog("解析失败:%v", err)
  15177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15178. return
  15179. }
  15180. res.InfRefmsgid = resOther.InfRefmsgid
  15181. res.Output = resOther.Output
  15182. res.ErrMsg = resOther.ErrMsg
  15183. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  15184. res.Infcode = infocode
  15185. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15186. var pp models.PublicParams
  15187. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15188. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15189. pp.FixmedinsName = miConfig.OrgName
  15190. pp.FixmedinsCode = miConfig.Code
  15191. pp.RequestUrl = miConfig.Url
  15192. pp.Cainfo = miConfig.Cainfo
  15193. pp.SecretKey = miConfig.SecretKey
  15194. pp.AccessKey = miConfig.AccessKey
  15195. pp.OpterName = curRoles.UserName
  15196. result, _ := service.Jxyb4101(struct4101, pp)
  15197. var dat map[string]interface{}
  15198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15199. fmt.Println(dat)
  15200. } else {
  15201. fmt.Println(err)
  15202. }
  15203. userJSONBytes, _ := json.Marshal(dat)
  15204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15205. utils.ErrorLog("解析失败:%v", err)
  15206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15207. return
  15208. }
  15209. } else {
  15210. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  15211. var dat map[string]interface{}
  15212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15213. fmt.Println(dat)
  15214. } else {
  15215. fmt.Println(err)
  15216. }
  15217. userJSONBytes, _ := json.Marshal(dat)
  15218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15219. utils.ErrorLog("解析失败:%v", err)
  15220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15221. return
  15222. }
  15223. }
  15224. if res.Infcode != 0 {
  15225. c.ServeSuccessJSON(map[string]interface{}{
  15226. "failed_code": -10,
  15227. "msg": res.ErrMsg,
  15228. })
  15229. return
  15230. } else {
  15231. if miConfig.MdtrtareaAdmvs != "150499" {
  15232. order.FaPiaoNumber = zero
  15233. order.FaPiaoCode = last_order.FaPiaoCode
  15234. service.UpdateOrder(order)
  15235. }
  15236. hisFundSettleListResult := &models.HisFundSettleListResult{
  15237. Number: res.Output.SetlListId,
  15238. Status: 1,
  15239. Ctime: time.Now().Unix(),
  15240. Mtime: time.Now().Unix(),
  15241. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15242. IsUpload: 1,
  15243. OrderId: order_id,
  15244. }
  15245. service.CreateUploadRecord(hisFundSettleListResult)
  15246. c.ServeSuccessJSON(map[string]interface{}{
  15247. "msg": "上传成功",
  15248. "result": hisFundSettleListResult,
  15249. })
  15250. return
  15251. }
  15252. }
  15253. //func (c *HisApiController) GetBatchSettleList() {
  15254. // orders, _ := service.GetAllHisOrder(10106)
  15255. // for _, item := range orders {
  15256. // order_id := item.ID
  15257. // order, _ := service.GetHisOrderByIDTwo(order_id)
  15258. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  15259. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  15260. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  15261. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  15262. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  15263. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15264. //
  15265. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  15266. //
  15267. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  15268. //
  15269. // if order.ID == 0 {
  15270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  15271. // return
  15272. // }
  15273. // if his.BalanceAccountsType == 2 {
  15274. // continue
  15275. // }
  15276. // struct4101 := service.Struct4101{
  15277. // PsnNo: order.PsnNo,
  15278. // MdtrtId: order.MdtrtId,
  15279. // SetlId: order.SetlId,
  15280. // PsnName: order.PsnName,
  15281. // Gend: order.Gend,
  15282. // Brdy: his.Brdy,
  15283. // Age: his.Age,
  15284. // Naty: order.Naty,
  15285. // PatnCertType: "01",
  15286. // Certno: order.Certno,
  15287. // Prfs: "90",
  15288. // ConerName: roles[0].UserName,
  15289. // PatnRlts: "99",
  15290. // ConerAddr: miConfig.OrgName,
  15291. // ConerTel: admin.Mobile,
  15292. // HiType: order.Insutype,
  15293. // Insuplc: his.InsuplcAdmdvs,
  15294. // MaindiagFlag: "1",
  15295. // BillCode: order.SetlId,
  15296. // BillNo: order.SetlId,
  15297. // BizSn: order.Number,
  15298. // PsnSelfPay: order.PsnPartAmt,
  15299. // PsnOwnPay: order.PsnPartAmt,
  15300. // AcctPay: order.AcctPay,
  15301. // PsnCashpay: order.PsnCashPay,
  15302. // HiPaymtd: "1",
  15303. // Hsorg: his.InsuplcAdmdvs,
  15304. // HsorgOpter: his.InsuplcAdmdvs,
  15305. // MedinsFillPsn: curRoles.UserName,
  15306. // MedinsFillDept: depart.Name,
  15307. // IptMedType: "2",
  15308. // }
  15309. // struct4101.SetlBegnDate = order.SetlTime
  15310. // struct4101.SetlEndDate = order.SetlTime
  15311. // //if order.SettleType == 1 {
  15312. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  15313. // // dateStr := t.Format("2006-01-02")
  15314. // // struct4101.SetlBegnDate = dateStr
  15315. // // struct4101.SetlEndDate = dateStr
  15316. // //} else {
  15317. // // t := time.Unix(int64(order.SettleStartTime), 0)
  15318. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  15319. // // dateStartStr := t.Format("2006-01-02")
  15320. // // dateEndStr := t2.Format("2006-01-02")
  15321. // // struct4101.SetlBegnDate = dateStartStr
  15322. // // struct4101.SetlEndDate = dateEndStr
  15323. // //}
  15324. //
  15325. // var rf []CustomFundPay
  15326. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  15327. //
  15328. // var tempFunPays []service.CustomStruct
  15329. // var tempFunPay610100 service.CustomStruct
  15330. //
  15331. // for _, item := range rf {
  15332. // if item.FundPayType == "610100" {
  15333. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  15334. // tempFunPay610100.FundPayType = item.FundPayType
  15335. // } else {
  15336. // var tempFunPay service.CustomStruct
  15337. // tempFunPay.FundPayamt = item.FundPayamt
  15338. // tempFunPay.FundPayType = item.FundPayType
  15339. // tempFunPays = append(tempFunPays, tempFunPay)
  15340. // }
  15341. // }
  15342. // tempFunPays = append(tempFunPays, tempFunPay610100)
  15343. // struct4101.CustomStruct = tempFunPays
  15344. //
  15345. // var tempDiaginfos []service.DiaginfoStructTwo
  15346. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  15347. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  15348. //
  15349. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  15350. // var config []*models.HisXtDiagnoseConfig
  15351. // for _, item := range diagnosis_ids {
  15352. // id, _ := strconv.ParseInt(item, 10, 64)
  15353. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  15354. // config = append(config, &diagnosisConfig)
  15355. // }
  15356. //
  15357. // for index, item := range config {
  15358. // if index == 0 {
  15359. // var tempDiaginfo service.DiaginfoStructTwo
  15360. // tempDiaginfo.DiagCode = item.CountryCode
  15361. // tempDiaginfo.DiagName = item.CountryContentName
  15362. // tempDiaginfo.DiagType = "1"
  15363. // tempDiaginfo.MaindiagFlag = "1"
  15364. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  15365. // } else {
  15366. //
  15367. // var tempDiaginfo service.DiaginfoStructTwo
  15368. // tempDiaginfo.DiagCode = item.CountryCode
  15369. // tempDiaginfo.DiagName = item.CountryContentName
  15370. // tempDiaginfo.DiagType = "2"
  15371. // tempDiaginfo.MaindiagFlag = "0"
  15372. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  15373. // }
  15374. // }
  15375. // struct4101.Diseinfo = tempDiaginfos
  15376. //
  15377. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  15378. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  15379. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  15380. // tempOpspdiseinfo2.OprnOprtCode = ""
  15381. // tempOpspdiseinfo2.OprnOprtName = ""
  15382. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  15383. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  15384. //
  15385. // var iteminfo service.IteminfoStruct
  15386. //
  15387. // var bedCostTotal float64 = 0 //床位总费
  15388. // var bedCostSelfTotal float64 = 0 //床位自费
  15389. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  15390. //
  15391. // var examineCostTotal float64 = 0 //诊查总费
  15392. // var examineCostSelfTotal float64 = 0 //诊查自费
  15393. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  15394. //
  15395. // var nursingCostTotal float64 = 0 //护理总费
  15396. // var nursingCostSelfTotal float64 = 0 //护理自费
  15397. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  15398. //
  15399. // var chineseMedicineCostTotal float64 = 0 //中成药
  15400. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  15401. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  15402. //
  15403. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  15404. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  15405. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  15406. //
  15407. // var registerCostTotal float64 = 0 //一般诊疗费
  15408. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  15409. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  15410. //
  15411. // var operationCostTotal float64 = 0 //手术费
  15412. // var operationCostSelfTotal float64 = 0 //手术费
  15413. // var operationCostPartSelfTotal float64 = 0 //手术费
  15414. //
  15415. // var otherCostTotal float64 = 0 //其他费用
  15416. // var otherCostSelfTotal float64 = 0 //其他费用
  15417. // var otherCostPartSelfTotal float64 = 0 //其他费用
  15418. //
  15419. // var materialCostTotal float64 = 0 //材料费
  15420. // var materialCostSelfTotal float64 = 0 //材料费
  15421. // var materialCostPartSelfTotal float64 = 0 //材料费
  15422. //
  15423. // var westernMedicineCostTotal float64 = 0 //西药费
  15424. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  15425. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  15426. //
  15427. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  15428. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  15429. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  15430. //
  15431. // var checkCostTotal float64 = 0 //检查费
  15432. // var checkCostSelfTotal float64 = 0 //检查费
  15433. // var checkCostPartSelfTotal float64 = 0 //检查费
  15434. //
  15435. // var laboratoryCostTotal float64 = 0 //化验费
  15436. // var laboratoryCostSelfTotal float64 = 0 //化验费
  15437. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  15438. //
  15439. // var treatCostTotal float64 = 0 //治疗费用
  15440. // var treatCostSelfTotal float64 = 0 //治疗费用
  15441. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  15442. //
  15443. // decimal.DivisionPrecision = 2
  15444. //
  15445. // var bed_fulamt_ownpay_amt float64 = 0
  15446. //
  15447. // var examine_fulamt_ownpay_amt float64 = 0
  15448. //
  15449. // var nursing_fulamt_ownpay_amt float64 = 0
  15450. //
  15451. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  15452. //
  15453. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  15454. //
  15455. // var register_fulamt_ownpay_amt float64 = 0
  15456. //
  15457. // var operation_fulamt_ownpay_amt float64 = 0
  15458. // var other_fulamt_ownpay_amt float64 = 0
  15459. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  15460. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  15461. // var check_fulamt_ownpay_amt float64 = 0
  15462. // var material_fulamt_ownpay_amt float64 = 0
  15463. // var laboratory_fulamt_ownpay_amt float64 = 0
  15464. // var treat_fulamt_ownpay_amt float64 = 0
  15465. //
  15466. // var bed_claa_sunmfee float64 = 0
  15467. // var bed_clab_amt float64 = 0
  15468. // var bed_other_amt float64 = 0
  15469. //
  15470. // var examine_claa_sunmfee float64 = 0
  15471. // var examine_clab_amt float64 = 0
  15472. // var examine_other_amt float64 = 0
  15473. //
  15474. // var nursing_claa_sunmfee float64 = 0
  15475. // var nursing_clab_amt float64 = 0
  15476. // var nursing_other_amt float64 = 0
  15477. //
  15478. // var chinese_medicine_claa_sunmfee float64 = 0
  15479. // var chinese_medicine_clab_amt float64 = 0
  15480. // var chinese_medicine_other_amt float64 = 0
  15481. //
  15482. // var commonly_treatment_claa_sunmfee float64 = 0
  15483. // var commonly_treatment_clab_amt float64 = 0
  15484. // var commonly_treatment_other_amt float64 = 0
  15485. //
  15486. // var operation_claa_sunmfee float64 = 0
  15487. // var operation_clab_amt float64 = 0
  15488. // var operation_other_amt float64 = 0
  15489. //
  15490. // var other_claa_sunmfee float64 = 0
  15491. // var other_clab_amt float64 = 0
  15492. // var other_other_amt float64 = 0
  15493. //
  15494. // var westernMedicine_claa_sunmfee float64 = 0
  15495. // var westernMedicine_clab_amt float64 = 0
  15496. // var westernMedicine_other_amt float64 = 0
  15497. //
  15498. // var chineseTraditional_claa_sunmfee float64 = 0
  15499. // var chineseTraditional_clab_amt float64 = 0
  15500. // var chineseTraditional_other_amt float64 = 0
  15501. //
  15502. // var check_claa_sunmfee float64 = 0
  15503. // var check_clab_amt float64 = 0
  15504. // var check_other_amt float64 = 0
  15505. //
  15506. // var material_claa_sunmfee float64 = 0
  15507. // var material_clab_amt float64 = 0
  15508. // var material_other_amt float64 = 0
  15509. //
  15510. // var laboratory_claa_sunmfee float64 = 0
  15511. // var laboratory_clab_amt float64 = 0
  15512. // var laboratory_other_amt float64 = 0
  15513. //
  15514. // var treat_claa_sunmfee float64 = 0
  15515. // var treat_clab_amt float64 = 0
  15516. // var treat_other_amt float64 = 0
  15517. //
  15518. // var register_claa_sunmfee float64 = 0
  15519. // var register_clab_amt float64 = 0
  15520. // var register_other_amt float64 = 0
  15521. //
  15522. // for _, item := range order.HisOrderInfo {
  15523. // if item.MedChrgitmType == "01" { //床位费
  15524. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15525. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15526. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15527. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15528. // if item.ChrgitmLv == "1" {
  15529. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15530. // }
  15531. // if item.ChrgitmLv == "2" {
  15532. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15533. //
  15534. // }
  15535. // if item.ChrgitmLv == "3" {
  15536. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15537. // }
  15538. //
  15539. // }
  15540. //
  15541. // if item.MedChrgitmType == "02" { //诊查
  15542. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15543. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15544. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15545. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15546. // if item.ChrgitmLv == "1" {
  15547. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15548. // }
  15549. // if item.ChrgitmLv == "2" {
  15550. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15551. //
  15552. // }
  15553. // if item.ChrgitmLv == "3" {
  15554. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15555. // }
  15556. //
  15557. // }
  15558. //
  15559. // if item.MedChrgitmType == "03" { //检查费
  15560. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15561. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15562. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15563. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15564. // if item.ChrgitmLv == "1" {
  15565. //
  15566. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15567. //
  15568. // }
  15569. // if item.ChrgitmLv == "2" {
  15570. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15571. //
  15572. // }
  15573. // if item.ChrgitmLv == "3" {
  15574. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15575. // }
  15576. // }
  15577. //
  15578. // if item.MedChrgitmType == "04" { //化验费
  15579. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15580. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15581. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15582. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15583. // if item.ChrgitmLv == "1" {
  15584. //
  15585. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15586. //
  15587. // }
  15588. // if item.ChrgitmLv == "2" {
  15589. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15590. //
  15591. // }
  15592. // if item.ChrgitmLv == "3" {
  15593. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15594. // }
  15595. // }
  15596. //
  15597. // if item.MedChrgitmType == "05" { //治疗费
  15598. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15599. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15600. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15601. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15602. // if item.ChrgitmLv == "1" {
  15603. //
  15604. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15605. //
  15606. // }
  15607. // if item.ChrgitmLv == "2" {
  15608. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15609. //
  15610. // }
  15611. // if item.ChrgitmLv == "3" {
  15612. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15613. // }
  15614. // }
  15615. //
  15616. // if item.MedChrgitmType == "06" { //手术费
  15617. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15618. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15619. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15620. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15621. //
  15622. // if item.ChrgitmLv == "1" {
  15623. //
  15624. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15625. //
  15626. // }
  15627. // if item.ChrgitmLv == "2" {
  15628. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15629. //
  15630. // }
  15631. // if item.ChrgitmLv == "3" {
  15632. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15633. // }
  15634. // }
  15635. //
  15636. // if item.MedChrgitmType == "07" { //手术费
  15637. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15638. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15639. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15640. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15641. //
  15642. // if item.ChrgitmLv == "1" {
  15643. //
  15644. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15645. //
  15646. // }
  15647. // if item.ChrgitmLv == "2" {
  15648. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15649. //
  15650. // }
  15651. // if item.ChrgitmLv == "3" {
  15652. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15653. // }
  15654. // }
  15655. //
  15656. // if item.MedChrgitmType == "08" { //材料费
  15657. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15658. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15659. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15660. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15661. // if item.ChrgitmLv == "1" {
  15662. //
  15663. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15664. //
  15665. // }
  15666. // if item.ChrgitmLv == "2" {
  15667. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15668. //
  15669. // }
  15670. // if item.ChrgitmLv == "3" {
  15671. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15672. // }
  15673. // }
  15674. // if item.MedChrgitmType == "09" { //西药费
  15675. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15676. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15677. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15678. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15679. // if item.ChrgitmLv == "1" {
  15680. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15681. // }
  15682. // if item.ChrgitmLv == "2" {
  15683. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15684. // }
  15685. // if item.ChrgitmLv == "3" {
  15686. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15687. // }
  15688. // }
  15689. // if item.MedChrgitmType == "10" { //中药饮片
  15690. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15691. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15692. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15693. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15694. // if item.ChrgitmLv == "1" {
  15695. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15696. // }
  15697. // if item.ChrgitmLv == "2" {
  15698. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15699. // }
  15700. // if item.ChrgitmLv == "3" {
  15701. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15702. // }
  15703. // }
  15704. //
  15705. // if item.MedChrgitmType == "11" { //中成费
  15706. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15707. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15708. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15709. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15710. // if item.ChrgitmLv == "1" {
  15711. //
  15712. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15713. //
  15714. // }
  15715. // if item.ChrgitmLv == "2" {
  15716. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15717. //
  15718. // }
  15719. // if item.ChrgitmLv == "3" {
  15720. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15721. // }
  15722. // }
  15723. //
  15724. // if item.MedChrgitmType == "12" { //中成费
  15725. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15726. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15727. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15728. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15729. // if item.ChrgitmLv == "1" {
  15730. //
  15731. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15732. //
  15733. // }
  15734. // if item.ChrgitmLv == "2" {
  15735. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15736. //
  15737. // }
  15738. // if item.ChrgitmLv == "3" {
  15739. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15740. // }
  15741. // }
  15742. //
  15743. // if item.MedChrgitmType == "13" { //中成费
  15744. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15745. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15746. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15747. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15748. // if item.ChrgitmLv == "1" {
  15749. //
  15750. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15751. //
  15752. // }
  15753. // if item.ChrgitmLv == "2" {
  15754. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15755. //
  15756. // }
  15757. // if item.ChrgitmLv == "3" {
  15758. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15759. // }
  15760. // }
  15761. //
  15762. // if item.MedChrgitmType == "14" { //其他费
  15763. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15764. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15765. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15766. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15767. // if item.ChrgitmLv == "1" {
  15768. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15769. //
  15770. // }
  15771. // if item.ChrgitmLv == "2" {
  15772. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15773. //
  15774. // }
  15775. // if item.ChrgitmLv == "3" {
  15776. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15777. // }
  15778. // }
  15779. //
  15780. // }
  15781. //
  15782. // var iteminfoStructs []service.IteminfoStruct
  15783. //
  15784. // if bedCostTotal != 0 {
  15785. // iteminfo.MedChrgitm = "01"
  15786. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15787. // iteminfo.Amt = bedCostTotal
  15788. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  15789. // iteminfo.ClabAmt = bed_clab_amt
  15790. // iteminfo.OthAmt = bed_other_amt
  15791. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15792. // }
  15793. //
  15794. // if examineCostTotal != 0 {
  15795. // iteminfo.MedChrgitm = "02"
  15796. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  15797. // iteminfo.Amt = examineCostTotal
  15798. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  15799. // iteminfo.ClabAmt = examine_clab_amt
  15800. // iteminfo.OthAmt = examine_other_amt
  15801. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15802. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15803. // }
  15804. //
  15805. // if checkCostTotal != 0 {
  15806. // iteminfo.MedChrgitm = "03"
  15807. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  15808. // iteminfo.Amt = checkCostTotal
  15809. // iteminfo.ClaaSumfee = check_claa_sunmfee
  15810. // iteminfo.ClabAmt = check_clab_amt
  15811. // iteminfo.OthAmt = check_other_amt
  15812. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15813. //
  15814. // }
  15815. //
  15816. // if laboratoryCostTotal != 0 {
  15817. // iteminfo.MedChrgitm = "04"
  15818. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  15819. // iteminfo.Amt = laboratoryCostTotal
  15820. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  15821. // iteminfo.ClabAmt = laboratory_clab_amt
  15822. // iteminfo.OthAmt = laboratory_other_amt
  15823. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15824. //
  15825. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15826. //
  15827. // }
  15828. //
  15829. // if treatCostTotal != 0 {
  15830. // iteminfo.MedChrgitm = "05"
  15831. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  15832. // iteminfo.Amt = treatCostTotal
  15833. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  15834. // iteminfo.ClabAmt = treat_clab_amt
  15835. // iteminfo.OthAmt = treat_other_amt
  15836. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15837. // //(struct4101.IteminfoStruct, iteminfo)
  15838. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15839. // }
  15840. //
  15841. // if operationCostTotal != 0 {
  15842. // iteminfo.MedChrgitm = "06"
  15843. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15844. // iteminfo.Amt = operationCostTotal
  15845. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  15846. // iteminfo.ClabAmt = operation_clab_amt
  15847. // iteminfo.OthAmt = operation_other_amt
  15848. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15849. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15850. // }
  15851. //
  15852. // if nursingCostTotal != 0 {
  15853. // iteminfo.MedChrgitm = "07"
  15854. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  15855. // iteminfo.Amt = nursingCostTotal
  15856. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  15857. // iteminfo.ClabAmt = nursing_clab_amt
  15858. // iteminfo.OthAmt = nursing_other_amt
  15859. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15860. // }
  15861. //
  15862. // if materialCostTotal != 0 {
  15863. // iteminfo.MedChrgitm = "08"
  15864. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  15865. // iteminfo.Amt = materialCostTotal
  15866. // iteminfo.ClaaSumfee = material_claa_sunmfee
  15867. // iteminfo.ClabAmt = material_clab_amt
  15868. // iteminfo.OthAmt = material_other_amt
  15869. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15870. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15871. // }
  15872. //
  15873. // if westernMedicineCostTotal != 0 {
  15874. // iteminfo.MedChrgitm = "09"
  15875. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15876. // iteminfo.Amt = westernMedicineCostTotal
  15877. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15878. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15879. // iteminfo.OthAmt = westernMedicine_other_amt
  15880. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15881. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15882. //
  15883. // }
  15884. //
  15885. // if chineseMedicineCostTotal != 0 {
  15886. // iteminfo.MedChrgitm = "10"
  15887. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  15888. // iteminfo.Amt = chineseMedicineCostTotal
  15889. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  15890. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  15891. // iteminfo.OthAmt = chinese_medicine_other_amt
  15892. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15893. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15894. //
  15895. // }
  15896. //
  15897. // if chineseTraditionalMedicineCostTotal != 0 {
  15898. // iteminfo.MedChrgitm = "11"
  15899. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15900. // iteminfo.Amt = westernMedicineCostTotal
  15901. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15902. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15903. // iteminfo.OthAmt = westernMedicine_other_amt
  15904. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15905. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15906. //
  15907. // }
  15908. //
  15909. // if commonlyTreatmentCostTotal != 0 {
  15910. // iteminfo.MedChrgitm = "12"
  15911. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  15912. // iteminfo.Amt = commonlyTreatmentCostTotal
  15913. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  15914. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  15915. // iteminfo.OthAmt = commonly_treatment_other_amt
  15916. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15917. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15918. //
  15919. // }
  15920. //
  15921. // if registerCostTotal != 0 {
  15922. // iteminfo.MedChrgitm = "13"
  15923. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  15924. // iteminfo.Amt = registerCostTotal
  15925. // iteminfo.ClaaSumfee = register_claa_sunmfee
  15926. // iteminfo.ClabAmt = register_clab_amt
  15927. // iteminfo.OthAmt = register_other_amt
  15928. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15929. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15930. //
  15931. // }
  15932. //
  15933. // if otherCostTotal != 0 {
  15934. // iteminfo.MedChrgitm = "14"
  15935. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15936. // iteminfo.Amt = otherCostTotal
  15937. // iteminfo.ClaaSumfee = other_claa_sunmfee
  15938. // iteminfo.ClabAmt = other_clab_amt
  15939. // iteminfo.OthAmt = other_other_amt
  15940. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15941. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15942. //
  15943. // }
  15944. // struct4101.IteminfoStruct = iteminfoStructs
  15945. // time_arr := strings.Split(order.SetlTime, " ")
  15946. // struct4101.AdmTime = time_arr[0]
  15947. // struct4101.AdmEndTime = time_arr[0]
  15948. //
  15949. // struct4101.DoctorName = doctor.UserName
  15950. // struct4101.DoctorCode = doctor.DoctorNumber
  15951. //
  15952. // struct4101.Ntly = "中国"
  15953. // struct4101.AdmCaty = "A03.06"
  15954. // var res ResultSeventeen
  15955. // if miConfig.MdtrtareaAdmvs == "421300" {
  15956. // data := make(map[string]interface{})
  15957. // data["struct4101"] = struct4101
  15958. // data["secret_key"] = miConfig.SecretKey
  15959. // data["org_name"] = miConfig.OrgName
  15960. // data["opera"] = curRoles.UserName
  15961. // data["code"] = miConfig.Code
  15962. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15963. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15964. //
  15965. // client := &http.Client{}
  15966. // bytesData, _ := json.Marshal(data)
  15967. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15968. // resp, _ := client.Do(req)
  15969. // defer resp.Body.Close()
  15970. // body, ioErr := ioutil.ReadAll(resp.Body)
  15971. // if ioErr != nil {
  15972. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15973. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15974. // return
  15975. // }
  15976. // var respJSON map[string]interface{}
  15977. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15978. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15980. // return
  15981. // }
  15982. //
  15983. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15984. // userJSONBytes, _ := json.Marshal(respJSON)
  15985. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15986. // utils.ErrorLog("解析失败:%v", err)
  15987. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15988. // adminUser := c.GetAdminUserInfo()
  15989. // errlog := &models.HisOrderError{
  15990. // UserOrgId: adminUser.CurrentOrgId,
  15991. // Ctime: time.Now().Unix(),
  15992. // Mtime: time.Now().Unix(),
  15993. // ErrMsg: res.ErrMsg + "解析失败",
  15994. // Status: 1,
  15995. // PatientId: order_id,
  15996. // Stage: 10088,
  15997. // }
  15998. // service.CreateErrMsgLog(errlog)
  15999. // continue
  16000. // }
  16001. //
  16002. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  16003. // data := make(map[string]interface{})
  16004. // data["struct4101"] = struct4101
  16005. // data["secret_key"] = miConfig.SecretKey
  16006. // data["org_name"] = miConfig.OrgName
  16007. // data["opera"] = curRoles.UserName
  16008. // data["code"] = miConfig.Code
  16009. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  16010. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  16011. //
  16012. // client := &http.Client{}
  16013. // bytesData, _ := json.Marshal(data)
  16014. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  16015. // resp, _ := client.Do(req)
  16016. // defer resp.Body.Close()
  16017. // body, ioErr := ioutil.ReadAll(resp.Body)
  16018. // if ioErr != nil {
  16019. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16020. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16021. // return
  16022. // }
  16023. // var respJSON map[string]interface{}
  16024. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16025. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16027. // return
  16028. // }
  16029. //
  16030. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16031. // userJSONBytes, _ := json.Marshal(respJSON)
  16032. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16033. // utils.ErrorLog("解析失败:%v", err)
  16034. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16035. // adminUser := c.GetAdminUserInfo()
  16036. // errlog := &models.HisOrderError{
  16037. // UserOrgId: adminUser.CurrentOrgId,
  16038. // Ctime: time.Now().Unix(),
  16039. // Mtime: time.Now().Unix(),
  16040. // ErrMsg: res.ErrMsg + "解析失败",
  16041. // Status: 1,
  16042. // PatientId: order_id,
  16043. // Stage: 10088,
  16044. // }
  16045. // service.CreateErrMsgLog(errlog)
  16046. // continue
  16047. // }
  16048. //
  16049. // } else {
  16050. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  16051. // fmt.Println(result)
  16052. //
  16053. // var dat map[string]interface{}
  16054. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16055. // fmt.Println(dat)
  16056. // } else {
  16057. // fmt.Println(err)
  16058. // }
  16059. // userJSONBytes, _ := json.Marshal(dat)
  16060. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16061. // utils.ErrorLog("解析失败:%v", err)
  16062. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16063. // adminUser := c.GetAdminUserInfo()
  16064. // errlog := &models.HisOrderError{
  16065. // UserOrgId: adminUser.CurrentOrgId,
  16066. // Ctime: time.Now().Unix(),
  16067. // Mtime: time.Now().Unix(),
  16068. // ErrMsg: res.ErrMsg + "解析失败",
  16069. // Status: 1,
  16070. // PatientId: order_id,
  16071. // Stage: 10106,
  16072. // }
  16073. // service.CreateErrMsgLog(errlog)
  16074. // continue
  16075. // }
  16076. // }
  16077. //
  16078. // if res.Infcode != 0 {
  16079. // adminUser := c.GetAdminUserInfo()
  16080. // errlog := &models.HisOrderError{
  16081. // UserOrgId: adminUser.CurrentOrgId,
  16082. // Ctime: time.Now().Unix(),
  16083. // Mtime: time.Now().Unix(),
  16084. // ErrMsg: res.ErrMsg,
  16085. // Status: 1,
  16086. // PatientId: order_id,
  16087. // Stage: 10106,
  16088. // }
  16089. // service.CreateErrMsgLog(errlog)
  16090. // continue
  16091. // } else {
  16092. // hisFundSettleListResult := &models.HisFundSettleListResult{
  16093. // Number: res.Output.SetlListId,
  16094. // Status: 1,
  16095. // Ctime: time.Now().Unix(),
  16096. // Mtime: time.Now().Unix(),
  16097. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16098. // IsUpload: 1,
  16099. // OrderId: order_id,
  16100. // }
  16101. // service.CreateUploadRecord(hisFundSettleListResult)
  16102. // continue
  16103. // }
  16104. // }
  16105. //}
  16106. func (c *HisApiController) GetOrgInfo() {
  16107. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  16108. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  16109. }
  16110. func (c *HisApiController) GetHisPatientInfo() {
  16111. medical_insurance_card := c.GetString("medical_insurance_card")
  16112. id_card_type, _ := c.GetInt64("id_card_type")
  16113. id_card := c.GetString("id_card")
  16114. adminInfo := c.GetAdminUserInfo()
  16115. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16116. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16117. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  16118. IdCardNo := ""
  16119. if id_card_type == 1 {
  16120. IdCardNo = medical_insurance_card
  16121. } else if id_card_type == 2 {
  16122. IdCardNo = id_card
  16123. }
  16124. if config.IsOpen == 1 {
  16125. 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
  16126. resp, requestErr := http.Get(api)
  16127. if requestErr != nil {
  16128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16129. return
  16130. }
  16131. defer resp.Body.Close()
  16132. body, ioErr := ioutil.ReadAll(resp.Body)
  16133. if ioErr != nil {
  16134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16136. return
  16137. }
  16138. var respJSON map[string]interface{}
  16139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16142. return
  16143. }
  16144. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16145. userJSONBytes, _ := json.Marshal(userJSON)
  16146. var res ResultTwo
  16147. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16148. utils.ErrorLog("解析失败:%v", err)
  16149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16150. return
  16151. }
  16152. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16153. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16154. infoStr := string(Iinfos)
  16155. idetinfoStr := string(Idetinfos)
  16156. if res.Infcode == 0 {
  16157. his := models.VMHisPatient{
  16158. Status: 1,
  16159. Ctime: time.Now().Unix(),
  16160. Mtime: time.Now().Unix(),
  16161. PsnNo: res.Output.Baseinfo.PsnNo,
  16162. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16163. Certno: res.Output.Baseinfo.Certno,
  16164. PsnName: res.Output.Baseinfo.PsnName,
  16165. Gend: res.Output.Baseinfo.Gend,
  16166. Naty: res.Output.Baseinfo.Naty,
  16167. Iinfo: infoStr,
  16168. Idetinfo: idetinfoStr,
  16169. UserOrgId: adminInfo.CurrentOrgId,
  16170. IsReturn: 1,
  16171. IdCardType: id_card_type,
  16172. }
  16173. c.ServeSuccessJSON(map[string]interface{}{
  16174. "info": his,
  16175. })
  16176. } else {
  16177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16178. return
  16179. }
  16180. }
  16181. }
  16182. //func GetBasBaseInfo() (jsonStr string, err error) {
  16183. //
  16184. // handle := syscall.NewLazyDLL("SSCard.dll")
  16185. // add := handle.NewProc("ReadCardBas")
  16186. // str := make([]byte, 1024)
  16187. // str1 := make([]byte, 1024)
  16188. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  16189. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  16190. //
  16191. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  16192. //
  16193. // fmt.Println("> Add(4,5)的结果为:", ret)
  16194. // handle.Release()
  16195. //
  16196. // return "", nil
  16197. //
  16198. //}
  16199. //func GetQRBaseInfo() (jsonStr string, err error) {
  16200. // handle := syscall.LoadDLL("SSCard.dll")
  16201. // ReadCardBas := handle.FindProc("GetQRBase")
  16202. //
  16203. // str := make([]byte, 256)
  16204. // str1 := make([]byte, 256)
  16205. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  16206. //
  16207. // fmt.Println(string(str))
  16208. // fmt.Println(r)
  16209. // return string(str), nil
  16210. //}
  16211. //func CardInit() int {
  16212. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  16213. // add := DllTestDef.MustFindProc("Init")
  16214. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  16215. // if err != nil {
  16216. // fmt.Println("SSCard的运算结果为:", ret)
  16217. // }
  16218. // result := int(ret)
  16219. // return result
  16220. //}
  16221. //func CardInit() int {
  16222. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  16223. // if err != nil {
  16224. // fmt.Println("SSCard的运算结果为:", ret)
  16225. // }
  16226. // fmt.Println(err)
  16227. // result := int(ret)
  16228. // return result
  16229. //}
  16230. func IntPtr(n int) uintptr {
  16231. return uintptr(n)
  16232. }
  16233. func StrPtr(s string) uintptr {
  16234. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  16235. }
  16236. type Result2001 struct {
  16237. Cainfo interface{} `json:"cainfo"`
  16238. ErrMsg string `json:"err_msg"`
  16239. InfRefmsgid string `json:"inf_refmsgid"`
  16240. Infcode int64 `json:"infcode"`
  16241. Output struct {
  16242. Trtinfo struct {
  16243. PsnNo string `json:"psn_no"`
  16244. TrtChkType string `json:"trt_chk_type"`
  16245. FundPayType string `json:"fund_pay_type"`
  16246. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  16247. Begndate string `json:"begndate"`
  16248. Enddate string `json:"enddate"`
  16249. TrtChkRslt string `json:"trt_chk_rslt"`
  16250. } `json:"trtinfo"`
  16251. } `json:"output"`
  16252. RefmsgTime string `json:"refmsg_time"`
  16253. RespondTime string `json:"respond_time"`
  16254. Signtype interface{} `json:"signtype"`
  16255. WarnMsg interface{} `json:"warn_msg"`
  16256. }
  16257. type Result2001Org10265 struct {
  16258. Cainfo interface{} `json:"cainfo"`
  16259. ErrMsg string `json:"err_msg"`
  16260. InfRefmsgid string `json:"inf_refmsgid"`
  16261. Infcode string `json:"infcode"`
  16262. Output struct {
  16263. Trtinfo struct {
  16264. PsnNo string `json:"psn_no"`
  16265. TrtChkType string `json:"trt_chk_type"`
  16266. FundPayType string `json:"fund_pay_type"`
  16267. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  16268. Begndate string `json:"begndate"`
  16269. Enddate string `json:"enddate"`
  16270. TrtChkRslt string `json:"trt_chk_rslt"`
  16271. } `json:"trtinfo"`
  16272. } `json:"output"`
  16273. RefmsgTime string `json:"refmsg_time"`
  16274. RespondTime string `json:"respond_time"`
  16275. Signtype interface{} `json:"signtype"`
  16276. WarnMsg interface{} `json:"warn_msg"`
  16277. }
  16278. type ResultTwo struct {
  16279. ErrMsg string `json:"err_msg"`
  16280. InfRefmsgid string `json:"inf_refmsgid"`
  16281. Infcode int64 `json:"infcode"`
  16282. Output struct {
  16283. Baseinfo struct {
  16284. //Brdy string `json:"brdy"`
  16285. Certno string `json:"certno"`
  16286. Gend string `json:"gend"`
  16287. Naty string `json:"naty"`
  16288. PsnCertType string `json:"psn_cert_type"`
  16289. PsnName string `json:"psn_name"`
  16290. PsnNo string `json:"psn_no"`
  16291. } `json:"baseinfo"`
  16292. Idetinfo []interface{} `json:"idetinfo"`
  16293. Iinfo []struct {
  16294. Balc float64 `json:"balc"`
  16295. CvlservFlag string `json:"cvlserv_flag"`
  16296. EmpName string `json:"emp_name"`
  16297. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  16298. Insutype string `json:"insutype"`
  16299. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  16300. //PausInsuDate string `json:"paus_insu_date"`
  16301. //PsnInsuDate string `json:"psn_insu_date"`
  16302. PsnInsuStas string `json:"psn_insu_stas"`
  16303. PsnType string `json:"psn_type"`
  16304. } `json:"insuinfo"`
  16305. } `json:"output"`
  16306. RefmsgTime string `json:"refmsg_time"`
  16307. RespondTime string `json:"respond_time"`
  16308. Signtype interface{} `json:"signtype"`
  16309. WarnInfo interface{} `json:"warn_info"`
  16310. }
  16311. type ResultTwo10265 struct {
  16312. ErrMsg string `json:"err_msg"`
  16313. InfRefmsgid string `json:"inf_refmsgid"`
  16314. Infcode string `json:"infcode"`
  16315. Output struct {
  16316. Baseinfo struct {
  16317. //Brdy string `json:"brdy"`
  16318. Certno string `json:"certno"`
  16319. Gend string `json:"gend"`
  16320. Naty string `json:"naty"`
  16321. PsnCertType string `json:"psn_cert_type"`
  16322. PsnName string `json:"psn_name"`
  16323. PsnNo string `json:"psn_no"`
  16324. } `json:"baseinfo"`
  16325. Idetinfo []interface{} `json:"idetinfo"`
  16326. Iinfo []struct {
  16327. Balc float64 `json:"balc"`
  16328. CvlservFlag string `json:"cvlserv_flag"`
  16329. EmpName string `json:"emp_name"`
  16330. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  16331. Insutype string `json:"insutype"`
  16332. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  16333. PsnInsuStas string `json:"psn_insu_stas"`
  16334. PsnType string `json:"psn_type"`
  16335. } `json:"insuinfo"`
  16336. } `json:"output"`
  16337. RefmsgTime string `json:"refmsg_time"`
  16338. RespondTime string `json:"respond_time"`
  16339. Signtype interface{} `json:"signtype"`
  16340. WarnInfo interface{} `json:"warn_info"`
  16341. }
  16342. type ResultThree struct {
  16343. Cainfo interface{} `json:"cainfo"`
  16344. ErrMsg string `json:"err_msg"`
  16345. InfRefmsgid string `json:"inf_refmsgid"`
  16346. Infcode int64 `json:"infcode"`
  16347. Output struct {
  16348. Data struct {
  16349. IptOtpNo string `json:"ipt_otp_no"`
  16350. MdtrtID string `json:"mdtrt_id"`
  16351. PsnNo string `json:"psn_no"`
  16352. } `json:"data"`
  16353. } `json:"output"`
  16354. RefmsgTime string `json:"refmsg_time"`
  16355. RespondTime string `json:"respond_time"`
  16356. Signtype interface{} `json:"signtype"`
  16357. WarnMsg interface{} `json:"warn_msg"`
  16358. }
  16359. type ResultThree10265 struct {
  16360. Cainfo interface{} `json:"cainfo"`
  16361. ErrMsg string `json:"err_msg"`
  16362. InfRefmsgid string `json:"inf_refmsgid"`
  16363. Infcode string `json:"infcode"`
  16364. Output struct {
  16365. Data struct {
  16366. IptOtpNo string `json:"ipt_otp_no"`
  16367. MdtrtID string `json:"mdtrt_id"`
  16368. PsnNo string `json:"psn_no"`
  16369. } `json:"data"`
  16370. } `json:"output"`
  16371. RefmsgTime string `json:"refmsg_time"`
  16372. RespondTime string `json:"respond_time"`
  16373. Signtype interface{} `json:"signtype"`
  16374. WarnMsg interface{} `json:"warn_msg"`
  16375. }
  16376. type ResultFour struct {
  16377. Cainfo string `json:"cainfo"`
  16378. ErrMsg string `json:"err_msg"`
  16379. InfRefmsgid string `json:"inf_refmsgid"`
  16380. Infcode int64 `json:"infcode"`
  16381. Output struct {
  16382. Result []struct {
  16383. BasMednFlag string `json:"bas_medn_flag"`
  16384. ChldMedcFlag string `json:"chld_medc_flag"`
  16385. ChrgitmLv string `json:"chrgitm_lv"`
  16386. Cnt float64 `json:"cnt"`
  16387. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  16388. DrtReimFlag string `json:"drt_reim_flag"`
  16389. FeedetlSn string `json:"feedetl_sn"`
  16390. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16391. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  16392. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16393. ListSpItemFlag string `json:"list_sp_item_flag"`
  16394. LmtUsedFlag string `json:"lmt_used_flag"`
  16395. MedChrgitmType string `json:"med_chrgitm_type"`
  16396. Memo string `json:"memo"`
  16397. OverlmtAmt float64 `json:"overlmt_amt"`
  16398. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16399. Pric float64 `json:"pric"`
  16400. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  16401. SelfpayProp float64 `json:"selfpay_prop"`
  16402. } `json:"result"`
  16403. } `json:"output"`
  16404. RefmsgTime string `json:"refmsg_time"`
  16405. RespondTime string `json:"respond_time"`
  16406. Signtype string `json:"signtype"`
  16407. WarnMsg string `json:"warn_msg"`
  16408. }
  16409. type ResultFour10265 struct {
  16410. Cainfo string `json:"cainfo"`
  16411. ErrMsg string `json:"err_msg"`
  16412. InfRefmsgid string `json:"inf_refmsgid"`
  16413. Infcode string `json:"infcode"`
  16414. Output struct {
  16415. Result []struct {
  16416. BasMednFlag string `json:"bas_medn_flag"`
  16417. ChldMedcFlag string `json:"chld_medc_flag"`
  16418. ChrgitmLv string `json:"chrgitm_lv"`
  16419. Cnt float64 `json:"cnt"`
  16420. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  16421. DrtReimFlag string `json:"drt_reim_flag"`
  16422. FeedetlSn string `json:"feedetl_sn"`
  16423. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16424. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  16425. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16426. ListSpItemFlag string `json:"list_sp_item_flag"`
  16427. LmtUsedFlag string `json:"lmt_used_flag"`
  16428. MedChrgitmType string `json:"med_chrgitm_type"`
  16429. Memo string `json:"memo"`
  16430. OverlmtAmt float64 `json:"overlmt_amt"`
  16431. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16432. Pric float64 `json:"pric"`
  16433. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  16434. SelfpayProp float64 `json:"selfpay_prop"`
  16435. } `json:"result"`
  16436. } `json:"output"`
  16437. RefmsgTime string `json:"refmsg_time"`
  16438. RespondTime string `json:"respond_time"`
  16439. Signtype string `json:"signtype"`
  16440. WarnMsg string `json:"warn_msg"`
  16441. }
  16442. type ResultMemo struct {
  16443. InsuAdmdvs string `json:"insuAdmdvs"`
  16444. }
  16445. // [{"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}]
  16446. type ResultIDInfo struct {
  16447. Begntime string `json:"begntime"`
  16448. Endtime string `json:"endtime"`
  16449. Memo string `json:"memo"`
  16450. }
  16451. type ResultFive struct {
  16452. Balc float64 `json:"balc"`
  16453. CvlservFlag string `json:"cvlserv_flag"`
  16454. EmpName string `json:"emp_name"`
  16455. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  16456. Insutype string `json:"insutype"`
  16457. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  16458. PausInsuDate string `json:"paus_insu_date"`
  16459. PsnInsuDate string `json:"psn_insu_date"`
  16460. PsnInsuStas string `json:"psn_insu_stas"`
  16461. PsnType string `json:"psn_type"`
  16462. }
  16463. type ResultSix struct {
  16464. Cainfo interface{} `json:"cainfo"`
  16465. ErrMsg string `json:"err_msg"`
  16466. InfRefmsgid string `json:"inf_refmsgid"`
  16467. Infcode int64 `json:"infcode"`
  16468. Output struct {
  16469. } `json:"output"`
  16470. RefmsgTime string `json:"refmsg_time"`
  16471. RespondTime string `json:"respond_time"`
  16472. Signtype interface{} `json:"signtype"`
  16473. WarnMsg interface{} `json:"warn_msg"`
  16474. }
  16475. type FJ3507Result struct {
  16476. Cainfo interface{} `json:"cainfo"`
  16477. ErrMsg string `json:"err_msg"`
  16478. InfRefmsgid string `json:"inf_refmsgid"`
  16479. Infcode int64 `json:"infcode"`
  16480. Output struct {
  16481. retRslt string `json:"retRslt"`
  16482. msgRslt string `json:"msgRslt"`
  16483. } `json:"output"`
  16484. RefmsgTime string `json:"refmsg_time"`
  16485. RespondTime string `json:"respond_time"`
  16486. Signtype interface{} `json:"signtype"`
  16487. WarnMsg interface{} `json:"warn_msg"`
  16488. }
  16489. type Result2406 struct {
  16490. Cainfo interface{} `json:"cainfo"`
  16491. ErrMsg string `json:"err_msg"`
  16492. InfRefmsgid string `json:"inf_refmsgid"`
  16493. Infcode int64 `json:"infcode"`
  16494. Output struct {
  16495. Result struct {
  16496. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  16497. } `json:"result"`
  16498. } `json:"output"`
  16499. RefmsgTime string `json:"refmsg_time"`
  16500. RespondTime string `json:"respond_time"`
  16501. Signtype interface{} `json:"signtype"`
  16502. WarnMsg interface{} `json:"warn_msg"`
  16503. }
  16504. type GZResultSix struct {
  16505. Cainfo interface{} `json:"cainfo"`
  16506. ErrMsg string `json:"err_msg"`
  16507. InfRefmsgid string `json:"inf_refmsgid"`
  16508. Infcode int64 `json:"infcode"`
  16509. Output string `json:"output"`
  16510. RefmsgTime string `json:"refmsg_time"`
  16511. RespondTime string `json:"respond_time"`
  16512. Signtype interface{} `json:"signtype"`
  16513. WarnMsg interface{} `json:"warn_msg"`
  16514. }
  16515. type ResultSix10265 struct {
  16516. Cainfo interface{} `json:"cainfo"`
  16517. ErrMsg string `json:"err_msg"`
  16518. InfRefmsgid string `json:"inf_refmsgid"`
  16519. Infcode string `json:"infcode"`
  16520. Output struct {
  16521. } `json:"output"`
  16522. RefmsgTime string `json:"refmsg_time"`
  16523. RespondTime string `json:"respond_time"`
  16524. Signtype interface{} `json:"signtype"`
  16525. WarnMsg interface{} `json:"warn_msg"`
  16526. }
  16527. type ResultSeven struct {
  16528. Cainfo string `json:"cainfo"`
  16529. ErrMsg string `json:"err_msg"`
  16530. InfRefmsgid string `json:"inf_refmsgid"`
  16531. Infcode int64 `json:"infcode"`
  16532. Output struct {
  16533. Setlinfo struct {
  16534. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16535. AcctPay float64 `json:"acct_pay"`
  16536. ActPayDedc float64 `json:"act_pay_dedc"`
  16537. Age float64 `json:"age"`
  16538. Balc float64 `json:"balc"`
  16539. Certno string `json:"certno"`
  16540. ClrOptins string `json:"clr_optins"`
  16541. ClrType string `json:"clr_type"`
  16542. ClrWay string `json:"clr_way"`
  16543. CvlservFlag string `json:"cvlserv_flag"`
  16544. CvlservPay float64 `json:"cvlserv_pay"`
  16545. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16546. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16547. Gend string `json:"gend"`
  16548. HifesPay float64 `json:"hifes_pay"`
  16549. HifmiPay float64 `json:"hifmi_pay"`
  16550. HifpPay float64 `json:"hifp_pay"`
  16551. HospPartAmt float64 `json:"hosp_part_amt"`
  16552. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16553. Insutype string `json:"insutype"`
  16554. MafPay float64 `json:"maf_pay"`
  16555. MdtrtCertType string `json:"mdtrt_cert_type"`
  16556. HifobPay float64 `json:"hifob_pay"`
  16557. MdtrtID string `json:"mdtrt_id"`
  16558. MedType string `json:"med_type"`
  16559. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16560. MedinsSetlID string `json:"medins_setl_id"`
  16561. Naty string `json:"naty"`
  16562. OthPay float64 `json:"oth_pay"`
  16563. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16564. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16565. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16566. PsnCashPay float64 `json:"psn_cash_pay"`
  16567. PsnCertType string `json:"psn_cert_type"`
  16568. PsnName string `json:"psn_name"`
  16569. PsnNo string `json:"psn_no"`
  16570. PsnPartAmt float64 `json:"psn_part_amt"`
  16571. PsnType string `json:"psn_type"`
  16572. SetlID string `json:"setl_id"`
  16573. SetlTime string `json:"setl_time"`
  16574. } `json:"setlinfo"`
  16575. Setldetail interface{} `json:"setldetail"`
  16576. } `json:"output"`
  16577. RefmsgTime string `json:"refmsg_time"`
  16578. RespondTime string `json:"respond_time"`
  16579. Signtype interface{} `json:"signtype"`
  16580. WarnMsg interface{} `json:"warn_msg"`
  16581. }
  16582. type ResultSevenAH struct {
  16583. Cainfo string `json:"cainfo"`
  16584. ErrMsg string `json:"err_msg"`
  16585. InfRefmsgid string `json:"inf_refmsgid"`
  16586. Infcode int64 `json:"infcode"`
  16587. Output struct {
  16588. Setlinfo struct {
  16589. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16590. AcctPay float64 `json:"acct_pay"`
  16591. ActPayDedc float64 `json:"act_pay_dedc"`
  16592. Age float64 `json:"age"`
  16593. Balc float64 `json:"balc"`
  16594. Certno string `json:"certno"`
  16595. ClrOptins string `json:"clr_optins"`
  16596. ClrType string `json:"clr_type"`
  16597. ClrWay string `json:"clr_way"`
  16598. CvlservFlag string `json:"cvlserv_flag"`
  16599. CvlservPay float64 `json:"cvlserv_pay"`
  16600. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16601. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16602. Gend string `json:"gend"`
  16603. HifesPay float64 `json:"hifes_pay"`
  16604. HifmiPay float64 `json:"hifmi_pay"`
  16605. HifpPay float64 `json:"hifp_pay"`
  16606. HospPartAmt float64 `json:"hosp_part_amt"`
  16607. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16608. Insutype string `json:"insutype"`
  16609. MafPay float64 `json:"maf_pay"`
  16610. MdtrtCertType string `json:"mdtrt_cert_type"`
  16611. HifobPay float64 `json:"hifob_pay"`
  16612. MdtrtID string `json:"mdtrt_id"`
  16613. MedType string `json:"med_type"`
  16614. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16615. MedinsSetlID string `json:"medins_setl_id"`
  16616. Naty string `json:"naty"`
  16617. OthPay float64 `json:"oth_pay"`
  16618. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16619. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16620. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16621. PsnCashPay float64 `json:"psn_cash_pay"`
  16622. PsnCertType string `json:"psn_cert_type"`
  16623. PsnName string `json:"psn_name"`
  16624. PsnNo string `json:"psn_no"`
  16625. PsnPartAmt float64 `json:"psn_part_amt"`
  16626. PsnType string `json:"psn_type"`
  16627. SetlID string `json:"setl_id"`
  16628. SetlTime int64 `json:"setl_time"`
  16629. } `json:"setlinfo"`
  16630. Setldetail interface{} `json:"setldetail"`
  16631. } `json:"output"`
  16632. RefmsgTime string `json:"refmsg_time"`
  16633. RespondTime string `json:"respond_time"`
  16634. Signtype interface{} `json:"signtype"`
  16635. WarnMsg interface{} `json:"warn_msg"`
  16636. }
  16637. type ResultSeven10265 struct {
  16638. Cainfo string `json:"cainfo"`
  16639. ErrMsg string `json:"err_msg"`
  16640. InfRefmsgid string `json:"inf_refmsgid"`
  16641. Infcode string `json:"infcode"`
  16642. Output struct {
  16643. Setlinfo struct {
  16644. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16645. AcctPay float64 `json:"acct_pay"`
  16646. ActPayDedc float64 `json:"act_pay_dedc"`
  16647. Age float64 `json:"age"`
  16648. Balc float64 `json:"balc"`
  16649. Certno string `json:"certno"`
  16650. ClrOptins string `json:"clr_optins"`
  16651. ClrType string `json:"clr_type"`
  16652. ClrWay string `json:"clr_way"`
  16653. CvlservFlag string `json:"cvlserv_flag"`
  16654. CvlservPay float64 `json:"cvlserv_pay"`
  16655. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16656. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16657. Gend string `json:"gend"`
  16658. HifesPay float64 `json:"hifes_pay"`
  16659. HifmiPay float64 `json:"hifmi_pay"`
  16660. HifpPay float64 `json:"hifp_pay"`
  16661. HospPartAmt float64 `json:"hosp_part_amt"`
  16662. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16663. Insutype string `json:"insutype"`
  16664. MafPay float64 `json:"maf_pay"`
  16665. MdtrtCertType string `json:"mdtrt_cert_type"`
  16666. HifobPay float64 `json:"hifob_pay"`
  16667. MdtrtID string `json:"mdtrt_id"`
  16668. MedType string `json:"med_type"`
  16669. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16670. MedinsSetlID string `json:"medins_setl_id"`
  16671. Naty string `json:"naty"`
  16672. OthPay float64 `json:"oth_pay"`
  16673. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16674. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16675. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16676. PsnCashPay float64 `json:"psn_cash_pay"`
  16677. PsnCertType string `json:"psn_cert_type"`
  16678. PsnName string `json:"psn_name"`
  16679. PsnNo string `json:"psn_no"`
  16680. PsnPartAmt float64 `json:"psn_part_amt"`
  16681. PsnType string `json:"psn_type"`
  16682. SetlID string `json:"setl_id"`
  16683. SetlTime string `json:"setl_time"`
  16684. } `json:"setlinfo"`
  16685. Setldetail interface{} `json:"setldetail"`
  16686. } `json:"output"`
  16687. RefmsgTime string `json:"refmsg_time"`
  16688. RespondTime string `json:"respond_time"`
  16689. Signtype interface{} `json:"signtype"`
  16690. WarnMsg interface{} `json:"warn_msg"`
  16691. }
  16692. type ResultSeven10265Two struct {
  16693. Cainfo string `json:"cainfo"`
  16694. ErrMsg string `json:"err_msg"`
  16695. InfRefmsgid string `json:"inf_refmsgid"`
  16696. Infcode string `json:"infcode"`
  16697. Output struct {
  16698. Setlinfo struct {
  16699. AcctMulaidPay string `json:"acct_mulaid_pay"`
  16700. AcctPay float64 `json:"acct_pay"`
  16701. ActPayDedc float64 `json:"act_pay_dedc"`
  16702. Age float64 `json:"age"`
  16703. Balc float64 `json:"balc"`
  16704. Certno string `json:"certno"`
  16705. ClrOptins string `json:"clr_optins"`
  16706. ClrType string `json:"clr_type"`
  16707. ClrWay string `json:"clr_way"`
  16708. CvlservFlag string `json:"cvlserv_flag"`
  16709. CvlservPay float64 `json:"cvlserv_pay"`
  16710. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16711. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16712. Gend string `json:"gend"`
  16713. HifesPay float64 `json:"hifes_pay"`
  16714. HifmiPay float64 `json:"hifmi_pay"`
  16715. HifpPay float64 `json:"hifp_pay"`
  16716. HospPartAmt string `json:"hosp_part_amt"`
  16717. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16718. Insutype string `json:"insutype"`
  16719. MafPay float64 `json:"maf_pay"`
  16720. MdtrtCertType string `json:"mdtrt_cert_type"`
  16721. HifobPay float64 `json:"hifob_pay"`
  16722. MdtrtID string `json:"mdtrt_id"`
  16723. MedType string `json:"med_type"`
  16724. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16725. MedinsSetlID string `json:"medins_setl_id"`
  16726. Naty string `json:"naty"`
  16727. OthPay float64 `json:"oth_pay"`
  16728. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16729. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  16730. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16731. PsnCashPay float64 `json:"psn_cash_pay"`
  16732. PsnCertType string `json:"psn_cert_type"`
  16733. PsnName string `json:"psn_name"`
  16734. PsnNo string `json:"psn_no"`
  16735. PsnPartAmt float64 `json:"psn_part_amt"`
  16736. PsnType string `json:"psn_type"`
  16737. SetlID string `json:"setl_id"`
  16738. SetlTime string `json:"setl_time"`
  16739. } `json:"setlinfo"`
  16740. Setldetail interface{} `json:"setldetail"`
  16741. } `json:"output"`
  16742. RefmsgTime string `json:"refmsg_time"`
  16743. RespondTime string `json:"respond_time"`
  16744. Signtype interface{} `json:"signtype"`
  16745. WarnMsg interface{} `json:"warn_msg"`
  16746. }
  16747. type GZResultSeven10265Two struct {
  16748. Cainfo string `json:"cainfo"`
  16749. ErrMsg string `json:"err_msg"`
  16750. InfRefmsgid string `json:"inf_refmsgid"`
  16751. Infcode int64 `json:"infcode"`
  16752. Output struct {
  16753. Setlinfo struct {
  16754. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16755. AcctPay float64 `json:"acct_pay"`
  16756. ActPayDedc float64 `json:"act_pay_dedc"`
  16757. Age float64 `json:"age"`
  16758. Balc float64 `json:"balc"`
  16759. Certno string `json:"certno"`
  16760. ClrOptins string `json:"clr_optins"`
  16761. ClrType string `json:"clr_type"`
  16762. ClrWay string `json:"clr_way"`
  16763. CvlservFlag string `json:"cvlserv_flag"`
  16764. CvlservPay float64 `json:"cvlserv_pay"`
  16765. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16766. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16767. Gend string `json:"gend"`
  16768. HifesPay float64 `json:"hifes_pay"`
  16769. HifmiPay float64 `json:"hifmi_pay"`
  16770. HifpPay float64 `json:"hifp_pay"`
  16771. HospPartAmt float64 `json:"hosp_part_amt"`
  16772. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16773. Insutype string `json:"insutype"`
  16774. MafPay float64 `json:"maf_pay"`
  16775. MdtrtCertType string `json:"mdtrt_cert_type"`
  16776. HifobPay float64 `json:"hifob_pay"`
  16777. MdtrtID string `json:"mdtrt_id"`
  16778. MedType string `json:"med_type"`
  16779. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16780. MedinsSetlID string `json:"medins_setl_id"`
  16781. Naty string `json:"naty"`
  16782. OthPay float64 `json:"oth_pay"`
  16783. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16784. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  16785. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16786. PsnCashPay float64 `json:"psn_cash_pay"`
  16787. PsnCertType string `json:"psn_cert_type"`
  16788. PsnName string `json:"psn_name"`
  16789. PsnNo string `json:"psn_no"`
  16790. PsnPartAmt float64 `json:"psn_part_amt"`
  16791. PsnType string `json:"psn_type"`
  16792. SetlID string `json:"setl_id"`
  16793. SetlTime string `json:"setl_time"`
  16794. } `json:"setlinfo"`
  16795. Setldetail interface{} `json:"setldetail"`
  16796. } `json:"output"`
  16797. RefmsgTime string `json:"refmsg_time"`
  16798. RespondTime string `json:"respond_time"`
  16799. Signtype interface{} `json:"signtype"`
  16800. WarnMsg interface{} `json:"warn_msg"`
  16801. }
  16802. type ResultEight struct {
  16803. Cainfo string `json:"cainfo"`
  16804. ErrMsg string `json:"err_msg"`
  16805. InfRefmsgid string `json:"inf_refmsgid"`
  16806. Infcode int64 `json:"infcode"`
  16807. Output struct {
  16808. Stmtinfo struct {
  16809. SetlOptins string `json:"setl_optins"`
  16810. StmtRslt string `json:"stmt_rslt"`
  16811. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  16812. } `json:"stmtinfo"`
  16813. } `json:"output"`
  16814. RefmsgTime string `json:"refmsg_time"`
  16815. RespondTime string `json:"respond_time"`
  16816. Signtype interface{} `json:"signtype"`
  16817. WarnMsg interface{} `json:"warn_msg"`
  16818. }
  16819. type ResultEightFor10188 struct {
  16820. Cainfo string `json:"cainfo"`
  16821. ErrMsg string `json:"err_msg"`
  16822. InfRefmsgid string `json:"inf_refmsgid"`
  16823. Infcode string `json:"infcode"`
  16824. Output struct {
  16825. Stmtinfo struct {
  16826. SetlOptins string `json:"setl_optins"`
  16827. StmtRslt string `json:"stmt_rslt"`
  16828. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  16829. } `json:"stmtinfo"`
  16830. } `json:"output"`
  16831. RefmsgTime string `json:"refmsg_time"`
  16832. RespondTime string `json:"respond_time"`
  16833. Signtype interface{} `json:"signtype"`
  16834. WarnMsg interface{} `json:"warn_msg"`
  16835. }
  16836. type ResultNine struct {
  16837. Cainfo string `json:"cainfo"`
  16838. ErrMsg string `json:"err_msg"`
  16839. InfRefmsgid string `json:"inf_refmsgid"`
  16840. Infcode int64 `json:"infcode"`
  16841. Output struct {
  16842. FileQuryNo string `json:"file_qury_no"`
  16843. } `json:"output"`
  16844. RefmsgTime string `json:"refmsg_time"`
  16845. RespondTime string `json:"respond_time"`
  16846. Signtype interface{} `json:"signtype"`
  16847. WarnMsg interface{} `json:"warn_msg"`
  16848. }
  16849. type ResultTen struct {
  16850. Cainfo string `json:"cainfo"`
  16851. ErrMsg string `json:"err_msg"`
  16852. InfRefmsgid string `json:"inf_refmsgid"`
  16853. Infcode int64 `json:"infcode"`
  16854. Output struct {
  16855. Fileinfo struct {
  16856. DldEndtime string `json:"dld_endtime"`
  16857. FileQuryNo string `json:"file_qury_no"`
  16858. Filename string `json:"filename"`
  16859. } `json:"fileinfo"`
  16860. } `json:"output"`
  16861. RefmsgTime string `json:"refmsg_time"`
  16862. RespondTime string `json:"respond_time"`
  16863. Signtype interface{} `json:"signtype"`
  16864. WarnMsg interface{} `json:"warn_msg"`
  16865. }
  16866. type Result5262 struct {
  16867. ErrMsg string `json:"err_msg"`
  16868. InfRefmsgid string `json:"inf_refmsgid"`
  16869. Infcode int64 `json:"infcode"`
  16870. Output struct {
  16871. PageInfo struct {
  16872. Size int `json:"size"`
  16873. RecordCounts int `json:"record_counts"`
  16874. } `json:"page_info"`
  16875. Idetinfo []interface{} `json:"idetinfo"`
  16876. Result []struct {
  16877. SetlID string `json:"setl_id"`
  16878. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16879. MdtrtID string `json:"mdtrt_id"`
  16880. InitSetlID string `json:"init_setl_id,omitempty"`
  16881. PsnNo string `json:"psn_no"`
  16882. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16883. PsnName string `json:"psn_name"`
  16884. PsnCertType string `json:"psn_cert_type"`
  16885. Certno string `json:"certno"`
  16886. Gend string `json:"gend,omitempty"`
  16887. Naty string `json:"naty,omitempty"`
  16888. Brdy string `json:"brdy,omitempty"`
  16889. Age float64 `json:"age,omitempty"`
  16890. Insutype string `json:"insutype,omitempty"`
  16891. PsnType string `json:"psn_type"`
  16892. CvlservFlag string `json:"cvlserv_flag"`
  16893. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16894. SpPsnType string `json:"sp_psn_type,omitempty"`
  16895. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16896. ClctGrde string `json:"clct_grde,omitempty"`
  16897. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16898. NwbFlag string `json:"nwb_flag,omitempty"`
  16899. InsuAdmdvs string `json:"insu_admdvs"`
  16900. EmpNo string `json:"emp_no,omitempty"`
  16901. EmpName string `json:"emp_name,omitempty"`
  16902. EmpType string `json:"emp_type,omitempty"`
  16903. EconType string `json:"econ_type,omitempty"`
  16904. AfilIndu string `json:"afil_indu,omitempty"`
  16905. AfilRlts string `json:"afil_rlts,omitempty"`
  16906. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16907. PayLoc string `json:"pay_loc,omitempty"`
  16908. FixmedinsCode string `json:"fixmedins_code"`
  16909. FixmedinsName string `json:"fixmedins_name"`
  16910. HospLv string `json:"hosp_lv,omitempty"`
  16911. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16912. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16913. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16914. Begndate string `json:"begndate"`
  16915. Enddate string `json:"enddate"`
  16916. SetlTime string `json:"setl_time"`
  16917. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16918. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16919. MedType string `json:"med_type"`
  16920. SetlType string `json:"setl_type,omitempty"`
  16921. ClrType string `json:"clr_type,omitempty"`
  16922. ClrWay string `json:"clr_way,omitempty"`
  16923. PsnSetlway string `json:"psn_setlway,omitempty"`
  16924. ClrOptins string `json:"clr_optins,omitempty"`
  16925. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16926. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16927. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16928. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16929. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16930. DedcStd float64 `json:"dedc_std,omitempty"`
  16931. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16932. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16933. HifpPay float64 `json:"hifp_pay,omitempty"`
  16934. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16935. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16936. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16937. HifesPay float64 `json:"hifes_pay,omitempty"`
  16938. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16939. HifobPay float64 `json:"hifob_pay,omitempty"`
  16940. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16941. MafPay float64 `json:"maf_pay,omitempty"`
  16942. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16943. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16944. PsnPay float64 `json:"psn_pay,omitempty"`
  16945. AcctPay float64 `json:"acct_pay,omitempty"`
  16946. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16947. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16948. Balc float64 `json:"balc,omitempty"`
  16949. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16950. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16951. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16952. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16953. Year string `json:"year,omitempty"`
  16954. DiseNo string `json:"dise_no,omitempty"`
  16955. DiseName string `json:"dise_name,omitempty"`
  16956. Invono string `json:"invono,omitempty"`
  16957. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16958. ValiFlag string `json:"vali_flag,omitempty"`
  16959. Memo string `json:"memo,omitempty"`
  16960. Rid string `json:"rid"`
  16961. UpdtTime string `json:"updt_time,omitempty"`
  16962. CrterID string `json:"crter_id,omitempty"`
  16963. CrterName string `json:"crter_name,omitempty"`
  16964. CrteTime string `json:"crte_time,omitempty"`
  16965. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  16966. OpterID string `json:"opter_id,omitempty"`
  16967. OpterName string `json:"opter_name,omitempty"`
  16968. OptTime string `json:"opt_time,omitempty"`
  16969. OptinsNo string `json:"optins_no,omitempty"`
  16970. PoolareaNo string `json:"poolarea_no,omitempty"`
  16971. } `json:"result"`
  16972. } `json:"output"`
  16973. RefmsgTime string `json:"refmsg_time"`
  16974. RespondTime string `json:"respond_time"`
  16975. Signtype interface{} `json:"signtype"`
  16976. WarnInfo interface{} `json:"warn_info"`
  16977. }
  16978. type Result5267 struct {
  16979. ErrMsg string `json:"err_msg"`
  16980. InfRefmsgid string `json:"inf_refmsgid"`
  16981. Infcode int64 `json:"infcode"`
  16982. Output struct {
  16983. PageInfo struct {
  16984. Size int `json:"size"`
  16985. RecordCounts int `json:"record_counts"`
  16986. } `json:"pageinfo"`
  16987. Result []struct {
  16988. SetlID string `json:"setl_id"`
  16989. ClrOptins string `json:"clr_optins"`
  16990. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16991. MdtrtID string `json:"mdtrt_id"`
  16992. InitSetlID string `json:"init_setl_id,omitempty"`
  16993. PsnNo string `json:"psn_no"`
  16994. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16995. PsnName string `json:"psn_name"`
  16996. PsnCertType string `json:"psn_cert_type"`
  16997. Certno string `json:"certno"`
  16998. Gend string `json:"gend,omitempty"`
  16999. Naty string `json:"naty,omitempty"`
  17000. Brdy string `json:"brdy,omitempty"`
  17001. Age float64 `json:"age,omitempty"`
  17002. Insutype string `json:"insutype,omitempty"`
  17003. PsnType string `json:"psn_type"`
  17004. CvlservFlag string `json:"cvlserv_flag"`
  17005. CvlservLv string `json:"cvlserv_lv,omitempty"`
  17006. SpPsnType string `json:"sp_psn_type,omitempty"`
  17007. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  17008. ClctGrde string `json:"clct_grde,omitempty"`
  17009. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  17010. NwbFlag string `json:"nwb_flag,omitempty"`
  17011. InsuAdmdvs string `json:"insu_admdvs"`
  17012. EmpNo string `json:"emp_no,omitempty"`
  17013. EmpName string `json:"emp_name,omitempty"`
  17014. EmpType string `json:"emp_type,omitempty"`
  17015. EconType string `json:"econ_type,omitempty"`
  17016. AfilIndu string `json:"afil_indu,omitempty"`
  17017. AfilRlts string `json:"afil_rlts,omitempty"`
  17018. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  17019. PayLoc string `json:"pay_loc,omitempty"`
  17020. FixmedinsCode string `json:"fixmedins_code"`
  17021. FixmedinsName string `json:"fixmedins_name"`
  17022. HospLv string `json:"hosp_lv,omitempty"`
  17023. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  17024. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  17025. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  17026. Begndate string `json:"begndate,omitempty"`
  17027. Enddate string `json:"enddate,omitempty"`
  17028. SetlTime string `json:"setl_time,omitempty"`
  17029. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  17030. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  17031. MedType string `json:"med_type"`
  17032. SetlType string `json:"setl_type,omitempty"`
  17033. ClrType string `json:"clr_type,omitempty"`
  17034. ClrWay string `json:"clr_way,omitempty"`
  17035. PsnSetlway string `json:"psn_setlway,omitempty"`
  17036. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  17037. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  17038. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  17039. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  17040. InscpAmt float64 `json:"inscp_amt,omitempty"`
  17041. DedcStd float64 `json:"dedc_std,omitempty"`
  17042. CrtDedc float64 `json:"crt_dedc,omitempty"`
  17043. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  17044. HifpPay float64 `json:"hifp_pay,omitempty"`
  17045. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  17046. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  17047. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  17048. HifesPay float64 `json:"hifes_pay,omitempty"`
  17049. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  17050. HifobPay float64 `json:"hifob_pay,omitempty"`
  17051. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  17052. MafPay float64 `json:"maf_pay,omitempty"`
  17053. OthfundPay float64 `json:"othfund_pay,omitempty"`
  17054. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  17055. PsnPay float64 `json:"psn_pay,omitempty"`
  17056. AcctPay float64 `json:"acct_pay,omitempty"`
  17057. CashPayamt float64 `json:"cash_payamt,omitempty"`
  17058. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  17059. Balc float64 `json:"balc,omitempty"`
  17060. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  17061. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  17062. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  17063. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  17064. Year string `json:"year,omitempty"`
  17065. DiseNo string `json:"dise_no,omitempty"`
  17066. DiseName string `json:"dise_name,omitempty"`
  17067. Invono string `json:"invono,omitempty"`
  17068. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  17069. Memo string `json:"memo,omitempty"`
  17070. UpdtTime string `json:"updt_time,omitempty"`
  17071. OpterID string `json:"opter_id,omitempty"`
  17072. OpterName string `json:"opter_name,omitempty"`
  17073. OptTime string `json:"opt_time,omitempty"`
  17074. OptinsNo string `json:"optins_no,omitempty"`
  17075. PoolareaNo string `json:"poolarea_no,omitempty"`
  17076. } `json:"result"`
  17077. } `json:"output"`
  17078. RefmsgTime string `json:"refmsg_time"`
  17079. RespondTime string `json:"respond_time"`
  17080. Signtype interface{} `json:"signtype"`
  17081. WarnInfo interface{} `json:"warn_info"`
  17082. }
  17083. // type Autogenerated struct {
  17084. // Output struct {
  17085. // Setlinfo struct {
  17086. // SetlTime string `json:"setl_time"`
  17087. // CvlservPay float64 `json:"cvlserv_pay"`
  17088. // Year string `json:"year"`
  17089. // MedType string `json:"med_type"`
  17090. // PsnPay float64 `json:"psn_pay"`
  17091. // OpterID string `json:"opter_id"`
  17092. // Begndate string `json:"begndate"`
  17093. // FlxempeFlag string `json:"flxempe_flag"`
  17094. // HifmiPay float64 `json:"hifmi_pay"`
  17095. // PsnNo string `json:"psn_no"`
  17096. // ActPayDedc float64 `json:"act_pay_dedc"`
  17097. // MedinsSetlID interface{} `json:"medins_setl_id"`
  17098. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  17099. // ClrWay string `json:"clr_way"`
  17100. // OthPay float64 `json:"oth_pay"`
  17101. // Gend string `json:"gend"`
  17102. // MdtrtID string `json:"mdtrt_id"`
  17103. // AcctPay float64 `json:"acct_pay"`
  17104. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  17105. // Insutype string `json:"insutype"`
  17106. // Invono interface{} `json:"invono"`
  17107. // Enddate string `json:"enddate"`
  17108. // CashPayamt float64 `json:"cash_payamt"`
  17109. // PsnType string `json:"psn_type"`
  17110. // FixmedinsName string `json:"fixmedins_name"`
  17111. // HifpPay float64 `json:"hifp_pay"`
  17112. // NewFlag interface{} `json:"new_flag"`
  17113. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17114. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  17115. // PayLoc string `json:"pay_loc"`
  17116. // ClrType string `json:"clr_type"`
  17117. // RefdSetlFlag string `json:"refd_setl_flag"`
  17118. // CvlservFlag string `json:"cvlserv_flag"`
  17119. // EmpName string `json:"emp_name"`
  17120. // Brdy string `json:"brdy"`
  17121. // Naty string `json:"naty"`
  17122. // Certno string `json:"certno"`
  17123. // DiseCode string `json:"dise_code"`
  17124. // FixmedinsCode string `json:"fixmedins_code"`
  17125. // DedcHospLv string `json:"dedc_hosp_lv"`
  17126. // OpterName string `json:"opter_name"`
  17127. // Balc float64 `json:"balc"`
  17128. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  17129. // PsnCertType string `json:"psn_cert_type"`
  17130. // HifobPay float64 `json:"hifob_pay"`
  17131. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  17132. // HifesPay float64 `json:"hifes_pay"`
  17133. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17134. // OptTime string `json:"opt_time"`
  17135. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17136. // SetlID string `json:"setl_id"`
  17137. // MafPay float64 `json:"maf_pay"`
  17138. // PsnName string `json:"psn_name"`
  17139. // InsuOptins interface{} `json:"insu_optins"`
  17140. // PrefFundPay interface{} `json:"pref_fund_pay"`
  17141. // ClrOptins string `json:"clr_optins"`
  17142. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  17143. // DiseName string `json:"dise_name"`
  17144. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  17145. // Age float64 `json:"age"`
  17146. // DtrtCertType string `json:"dtrt_cert_type"`
  17147. // HospLv string `json:"hosp_lv"`
  17148. // } `json:"setlinfo"`
  17149. // Setldetail []struct {
  17150. // FundPayType string `json:"fund_pay_type"`
  17151. // FundPayamt float64 `json:"fund_payamt"`
  17152. // SetlProcInfo interface{} `json:"setl_proc_info"`
  17153. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  17154. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  17155. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  17156. // PrefFundPay interface{} `json:"pref_fund_pay"`
  17157. // } `json:"setldetail"`
  17158. // } `json:"output"`
  17159. // Infcode int `json:"infcode"`
  17160. // WarnMsg interface{} `json:"warn_msg"`
  17161. // Cainfo interface{} `json:"cainfo"`
  17162. // ErrMsg interface{} `json:"err_msg"`
  17163. // RefmsgTime string `json:"refmsg_time"`
  17164. // Signtype interface{} `json:"signtype"`
  17165. // RespondTime string `json:"respond_time"`
  17166. // InfRefmsgid string `json:"inf_refmsgid"`
  17167. // }
  17168. type Result002 struct {
  17169. Cainfo interface{} `json:"cainfo"`
  17170. ErrMsg string `json:"err_msg"`
  17171. InfRefmsgid string `json:"inf_refmsgid"`
  17172. Infcode int64 `json:"infcode"`
  17173. Output struct {
  17174. RxFile string `json:"rx_file"`
  17175. SignDigest string `json:"sign_digest"`
  17176. SignCertSn string `json:"sign_cert_sn"`
  17177. SignCertDn string `json:"sign_cert_dn"`
  17178. } `json:"output"`
  17179. RefmsgTime string `json:"refmsg_time"`
  17180. RespondTime string `json:"respond_time"`
  17181. Signtype interface{} `json:"signtype"`
  17182. WarnMsg interface{} `json:"warn_msg"`
  17183. }
  17184. type Result003 struct {
  17185. Cainfo interface{} `json:"cainfo"`
  17186. ErrMsg string `json:"err_msg"`
  17187. InfRefmsgid string `json:"inf_refmsgid"`
  17188. Infcode int64 `json:"infcode"`
  17189. Output struct {
  17190. HiRxno string `json:"hi_rxno"`
  17191. RxStasCodg string `json:"rx_stas_codg"`
  17192. RxStasName string `json:"rx_stas_name"`
  17193. } `json:"output"`
  17194. RefmsgTime string `json:"refmsg_time"`
  17195. RespondTime string `json:"respond_time"`
  17196. Signtype interface{} `json:"signtype"`
  17197. WarnMsg interface{} `json:"warn_msg"`
  17198. }
  17199. type ResultEleven struct {
  17200. Cainfo string `json:"cainfo"`
  17201. ErrMsg string `json:"err_msg"`
  17202. InfRefmsgid string `json:"inf_refmsgid"`
  17203. Infcode int64 `json:"infcode"`
  17204. Output struct {
  17205. Setlinfo struct {
  17206. SetlTime string `json:"setl_time"`
  17207. CvlservPay float64 `json:"cvlserv_pay"`
  17208. Year string `json:"year"`
  17209. MedType string `json:"med_type"`
  17210. PsnPay float64 `json:"psn_pay"`
  17211. OpterID string `json:"opter_id"`
  17212. Begndate string `json:"begndate"`
  17213. FlxempeFlag string `json:"flxempe_flag"`
  17214. HifmiPay float64 `json:"hifmi_pay"`
  17215. PsnNo string `json:"psn_no"`
  17216. ActPayDedc float64 `json:"act_pay_dedc"`
  17217. MedinsSetlID interface{} `json:"medins_setl_id"`
  17218. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  17219. ClrWay string `json:"clr_way"`
  17220. OthPay float64 `json:"oth_pay"`
  17221. Gend string `json:"gend"`
  17222. MdtrtID string `json:"mdtrt_id"`
  17223. AcctPay float64 `json:"acct_pay"`
  17224. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17225. Insutype string `json:"insutype"`
  17226. Invono interface{} `json:"invono"`
  17227. Enddate string `json:"enddate"`
  17228. CashPayamt float64 `json:"cash_payamt"`
  17229. PsnType string `json:"psn_type"`
  17230. FixmedinsName string `json:"fixmedins_name"`
  17231. HifpPay float64 `json:"hifp_pay"`
  17232. NewFlag interface{} `json:"new_flag"`
  17233. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17234. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17235. PayLoc string `json:"pay_loc"`
  17236. ClrType string `json:"clr_type"`
  17237. RefdSetlFlag string `json:"refd_setl_flag"`
  17238. CvlservFlag string `json:"cvlserv_flag"`
  17239. EmpName string `json:"emp_name"`
  17240. Brdy string `json:"brdy"`
  17241. Naty string `json:"naty"`
  17242. Certno string `json:"certno"`
  17243. DiseCode string `json:"dise_code"`
  17244. FixmedinsCode string `json:"fixmedins_code"`
  17245. DedcHospLv string `json:"dedc_hosp_lv"`
  17246. OpterName string `json:"opter_name"`
  17247. Balc float64 `json:"balc"`
  17248. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  17249. PsnCertType string `json:"psn_cert_type"`
  17250. HifobPay float64 `json:"hifob_pay"`
  17251. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17252. HifesPay float64 `json:"hifes_pay"`
  17253. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17254. OptTime string `json:"opt_time"`
  17255. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17256. SetlID string `json:"setl_id"`
  17257. MafPay float64 `json:"maf_pay"`
  17258. PsnName string `json:"psn_name"`
  17259. InsuOptins interface{} `json:"insu_optins"`
  17260. PrefFundPay interface{} `json:"pref_fund_pay"`
  17261. ClrOptins string `json:"clr_optins"`
  17262. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  17263. DiseName string `json:"dise_name"`
  17264. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  17265. Age float64 `json:"age"`
  17266. DtrtCertType string `json:"dtrt_cert_type"`
  17267. HospLv string `json:"hosp_lv"`
  17268. PsnCashPay float64 `json:"psn_cash_pay"`
  17269. } `json:"setlinfo"`
  17270. } `json:"output"`
  17271. RefmsgTime string `json:"refmsg_time"`
  17272. RespondTime string `json:"respond_time"`
  17273. Signtype interface{} `json:"signtype"`
  17274. WarnMsg interface{} `json:"warn_msg"`
  17275. }
  17276. type ResultElevenah struct {
  17277. Cainfo string `json:"cainfo"`
  17278. ErrMsg string `json:"err_msg"`
  17279. InfRefmsgid string `json:"inf_refmsgid"`
  17280. Infcode int64 `json:"infcode"`
  17281. Output struct {
  17282. Setlinfo struct {
  17283. SetlTime int64 `json:"setl_time"`
  17284. CvlservPay float64 `json:"cvlserv_pay"`
  17285. Year string `json:"year"`
  17286. MedType string `json:"med_type"`
  17287. PsnPay float64 `json:"psn_pay"`
  17288. OpterID string `json:"opter_id"`
  17289. Begndate int64 `json:"begndate"`
  17290. FlxempeFlag string `json:"flxempe_flag"`
  17291. HifmiPay float64 `json:"hifmi_pay"`
  17292. PsnNo string `json:"psn_no"`
  17293. ActPayDedc float64 `json:"act_pay_dedc"`
  17294. MedinsSetlID interface{} `json:"medins_setl_id"`
  17295. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  17296. ClrWay string `json:"clr_way"`
  17297. OthPay float64 `json:"oth_pay"`
  17298. Gend string `json:"gend"`
  17299. MdtrtID string `json:"mdtrt_id"`
  17300. AcctPay float64 `json:"acct_pay"`
  17301. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17302. Insutype string `json:"insutype"`
  17303. Invono interface{} `json:"invono"`
  17304. Enddate int64 `json:"enddate"`
  17305. CashPayamt float64 `json:"cash_payamt"`
  17306. PsnType string `json:"psn_type"`
  17307. FixmedinsName string `json:"fixmedins_name"`
  17308. HifpPay float64 `json:"hifp_pay"`
  17309. NewFlag interface{} `json:"new_flag"`
  17310. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17311. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17312. PayLoc string `json:"pay_loc"`
  17313. ClrType string `json:"clr_type"`
  17314. RefdSetlFlag string `json:"refd_setl_flag"`
  17315. CvlservFlag string `json:"cvlserv_flag"`
  17316. EmpName string `json:"emp_name"`
  17317. Brdy int64 `json:"brdy"`
  17318. Naty string `json:"naty"`
  17319. Certno string `json:"certno"`
  17320. DiseCode string `json:"dise_code"`
  17321. FixmedinsCode string `json:"fixmedins_code"`
  17322. DedcHospLv string `json:"dedc_hosp_lv"`
  17323. OpterName string `json:"opter_name"`
  17324. Balc float64 `json:"balc"`
  17325. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  17326. PsnCertType string `json:"psn_cert_type"`
  17327. HifobPay float64 `json:"hifob_pay"`
  17328. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17329. HifesPay float64 `json:"hifes_pay"`
  17330. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17331. OptTime int64 `json:"opt_time"`
  17332. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17333. SetlID string `json:"setl_id"`
  17334. MafPay float64 `json:"maf_pay"`
  17335. PsnName string `json:"psn_name"`
  17336. InsuOptins interface{} `json:"insu_optins"`
  17337. PrefFundPay interface{} `json:"pref_fund_pay"`
  17338. ClrOptins string `json:"clr_optins"`
  17339. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  17340. DiseName string `json:"dise_name"`
  17341. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  17342. Age float64 `json:"age"`
  17343. DtrtCertType string `json:"dtrt_cert_type"`
  17344. HospLv string `json:"hosp_lv"`
  17345. PsnCashPay float64 `json:"psn_cash_pay"`
  17346. } `json:"setlinfo"`
  17347. } `json:"output"`
  17348. RefmsgTime string `json:"refmsg_time"`
  17349. RespondTime string `json:"respond_time"`
  17350. Signtype interface{} `json:"signtype"`
  17351. WarnMsg interface{} `json:"warn_msg"`
  17352. }
  17353. type ResultEleven10265 struct {
  17354. Cainfo string `json:"cainfo"`
  17355. ErrMsg string `json:"err_msg"`
  17356. InfRefmsgid string `json:"inf_refmsgid"`
  17357. Infcode string `json:"infcode"`
  17358. Output struct {
  17359. Setlinfo struct {
  17360. SetlTime string `json:"setl_time"`
  17361. CvlservPay float64 `json:"cvlserv_pay"`
  17362. Year string `json:"year"`
  17363. MedType string `json:"med_type"`
  17364. PsnPay float64 `json:"psn_pay"`
  17365. OpterID string `json:"opter_id"`
  17366. Begndate string `json:"begndate"`
  17367. FlxempeFlag string `json:"flxempe_flag"`
  17368. HifmiPay float64 `json:"hifmi_pay"`
  17369. PsnNo string `json:"psn_no"`
  17370. ActPayDedc float64 `json:"act_pay_dedc"`
  17371. MedinsSetlID interface{} `json:"medins_setl_id"`
  17372. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  17373. ClrWay string `json:"clr_way"`
  17374. OthPay float64 `json:"oth_pay"`
  17375. Gend string `json:"gend"`
  17376. MdtrtID string `json:"mdtrt_id"`
  17377. AcctPay float64 `json:"acct_pay"`
  17378. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17379. Insutype string `json:"insutype"`
  17380. Invono interface{} `json:"invono"`
  17381. Enddate string `json:"enddate"`
  17382. CashPayamt float64 `json:"cash_payamt"`
  17383. PsnType string `json:"psn_type"`
  17384. FixmedinsName string `json:"fixmedins_name"`
  17385. HifpPay float64 `json:"hifp_pay"`
  17386. NewFlag interface{} `json:"new_flag"`
  17387. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17388. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17389. PayLoc string `json:"pay_loc"`
  17390. ClrType string `json:"clr_type"`
  17391. RefdSetlFlag string `json:"refd_setl_flag"`
  17392. CvlservFlag string `json:"cvlserv_flag"`
  17393. EmpName string `json:"emp_name"`
  17394. Brdy string `json:"brdy"`
  17395. Naty string `json:"naty"`
  17396. Certno string `json:"certno"`
  17397. DiseCode string `json:"dise_code"`
  17398. FixmedinsCode string `json:"fixmedins_code"`
  17399. DedcHospLv string `json:"dedc_hosp_lv"`
  17400. OpterName string `json:"opter_name"`
  17401. Balc float64 `json:"balc"`
  17402. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  17403. PsnCertType string `json:"psn_cert_type"`
  17404. HifobPay float64 `json:"hifob_pay"`
  17405. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17406. HifesPay float64 `json:"hifes_pay"`
  17407. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17408. OptTime string `json:"opt_time"`
  17409. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17410. SetlID string `json:"setl_id"`
  17411. MafPay float64 `json:"maf_pay"`
  17412. PsnName string `json:"psn_name"`
  17413. InsuOptins interface{} `json:"insu_optins"`
  17414. PrefFundPay interface{} `json:"pref_fund_pay"`
  17415. ClrOptins string `json:"clr_optins"`
  17416. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  17417. DiseName string `json:"dise_name"`
  17418. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  17419. Age float64 `json:"age"`
  17420. DtrtCertType string `json:"dtrt_cert_type"`
  17421. HospLv string `json:"hosp_lv"`
  17422. PsnCashPay float64 `json:"psn_cash_pay"`
  17423. } `json:"setlinfo"`
  17424. } `json:"output"`
  17425. RefmsgTime string `json:"refmsg_time"`
  17426. RespondTime string `json:"respond_time"`
  17427. Signtype interface{} `json:"signtype"`
  17428. WarnMsg interface{} `json:"warn_msg"`
  17429. }
  17430. type ResultTwelve struct {
  17431. Cainfo string `json:"cainfo"`
  17432. ErrMsg string `json:"err_msg"`
  17433. InfRefmsgid string `json:"inf_refmsgid"`
  17434. Infcode int64 `json:"infcode"`
  17435. Output struct {
  17436. MdtrtId string `json:"mdtrt_id"`
  17437. ChrgBchno string `json:"chrg_bchno"`
  17438. PsnNo string `json:"psn_no"`
  17439. } `json:"output"`
  17440. RefmsgTime string `json:"refmsg_time"`
  17441. RespondTime string `json:"respond_time"`
  17442. Signtype interface{} `json:"signtype"`
  17443. WarnMsg interface{} `json:"warn_msg"`
  17444. }
  17445. type ResultThirteen struct {
  17446. ErrMsg string `json:"err_msg"`
  17447. InfRefmsgid string `json:"inf_refmsgid"`
  17448. Infcode int64 `json:"infcode"`
  17449. Output struct {
  17450. Result struct {
  17451. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  17452. } `json:"result"`
  17453. } `json:"output"`
  17454. RefmsgTime string `json:"refmsg_time"`
  17455. RespondTime string `json:"respond_time"`
  17456. Signtype interface{} `json:"signtype"`
  17457. WarnInfo interface{} `json:"warn_info"`
  17458. }
  17459. type ResultThirteen10265 struct {
  17460. ErrMsg string `json:"err_msg"`
  17461. InfRefmsgid string `json:"inf_refmsgid"`
  17462. Infcode string `json:"infcode"`
  17463. Output struct {
  17464. Result struct {
  17465. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  17466. } `json:"result"`
  17467. } `json:"output"`
  17468. RefmsgTime string `json:"refmsg_time"`
  17469. RespondTime string `json:"respond_time"`
  17470. Signtype interface{} `json:"signtype"`
  17471. WarnInfo interface{} `json:"warn_info"`
  17472. }
  17473. type ResultFourteen struct {
  17474. ErrMsg string `json:"err_msg"`
  17475. InfRefmsgid string `json:"inf_refmsgid"`
  17476. Infcode int64 `json:"infcode"`
  17477. Output struct {
  17478. } `json:"output"`
  17479. RefmsgTime string `json:"refmsg_time"`
  17480. RespondTime string `json:"respond_time"`
  17481. Signtype interface{} `json:"signtype"`
  17482. WarnInfo interface{} `json:"warn_info"`
  17483. }
  17484. type ResultCFYLJG001 struct {
  17485. ErrMsg string `json:"err_msg"`
  17486. InfRefmsgid string `json:"inf_refmsgid"`
  17487. Infcode int64 `json:"infcode"`
  17488. Output struct {
  17489. RxTraceCode string `json:"rx_trace_code"`
  17490. HiRxno string `json:"hi_rxno"`
  17491. } `json:"output"`
  17492. RefmsgTime string `json:"refmsg_time"`
  17493. RespondTime string `json:"respond_time"`
  17494. Signtype interface{} `json:"signtype"`
  17495. WarnInfo interface{} `json:"warn_info"`
  17496. }
  17497. type ResultCFYLJG007 struct {
  17498. ErrMsg string `json:"err_msg"`
  17499. InfRefmsgid string `json:"inf_refmsgid"`
  17500. Infcode int64 `json:"infcode"`
  17501. Output struct {
  17502. HiRxno string `json:"hi_rxno"`
  17503. RxStasName string `json:"rx_stas_name"`
  17504. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  17505. Seltdelts []interface{} `json:"seltdelts"`
  17506. RxUsedStasName string `json:"rx_used_stas_name"`
  17507. RxStasCodg string `json:"rx_stas_codg"`
  17508. } `json:"output"`
  17509. RefmsgTime string `json:"refmsg_time"`
  17510. RespondTime string `json:"respond_time"`
  17511. Signtype interface{} `json:"signtype"`
  17512. WarnInfo interface{} `json:"warn_info"`
  17513. }
  17514. type ResultCFYLJG002 struct {
  17515. ErrMsg string `json:"err_msg"`
  17516. InfRefmsgid string `json:"inf_refmsgid"`
  17517. Infcode int64 `json:"infcode"`
  17518. Output struct {
  17519. RxFile string `json:"rx_file"`
  17520. SignDigest string `json:"sign_digest"`
  17521. SignCertSn string `json:"sign_cert_sn"`
  17522. SignCertDn string `json:"sign_cert_dn"`
  17523. } `json:"output"`
  17524. RefmsgTime string `json:"refmsg_time"`
  17525. RespondTime string `json:"respond_time"`
  17526. Signtype interface{} `json:"signtype"`
  17527. WarnInfo interface{} `json:"warn_info"`
  17528. }
  17529. type ResultCFYLJG003 struct {
  17530. ErrMsg string `json:"err_msg"`
  17531. InfRefmsgid string `json:"inf_refmsgid"`
  17532. Infcode int64 `json:"infcode"`
  17533. Output struct {
  17534. HiRxno string `json:"hi_rxno"`
  17535. RxStasCodg string `json:"rx_stas_codg"`
  17536. RxStasName string `json:"rx_stas_name"`
  17537. } `json:"output"`
  17538. RefmsgTime string `json:"refmsg_time"`
  17539. RespondTime string `json:"respond_time"`
  17540. Signtype interface{} `json:"signtype"`
  17541. WarnInfo interface{} `json:"warn_info"`
  17542. }
  17543. type ResultCFYLJG004 struct {
  17544. ErrMsg string `json:"err_msg"`
  17545. InfRefmsgid string `json:"inf_refmsgid"`
  17546. Infcode int64 `json:"infcode"`
  17547. Output struct {
  17548. HiRxno string `json:"hi_rxno"`
  17549. RxStasCodg string `json:"rx_stas_codg"`
  17550. RxStasName string `json:"rx_stas_name"`
  17551. } `json:"output"`
  17552. RefmsgTime string `json:"refmsg_time"`
  17553. RespondTime string `json:"respond_time"`
  17554. Signtype interface{} `json:"signtype"`
  17555. WarnInfo interface{} `json:"warn_info"`
  17556. }
  17557. type ResultCFYLJG008 struct {
  17558. ErrMsg string `json:"err_msg"`
  17559. InfRefmsgid string `json:"inf_refmsgid"`
  17560. Infcode int64 `json:"infcode"`
  17561. Output struct {
  17562. PoolareaNo string `json:"poolareaNo"`
  17563. AdmdvsName string `json:"admdvsName"`
  17564. Count string `json:"count"`
  17565. } `json:"output"`
  17566. RefmsgTime string `json:"refmsg_time"`
  17567. RespondTime string `json:"respond_time"`
  17568. Signtype interface{} `json:"signtype"`
  17569. WarnInfo interface{} `json:"warn_info"`
  17570. }
  17571. type ResultCFYLJG005 struct {
  17572. ErrMsg string `json:"err_msg"`
  17573. InfRefmsgid string `json:"inf_refmsgid"`
  17574. Infcode int64 `json:"infcode"`
  17575. Output struct {
  17576. HiRxNo string `json:"hi_rxno"`
  17577. FixMedinsCode string `json:"fixmedins_code"`
  17578. FixMedinsName string `json:"fixmedins_name"`
  17579. RxStasCodg string `json:"rx_stas_codg"`
  17580. RxStasName string `json:"rx_stas_name"`
  17581. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  17582. RxUserdStasName string `json:"rx_userd_stas_name"`
  17583. PrscTime string `json:"prsc_time"`
  17584. RxDrugCnt float64 `json:"rx_drug_cnt"`
  17585. RxUsedWayCodg string `json:"rx_used_way_codg"`
  17586. RxUsedWayName string `json:"rx_used_way_name"`
  17587. RxFrquCodg string `json:"rx_frqu_codg"`
  17588. RxFrquName string `json:"rx_frqu_name"`
  17589. RxDosunt string `json:"rx_dosunt"`
  17590. RxDoscnt float64 `json:"rx_doscnt"`
  17591. RxDrordDscr string `json:"rx_drord_dscr"`
  17592. ValiDays int64 `json:"vali_days"`
  17593. ValiEndTime string `json:"vali_end_time"`
  17594. ReptFlag string `json:"rept_flag"`
  17595. MaxReptCnt int64 `json:"max_rept_cnt"`
  17596. ReptdCnt int64 `json:"reptd_cnt"`
  17597. MinInrvDays int64 `json:"min_inrv_days"`
  17598. RxTypeCode string `json:"rx_type_code"`
  17599. RxTypeName string `json:"rx_type_name"`
  17600. LongRxFlag string `json:"long_rx_flag"`
  17601. RxDetlList []struct {
  17602. MedListCodg string `json:"med_list_codg"`
  17603. MedinsListCodg string `json:"medins_list_codg"`
  17604. HospPrepFlag string `json:"hosp_prep_flag"`
  17605. RxItemTypeCode string `json:"rx_item_type_code"`
  17606. RxItemTypeName string `json:"rx_item_type_name"`
  17607. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  17608. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  17609. TcmHerbFoote string `json:"tcmherb_foote"`
  17610. MednTypeCode string `json:"medn_type_code"`
  17611. MednTypeName string `json:"medn_type_name"`
  17612. MainMedcFlag string `json:"main_medc_flag"`
  17613. UrgtFlag string `json:"urgt_flag"`
  17614. BasMednFlag string `json:"bas_medn_flag"`
  17615. ImpDrugFlag string `json:"imp_drug_flag"`
  17616. ProdBarc string `json:"prod_barc"`
  17617. DrugProdname string `json:"drug_prodname"`
  17618. GennameCodg string `json:"genname_codg"`
  17619. DrugGenname string `json:"drug_genname"`
  17620. DrugDosform string `json:"drug_dosform"`
  17621. DrugSpec string `json:"drug_spec"`
  17622. PrdrName string `json:"prdr_name"`
  17623. MedcWayCodg string `json:"medc_way_codg"`
  17624. MedcWayDscr string `json:"medc_way_dscr"`
  17625. MedcBegntime string `json:"medc_begntime"`
  17626. MedcEndtime string `json:"medc_endtime"`
  17627. MedcDays float64 `json:"medc_days"`
  17628. DrugPric float64 `json:"drug_pric"`
  17629. DrugSumamt float64 `json:"drug_sumamt"`
  17630. DrugCnt float64 `json:"drug_cnt"`
  17631. DrugDosunt string `json:"drug_dosunt"`
  17632. SinDoscnt float64 `json:"sin_doscnt"`
  17633. SinDosunt string `json:"sin_dosunt"`
  17634. UsedFrquCodg string `json:"used_frqu_codg"`
  17635. UsedFrquName string `json:"used_frqu_name"`
  17636. DrugTotlcnt string `json:"drug_totlcnt"`
  17637. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  17638. DiseCodg string `json:"dise_codg"`
  17639. HospApprFlag string `json:"hosp_appr_flag"`
  17640. } `json:"rx_detl_list"`
  17641. RxOtpinfo struct {
  17642. MedType string `json:"med_type"`
  17643. IptOtpNo string `json:"ipt_otp_no"`
  17644. OtpIptFlag string `json:"otp_ipt_flag"`
  17645. PatnName string `json:"patn_name"`
  17646. PatnAge float64 `json:"patn_age"`
  17647. PatnHgt float64 `json:"patn_hgt"`
  17648. PatnWt float64 `json:"patn_wt"`
  17649. Gend string `json:"gend"`
  17650. GesoVal float64 `json:"geso_val"`
  17651. NwbFlag string `json:"nwb_flag"`
  17652. NwbAge string `json:"nwb_age"`
  17653. SuckPrdFlag string `json:"suck_prd_flag"`
  17654. AlgsHis string `json:"algs_his"`
  17655. Insutype string `json:"insutype"`
  17656. PrscDeptName string `json:"prsc_dept_name"`
  17657. PrscDrName string `json:"prsc_dr_name"`
  17658. PharName string `json:"phar_name"`
  17659. PharChkTime string `json:"phar_chk_time"`
  17660. MdtrtTime string `json:"mdtrt_time"`
  17661. DiseCodg string `json:"dise_codg"`
  17662. DiseName string `json:"dise_name"`
  17663. SpDiseFlag string `json:"sp_dise_flag"`
  17664. MaindiagCode string `json:"maindiag_code"`
  17665. MaindiagName string `json:"maindiag_name"`
  17666. DiseCondDscr string `json:"dise_cond_dscr"`
  17667. FstdiagFlag string `json:"fstdiag_flag"`
  17668. } `json:"rx_otpinfo"`
  17669. RxDiseList []struct {
  17670. DiagType string `json:"diag_type"`
  17671. MaindiagFlag string `json:"maindiag_flag"`
  17672. DiagSrtNo string `json:"diag_srt_no"`
  17673. DiagCode string `json:"diag_code"`
  17674. DiagName string `json:"diag_name"`
  17675. DiagDept string `json:"diag_dept"`
  17676. DiagDrNo string `json:"diag_dr_no"`
  17677. DiagDrName string `json:"diag_dr_name"`
  17678. DiagTime string `json:"diag_time"`
  17679. TcmDiseCode string `json:"tcm_dise_code"`
  17680. TcmDiseName string `json:"tcm_dise_name"`
  17681. TcmSympCode string `json:"tcmsymp_code"`
  17682. TcmSymp string `json:"tcmsymp"`
  17683. } `json:"rx_dise_list"`
  17684. } `json:"output"`
  17685. RefmsgTime string `json:"refmsg_time"`
  17686. RespondTime string `json:"respond_time"`
  17687. Signtype interface{} `json:"signtype"`
  17688. WarnInfo interface{} `json:"warn_info"`
  17689. }
  17690. type ResultCFYLJG006 struct {
  17691. ErrMsg string `json:"err_msg"`
  17692. InfRefmsgid string `json:"inf_refmsgid"`
  17693. Infcode int64 `json:"infcode"`
  17694. Output struct {
  17695. HiRxNo string `json:"hi_rxno"`
  17696. PharCode string `json:"phar_code"`
  17697. PharName string `json:"phar_name"`
  17698. RxChkOpnn string `json:"rx_chk_opnn"`
  17699. RxChkTime string `json:"rx_chk_time"`
  17700. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  17701. RxChkStasName string `json:"rx_chk_stas_name"`
  17702. RxStasCodg string `json:"rx_stas_codg"`
  17703. RxStasName string `json:"rx_stas_name"`
  17704. } `json:"output"`
  17705. RefmsgTime string `json:"refmsg_time"`
  17706. RespondTime string `json:"respond_time"`
  17707. Signtype interface{} `json:"signtype"`
  17708. WarnInfo interface{} `json:"warn_info"`
  17709. }
  17710. type ResultFourteen10265 struct {
  17711. ErrMsg string `json:"err_msg"`
  17712. InfRefmsgid string `json:"inf_refmsgid"`
  17713. Infcode string `json:"infcode"`
  17714. Output struct {
  17715. } `json:"output"`
  17716. RefmsgTime string `json:"refmsg_time"`
  17717. RespondTime string `json:"respond_time"`
  17718. Signtype interface{} `json:"signtype"`
  17719. WarnInfo interface{} `json:"warn_info"`
  17720. }
  17721. type ResultSixteen struct {
  17722. Cainfo string `json:"cainfo"`
  17723. ErrMsg string `json:"err_msg"`
  17724. InfRefmsgid string `json:"inf_refmsgid"`
  17725. Infcode int64 `json:"infcode"`
  17726. Output struct {
  17727. Setlinfo struct {
  17728. MdtrtID string `json:"mdtrt_id"`
  17729. SetlID string `json:"setl_id"`
  17730. ClrOptins string `json:"clr_optins"`
  17731. SetlTime string `json:"setl_time"`
  17732. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17733. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17734. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17735. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17736. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17737. ActPayDedc float64 `json:"act_pay_dedc"`
  17738. HifpPay float64 `json:"hifp_pay"`
  17739. PoolPropSe float64 `json:"pool_prop_selfpay"`
  17740. Lfpay float64 `json:"selfpay"`
  17741. CvlservPay float64 `json:"cvlserv_pay"`
  17742. HifesPay float64 `json:"hifes_pay"`
  17743. HifmiPay float64 `json:"hifmi_pay"`
  17744. HifobPay float64 `json:"hifob_pay"`
  17745. MafPay float64 `json:"maf_pay"`
  17746. OthPay float64 `json:"oth_pay"`
  17747. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17748. PsnPartAmt float64 `json:"psn_part_amt"`
  17749. AcctPay float64 `json:"acct_pay"`
  17750. Balc float64 `json:"balc"`
  17751. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  17752. HospPartAmt float64 `json:"hosp_part_amt"`
  17753. MedinsSetlID string `json:"medins_setl_id"`
  17754. PdnCashPay string `json:"pdn_cash_pay"`
  17755. } `json:"setlinfo"`
  17756. } `json:"output"`
  17757. RefmsgTime string `json:"refmsg_time"`
  17758. RespondTime string `json:"respond_time"`
  17759. Signtype interface{} `json:"signtype"`
  17760. WarnMsg interface{} `json:"warn_msg"`
  17761. }
  17762. type ResultSixteen10265 struct {
  17763. Cainfo string `json:"cainfo"`
  17764. ErrMsg string `json:"err_msg"`
  17765. InfRefmsgid string `json:"inf_refmsgid"`
  17766. Infcode string `json:"infcode"`
  17767. Output struct {
  17768. Setlinfo struct {
  17769. MdtrtID string `json:"mdtrt_id"`
  17770. SetlID string `json:"setl_id"`
  17771. ClrOptins string `json:"clr_optins"`
  17772. SetlTime string `json:"setl_time"`
  17773. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17774. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17775. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17776. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17777. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17778. ActPayDedc float64 `json:"act_pay_dedc"`
  17779. HifpPay float64 `json:"hifp_pay"`
  17780. PoolPropSe float64 `json:"pool_prop_selfpay"`
  17781. Lfpay float64 `json:"selfpay"`
  17782. CvlservPay float64 `json:"cvlserv_pay"`
  17783. HifesPay float64 `json:"hifes_pay"`
  17784. HifmiPay float64 `json:"hifmi_pay"`
  17785. HifobPay float64 `json:"hifob_pay"`
  17786. MafPay float64 `json:"maf_pay"`
  17787. OthPay float64 `json:"oth_pay"`
  17788. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17789. PsnPartAmt float64 `json:"psn_part_amt"`
  17790. AcctPay float64 `json:"acct_pay"`
  17791. Balc float64 `json:"balc"`
  17792. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  17793. HospPartAmt float64 `json:"hosp_part_amt"`
  17794. MedinsSetlID string `json:"medins_setl_id"`
  17795. PdnCashPay string `json:"pdn_cash_pay"`
  17796. } `json:"setlinfo"`
  17797. } `json:"output"`
  17798. RefmsgTime string `json:"refmsg_time"`
  17799. RespondTime string `json:"respond_time"`
  17800. Signtype interface{} `json:"signtype"`
  17801. WarnMsg interface{} `json:"warn_msg"`
  17802. }
  17803. type ResultSixteen10265Two struct {
  17804. Cainfo string `json:"cainfo"`
  17805. ErrMsg string `json:"err_msg"`
  17806. InfRefmsgid string `json:"inf_refmsgid"`
  17807. Infcode string `json:"infcode"`
  17808. Output struct {
  17809. Setlinfo interface{} `json:"setlinfo"`
  17810. } `json:"output"`
  17811. RefmsgTime string `json:"refmsg_time"`
  17812. RespondTime string `json:"respond_time"`
  17813. Signtype interface{} `json:"signtype"`
  17814. WarnMsg interface{} `json:"warn_msg"`
  17815. }
  17816. type ResultgzSixteen10265Two struct {
  17817. Cainfo string `json:"cainfo"`
  17818. ErrMsg string `json:"err_msg"`
  17819. InfRefmsgid string `json:"inf_refmsgid"`
  17820. Infcode int64 `json:"infcode"`
  17821. Output struct {
  17822. Setlinfo interface{} `json:"setlinfo"`
  17823. } `json:"output"`
  17824. RefmsgTime string `json:"refmsg_time"`
  17825. RespondTime string `json:"respond_time"`
  17826. Signtype interface{} `json:"signtype"`
  17827. WarnMsg interface{} `json:"warn_msg"`
  17828. }
  17829. type ResultSeventeen struct {
  17830. ErrMsg string `json:"err_msg"`
  17831. InfRefmsgid string `json:"inf_refmsgid"`
  17832. Infcode int64 `json:"infcode"`
  17833. Output struct {
  17834. SetlListId string `json:"setl_list_id"`
  17835. } `json:"output"`
  17836. RefmsgTime string `json:"refmsg_time"`
  17837. RespondTime string `json:"respond_time"`
  17838. Signtype string `json:"signtype"`
  17839. WarnInfo string `json:"warn_info"`
  17840. }
  17841. type ResultSeventeenOther struct {
  17842. ErrMsg string `json:"err_msg"`
  17843. InfRefmsgid string `json:"inf_refmsgid"`
  17844. Infcode string `json:"infcode"`
  17845. Output struct {
  17846. SetlListId string `json:"setl_list_id"`
  17847. } `json:"output"`
  17848. RefmsgTime string `json:"refmsg_time"`
  17849. RespondTime string `json:"respond_time"`
  17850. Signtype string `json:"signtype"`
  17851. WarnInfo string `json:"warn_info"`
  17852. }
  17853. type Result90991 struct {
  17854. ErrMsg string `json:"err_msg"`
  17855. InfRefmsgid string `json:"inf_refmsgid"`
  17856. Infcode int64 `json:"infcode"`
  17857. Output struct {
  17858. Result struct {
  17859. PsnNo string `json:"psn_no"`
  17860. CardStat string `json:"card_stat"`
  17861. Certno string `json:"certno"`
  17862. PsnName string `json:"psn_name"`
  17863. CheckStat string `json:"check_stat"`
  17864. SscnoCheckStat string `json:"sscno_check_stat"`
  17865. } `json:"result"`
  17866. } `json:"output"`
  17867. RefmsgTime string `json:"refmsg_time"`
  17868. RespondTime string `json:"respond_time"`
  17869. Signtype interface{} `json:"signtype"`
  17870. WarnInfo interface{} `json:"warn_info"`
  17871. }
  17872. type Result90100 struct {
  17873. ErrMsg string `json:"err_msg"`
  17874. InfRefmsgid string `json:"inf_refmsgid"`
  17875. Infcode int64 `json:"infcode"`
  17876. Output struct {
  17877. PoolareaNo string `json:"poolarea_no"`
  17878. PoolareaNoName string `json:"poolarea_no_name"`
  17879. Insutype string `json:"insutype"`
  17880. InsutypeName string `json:"insutype_name"`
  17881. ClctType string `json:"clct_type"`
  17882. ClctTypeName string `json:"clct_type_name"`
  17883. ClctFlag string `json:"clct_flag"`
  17884. ClctFlagName string `json:"clct_flag_name"`
  17885. AccrymBegn string `json:"accrym_begn"`
  17886. AccrymEnd string `json:"accrym_end"`
  17887. ClctTime string `json:"clct_time"`
  17888. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  17889. } `json:"output"`
  17890. RefmsgTime string `json:"refmsg_time"`
  17891. RespondTime string `json:"respond_time"`
  17892. Signtype interface{} `json:"signtype"`
  17893. WarnInfo interface{} `json:"warn_info"`
  17894. }
  17895. type Custom struct {
  17896. DetItemFeeSumamt string
  17897. Cut string
  17898. FeedetlSn string
  17899. Price string
  17900. MedListCodg string
  17901. Type int64
  17902. AdviceId int64
  17903. ProjectId int64
  17904. ItemId int64
  17905. }
  17906. type Result5301 struct {
  17907. ErrMsg string `json:"err_msg"`
  17908. InfRefmsgid string `json:"inf_refmsgid"`
  17909. Infcode int64 `json:"infcode"`
  17910. Output struct {
  17911. Result []struct {
  17912. OpspDiseCode string `json:"opsp_dise_code"`
  17913. OpspDiseName string `json:"opsp_dise_name"`
  17914. Begndate string `json:"begndate"`
  17915. Enddate string `json:"enddate"`
  17916. } `json:"feedetail"`
  17917. } `json:"output"`
  17918. RefmsgTime string `json:"refmsg_time"`
  17919. RespondTime string `json:"respond_time"`
  17920. Signtype interface{} `json:"signtype"`
  17921. WarnInfo interface{} `json:"warn_info"`
  17922. }
  17923. type Result5301For10265 struct {
  17924. ErrMsg string `json:"err_msg"`
  17925. InfRefmsgid string `json:"inf_refmsgid"`
  17926. Infcode string `json:"infcode"`
  17927. Output struct {
  17928. Result []struct {
  17929. OpspDiseCode string `json:"opsp_dise_code"`
  17930. OpspDiseName string `json:"opsp_dise_name"`
  17931. Begndate string `json:"begndate"`
  17932. Enddate string `json:"enddate"`
  17933. } `json:"feedetail"`
  17934. } `json:"output"`
  17935. RefmsgTime string `json:"refmsg_time"`
  17936. RespondTime string `json:"respond_time"`
  17937. Signtype interface{} `json:"signtype"`
  17938. WarnInfo interface{} `json:"warn_info"`
  17939. }
  17940. //获取个人信息----挂号-----上传就诊信息
  17941. func (c *HisApiController) GetRegisterInfo() {
  17942. id, _ := c.GetInt64("id")
  17943. record_time := c.GetString("record_time")
  17944. settlementValue, _ := c.GetInt64("settlement_value")
  17945. medical_insurance_card := c.GetString("medical_insurance_card")
  17946. name := c.GetString("name")
  17947. id_card_type, _ := c.GetInt64("id_card_type")
  17948. certificates, _ := c.GetInt64("certificates")
  17949. medical_care, _ := c.GetInt64("medical_care")
  17950. birthday := c.GetString("birthday")
  17951. id_card := c.GetString("id_card")
  17952. register_type, _ := c.GetInt64("register")
  17953. doctor, _ := c.GetInt64("doctor")
  17954. department, _ := c.GetInt64("department")
  17955. gender, _ := c.GetInt64("sex")
  17956. registration_fee, _ := c.GetFloat("registration_fee")
  17957. medical_expenses, _ := c.GetFloat("medical_expenses")
  17958. social_type, _ := c.GetInt64("social_type")
  17959. admin_user_id, _ := c.GetInt64("admin_user_id")
  17960. insuplc_admdvs := c.GetString("insuplc_admdvs")
  17961. mdtrt_type := c.GetString("mdtrt_type")
  17962. if id_card_type == 5 {
  17963. id_card_type = 4
  17964. }
  17965. timeLayout := "2006-01-02"
  17966. loc, _ := time.LoadLocation("Local")
  17967. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  17968. birthUnix := birthdays.Unix()
  17969. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17970. if err != nil {
  17971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17972. return
  17973. }
  17974. recordDateTime := theTime.Unix()
  17975. adminInfo := c.GetAdminUserInfo()
  17976. var patient service.Patients
  17977. if id == 0 {
  17978. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  17979. } else {
  17980. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  17981. }
  17982. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17983. if patientPrescription.ID == 0 {
  17984. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17985. }
  17986. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17987. if patient.ID == 0 {
  17988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17989. return
  17990. }
  17991. if len(patient.IdCardNo) == 0 {
  17992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  17993. return
  17994. }
  17995. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  17996. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  17997. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  17998. //就诊结算未完成,不能进行二次挂号
  17999. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  18000. //if len(his) >= 1 {
  18001. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  18002. // if len(his) >= 1 && order.ID == 0 {
  18003. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  18004. // return
  18005. // }
  18006. //}
  18007. //var register_log string
  18008. if config.IsOpen == 1 {
  18009. var res ResultTwo
  18010. var res10265 ResultTwo10265
  18011. var PsnNo string
  18012. var PsnCertType string
  18013. var Certno string
  18014. var PsnName string
  18015. var Gend string
  18016. var Naty string
  18017. var Brdy string
  18018. var Age float64
  18019. var infoStr string
  18020. var idetinfoStr string
  18021. var infocode int64
  18022. var verify_number string
  18023. fmt.Println(verify_number)
  18024. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  18025. psn_info, _ := service.GetPsnByPatientId(id)
  18026. PsnNo = psn_info.PsnNo
  18027. PsnCertType = psn_info.PsnCertType
  18028. Certno = psn_info.Certno
  18029. PsnName = psn_info.PsnName
  18030. Gend = psn_info.Gend
  18031. Naty = psn_info.Naty
  18032. Brdy = psn_info.Brdy
  18033. Age = psn_info.Age
  18034. infoStr = psn_info.Insuinfo
  18035. idetinfoStr = psn_info.Idetinfo
  18036. infocode = 0
  18037. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18038. psn_info, _ := service.GetPsnByPatientId(id)
  18039. PsnNo = psn_info.PsnNo
  18040. PsnCertType = psn_info.PsnCertType
  18041. Certno = psn_info.Certno
  18042. PsnName = psn_info.PsnName
  18043. Gend = psn_info.Gend
  18044. Naty = psn_info.Naty
  18045. Brdy = psn_info.Brdy
  18046. Age = psn_info.Age
  18047. infoStr = psn_info.Insuinfo
  18048. idetinfoStr = psn_info.Idetinfo
  18049. infocode = 0
  18050. verify_number = psn_info.VerifyNumber
  18051. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18052. if id_card_type == 2 {
  18053. //请求内网数据
  18054. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  18055. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18056. "&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
  18057. resp, requestErr := http.Get(api)
  18058. if requestErr != nil {
  18059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18060. return
  18061. }
  18062. body, ioErr := ioutil.ReadAll(resp.Body)
  18063. if ioErr != nil {
  18064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18066. return
  18067. }
  18068. var respJSON map[string]interface{}
  18069. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18072. return
  18073. }
  18074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18075. result_byte, _ := json.Marshal(respJSON)
  18076. result := string(result_byte)
  18077. var dat map[string]interface{}
  18078. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18079. fmt.Println(dat)
  18080. } else {
  18081. fmt.Println(err)
  18082. }
  18083. userJSONBytes, _ := json.Marshal(dat)
  18084. var res ResultTwo
  18085. var resTwo10265 ResultTwo10265
  18086. if miConfig.Code == "H15049901371" {
  18087. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  18088. utils.ErrorLog("解析失败:%v", err)
  18089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18090. return
  18091. }
  18092. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  18093. res.Infcode = Infcode
  18094. res.ErrMsg = resTwo10265.ErrMsg
  18095. res.Output = resTwo10265.Output
  18096. res.InfRefmsgid = resTwo10265.InfRefmsgid
  18097. res.RespondTime = resTwo10265.RespondTime
  18098. res.WarnInfo = resTwo10265.WarnInfo
  18099. } else {
  18100. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18101. utils.ErrorLog("解析失败:%v", err)
  18102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18103. return
  18104. }
  18105. }
  18106. //var insutypes []string
  18107. //var insutype string
  18108. //var is390 int = 0
  18109. //var is310 int = 0
  18110. //for _, item := range res.Output.Iinfo {
  18111. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18112. // insutypes = append(insutypes, item.Insutype)
  18113. // }
  18114. //}
  18115. //if len(insutypes) == 1 {
  18116. // insutype = insutypes[0]
  18117. //} else {
  18118. // for _, i := range insutypes {
  18119. // if i == "390" {
  18120. // is390 = 1
  18121. // }
  18122. //
  18123. // if i == "310" {
  18124. // is310 = 1
  18125. // }
  18126. // }
  18127. //}
  18128. //if is390 == 1 {
  18129. // insutype = "390"
  18130. //}
  18131. //if is310 == 1 {
  18132. // insutype = "310"
  18133. //}
  18134. //if len(insutypes) == 0 {
  18135. // insutype = "310"
  18136. //}
  18137. PsnNo = res.Output.Baseinfo.PsnNo
  18138. PsnCertType = res.Output.Baseinfo.PsnCertType
  18139. Certno = res.Output.Baseinfo.Certno
  18140. PsnName = res.Output.Baseinfo.PsnName
  18141. Gend = res.Output.Baseinfo.Gend
  18142. Naty = res.Output.Baseinfo.Naty
  18143. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18144. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18145. infoStr = string(Iinfos)
  18146. idetinfoStr = string(Idetinfos)
  18147. infocode = res.Infcode
  18148. //infocode = 0
  18149. //verify_number = psn_info.VerifyNumber
  18150. } else {
  18151. psn_info, _ := service.GetPsnByPatientId(id)
  18152. PsnNo = psn_info.PsnNo
  18153. PsnCertType = psn_info.PsnCertType
  18154. Certno = psn_info.Certno
  18155. PsnName = psn_info.PsnName
  18156. Gend = psn_info.Gend
  18157. Naty = psn_info.Naty
  18158. Brdy = psn_info.Brdy
  18159. Age = psn_info.Age
  18160. infoStr = psn_info.Insuinfo
  18161. idetinfoStr = psn_info.Idetinfo
  18162. infocode = 0
  18163. verify_number = psn_info.VerifyNumber
  18164. }
  18165. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18166. if id_card_type == 1 {
  18167. psn_info, _ := service.GetPsnByPatientId(id)
  18168. PsnNo = psn_info.PsnNo
  18169. PsnCertType = psn_info.PsnCertType
  18170. Certno = psn_info.Certno
  18171. PsnName = psn_info.PsnName
  18172. Gend = psn_info.Gend
  18173. Naty = psn_info.Naty
  18174. Brdy = psn_info.Brdy
  18175. Age = psn_info.Age
  18176. infoStr = psn_info.Insuinfo
  18177. idetinfoStr = psn_info.Idetinfo
  18178. infocode = 0
  18179. verify_number = psn_info.VerifyNumber
  18180. } else if id_card_type == 2 {
  18181. 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)
  18182. fmt.Println(errMsgLog)
  18183. saveLog(result, requestLog, "1101", "人员基本信息获取")
  18184. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18185. utils.ErrorLog("解析失败:%v", err)
  18186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18187. return
  18188. }
  18189. PsnNo = res.Output.Baseinfo.PsnNo
  18190. PsnCertType = res.Output.Baseinfo.PsnCertType
  18191. Certno = res.Output.Baseinfo.Certno
  18192. PsnName = res.Output.Baseinfo.PsnName
  18193. Gend = res.Output.Baseinfo.Gend
  18194. Naty = res.Output.Baseinfo.Naty
  18195. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18196. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18197. infoStr = string(Iinfos)
  18198. idetinfoStr = string(Idetinfos)
  18199. infocode = res.Infcode
  18200. }
  18201. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18202. if id_card_type == 1 {
  18203. psn_info, _ := service.GetPsnByPatientId(id)
  18204. PsnNo = psn_info.PsnNo
  18205. PsnCertType = psn_info.PsnCertType
  18206. Certno = psn_info.Certno
  18207. PsnName = psn_info.PsnName
  18208. Gend = psn_info.Gend
  18209. Naty = psn_info.Naty
  18210. Brdy = psn_info.Brdy
  18211. Age = psn_info.Age
  18212. infoStr = psn_info.Insuinfo
  18213. idetinfoStr = psn_info.Idetinfo
  18214. infocode = 0
  18215. verify_number = psn_info.VerifyNumber
  18216. } else if id_card_type == 2 {
  18217. 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, "")
  18218. saveLog(result, requestLog, "1101", "人员基本信息获取")
  18219. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18220. utils.ErrorLog("解析失败:%v", err)
  18221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18222. return
  18223. }
  18224. PsnNo = res.Output.Baseinfo.PsnNo
  18225. PsnCertType = res.Output.Baseinfo.PsnCertType
  18226. Certno = res.Output.Baseinfo.Certno
  18227. PsnName = res.Output.Baseinfo.PsnName
  18228. Gend = res.Output.Baseinfo.Gend
  18229. Naty = res.Output.Baseinfo.Naty
  18230. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18231. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18232. infoStr = string(Iinfos)
  18233. idetinfoStr = string(Idetinfos)
  18234. infocode = res.Infcode
  18235. } else {
  18236. psn_info, _ := service.GetPsnByPatientId(id)
  18237. PsnNo = psn_info.PsnNo
  18238. PsnCertType = psn_info.PsnCertType
  18239. Certno = psn_info.Certno
  18240. PsnName = psn_info.PsnName
  18241. Gend = psn_info.Gend
  18242. Naty = psn_info.Naty
  18243. Brdy = psn_info.Brdy
  18244. Age = psn_info.Age
  18245. infoStr = psn_info.Insuinfo
  18246. idetinfoStr = psn_info.Idetinfo
  18247. infocode = 0
  18248. verify_number = psn_info.VerifyNumber
  18249. }
  18250. } else if miConfig.MdtrtareaAdmvs == "341203" {
  18251. psn_info, _ := service.GetPsnByPatientId(id)
  18252. PsnNo = psn_info.PsnNo
  18253. PsnCertType = psn_info.PsnCertType
  18254. Certno = psn_info.Certno
  18255. PsnName = psn_info.PsnName
  18256. Gend = psn_info.Gend
  18257. Naty = psn_info.Naty
  18258. Brdy = psn_info.Brdy
  18259. Age = psn_info.Age
  18260. infoStr = psn_info.Insuinfo
  18261. idetinfoStr = psn_info.Idetinfo
  18262. infocode = 0
  18263. verify_number = psn_info.VerifyNumber
  18264. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18265. if id_card_type == 1 {
  18266. psn_info, _ := service.GetPsnByPatientId(id)
  18267. PsnNo = psn_info.PsnNo
  18268. PsnCertType = psn_info.PsnCertType
  18269. Certno = psn_info.Certno
  18270. PsnName = psn_info.PsnName
  18271. Gend = psn_info.Gend
  18272. Naty = psn_info.Naty
  18273. Brdy = psn_info.Brdy
  18274. Age = psn_info.Age
  18275. infoStr = psn_info.Insuinfo
  18276. idetinfoStr = psn_info.Idetinfo
  18277. infocode = 0
  18278. verify_number = psn_info.VerifyNumber
  18279. } else if id_card_type == 2 {
  18280. 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)
  18281. saveLog(result, requestLog, "1101", "人员基本信息获取")
  18282. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18283. utils.ErrorLog("解析失败:%v", err)
  18284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18285. return
  18286. }
  18287. PsnNo = res.Output.Baseinfo.PsnNo
  18288. PsnCertType = res.Output.Baseinfo.PsnCertType
  18289. Certno = res.Output.Baseinfo.Certno
  18290. PsnName = res.Output.Baseinfo.PsnName
  18291. Gend = res.Output.Baseinfo.Gend
  18292. Naty = res.Output.Baseinfo.Naty
  18293. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18294. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18295. infoStr = string(Iinfos)
  18296. idetinfoStr = string(Idetinfos)
  18297. infocode = res.Infcode
  18298. } else if id_card_type == 4 {
  18299. psn_info, _ := service.GetPsnByPatientId(id)
  18300. PsnNo = psn_info.PsnNo
  18301. PsnCertType = psn_info.PsnCertType
  18302. Certno = psn_info.Certno
  18303. PsnName = psn_info.PsnName
  18304. Gend = psn_info.Gend
  18305. Naty = psn_info.Naty
  18306. Brdy = psn_info.Brdy
  18307. Age = psn_info.Age
  18308. infoStr = psn_info.Insuinfo
  18309. idetinfoStr = psn_info.Idetinfo
  18310. infocode = 0
  18311. verify_number = psn_info.VerifyNumber
  18312. }
  18313. } else if miConfig.MdtrtareaAdmvs == "131023" {
  18314. var result string
  18315. var requestLog string
  18316. 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), "")
  18317. if id_card_type == 4 {
  18318. psn_info, _ := service.GetPsnByPatientId(id)
  18319. PsnNo = psn_info.PsnNo
  18320. PsnCertType = psn_info.PsnCertType
  18321. Certno = psn_info.Certno
  18322. PsnName = psn_info.PsnName
  18323. Gend = psn_info.Gend
  18324. Naty = psn_info.Naty
  18325. Brdy = psn_info.Brdy
  18326. Age = psn_info.Age
  18327. infoStr = psn_info.Insuinfo
  18328. idetinfoStr = psn_info.Idetinfo
  18329. infocode = 0
  18330. verify_number = psn_info.VerifyNumber
  18331. } else {
  18332. saveLog(result, requestLog, "1101", "人员基本信息获取")
  18333. if miConfig.Code == "H15049901371" {
  18334. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18335. utils.ErrorLog("解析失败:%v", err)
  18336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18337. return
  18338. }
  18339. res.ErrMsg = res10265.ErrMsg
  18340. res.Output = res10265.Output
  18341. res.InfRefmsgid = res10265.InfRefmsgid
  18342. } else {
  18343. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18344. utils.ErrorLog("解析失败:%v", err)
  18345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18346. return
  18347. }
  18348. }
  18349. PsnNo = res.Output.Baseinfo.PsnNo
  18350. PsnCertType = res.Output.Baseinfo.PsnCertType
  18351. Certno = res.Output.Baseinfo.Certno
  18352. PsnName = res.Output.Baseinfo.PsnName
  18353. Gend = res.Output.Baseinfo.Gend
  18354. Naty = res.Output.Baseinfo.Naty
  18355. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18356. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18357. infoStr = string(Iinfos)
  18358. idetinfoStr = string(Idetinfos)
  18359. if miConfig.Code == "H15049901371" {
  18360. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  18361. } else {
  18362. infocode = res.Infcode
  18363. }
  18364. }
  18365. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18366. psn_info, _ := service.GetPsnByPatientId(id)
  18367. PsnNo = psn_info.PsnNo
  18368. PsnCertType = psn_info.PsnCertType
  18369. Certno = psn_info.Certno
  18370. PsnName = psn_info.PsnName
  18371. Gend = psn_info.Gend
  18372. Naty = psn_info.Naty
  18373. Brdy = psn_info.Brdy
  18374. Age = psn_info.Age
  18375. infoStr = psn_info.Insuinfo
  18376. idetinfoStr = psn_info.Idetinfo
  18377. infocode = 0
  18378. verify_number = psn_info.VerifyNumber
  18379. } else if miConfig.MdtrtareaAdmvs == "450721" {
  18380. psn_info, _ := service.GetPsnByPatientId(id)
  18381. PsnNo = psn_info.PsnNo
  18382. PsnCertType = psn_info.PsnCertType
  18383. Certno = psn_info.Certno
  18384. PsnName = psn_info.PsnName
  18385. Gend = psn_info.Gend
  18386. Naty = psn_info.Naty
  18387. Brdy = psn_info.Brdy
  18388. Age = psn_info.Age
  18389. infoStr = psn_info.Insuinfo
  18390. idetinfoStr = psn_info.Idetinfo
  18391. infocode = 0
  18392. verify_number = psn_info.VerifyNumber
  18393. } else {
  18394. var result string
  18395. var requestLog string
  18396. //if miConfig.UserOrgId == 10138 {
  18397. if id_card_type != 4 || id_card_type != 1 {
  18398. var insa string
  18399. if len(patient.InsuplcAdmdvs) > 0 {
  18400. insa = patient.InsuplcAdmdvs
  18401. } else {
  18402. insa = miConfig.InsuplcAdmdvs
  18403. }
  18404. //psn_info, _ := service.GetPsnByPatientId(id)
  18405. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  18406. 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)
  18407. }
  18408. //}
  18409. //else {
  18410. // var insa string
  18411. // if len(patient.InsuplcAdmdvs) > 0 {
  18412. // insa = patient.InsuplcAdmdvs
  18413. // } else {
  18414. // insa = miConfig.InsuplcAdmdvs
  18415. // }
  18416. // 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)
  18417. //}
  18418. if id_card_type == 4 || id_card_type == 1 {
  18419. psn_info, _ := service.GetPsnByPatientId(id)
  18420. PsnNo = psn_info.PsnNo
  18421. PsnCertType = psn_info.PsnCertType
  18422. Certno = psn_info.Certno
  18423. PsnName = psn_info.PsnName
  18424. Gend = psn_info.Gend
  18425. Naty = psn_info.Naty
  18426. Brdy = psn_info.Brdy
  18427. Age = psn_info.Age
  18428. infoStr = psn_info.Insuinfo
  18429. idetinfoStr = psn_info.Idetinfo
  18430. infocode = 0
  18431. verify_number = psn_info.VerifyNumber
  18432. } else {
  18433. saveLog(result, requestLog, "1101", "人员基本信息获取")
  18434. if miConfig.Code == "H15049901371" {
  18435. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18436. utils.ErrorLog("解析失败:%v", err)
  18437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18438. return
  18439. }
  18440. res.ErrMsg = res10265.ErrMsg
  18441. res.Output = res10265.Output
  18442. res.InfRefmsgid = res10265.InfRefmsgid
  18443. } else {
  18444. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18445. utils.ErrorLog("解析失败:%v", err)
  18446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18447. return
  18448. }
  18449. }
  18450. PsnNo = res.Output.Baseinfo.PsnNo
  18451. PsnCertType = res.Output.Baseinfo.PsnCertType
  18452. Certno = res.Output.Baseinfo.Certno
  18453. PsnName = res.Output.Baseinfo.PsnName
  18454. Gend = res.Output.Baseinfo.Gend
  18455. Naty = res.Output.Baseinfo.Naty
  18456. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18457. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18458. infoStr = string(Iinfos)
  18459. idetinfoStr = string(Idetinfos)
  18460. if miConfig.Code == "H15049901371" {
  18461. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  18462. } else {
  18463. infocode = res.Infcode
  18464. }
  18465. }
  18466. }
  18467. if infocode == 0 {
  18468. his := models.VMHisPatient{
  18469. Name: name,
  18470. Gender: gender,
  18471. Birthday: birthUnix,
  18472. MedicalTreatmentType: medical_care,
  18473. IdType: certificates,
  18474. IdCardNo: id_card,
  18475. BalanceAccountsType: settlementValue,
  18476. SocialType: social_type,
  18477. MedicalInsuranceNumber: medical_insurance_card,
  18478. RegisterType: register_type,
  18479. RegisterCost: registration_fee,
  18480. TreatmentCost: medical_expenses,
  18481. Status: 1,
  18482. Ctime: time.Now().Unix(),
  18483. Mtime: time.Now().Unix(),
  18484. PsnNo: PsnNo,
  18485. PsnCertType: PsnCertType,
  18486. Certno: Certno,
  18487. PsnName: PsnName,
  18488. Gend: Gend,
  18489. Naty: Naty,
  18490. Brdy: Brdy,
  18491. Age: Age,
  18492. Iinfo: infoStr,
  18493. Idetinfo: idetinfoStr,
  18494. PatientId: patient.ID,
  18495. RecordDate: theTime.Unix(),
  18496. UserOrgId: adminInfo.CurrentOrgId,
  18497. AdminUserId: admin_user_id,
  18498. IsReturn: 1,
  18499. IdCardType: id_card_type,
  18500. Doctor: doctor,
  18501. Departments: department,
  18502. MdtrtGrpType: mdtrt_type,
  18503. }
  18504. timestamp := time.Now().Unix()
  18505. tempTime := time.Unix(timestamp, 0)
  18506. timeFormat := tempTime.Format("20060102150405")
  18507. chrgBchno := rand.Intn(100000) + 10000
  18508. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  18509. his.Number = ipt_otp_no
  18510. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  18511. department, _ := service.GetDepartMentDetail(department)
  18512. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  18513. IdCardNo := ""
  18514. if id_card_type == 1 {
  18515. // IdCardNo = medical_insurance_card
  18516. IdCardNo = patient.IdCardNo
  18517. } else {
  18518. IdCardNo = patient.IdCardNo
  18519. }
  18520. var rf []*ResultFive
  18521. json.Unmarshal([]byte(his.Iinfo), &rf)
  18522. var insutypes []*ResultFive
  18523. var insutype string
  18524. var insuplc_admdvs_temp string
  18525. var is390 int = 0
  18526. var is310 int = 0
  18527. for _, item := range rf {
  18528. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18529. insutypes = append(insutypes, item)
  18530. }
  18531. }
  18532. if len(insutypes) == 1 {
  18533. insutype = insutypes[0].Insutype
  18534. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18535. if insutype == "390" {
  18536. is390 = 1
  18537. }
  18538. if insutype == "310" {
  18539. is310 = 1
  18540. }
  18541. } else {
  18542. for _, i := range insutypes {
  18543. if i.Insutype == "390" {
  18544. is390 = 1
  18545. }
  18546. if i.Insutype == "310" {
  18547. is310 = 1
  18548. }
  18549. }
  18550. }
  18551. if is390 == 1 {
  18552. insutype = "390"
  18553. }
  18554. if is310 == 1 {
  18555. insutype = "310"
  18556. }
  18557. fmt.Println(social_type)
  18558. if social_type > 0 {
  18559. insutype = strconv.FormatInt(social_type, 10)
  18560. }
  18561. var infocode int64
  18562. var resThree ResultThree
  18563. var resThree10265 ResultThree10265
  18564. if len(insuplc_admdvs) == 0 {
  18565. psn_info, _ := service.GetPsnByPatientId(id)
  18566. //if len(psn_info.InsuplcAdmdvs) > 0 {
  18567. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18568. //}
  18569. } else {
  18570. insuplc_admdvs_temp = insuplc_admdvs
  18571. }
  18572. if miConfig.MdtrtareaAdmvs == "421300" {
  18573. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18574. psn_info, _ := service.GetPsnByPatientId(id)
  18575. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18576. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18577. "&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
  18578. resp, requestErr := http.Get(api)
  18579. if requestErr != nil {
  18580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18581. return
  18582. }
  18583. body, ioErr := ioutil.ReadAll(resp.Body)
  18584. if ioErr != nil {
  18585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18587. return
  18588. }
  18589. var respJSON map[string]interface{}
  18590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18593. return
  18594. }
  18595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18596. result, _ := json.Marshal(respJSON)
  18597. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18598. utils.ErrorLog("解析失败:%v", err)
  18599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18600. return
  18601. }
  18602. infocode = resThree.Infcode
  18603. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18604. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18605. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  18606. // insuplc_admdvs_temp =
  18607. //}
  18608. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  18609. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18610. //}
  18611. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18612. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18613. "&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
  18614. resp, requestErr := http.Get(api)
  18615. if requestErr != nil {
  18616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18617. return
  18618. }
  18619. body, ioErr := ioutil.ReadAll(resp.Body)
  18620. if ioErr != nil {
  18621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18623. return
  18624. }
  18625. var respJSON map[string]interface{}
  18626. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18629. return
  18630. }
  18631. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18632. result, _ := json.Marshal(respJSON)
  18633. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18634. utils.ErrorLog("解析失败:%v", err)
  18635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18636. return
  18637. }
  18638. infocode = resThree.Infcode
  18639. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18640. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18641. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  18642. // insuplc_admdvs_temp =
  18643. //}
  18644. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  18645. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18646. //}
  18647. utils.ErrorLog("解析失败:%v", insutype)
  18648. utils.ErrorLog("解析失败:%v", PsnNo)
  18649. utils.ErrorLog("解析失败:%v", Certno)
  18650. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  18651. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  18652. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  18653. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  18654. utils.ErrorLog("解析失败:%v", PsnNo)
  18655. utils.ErrorLog("解析失败:%v", department.Number)
  18656. utils.ErrorLog("解析失败:%v", department.Name)
  18657. utils.ErrorLog("解析失败:%v", roles.UserName)
  18658. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18659. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18660. "&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
  18661. resp, requestErr := http.Get(api)
  18662. if requestErr != nil {
  18663. utils.ErrorLog("解析失败:%v", requestErr)
  18664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18665. return
  18666. }
  18667. body, ioErr := ioutil.ReadAll(resp.Body)
  18668. if ioErr != nil {
  18669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18671. return
  18672. }
  18673. var respJSON map[string]interface{}
  18674. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18677. return
  18678. }
  18679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18680. result, _ := json.Marshal(respJSON)
  18681. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18682. utils.ErrorLog("解析失败:%v", err)
  18683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18684. return
  18685. }
  18686. infocode = resThree.Infcode
  18687. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18688. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18689. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  18690. // insuplc_admdvs_temp =
  18691. //}
  18692. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  18693. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18694. //}
  18695. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18696. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18697. "&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
  18698. resp, requestErr := http.Get(api)
  18699. if requestErr != nil {
  18700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18701. return
  18702. }
  18703. body, ioErr := ioutil.ReadAll(resp.Body)
  18704. if ioErr != nil {
  18705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18707. return
  18708. }
  18709. var respJSON map[string]interface{}
  18710. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18713. return
  18714. }
  18715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18716. result, _ := json.Marshal(respJSON)
  18717. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18718. utils.ErrorLog("解析失败:%v", err)
  18719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18720. return
  18721. }
  18722. infocode = resThree.Infcode
  18723. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18724. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18725. psn_info, _ := service.GetPsnByPatientId(id)
  18726. var verify_number string
  18727. if id_card_type == 4 {
  18728. verify_number = psn_info.VerifyNumber
  18729. } else if id_card_type == 1 {
  18730. bas := strings.Split(psn_info.CardInfo, "|")
  18731. cardNumber := bas[2]
  18732. verify_number = cardNumber
  18733. }
  18734. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18735. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18736. "&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
  18737. resp, requestErr := http.Get(api)
  18738. if requestErr != nil {
  18739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18740. return
  18741. }
  18742. body, ioErr := ioutil.ReadAll(resp.Body)
  18743. if ioErr != nil {
  18744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18746. return
  18747. }
  18748. var respJSON map[string]interface{}
  18749. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18752. return
  18753. }
  18754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18755. result, _ := json.Marshal(respJSON)
  18756. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18757. // utils.ErrorLog("解析失败:%v", err)
  18758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18759. // return
  18760. //}
  18761. //infocode = resThree.Infcode
  18762. //result, _ := json.Marshal(respJSON)
  18763. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18764. utils.ErrorLog("解析失败:%v", err)
  18765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18766. return
  18767. }
  18768. resThree.ErrMsg = resThree10265.ErrMsg
  18769. resThree.Output = resThree10265.Output
  18770. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18771. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18772. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18773. psn_info, _ := service.GetPsnByPatientId(id)
  18774. his.PsnNo = psn_info.PsnNo
  18775. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18776. var cert_no string
  18777. if id_card_type == 3 {
  18778. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  18779. cert_no = IdCardNo
  18780. } else if id_card_type == 4 {
  18781. cert_no = IdCardNo
  18782. psn_info.VerifyNumber = psn_info.VerifyNumber
  18783. } else {
  18784. bas := strings.Split(psn_info.CardInfo, "|")
  18785. cert_no = bas[2]
  18786. }
  18787. var hisPrescription []*models.HisPrescription
  18788. for _, item := range rf {
  18789. if item.Insutype == insutype {
  18790. //insuplc_admdvs = item.InsuplcAdmdvs
  18791. his.InsuplcAdmdvs = insuplc_admdvs
  18792. }
  18793. }
  18794. his.Insutype = insutype
  18795. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18796. fmt.Println(res3101)
  18797. fmt.Println(res3101.Infcode)
  18798. if res3101.Infcode == "0" {
  18799. fmt.Println("33333333")
  18800. if len(res3101.Output.Result) > 0 {
  18801. fmt.Println("222222")
  18802. for _, item := range res3101.Output.Result {
  18803. if len(res3101.ErrMsg) == 0 {
  18804. res3101.ErrMsg = item.VolaCont
  18805. } else {
  18806. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18807. }
  18808. }
  18809. c.ServeSuccessJSON(map[string]interface{}{
  18810. "failed_code": -10,
  18811. "msg": res3101.ErrMsg,
  18812. })
  18813. return
  18814. } else {
  18815. fmt.Println("11111")
  18816. var api string
  18817. if miConfig.MdtrtareaAdmvs == "320921" {
  18818. ipt_otp_no = timeFormat
  18819. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18820. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18821. "&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
  18822. } else {
  18823. ipt_otp_no = timeFormat
  18824. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18825. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18826. "&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
  18827. }
  18828. resp, requestErr := http.Get(api)
  18829. if requestErr != nil {
  18830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18831. return
  18832. }
  18833. body, ioErr := ioutil.ReadAll(resp.Body)
  18834. if ioErr != nil {
  18835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18837. return
  18838. }
  18839. var respJSON map[string]interface{}
  18840. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18843. return
  18844. }
  18845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18846. result, _ := json.Marshal(respJSON)
  18847. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18848. utils.ErrorLog("解析失败:%v", err)
  18849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18850. return
  18851. }
  18852. resThree.ErrMsg = resThree10265.ErrMsg
  18853. resThree.Output = resThree10265.Output
  18854. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18855. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18856. }
  18857. } else if res3101.Infcode != "0" {
  18858. c.ServeSuccessJSON(map[string]interface{}{
  18859. "failed_code": -10,
  18860. "msg": res3101.ErrMsg,
  18861. })
  18862. return
  18863. }
  18864. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18865. psn_info, _ := service.GetPsnByPatientId(id)
  18866. var cert_no string
  18867. if id_card_type == 1 {
  18868. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  18869. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18870. } else if id_card_type == 4 {
  18871. cert_no = psn_info.VerifyNumber
  18872. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18873. } else {
  18874. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18875. cert_no = psn_info.VerifyNumber
  18876. }
  18877. 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)
  18878. saveLog(result, requestLog, "2201", "挂号")
  18879. if miConfig.Code == "H15049901371" {
  18880. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18881. utils.ErrorLog("解析失败:%v", err)
  18882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18883. return
  18884. }
  18885. resThree.ErrMsg = resThree10265.ErrMsg
  18886. resThree.Output = resThree10265.Output
  18887. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18888. } else {
  18889. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18890. utils.ErrorLog("解析失败:%v", err)
  18891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18892. return
  18893. }
  18894. }
  18895. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18896. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  18897. psn_info, _ := service.GetPsnByPatientId(id)
  18898. var result string
  18899. var requestLog string
  18900. if id_card_type == 1 {
  18901. bas := strings.Split(psn_info.CardInfo, "|")
  18902. basNumber := bas[2]
  18903. card_sn := bas[3]
  18904. 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)
  18905. saveLog(result, requestLog, "2201A", "挂号")
  18906. } else if id_card_type == 2 {
  18907. 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, "", "", "", "", "", "")
  18908. saveLog(result, requestLog, "2201A", "挂号")
  18909. } else {
  18910. 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)
  18911. saveLog(result, requestLog, "2201A", "挂号")
  18912. }
  18913. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18914. utils.ErrorLog("解析失败:%v", err)
  18915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18916. return
  18917. }
  18918. infocode = resThree.Infcode
  18919. } else if miConfig.MdtrtareaAdmvs == "341203" {
  18920. psn_info, _ := service.GetPsnByPatientId(id)
  18921. his.PsnNo = psn_info.PsnNo
  18922. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18923. var cert_no string
  18924. if id_card_type == 1 {
  18925. bas := strings.Split(psn_info.CardInfo, "|")
  18926. cert_no = bas[2]
  18927. } else if id_card_type == 4 {
  18928. cert_no = IdCardNo
  18929. psn_info.VerifyNumber = psn_info.VerifyNumber
  18930. } else {
  18931. cert_no = IdCardNo
  18932. psn_info.VerifyNumber = cert_no
  18933. }
  18934. for _, item := range rf {
  18935. if item.Insutype == insutype {
  18936. his.InsuplcAdmdvs = insuplc_admdvs
  18937. }
  18938. }
  18939. his.Insutype = insutype
  18940. var api string
  18941. ipt_otp_no = timeFormat
  18942. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18943. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18944. "&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
  18945. resp, requestErr := http.Get(api)
  18946. if requestErr != nil {
  18947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18948. return
  18949. }
  18950. body, ioErr := ioutil.ReadAll(resp.Body)
  18951. if ioErr != nil {
  18952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18954. return
  18955. }
  18956. var respJSON map[string]interface{}
  18957. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18960. return
  18961. }
  18962. status := respJSON["data"].(map[string]interface{})["status"].(string)
  18963. if status == "0" {
  18964. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  18965. c.ServeSuccessJSON(map[string]interface{}{
  18966. "failed_code": -10,
  18967. "msg": err_msg,
  18968. })
  18969. return
  18970. }
  18971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18972. result, _ := json.Marshal(respJSON)
  18973. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18974. utils.ErrorLog("解析失败:%v", err)
  18975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18976. return
  18977. }
  18978. infocode = resThree.Infcode
  18979. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18980. psn_info, _ := service.GetPsnByPatientId(id)
  18981. var result string
  18982. var requestLog string
  18983. if id_card_type == 1 {
  18984. bas := strings.Split(psn_info.CardInfo, "|")
  18985. basNumber := bas[2]
  18986. card_sn := bas[3]
  18987. 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)
  18988. saveLog(result, requestLog, "2201A", "挂号")
  18989. } else if id_card_type == 2 {
  18990. 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, "", "")
  18991. saveLog(result, requestLog, "2201A", "挂号")
  18992. } else {
  18993. 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, "", "")
  18994. saveLog(result, requestLog, "2201A", "挂号")
  18995. }
  18996. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18997. utils.ErrorLog("解析失败:%v", err)
  18998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18999. return
  19000. }
  19001. infocode = resThree.Infcode
  19002. } else if miConfig.MdtrtareaAdmvs == "131023" {
  19003. psn_info, _ := service.GetPsnByPatientId(id)
  19004. 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)
  19005. saveLog(result, requestLog, "2201A", "挂号")
  19006. if miConfig.Code == "H15049901371" {
  19007. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  19008. utils.ErrorLog("解析失败:%v", err)
  19009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19010. return
  19011. }
  19012. resThree.ErrMsg = resThree10265.ErrMsg
  19013. resThree.Output = resThree10265.Output
  19014. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  19015. } else {
  19016. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  19017. utils.ErrorLog("解析失败:%v", err)
  19018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19019. return
  19020. }
  19021. }
  19022. if miConfig.Code == "H15049901371" {
  19023. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  19024. } else {
  19025. infocode = resThree.Infcode
  19026. }
  19027. } else {
  19028. psn_info, _ := service.GetPsnByPatientId(id)
  19029. if id_card_type == 4 || id_card_type == 1 {
  19030. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  19031. }
  19032. var rf []*ResultFive
  19033. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  19034. var insutypes []*ResultFive
  19035. var insutype string
  19036. var is390 int = 0
  19037. var is310 int = 0
  19038. for _, item := range rf {
  19039. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19040. insutypes = append(insutypes, item)
  19041. }
  19042. }
  19043. if len(insutypes) == 1 {
  19044. insutype = insutypes[0].Insutype
  19045. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  19046. } else {
  19047. for _, i := range insutypes {
  19048. if i.Insutype == "390" {
  19049. is390 = 1
  19050. }
  19051. if i.Insutype == "310" {
  19052. is310 = 1
  19053. }
  19054. }
  19055. }
  19056. if is390 == 1 {
  19057. insutype = "390"
  19058. }
  19059. if is310 == 1 {
  19060. insutype = "310"
  19061. }
  19062. fmt.Println(len(insutypes))
  19063. if len(insutypes) == 0 {
  19064. for index, item := range rf {
  19065. if index == 0 {
  19066. insutype = item.Insutype
  19067. insuplc_admdvs = item.InsuplcAdmdvs
  19068. }
  19069. }
  19070. fmt.Println(insutype)
  19071. fmt.Println(insuplc_admdvs)
  19072. }
  19073. if social_type > 0 {
  19074. insutype = strconv.FormatInt(social_type, 10)
  19075. }
  19076. fmt.Println("--------")
  19077. fmt.Println(psn_info)
  19078. fmt.Println(psn_info.PsnNo)
  19079. if miConfig.MdtrtareaAdmvs == "441202" {
  19080. var hisPrescription []*models.HisPrescription
  19081. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  19082. if res3101.Infcode == 0 {
  19083. fmt.Println("33333333")
  19084. if len(res3101.Output.Result) > 0 {
  19085. fmt.Println("222222")
  19086. for _, item := range res3101.Output.Result {
  19087. if len(res3101.ErrMsg) == 0 {
  19088. res3101.ErrMsg = item.VolaCont
  19089. } else {
  19090. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  19091. }
  19092. }
  19093. c.ServeSuccessJSON(map[string]interface{}{
  19094. "failed_code": -10,
  19095. "msg": res3101.ErrMsg,
  19096. })
  19097. return
  19098. } else {
  19099. hour := time.Now().Format("15")
  19100. min := time.Now().Format("04")
  19101. sec := time.Now().Format("05")
  19102. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  19103. fmt.Println(record_time_two)
  19104. 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)
  19105. saveLog(result, requestLog, "2201A", "挂号")
  19106. if miConfig.Code == "H15049901371" {
  19107. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  19108. utils.ErrorLog("解析失败:%v", err)
  19109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19110. return
  19111. }
  19112. resThree.ErrMsg = resThree10265.ErrMsg
  19113. resThree.Output = resThree10265.Output
  19114. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  19115. } else {
  19116. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  19117. utils.ErrorLog("解析失败:%v", err)
  19118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19119. return
  19120. }
  19121. }
  19122. if miConfig.Code == "H15049901371" {
  19123. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  19124. } else {
  19125. infocode = resThree.Infcode
  19126. }
  19127. }
  19128. } else if res3101.Infcode != 0 {
  19129. c.ServeSuccessJSON(map[string]interface{}{
  19130. "failed_code": -10,
  19131. "msg": res3101.ErrMsg,
  19132. })
  19133. return
  19134. }
  19135. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19136. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  19137. psn_info, _ := service.GetPsnByPatientId(id)
  19138. var verify_number string
  19139. if id_card_type == 4 {
  19140. verify_number = psn_info.VerifyNumber
  19141. } else if id_card_type == 1 {
  19142. bas := strings.Split(psn_info.CardInfo, "|")
  19143. cardNumber := bas[2]
  19144. verify_number = cardNumber
  19145. } else {
  19146. verify_number = psn_info.Certno
  19147. }
  19148. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  19149. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  19150. "&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
  19151. resp, requestErr := http.Get(api)
  19152. if requestErr != nil {
  19153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19154. return
  19155. }
  19156. body, ioErr := ioutil.ReadAll(resp.Body)
  19157. if ioErr != nil {
  19158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19160. return
  19161. }
  19162. var respJSON map[string]interface{}
  19163. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19166. return
  19167. }
  19168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19169. result, _ := json.Marshal(respJSON)
  19170. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  19171. utils.ErrorLog("解析失败:%v", err)
  19172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19173. return
  19174. }
  19175. infocode = resThree.Infcode
  19176. } else {
  19177. hour := time.Now().Format("15")
  19178. min := time.Now().Format("04")
  19179. sec := time.Now().Format("05")
  19180. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  19181. if id_card_type == 1 {
  19182. for _, item := range rf {
  19183. if item.Insutype == strconv.FormatInt(social_type, 10) {
  19184. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  19185. insuplc_admdvs_temp = item.InsuplcAdmdvs
  19186. } else if strconv.FormatInt(social_type, 10) == "390" {
  19187. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  19188. } else {
  19189. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  19190. }
  19191. }
  19192. }
  19193. }
  19194. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  19195. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  19196. }
  19197. if id_card_type == 1 {
  19198. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  19199. bas := strings.Split(psn_info.CardInfo, "|")
  19200. basNumber := bas[1]
  19201. IdCardNo = basNumber
  19202. }
  19203. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  19204. IdCardNo = psn_info.VerifyNumber
  19205. }
  19206. 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)
  19207. saveLog(result, requestLog, "2201A", "挂号")
  19208. if miConfig.Code == "H15049901371" {
  19209. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  19210. utils.ErrorLog("解析失败:%v", err)
  19211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19212. return
  19213. }
  19214. resThree.ErrMsg = resThree10265.ErrMsg
  19215. resThree.Output = resThree10265.Output
  19216. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  19217. } else {
  19218. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  19219. utils.ErrorLog("解析失败:%v", err)
  19220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19221. return
  19222. }
  19223. }
  19224. if miConfig.Code == "H15049901371" {
  19225. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  19226. } else {
  19227. infocode = resThree.Infcode
  19228. }
  19229. }
  19230. }
  19231. if infocode != 0 {
  19232. adminUser := c.GetAdminUserInfo()
  19233. errlog := &models.HisOrderError{
  19234. UserOrgId: adminUser.CurrentOrgId,
  19235. Ctime: time.Now().Unix(),
  19236. Mtime: time.Now().Unix(),
  19237. ErrMsg: resThree.ErrMsg,
  19238. Status: 1,
  19239. PatientId: id,
  19240. RecordTime: recordDateTime,
  19241. Stage: 2,
  19242. }
  19243. service.CreateErrMsgLog(errlog)
  19244. c.ServeSuccessJSON(map[string]interface{}{
  19245. "failed_code": -10,
  19246. "msg": resThree.ErrMsg,
  19247. })
  19248. return
  19249. }
  19250. his.Number = resThree.Output.Data.MdtrtID
  19251. his.PsnNo = resThree.Output.Data.PsnNo
  19252. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  19253. his.IdCardNo = patient.IdCardNo
  19254. his.PhoneNumber = patient.Phone
  19255. his.UserOrgId = adminInfo.CurrentOrgId
  19256. his.Insutype = insutype
  19257. his.Ctime = time.Now().Unix()
  19258. his.Mtime = time.Now().Unix()
  19259. his.InsuplcAdmdvs = insuplc_admdvs_temp
  19260. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  19261. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  19262. }
  19263. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  19264. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  19265. }
  19266. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  19267. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  19268. }
  19269. his.Status = 1
  19270. his.MdtrtGrpType = mdtrt_type
  19271. service.UpdateHisPatientStatus(&his)
  19272. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  19273. c.ServeSuccessJSON(map[string]interface{}{
  19274. "his_info": his,
  19275. })
  19276. } else {
  19277. adminUser := c.GetAdminUserInfo()
  19278. errlog := &models.HisOrderError{
  19279. UserOrgId: adminUser.CurrentOrgId,
  19280. Ctime: time.Now().Unix(),
  19281. Mtime: time.Now().Unix(),
  19282. ErrMsg: res.ErrMsg,
  19283. Status: 1,
  19284. PatientId: id,
  19285. RecordTime: recordDateTime,
  19286. Stage: 1,
  19287. }
  19288. service.CreateErrMsgLog(errlog)
  19289. c.ServeSuccessJSON(map[string]interface{}{
  19290. "failed_code": -10,
  19291. "msg": res.ErrMsg,
  19292. })
  19293. return
  19294. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  19295. }
  19296. }
  19297. }
  19298. func (c *HisApiController) GetUploadInfo() {
  19299. id, _ := c.GetInt64("id")
  19300. record_time := c.GetString("record_time")
  19301. his_patient_id, _ := c.GetInt64("his_patient_id")
  19302. order_id, _ := c.GetInt64("order_id")
  19303. pay_way, _ := c.GetInt64("pay_way")
  19304. pay_ways := c.GetString("pay_ways")
  19305. oth_desc := c.GetString("oth_desc")
  19306. pay_price, _ := c.GetFloat("pay_price")
  19307. pay_card_no := c.GetString("pay_card_no")
  19308. discount_price, _ := c.GetFloat("discount_price")
  19309. preferential_price, _ := c.GetFloat("preferential_price")
  19310. reality_price, _ := c.GetFloat("reality_price")
  19311. found_price, _ := c.GetFloat("found_price")
  19312. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  19313. private_price, _ := c.GetFloat("private_price")
  19314. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  19315. admin_user_id, _ := c.GetInt64("admin_user_id")
  19316. fapiao_code := c.GetString("fapiao_code")
  19317. fapiao_number := c.GetString("fapiao_number")
  19318. diagnosis_id := c.GetString("diagnosis")
  19319. sick_type, _ := c.GetInt64("sick_type")
  19320. reg_type, _ := c.GetInt64("p_type")
  19321. begin_time := c.GetString("begin_time")
  19322. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  19323. cash_pay := c.GetString("cash_pay")
  19324. band_card_pay := c.GetString("band_card_pay")
  19325. wechat_pay := c.GetString("wechat_pay")
  19326. ali_pay := c.GetString("ali_pay")
  19327. jifen_pay := c.GetString("jifen_pay")
  19328. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  19329. fmt.Println(acct_used_flag)
  19330. id_str := c.GetString("ids")
  19331. ids_arr := strings.Split(id_str, ",")
  19332. timeLayout := "2006-01-02"
  19333. loc, _ := time.LoadLocation("Local")
  19334. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  19335. if err != nil {
  19336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19337. return
  19338. }
  19339. recordDateTime := theTime.Unix()
  19340. adminUser := c.GetAdminUserInfo()
  19341. var tempOrder models.HisOrder
  19342. tempOrder, _ = service.GetHisOrderByID(order_id)
  19343. var prescriptions []*models.HisPrescription
  19344. var start_time int64
  19345. var end_time int64
  19346. //押金模块
  19347. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  19348. tmp_decimal := c.GetString("tmp_decimal")
  19349. var decimal float64 //本次使用的押金
  19350. var errmsg error
  19351. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  19352. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  19353. return
  19354. }
  19355. if len(tmp_decimal) > 0 {
  19356. if tmp_decimal[0] == 45 {
  19357. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  19358. return
  19359. }
  19360. }
  19361. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  19362. fmt.Println(errs)
  19363. decimal = tt
  19364. //if adminUser.CurrentOrgId == 10106{
  19365. // if len(fapiao_code) == 0{
  19366. // fapiao_code = "144072080589"
  19367. // }
  19368. // if len(fapiao_number) == 0{
  19369. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  19370. // if order.ID == 0{
  19371. // fapiao_number = "00001520"
  19372. // }else{
  19373. // //fapiao_code = "00001520"
  19374. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  19375. // var zero string
  19376. // if fpNumber >= 1000{
  19377. // zero = "0000" + strconv.Itoa(fpNumber)
  19378. // }else if fpNumber >= 10000{
  19379. // zero = "000" + strconv.Itoa(fpNumber)
  19380. // } else if fpNumber >= 100000{
  19381. // zero = "00" + strconv.Itoa(fpNumber)
  19382. // } else if fpNumber >= 1000000{
  19383. // zero = "0" + strconv.Itoa(fpNumber)
  19384. // }else {
  19385. // zero = strconv.Itoa(fpNumber)
  19386. // }
  19387. // fapiao_number = zero
  19388. // }
  19389. // }
  19390. //}
  19391. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  19392. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  19393. var patientPrescription models.HisPrescriptionInfo
  19394. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  19395. if patientPrescription.ID == 0 {
  19396. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  19397. }
  19398. //if patientPrescription.Do
  19399. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  19400. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  19401. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  19402. diagnosis_ids := strings.Split(diagnosis_id, ",")
  19403. var config []*models.HisXtDiagnoseConfig
  19404. for _, item := range diagnosis_ids {
  19405. id, _ := strconv.ParseInt(item, 10, 64)
  19406. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19407. config = append(config, &diagnosisConfig)
  19408. }
  19409. sickConfig, _ := service.FindSickById(sick_type)
  19410. //if tempOrder.ID == 0 {
  19411. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  19412. //}
  19413. if tempOrder.ID == 0 {
  19414. var result string
  19415. var requestLog string
  19416. var res2 ResultSix
  19417. var res3 GZResultSix
  19418. var ressix10265 ResultSix10265
  19419. if miConfig.MdtrtareaAdmvs == "421300" {
  19420. data := make(map[string]interface{})
  19421. client := &http.Client{}
  19422. data["psn_no"] = his.PsnNo
  19423. data["mdtrt_id"] = his.Number
  19424. data["opter"] = roles.UserName
  19425. data["org_name"] = miConfig.OrgName
  19426. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19427. data["doctor_id"] = doctor_info.DoctorNumber
  19428. data["doctor_name"] = doctor_info.UserName
  19429. data["department"] = department.Name
  19430. data["fixmedins_code"] = miConfig.Code
  19431. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19432. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19433. data["secret_key"] = miConfig.SecretKey
  19434. data["sick_code"] = sickConfig.CountryCode
  19435. data["sick_name"] = sickConfig.ClassName
  19436. data["dept"] = strconv.FormatInt(department.ID, 10)
  19437. data["config"] = config
  19438. data["begin_time"] = begin_time
  19439. bytesData, _ := json.Marshal(data)
  19440. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  19441. resp, _ := client.Do(req)
  19442. defer resp.Body.Close()
  19443. body, ioErr := ioutil.ReadAll(resp.Body)
  19444. if ioErr != nil {
  19445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19447. return
  19448. }
  19449. var respJSON map[string]interface{}
  19450. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19453. return
  19454. }
  19455. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19456. userJSONBytes, _ := json.Marshal(respJSON)
  19457. fmt.Println("log")
  19458. fmt.Println(string(userJSONBytes))
  19459. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19460. utils.ErrorLog("解析失败:%v", err)
  19461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19462. return
  19463. }
  19464. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19465. data := make(map[string]interface{})
  19466. client := &http.Client{}
  19467. data["psn_no"] = his.PsnNo
  19468. data["mdtrt_id"] = his.Number
  19469. data["opter"] = roles.UserName
  19470. data["org_name"] = miConfig.OrgName
  19471. if reg_type == 11 && his.Insutype == "390" {
  19472. data["med_type"] = "110104"
  19473. } else {
  19474. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19475. }
  19476. data["doctor_id"] = doctor_info.DoctorNumber
  19477. data["doctor_name"] = doctor_info.UserName
  19478. data["department"] = department.Name
  19479. data["fixmedins_code"] = miConfig.Code
  19480. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19481. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19482. data["secret_key"] = miConfig.SecretKey
  19483. data["sick_code"] = sickConfig.CountryCode
  19484. data["sick_name"] = sickConfig.ClassName
  19485. data["dept"] = strconv.FormatInt(department.ID, 10)
  19486. data["config"] = config
  19487. data["begin_time"] = begin_time
  19488. bytesData, _ := json.Marshal(data)
  19489. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  19490. resp, _ := client.Do(req)
  19491. defer resp.Body.Close()
  19492. body, ioErr := ioutil.ReadAll(resp.Body)
  19493. if ioErr != nil {
  19494. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19496. return
  19497. }
  19498. var respJSON map[string]interface{}
  19499. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19500. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19502. return
  19503. }
  19504. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19505. userJSONBytes, _ := json.Marshal(respJSON)
  19506. fmt.Println("log")
  19507. fmt.Println(string(userJSONBytes))
  19508. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19509. utils.ErrorLog("解析失败:%v", err)
  19510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19511. return
  19512. }
  19513. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19514. data := make(map[string]interface{})
  19515. client := &http.Client{}
  19516. data["psn_no"] = his.PsnNo
  19517. data["mdtrt_id"] = his.Number
  19518. data["opter"] = roles.UserName
  19519. data["org_name"] = miConfig.OrgName
  19520. if reg_type == 11 && his.Insutype == "390" {
  19521. data["med_type"] = "110104"
  19522. } else {
  19523. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19524. }
  19525. data["doctor_id"] = doctor_info.DoctorNumber
  19526. data["doctor_name"] = doctor_info.UserName
  19527. data["department"] = department.Name
  19528. data["fixmedins_code"] = miConfig.Code
  19529. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19530. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19531. data["secret_key"] = miConfig.SecretKey
  19532. data["sick_code"] = sickConfig.CountryCode
  19533. data["sick_name"] = sickConfig.ClassName
  19534. data["dept"] = strconv.FormatInt(department.ID, 10)
  19535. data["config"] = config
  19536. data["begin_time"] = begin_time
  19537. bytesData, _ := json.Marshal(data)
  19538. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  19539. resp, _ := client.Do(req)
  19540. defer resp.Body.Close()
  19541. body, ioErr := ioutil.ReadAll(resp.Body)
  19542. if ioErr != nil {
  19543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19545. return
  19546. }
  19547. var respJSON map[string]interface{}
  19548. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19551. return
  19552. }
  19553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19554. userJSONBytes, _ := json.Marshal(respJSON)
  19555. fmt.Println("log")
  19556. fmt.Println(string(userJSONBytes))
  19557. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19558. utils.ErrorLog("解析失败:%v", err)
  19559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19560. return
  19561. }
  19562. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19563. data := make(map[string]interface{})
  19564. client := &http.Client{}
  19565. data["psn_no"] = his.PsnNo
  19566. data["mdtrt_id"] = his.Number
  19567. data["opter"] = roles.UserName
  19568. data["org_name"] = miConfig.OrgName
  19569. if reg_type == 11 && his.Insutype == "390" {
  19570. data["med_type"] = "110104"
  19571. } else {
  19572. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19573. }
  19574. data["doctor_id"] = doctor_info.DoctorNumber
  19575. data["doctor_name"] = doctor_info.UserName
  19576. data["department"] = department.Name
  19577. data["fixmedins_code"] = miConfig.Code
  19578. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19579. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19580. data["secret_key"] = miConfig.SecretKey
  19581. data["sick_code"] = sickConfig.CountryCode
  19582. data["sick_name"] = sickConfig.ClassName
  19583. data["dept"] = strconv.FormatInt(department.ID, 10)
  19584. data["config"] = config
  19585. data["begin_time"] = begin_time
  19586. bytesData, _ := json.Marshal(data)
  19587. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  19588. resp, _ := client.Do(req)
  19589. defer resp.Body.Close()
  19590. body, ioErr := ioutil.ReadAll(resp.Body)
  19591. if ioErr != nil {
  19592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19594. return
  19595. }
  19596. var respJSON map[string]interface{}
  19597. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19600. return
  19601. }
  19602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19603. userJSONBytes, _ := json.Marshal(respJSON)
  19604. fmt.Println("log")
  19605. fmt.Println(string(userJSONBytes))
  19606. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19607. utils.ErrorLog("解析失败:%v", err)
  19608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19609. return
  19610. }
  19611. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19612. data := make(map[string]interface{})
  19613. client := &http.Client{}
  19614. data["psn_no"] = his.PsnNo
  19615. data["mdtrt_id"] = his.Number
  19616. data["doctor"] = roles.UserName
  19617. data["department"] = department.Name
  19618. data["org_name"] = miConfig.OrgName
  19619. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19620. data["doctor_id"] = doctor_info.DoctorNumber
  19621. data["new_doctor_name"] = doctor_info.UserName
  19622. data["fixmedins_code"] = miConfig.Code
  19623. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19624. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19625. data["secret_key"] = miConfig.SecretKey
  19626. data["sick_code"] = sickConfig.CountryCode
  19627. data["sick_name"] = sickConfig.ClassName
  19628. data["url"] = miConfig.Url
  19629. data["ak"] = miConfig.AccessKey
  19630. data["begin_time"] = begin_time
  19631. data["cainfo"] = miConfig.Cainfo
  19632. data["dept"] = strconv.FormatInt(department.ID, 10)
  19633. data["config"] = config
  19634. bytesData, _ := json.Marshal(data)
  19635. var req *http.Request
  19636. if miConfig.MdtrtareaAdmvs == "320921" {
  19637. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  19638. //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 +
  19639. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  19640. } else {
  19641. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  19642. }
  19643. resp, _ := client.Do(req)
  19644. defer resp.Body.Close()
  19645. body, ioErr := ioutil.ReadAll(resp.Body)
  19646. if ioErr != nil {
  19647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19649. return
  19650. }
  19651. var respJSON map[string]interface{}
  19652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19655. return
  19656. }
  19657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19658. userJSONBytes, _ := json.Marshal(respJSON)
  19659. fmt.Println("log")
  19660. fmt.Println(string(userJSONBytes))
  19661. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  19662. utils.ErrorLog("解析失败:%v", err)
  19663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19664. return
  19665. }
  19666. res2.InfRefmsgid = ressix10265.InfRefmsgid
  19667. res2.Output = ressix10265.Output
  19668. res2.ErrMsg = ressix10265.ErrMsg
  19669. res2.Cainfo = ressix10265.Cainfo
  19670. res2.WarnMsg = ressix10265.WarnMsg
  19671. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  19672. res2.Infcode = infocode
  19673. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19674. data := make(map[string]interface{})
  19675. client := &http.Client{}
  19676. data["psn_no"] = his.PsnNo
  19677. data["mdtrt_id"] = his.Number
  19678. data["doctor"] = roles.UserName
  19679. data["department"] = department.Name
  19680. data["org_name"] = miConfig.OrgName
  19681. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19682. data["doctor_id"] = doctor_info.DoctorNumber
  19683. data["new_doctor_name"] = doctor_info.UserName
  19684. data["fixmedins_code"] = miConfig.Code
  19685. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19686. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19687. data["secret_key"] = miConfig.SecretKey
  19688. data["sick_code"] = sickConfig.CountryCode
  19689. data["sick_name"] = sickConfig.ClassName
  19690. data["url"] = miConfig.Url
  19691. data["ak"] = miConfig.AccessKey
  19692. data["begin_time"] = begin_time
  19693. data["cainfo"] = miConfig.Cainfo
  19694. data["dept"] = strconv.FormatInt(department.ID, 10)
  19695. data["config"] = config
  19696. bytesData, _ := json.Marshal(data)
  19697. var req *http.Request
  19698. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  19699. resp, _ := client.Do(req)
  19700. defer resp.Body.Close()
  19701. body, ioErr := ioutil.ReadAll(resp.Body)
  19702. if ioErr != nil {
  19703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19705. return
  19706. }
  19707. var respJSON map[string]interface{}
  19708. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19711. return
  19712. }
  19713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19714. userJSONBytes, _ := json.Marshal(respJSON)
  19715. fmt.Println("log")
  19716. fmt.Println(string(userJSONBytes))
  19717. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  19718. utils.ErrorLog("解析失败:%v", err)
  19719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19720. return
  19721. }
  19722. res2.InfRefmsgid = ressix10265.InfRefmsgid
  19723. res2.Output = ressix10265.Output
  19724. res2.ErrMsg = ressix10265.ErrMsg
  19725. res2.Cainfo = ressix10265.Cainfo
  19726. res2.WarnMsg = ressix10265.WarnMsg
  19727. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  19728. res2.Infcode = infocode
  19729. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19730. 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)
  19731. saveLog(result, requestLog, "2203", "上传就诊信息")
  19732. var respJSON2 map[string]interface{}
  19733. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  19734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19736. return
  19737. }
  19738. userJSONBytes2, _ := json.Marshal(respJSON2)
  19739. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  19740. utils.ErrorLog("解析失败:%v", err)
  19741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19742. return
  19743. }
  19744. 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)
  19745. fmt.Println(result2)
  19746. fmt.Println(src_request)
  19747. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19748. data := make(map[string]interface{})
  19749. client := &http.Client{}
  19750. data["psn_no"] = his.PsnNo
  19751. data["mdtrt_id"] = his.Number
  19752. data["doctor"] = roles.UserName
  19753. data["department"] = department.Name
  19754. data["org_name"] = miConfig.OrgName
  19755. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19756. data["doctor_id"] = doctor_info.DoctorNumber
  19757. data["new_doctor_name"] = doctor_info.UserName
  19758. data["fixmedins_code"] = miConfig.Code
  19759. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19760. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19761. data["secret_key"] = miConfig.SecretKey
  19762. data["sick_code"] = sickConfig.CountryCode
  19763. data["sick_name"] = sickConfig.ClassName
  19764. data["url"] = miConfig.Url
  19765. data["ak"] = miConfig.AccessKey
  19766. data["begin_time"] = begin_time
  19767. data["cainfo"] = miConfig.Cainfo
  19768. data["dept"] = strconv.FormatInt(department.ID, 10)
  19769. data["config"] = config
  19770. bytesData, _ := json.Marshal(data)
  19771. var req *http.Request
  19772. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  19773. resp, _ := client.Do(req)
  19774. defer resp.Body.Close()
  19775. body, ioErr := ioutil.ReadAll(resp.Body)
  19776. if ioErr != nil {
  19777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19779. return
  19780. }
  19781. var respJSON map[string]interface{}
  19782. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19785. return
  19786. }
  19787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19788. userJSONBytes, _ := json.Marshal(respJSON)
  19789. fmt.Println("log")
  19790. fmt.Println(string(userJSONBytes))
  19791. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19792. utils.ErrorLog("解析失败:%v", err)
  19793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19794. return
  19795. }
  19796. } else {
  19797. if miConfig.MdtrtareaAdmvs == "440781" { //
  19798. 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)
  19799. } else {
  19800. if miConfig.Code == "H15049901371" {
  19801. //赤峰地区国家医保医疗类别
  19802. //职工透析:医疗类别选特殊情况门诊990502
  19803. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19804. var med_type string
  19805. if his.Insutype == "390" {
  19806. if reg_type == 14 {
  19807. med_type = "9933"
  19808. } else if reg_type == 11 {
  19809. med_type = "11"
  19810. }
  19811. } else if his.Insutype == "310" {
  19812. if reg_type == 14 {
  19813. med_type = "990502"
  19814. } else if reg_type == 11 {
  19815. med_type = "11"
  19816. }
  19817. }
  19818. 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)
  19819. } else {
  19820. 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)
  19821. }
  19822. }
  19823. saveLog(result, requestLog, "2203", "上传就诊信息")
  19824. var respJSON2 map[string]interface{}
  19825. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  19826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19828. return
  19829. }
  19830. userJSONBytes2, _ := json.Marshal(respJSON2)
  19831. if miConfig.Code == "H15049901371" {
  19832. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  19833. utils.ErrorLog("解析失败:%v", err)
  19834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19835. return
  19836. }
  19837. res2.InfRefmsgid = ressix10265.InfRefmsgid
  19838. res2.Output = ressix10265.Output
  19839. res2.ErrMsg = ressix10265.ErrMsg
  19840. res2.Cainfo = ressix10265.Cainfo
  19841. res2.WarnMsg = ressix10265.WarnMsg
  19842. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  19843. res2.Infcode = infocode
  19844. } else {
  19845. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19846. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  19847. utils.ErrorLog("解析失败:%v", err)
  19848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19849. return
  19850. }
  19851. res2.Infcode = res3.Infcode
  19852. } else {
  19853. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  19854. utils.ErrorLog("解析失败:%v", err)
  19855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19856. return
  19857. }
  19858. }
  19859. }
  19860. }
  19861. if res2.Infcode != 0 {
  19862. adminUser := c.GetAdminUserInfo()
  19863. errlog := &models.HisOrderError{
  19864. UserOrgId: adminUser.CurrentOrgId,
  19865. Ctime: time.Now().Unix(),
  19866. Mtime: time.Now().Unix(),
  19867. ErrMsg: res2.ErrMsg,
  19868. Status: 1,
  19869. PatientId: id,
  19870. RecordTime: recordDateTime,
  19871. Stage: 3,
  19872. }
  19873. service.CreateErrMsgLog(errlog)
  19874. c.ServeSuccessJSON(map[string]interface{}{
  19875. "failed_code": -10,
  19876. "msg": res2.ErrMsg,
  19877. })
  19878. return
  19879. } else {
  19880. his.Diagnosis = diagnosis_id
  19881. his.SickType = sickConfig.ID
  19882. //var p_type int64
  19883. //if reg_type == 1111 || reg_type == 1112 {
  19884. // p_type = 11
  19885. //
  19886. //}
  19887. his.PType = fmt.Sprintf("%d", reg_type)
  19888. service.UpdateHisPatientThree(&his)
  19889. data := make(map[string]interface{})
  19890. if settle_accounts_type == 1 { //日结
  19891. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  19892. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  19893. } else {
  19894. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  19895. }
  19896. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  19897. data["pre"] = prescriptions
  19898. } else { //月结
  19899. start_time_str := c.GetString("start_time")
  19900. end_time_str := c.GetString("end_time")
  19901. timeLayout := "2006-01-02"
  19902. loc, _ := time.LoadLocation("Local")
  19903. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  19904. if err != nil {
  19905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19906. return
  19907. }
  19908. recordStartTime := theStartTime.Unix()
  19909. start_time = recordStartTime
  19910. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  19911. if err != nil {
  19912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19913. return
  19914. }
  19915. recordEndTime := theEndTime.Unix()
  19916. end_time = recordEndTime
  19917. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  19918. data["pre"] = prescriptions
  19919. }
  19920. timestamp := time.Now().Unix()
  19921. tempTime := time.Unix(timestamp, 0)
  19922. timeFormat := tempTime.Format("20060102150405")
  19923. chrgBchno := rand.Intn(100000) + 10000
  19924. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  19925. strconv.FormatInt(his.PatientId, 10)
  19926. client := &http.Client{}
  19927. data["psn_no"] = his.PsnNo
  19928. data["mdtrt_id"] = his.Number
  19929. data["chrg_bchno"] = chrg_bchno
  19930. data["org_name"] = miConfig.OrgName
  19931. data["doctor"] = doctor_info.UserName
  19932. data["doctor_id"] = doctor_info.DoctorNumber
  19933. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  19934. data["fixmedins_code"] = miConfig.Code
  19935. data["dept_code"] = department.Number
  19936. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19937. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19938. data["secret_key"] = miConfig.SecretKey
  19939. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  19940. data["url"] = miConfig.Url
  19941. data["ak"] = miConfig.AccessKey
  19942. data["new_doctor_name"] = patientPrescription.Doctor
  19943. data["diag_code"] = sickConfig.CountryCode
  19944. data["cainfo"] = miConfig.Cainfo
  19945. data["opter"] = roles.UserName
  19946. var ids []int64
  19947. for _, item := range prescriptions {
  19948. ids = append(ids, item.ID)
  19949. }
  19950. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19951. if config.IsOpen == 1 { //对接了医保,走医保流程
  19952. var res ResultFour
  19953. var resFour10265 ResultFour10265
  19954. if miConfig.MdtrtareaAdmvs == "421300" {
  19955. bytesData, _ := json.Marshal(data)
  19956. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19957. resp, _ := client.Do(req)
  19958. defer resp.Body.Close()
  19959. body, ioErr := ioutil.ReadAll(resp.Body)
  19960. if ioErr != nil {
  19961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19963. return
  19964. }
  19965. var respJSON map[string]interface{}
  19966. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19969. return
  19970. }
  19971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19972. userJSONBytes, _ := json.Marshal(respJSON)
  19973. fmt.Println("log")
  19974. fmt.Println(string(userJSONBytes))
  19975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19976. utils.ErrorLog("解析失败:%v", err)
  19977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19978. return
  19979. }
  19980. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19981. bytesData, _ := json.Marshal(data)
  19982. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19983. resp, _ := client.Do(req)
  19984. defer resp.Body.Close()
  19985. body, ioErr := ioutil.ReadAll(resp.Body)
  19986. if ioErr != nil {
  19987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19989. return
  19990. }
  19991. var respJSON map[string]interface{}
  19992. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19995. return
  19996. }
  19997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19998. userJSONBytes, _ := json.Marshal(respJSON)
  19999. fmt.Println("log")
  20000. fmt.Println(string(userJSONBytes))
  20001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20002. utils.ErrorLog("解析失败:%v", err)
  20003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20004. return
  20005. }
  20006. } else if miConfig.MdtrtareaAdmvs == "420902" {
  20007. bytesData, _ := json.Marshal(data)
  20008. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  20009. resp, _ := client.Do(req)
  20010. defer resp.Body.Close()
  20011. body, ioErr := ioutil.ReadAll(resp.Body)
  20012. if ioErr != nil {
  20013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20015. return
  20016. }
  20017. var respJSON map[string]interface{}
  20018. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20021. return
  20022. }
  20023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20024. userJSONBytes, _ := json.Marshal(respJSON)
  20025. fmt.Println("log")
  20026. fmt.Println(string(userJSONBytes))
  20027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20028. utils.ErrorLog("解析失败:%v", err)
  20029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20030. return
  20031. }
  20032. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20033. bytesData, _ := json.Marshal(data)
  20034. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  20035. resp, _ := client.Do(req)
  20036. defer resp.Body.Close()
  20037. body, ioErr := ioutil.ReadAll(resp.Body)
  20038. if ioErr != nil {
  20039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20041. return
  20042. }
  20043. var respJSON map[string]interface{}
  20044. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20047. return
  20048. }
  20049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20050. userJSONBytes, _ := json.Marshal(respJSON)
  20051. fmt.Println("log")
  20052. fmt.Println(string(userJSONBytes))
  20053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20054. utils.ErrorLog("解析失败:%v", err)
  20055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20056. return
  20057. }
  20058. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20059. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  20060. if result3101.Infcode == "0" {
  20061. if len(result3101.Output.Result) > 0 {
  20062. var errMsgs []string
  20063. for _, item := range result3101.Output.Result {
  20064. errMsgs = append(errMsgs, item.VolaCont)
  20065. }
  20066. c.ServeSuccessJSON(map[string]interface{}{
  20067. "failed_code": -10,
  20068. "msg": errMsgs,
  20069. })
  20070. return
  20071. }
  20072. }
  20073. bytesData, _ := json.Marshal(data)
  20074. var req *http.Request
  20075. if miConfig.MdtrtareaAdmvs == "320921" {
  20076. data["diag_code"] = sickConfig.CountryCode
  20077. fmt.Println(data)
  20078. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20079. } else {
  20080. data["diag_code"] = sickConfig.CountryCode
  20081. fmt.Println(data)
  20082. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20083. }
  20084. resp, _ := client.Do(req)
  20085. defer resp.Body.Close()
  20086. body, ioErr := ioutil.ReadAll(resp.Body)
  20087. if ioErr != nil {
  20088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20090. return
  20091. }
  20092. var respJSON map[string]interface{}
  20093. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20096. return
  20097. }
  20098. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20099. userJSONBytes, _ := json.Marshal(respJSON)
  20100. fmt.Println("log")
  20101. fmt.Println(string(userJSONBytes))
  20102. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20103. utils.ErrorLog("解析失败:%v", err)
  20104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20105. return
  20106. }
  20107. res.InfRefmsgid = resFour10265.InfRefmsgid
  20108. res.Output = resFour10265.Output
  20109. res.ErrMsg = resFour10265.ErrMsg
  20110. res.Cainfo = resFour10265.Cainfo
  20111. res.WarnMsg = resFour10265.WarnMsg
  20112. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20113. res.Infcode = infocode
  20114. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20115. var pagesize int = 2
  20116. var start int = 1
  20117. var stop int
  20118. var pagecount int
  20119. var curpage int
  20120. var isSuccess bool = true
  20121. data["doctor_id"] = doctor_info.DoctorNumber
  20122. //总页数,向上取整,注意除之前要先转换类型为float64
  20123. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  20124. for curpage = 1; curpage <= pagecount; curpage++ {
  20125. if curpage == 1 {
  20126. start = 1
  20127. } else {
  20128. start = (curpage-1)*pagesize + 1
  20129. }
  20130. stop = curpage * pagesize
  20131. if stop > len(prescriptions) {
  20132. stop = len(prescriptions)
  20133. }
  20134. //var requestLog string
  20135. data["pre"] = prescriptions[start-1 : stop]
  20136. fmt.Println(data["pre"])
  20137. bytesData, _ := json.Marshal(data)
  20138. var req *http.Request
  20139. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  20140. resp, _ := client.Do(req)
  20141. defer resp.Body.Close()
  20142. body, ioErr := ioutil.ReadAll(resp.Body)
  20143. if ioErr != nil {
  20144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20146. return
  20147. }
  20148. var respJSON map[string]interface{}
  20149. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20152. return
  20153. }
  20154. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20155. userJSONBytes, _ := json.Marshal(respJSON)
  20156. fmt.Println("log")
  20157. fmt.Println(string(userJSONBytes))
  20158. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20159. utils.ErrorLog("解析失败:%v", err)
  20160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20161. return
  20162. }
  20163. res.InfRefmsgid = resFour10265.InfRefmsgid
  20164. res.Output = resFour10265.Output
  20165. res.ErrMsg = resFour10265.ErrMsg
  20166. res.Cainfo = resFour10265.Cainfo
  20167. res.WarnMsg = resFour10265.WarnMsg
  20168. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20169. res.Infcode = infocode
  20170. if infocode == 0 {
  20171. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  20172. } else {
  20173. isSuccess = false
  20174. errlog := &models.HisOrderError{
  20175. UserOrgId: adminUser.CurrentOrgId,
  20176. Ctime: time.Now().Unix(),
  20177. Mtime: time.Now().Unix(),
  20178. Number: chrg_bchno,
  20179. ErrMsg: "",
  20180. Status: 1,
  20181. PatientId: id,
  20182. RecordTime: recordDateTime,
  20183. Stage: 4,
  20184. }
  20185. service.CreateErrMsgLog(errlog)
  20186. c.ServeSuccessJSON(map[string]interface{}{
  20187. "failed_code": -10,
  20188. "msg": res.ErrMsg,
  20189. })
  20190. return
  20191. }
  20192. }
  20193. if isSuccess {
  20194. res.Infcode = 0
  20195. }
  20196. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20197. 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)
  20198. var dat map[string]interface{}
  20199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20200. fmt.Println(dat)
  20201. } else {
  20202. fmt.Println(err)
  20203. }
  20204. saveLog(result, request_log, "2204", "上传费用明细")
  20205. userJSONBytes, _ := json.Marshal(dat)
  20206. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20207. utils.ErrorLog("解析失败:%v", err)
  20208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20209. return
  20210. }
  20211. res.InfRefmsgid = resFour10265.InfRefmsgid
  20212. res.Output = resFour10265.Output
  20213. res.ErrMsg = resFour10265.ErrMsg
  20214. res.Cainfo = resFour10265.Cainfo
  20215. res.WarnMsg = resFour10265.WarnMsg
  20216. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20217. res.Infcode = infocode
  20218. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20219. bytesData, _ := json.Marshal(data)
  20220. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  20221. resp, _ := client.Do(req)
  20222. defer resp.Body.Close()
  20223. body, ioErr := ioutil.ReadAll(resp.Body)
  20224. if ioErr != nil {
  20225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20227. return
  20228. }
  20229. var respJSON map[string]interface{}
  20230. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20233. return
  20234. }
  20235. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20236. userJSONBytes, _ := json.Marshal(respJSON)
  20237. fmt.Println("log")
  20238. fmt.Println(string(userJSONBytes))
  20239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20240. utils.ErrorLog("解析失败:%v", err)
  20241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20242. return
  20243. }
  20244. } else {
  20245. if miConfig.Code == "H15049901371" {
  20246. 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)
  20247. var dat map[string]interface{}
  20248. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20249. fmt.Println(dat)
  20250. } else {
  20251. fmt.Println(err)
  20252. }
  20253. saveLog(result, request_log, "2204", "上传费用明细")
  20254. userJSONBytes, _ := json.Marshal(dat)
  20255. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20256. utils.ErrorLog("解析失败:%v", err)
  20257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20258. return
  20259. }
  20260. res.InfRefmsgid = resFour10265.InfRefmsgid
  20261. res.Output = resFour10265.Output
  20262. res.ErrMsg = resFour10265.ErrMsg
  20263. res.Cainfo = resFour10265.Cainfo
  20264. res.WarnMsg = resFour10265.WarnMsg
  20265. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20266. res.Infcode = infocode
  20267. } else {
  20268. 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)
  20269. var dat map[string]interface{}
  20270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20271. fmt.Println(dat)
  20272. } else {
  20273. fmt.Println(err)
  20274. }
  20275. saveLog(result, request_log, "2204", "上传费用明细")
  20276. userJSONBytes, _ := json.Marshal(dat)
  20277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20278. utils.ErrorLog("解析失败:%v", err)
  20279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20280. return
  20281. }
  20282. }
  20283. }
  20284. if res.Infcode == 0 {
  20285. order := &models.HisOrder{
  20286. UserOrgId: adminUser.CurrentOrgId,
  20287. HisPatientId: his.ID,
  20288. PatientId: his.PatientId,
  20289. SettleAccountsDate: recordDateTime,
  20290. MdtrtId: his.Number,
  20291. PsnNo: his.PsnNo,
  20292. MedType: strconv.FormatInt(reg_type, 10),
  20293. Ctime: time.Now().Unix(),
  20294. Mtime: time.Now().Unix(),
  20295. Status: 1,
  20296. Number: chrg_bchno,
  20297. Infcode: res.Infcode,
  20298. WarnMsg: res.WarnMsg,
  20299. Cainfo: res.Cainfo,
  20300. ErrMsg: res.ErrMsg,
  20301. RespondTime: res.RefmsgTime,
  20302. InfRefmsgid: res.InfRefmsgid,
  20303. OrderStatus: 1,
  20304. PayWay: pay_way,
  20305. PayWays: pay_ways,
  20306. OthDesc: oth_desc,
  20307. PayPrice: pay_price,
  20308. PayCardNo: pay_card_no,
  20309. DiscountPrice: discount_price,
  20310. PreferentialPrice: preferential_price,
  20311. RealityPrice: reality_price,
  20312. FoundPrice: found_price,
  20313. MedicalInsurancePrice: medical_insurance_price,
  20314. PrivatePrice: private_price,
  20315. IsMedicineInsurance: 1,
  20316. SettleType: settle_accounts_type,
  20317. SettleStartTime: start_time,
  20318. SettleEndTime: end_time,
  20319. Creator: roles.AdminUserId,
  20320. Modify: roles.AdminUserId,
  20321. FaPiaoNumber: fapiao_number,
  20322. FaPiaoCode: fapiao_code,
  20323. PType: 2,
  20324. Diagnosis: diagnosis_id,
  20325. CashPay: cash_pay,
  20326. WechatPay: wechat_pay,
  20327. AliPay: ali_pay,
  20328. JifenPay: jifen_pay,
  20329. BandCardPay: band_card_pay,
  20330. }
  20331. err = service.CreateOrder(order)
  20332. if err != nil {
  20333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  20334. return
  20335. }
  20336. for _, item := range res.Output.Result {
  20337. temp := strings.Split(item.FeedetlSn, "-")
  20338. var advice_id int64 = 0
  20339. var project_id int64 = 0
  20340. var types int64 = 0
  20341. id, _ := strconv.ParseInt(temp[2], 10, 64)
  20342. types, _ = strconv.ParseInt(temp[1], 10, 64)
  20343. if temp[1] == "1" {
  20344. advice_id = id
  20345. project_id = 0
  20346. } else if temp[1] == "2" {
  20347. advice_id = 0
  20348. project_id = id
  20349. }
  20350. if item.MedChrgitmType == "9" {
  20351. item.MedChrgitmType = "09"
  20352. }
  20353. info := &models.HisOrderInfo{
  20354. OrderNumber: order.Number,
  20355. FeedetlSn: item.FeedetlSn,
  20356. UploadDate: time.Now().Unix(),
  20357. AdviceId: advice_id,
  20358. DetItemFeeSumamt: item.DetItemFeeSumamt,
  20359. Cnt: item.Cnt,
  20360. Pric: float64(item.Pric),
  20361. PatientId: his.PatientId,
  20362. PricUplmtAmt: item.PricUplmtAmt,
  20363. SelfpayProp: item.SelfpayProp,
  20364. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  20365. OverlmtAmt: item.OverlmtAmt,
  20366. PreselfpayAmt: item.PreselfpayAmt,
  20367. BasMednFlag: item.BasMednFlag,
  20368. MedChrgitmType: item.MedChrgitmType,
  20369. HiNegoDrugFlag: item.HiNegoDrugFlag,
  20370. Status: 1,
  20371. Memo: item.Memo,
  20372. Mtime: time.Now().Unix(),
  20373. InscpScpAmt: item.InscpScpAmt,
  20374. DrtReimFlag: item.DrtReimFlag,
  20375. Ctime: time.Now().Unix(),
  20376. ListSpItemFlag: item.ListSpItemFlag,
  20377. ChldMedcFlag: item.ChldMedcFlag,
  20378. LmtUsedFlag: item.LmtUsedFlag,
  20379. ChrgitmLv: item.ChrgitmLv,
  20380. UserOrgId: adminUser.CurrentOrgId,
  20381. HisPatientId: his.ID,
  20382. OrderId: order.ID,
  20383. ProjectId: project_id,
  20384. Type: types,
  20385. }
  20386. service.CreateOrderInfo(info)
  20387. }
  20388. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  20389. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  20390. var total float64
  20391. for _, item := range prescriptions {
  20392. if item.Type == 1 { //药品
  20393. for _, subItem := range item.HisDoctorAdviceInfo {
  20394. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  20395. total_one := price * subItem.PrescribingNumber
  20396. total = total + total_one
  20397. }
  20398. }
  20399. if item.Type == 2 { //项目
  20400. for _, subItem := range item.HisPrescriptionProject {
  20401. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  20402. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  20403. total_one := price * cnt
  20404. total = total + total_one
  20405. }
  20406. }
  20407. }
  20408. allTotal := fmt.Sprintf("%.2f", total)
  20409. //if adminUser.CurrentOrgId == 9919 {
  20410. //
  20411. // allTotal = fmt.Sprintf("%.2f", total)
  20412. //
  20413. //} else {
  20414. //
  20415. // allTotal = fmt.Sprintf("%.2f", total)
  20416. //
  20417. //}
  20418. if res.Infcode == 0 {
  20419. var rf []*ResultFive
  20420. json.Unmarshal([]byte(his.Iinfo), &rf)
  20421. chrg_bchno := chrg_bchno
  20422. cert_no := his.Certno
  20423. var insutypes []string
  20424. var insutype string
  20425. var is390 int = 0
  20426. var is310 int = 0
  20427. for _, item := range rf {
  20428. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20429. insutypes = append(insutypes, item.Insutype)
  20430. }
  20431. }
  20432. if len(insutypes) == 1 {
  20433. insutype = insutypes[0]
  20434. } else {
  20435. for _, i := range insutypes {
  20436. if i == "390" {
  20437. is390 = 1
  20438. }
  20439. if i == "310" {
  20440. is310 = 1
  20441. }
  20442. }
  20443. }
  20444. if is390 == 1 {
  20445. insutype = "390"
  20446. }
  20447. if is310 == 1 {
  20448. insutype = "310"
  20449. }
  20450. if len(insutypes) == 0 {
  20451. insutype = "310"
  20452. }
  20453. if len(insutypes) == 2 {
  20454. insutype = strconv.FormatInt(his.SocialType, 10)
  20455. }
  20456. insutype = strconv.FormatInt(his.SocialType, 10)
  20457. //insutype = "390"
  20458. if his.IdCardType == 1 {
  20459. // cert_no = his.MedicalInsuranceNumber
  20460. cert_no = his.Certno
  20461. } else {
  20462. cert_no = his.Certno
  20463. }
  20464. var res ResultSeven
  20465. var resSeven10265 ResultSeven10265
  20466. var gzresSeven10265Two GZResultSeven10265Two
  20467. var src_resquest string
  20468. var result2 string
  20469. if miConfig.MdtrtareaAdmvs == "421300" {
  20470. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20471. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20472. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20473. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20474. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20475. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20476. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20477. resp, requestErr := http.Get(api)
  20478. if requestErr != nil {
  20479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20480. return
  20481. }
  20482. body, ioErr := ioutil.ReadAll(resp.Body)
  20483. if ioErr != nil {
  20484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20486. return
  20487. }
  20488. var respJSON map[string]interface{}
  20489. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20492. return
  20493. }
  20494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20495. result, _ := json.Marshal(respJSON)
  20496. if miConfig.Code == "H15049901371" {
  20497. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20498. utils.ErrorLog("解析失败:%v", err)
  20499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20500. return
  20501. }
  20502. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20503. res.Output = resSeven10265.Output
  20504. res.ErrMsg = resSeven10265.ErrMsg
  20505. res.Cainfo = resSeven10265.Cainfo
  20506. res.WarnMsg = resSeven10265.WarnMsg
  20507. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20508. res.Infcode = infocode
  20509. } else {
  20510. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20511. utils.ErrorLog("解析失败:%v", err)
  20512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20513. return
  20514. }
  20515. }
  20516. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20517. if reg_type == 11 && his.Insutype == "390" {
  20518. reg_type = 110104
  20519. }
  20520. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20521. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20522. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20523. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20524. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20525. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20526. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20527. resp, requestErr := http.Get(api)
  20528. if requestErr != nil {
  20529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20530. return
  20531. }
  20532. body, ioErr := ioutil.ReadAll(resp.Body)
  20533. if ioErr != nil {
  20534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20536. return
  20537. }
  20538. var respJSON map[string]interface{}
  20539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20542. return
  20543. }
  20544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20545. result, _ := json.Marshal(respJSON)
  20546. if miConfig.Code == "H15049901371" {
  20547. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20548. utils.ErrorLog("解析失败:%v", err)
  20549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20550. return
  20551. }
  20552. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20553. res.Output = resSeven10265.Output
  20554. res.ErrMsg = resSeven10265.ErrMsg
  20555. res.Cainfo = resSeven10265.Cainfo
  20556. res.WarnMsg = resSeven10265.WarnMsg
  20557. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20558. res.Infcode = infocode
  20559. } else {
  20560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20561. utils.ErrorLog("解析失败:%v", err)
  20562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20563. return
  20564. }
  20565. }
  20566. } else if miConfig.MdtrtareaAdmvs == "420902" {
  20567. if reg_type == 11 && his.Insutype == "390" {
  20568. reg_type = 110104
  20569. }
  20570. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20571. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20572. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20573. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20574. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20575. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20576. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20577. resp, requestErr := http.Get(api)
  20578. if requestErr != nil {
  20579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20580. return
  20581. }
  20582. body, ioErr := ioutil.ReadAll(resp.Body)
  20583. if ioErr != nil {
  20584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20586. return
  20587. }
  20588. var respJSON map[string]interface{}
  20589. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20592. return
  20593. }
  20594. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20595. result, _ := json.Marshal(respJSON)
  20596. if miConfig.Code == "H15049901371" {
  20597. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20598. utils.ErrorLog("解析失败:%v", err)
  20599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20600. return
  20601. }
  20602. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20603. res.Output = resSeven10265.Output
  20604. res.ErrMsg = resSeven10265.ErrMsg
  20605. res.Cainfo = resSeven10265.Cainfo
  20606. res.WarnMsg = resSeven10265.WarnMsg
  20607. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20608. res.Infcode = infocode
  20609. } else {
  20610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20611. utils.ErrorLog("解析失败:%v", err)
  20612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20613. return
  20614. }
  20615. }
  20616. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20617. if reg_type == 11 && his.Insutype == "390" {
  20618. reg_type = 110104
  20619. }
  20620. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20621. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20622. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20623. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20624. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20625. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20626. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20627. resp, requestErr := http.Get(api)
  20628. if requestErr != nil {
  20629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20630. return
  20631. }
  20632. body, ioErr := ioutil.ReadAll(resp.Body)
  20633. if ioErr != nil {
  20634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20636. return
  20637. }
  20638. var respJSON map[string]interface{}
  20639. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20642. return
  20643. }
  20644. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20645. result, _ := json.Marshal(respJSON)
  20646. if miConfig.Code == "H15049901371" {
  20647. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20648. utils.ErrorLog("解析失败:%v", err)
  20649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20650. return
  20651. }
  20652. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20653. res.Output = resSeven10265.Output
  20654. res.ErrMsg = resSeven10265.ErrMsg
  20655. res.Cainfo = resSeven10265.Cainfo
  20656. res.WarnMsg = resSeven10265.WarnMsg
  20657. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20658. res.Infcode = infocode
  20659. } else {
  20660. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20661. utils.ErrorLog("解析失败:%v", err)
  20662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20663. return
  20664. }
  20665. }
  20666. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20667. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  20668. if result3101.Infcode == "0" {
  20669. if len(result3101.Output.Result) > 0 {
  20670. var errMsgs []string
  20671. for _, item := range result3101.Output.Result {
  20672. errMsgs = append(errMsgs, item.VolaCont)
  20673. }
  20674. c.ServeSuccessJSON(map[string]interface{}{
  20675. "failed_code": -10,
  20676. "msg": errMsgs,
  20677. })
  20678. return
  20679. } else {
  20680. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20681. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20682. bas := strings.Split(psn_info.CardInfo, "|")
  20683. if his.IdCardType == 1 {
  20684. cert_no = bas[2]
  20685. } else if his.IdCardType == 3 {
  20686. cert_no = his.Certno
  20687. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20688. } else if his.IdCardType == 4 {
  20689. cert_no = his.Certno
  20690. psn_info.VerifyNumber = psn_info.VerifyNumber
  20691. }
  20692. var api string
  20693. if miConfig.MdtrtareaAdmvs == "320921" {
  20694. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20695. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20696. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20697. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20698. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20699. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20700. "&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
  20701. } else {
  20702. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20703. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20704. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20705. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20706. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20707. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20708. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + 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
  20709. }
  20710. resp, requestErr := http.Get(api)
  20711. if requestErr != nil {
  20712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20713. return
  20714. }
  20715. body, ioErr := ioutil.ReadAll(resp.Body)
  20716. if ioErr != nil {
  20717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20719. return
  20720. }
  20721. var respJSON map[string]interface{}
  20722. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20725. return
  20726. }
  20727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20728. result, _ := json.Marshal(respJSON)
  20729. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20730. utils.ErrorLog("解析失败:%v", err)
  20731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20732. return
  20733. }
  20734. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20735. res.Output = resSeven10265.Output
  20736. res.ErrMsg = resSeven10265.ErrMsg
  20737. res.Cainfo = resSeven10265.Cainfo
  20738. res.WarnMsg = resSeven10265.WarnMsg
  20739. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20740. res.Infcode = infocode
  20741. }
  20742. }
  20743. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20744. psn_info, _ := service.GetPsnByPatientId(id)
  20745. var verify_number string
  20746. if psn_info.IdCardType == 4 {
  20747. verify_number = psn_info.VerifyNumber
  20748. } else if psn_info.IdCardType == 1 {
  20749. bas := strings.Split(psn_info.CardInfo, "|")
  20750. cardNumber := bas[2]
  20751. verify_number = cardNumber
  20752. } else {
  20753. psn_info.IdCardType = 2
  20754. verify_number = psn_info.Certno
  20755. }
  20756. var api string
  20757. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20758. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20759. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20760. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20761. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20762. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20763. "&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
  20764. resp, requestErr := http.Get(api)
  20765. if requestErr != nil {
  20766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20767. return
  20768. }
  20769. body, ioErr := ioutil.ReadAll(resp.Body)
  20770. if ioErr != nil {
  20771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20773. return
  20774. }
  20775. var respJSON map[string]interface{}
  20776. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20779. return
  20780. }
  20781. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20782. result, _ := json.Marshal(respJSON)
  20783. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20784. utils.ErrorLog("解析失败:%v", err)
  20785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20786. return
  20787. }
  20788. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20789. res.Output = resSeven10265.Output
  20790. res.ErrMsg = resSeven10265.ErrMsg
  20791. res.Cainfo = resSeven10265.Cainfo
  20792. res.WarnMsg = resSeven10265.WarnMsg
  20793. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20794. res.Infcode = infocode
  20795. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20796. var cert_no string
  20797. if his.IdCardType == 4 {
  20798. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20799. cert_no = psn_info.VerifyNumber
  20800. 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)
  20801. } else if his.IdCardType == 1 {
  20802. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20803. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20804. 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)
  20805. }
  20806. //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)
  20807. var dat map[string]interface{}
  20808. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20809. fmt.Println(dat)
  20810. } else {
  20811. fmt.Println(err)
  20812. }
  20813. saveLog(result2, src_resquest, "2207", "结算")
  20814. userJSONBytes, _ := json.Marshal(dat)
  20815. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20816. utils.ErrorLog("解析失败:%v", err)
  20817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20818. return
  20819. }
  20820. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20821. res.Output = resSeven10265.Output
  20822. res.ErrMsg = resSeven10265.ErrMsg
  20823. res.Cainfo = resSeven10265.Cainfo
  20824. res.WarnMsg = resSeven10265.WarnMsg
  20825. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20826. res.Infcode = infocode
  20827. } else if miConfig.MdtrtareaAdmvs == "450721" {
  20828. res2 := c.GetoleInfo()
  20829. if res2.Infcode == 0 {
  20830. var result string
  20831. var request_log string
  20832. var result_log string
  20833. if res2.Output.MdtrtCertType == "02" {
  20834. 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)
  20835. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20836. } else if res2.Output.MdtrtCertType == "01" {
  20837. 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)
  20838. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20839. } else {
  20840. 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)
  20841. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20842. }
  20843. var dat map[string]interface{}
  20844. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20845. fmt.Println(dat)
  20846. } else {
  20847. fmt.Println(err)
  20848. }
  20849. userJSONBytes, _ := json.Marshal(dat)
  20850. var res5 ResultTwo
  20851. //var resTwo10265 ResultTwo10265
  20852. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20853. utils.ErrorLog("解析失败:%v", err)
  20854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20855. return
  20856. }
  20857. if res5.Infcode == -1 {
  20858. c.ServeSuccessJSON(map[string]interface{}{
  20859. "failed_code": -10,
  20860. "msg": res5.ErrMsg,
  20861. })
  20862. return
  20863. }
  20864. var insutypes []string
  20865. var insutype string
  20866. var is390 int = 0
  20867. var is310 int = 0
  20868. for _, item := range res5.Output.Iinfo {
  20869. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20870. insutypes = append(insutypes, item.Insutype)
  20871. }
  20872. }
  20873. if len(insutypes) == 1 {
  20874. insutype = insutypes[0]
  20875. } else {
  20876. for _, i := range insutypes {
  20877. if i == "390" {
  20878. is390 = 1
  20879. }
  20880. if i == "310" {
  20881. is310 = 1
  20882. }
  20883. }
  20884. }
  20885. if is390 == 1 {
  20886. insutype = "390"
  20887. }
  20888. if is310 == 1 {
  20889. insutype = "310"
  20890. }
  20891. if len(insutypes) == 0 {
  20892. insutype = "310"
  20893. }
  20894. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20895. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20896. infoStr := string(Iinfos)
  20897. idetinfoStr := string(Idetinfos)
  20898. psn := &models.HisPsn{
  20899. PsnNo: res5.Output.Baseinfo.PsnNo,
  20900. PatientId: id,
  20901. Certno: res5.Output.Baseinfo.Certno,
  20902. Gend: res5.Output.Baseinfo.Gend,
  20903. Naty: res5.Output.Baseinfo.Naty,
  20904. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20905. PsnName: res5.Output.Baseinfo.PsnName,
  20906. Idetinfo: idetinfoStr,
  20907. Insuinfo: infoStr,
  20908. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20909. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20910. VerifyNumber: res2.Output.EcToken,
  20911. }
  20912. if res2.Output.MdtrtCertType == "01" {
  20913. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20914. psn.VerifyNumber = res2.Output.EcToken
  20915. } else if res2.Output.MdtrtCertType == "02" {
  20916. psn.VerifyNumber = res2.Output.CardNo
  20917. } else {
  20918. psn.VerifyNumber = res2.Output.MdtrtCertNo
  20919. }
  20920. service.CreateHisPsn(psn)
  20921. if res2.Output.MdtrtCertType == "01" {
  20922. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20923. token := res2.Output.EcToken
  20924. 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)
  20925. } else if res2.Output.MdtrtCertType == "02" {
  20926. 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)
  20927. } else {
  20928. 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)
  20929. }
  20930. var dat2 map[string]interface{}
  20931. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20932. fmt.Println(dat2)
  20933. } else {
  20934. fmt.Println(err)
  20935. }
  20936. userJSONBytes3, _ := json.Marshal(dat2)
  20937. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20938. utils.ErrorLog("解析失败:%v", err)
  20939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20940. return
  20941. }
  20942. saveLog(result2, src_resquest, "2207", "结算")
  20943. } else {
  20944. c.ServeSuccessJSON(map[string]interface{}{
  20945. "failed_code": -10,
  20946. "msg": res2.ErrMsg,
  20947. })
  20948. return
  20949. }
  20950. } else {
  20951. if miConfig.Code == "H15049901371" {
  20952. //赤峰地区国家医保医疗类别
  20953. //职工透析:医疗类别选特殊情况门诊990502
  20954. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20955. var med_type string
  20956. if his.Insutype == "390" {
  20957. if reg_type == 14 {
  20958. med_type = "9933"
  20959. } else if reg_type == 11 {
  20960. med_type = "11"
  20961. }
  20962. } else if his.Insutype == "310" {
  20963. if reg_type == 14 {
  20964. med_type = "990502"
  20965. } else if reg_type == 11 {
  20966. med_type = "11"
  20967. }
  20968. }
  20969. 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)
  20970. } else {
  20971. if his.IdCardType == 4 {
  20972. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20973. var token string
  20974. token = psn_info.VerifyNumber
  20975. 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)
  20976. } else {
  20977. if his.IdCardType == 1 {
  20978. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20979. bas := strings.Split(psn_info.CardInfo, "|")
  20980. basNumber := bas[2]
  20981. cert_no = basNumber
  20982. }
  20983. 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)
  20984. }
  20985. }
  20986. //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)
  20987. var dat map[string]interface{}
  20988. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20989. fmt.Println(dat)
  20990. } else {
  20991. fmt.Println(err)
  20992. }
  20993. saveLog(result2, src_resquest, "2207", "结算")
  20994. userJSONBytes, _ := json.Marshal(dat)
  20995. if miConfig.Code == "H15049901371" {
  20996. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20997. utils.ErrorLog("解析失败:%v", err)
  20998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20999. return
  21000. }
  21001. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21002. res.Output = resSeven10265.Output
  21003. res.ErrMsg = resSeven10265.ErrMsg
  21004. res.Cainfo = resSeven10265.Cainfo
  21005. res.WarnMsg = resSeven10265.WarnMsg
  21006. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21007. res.Infcode = infocode
  21008. } else {
  21009. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21010. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  21011. utils.ErrorLog("解析失败:%v", err)
  21012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21013. return
  21014. }
  21015. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  21016. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  21017. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  21018. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21019. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  21020. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  21021. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  21022. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21023. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  21024. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21025. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21026. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21027. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21028. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21029. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  21030. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  21031. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  21032. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  21033. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  21034. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  21035. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21036. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  21037. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  21038. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  21039. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  21040. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  21041. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  21042. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  21043. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  21044. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  21045. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  21046. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  21047. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  21048. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  21049. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21050. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  21051. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  21052. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  21053. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21054. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  21055. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  21056. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  21057. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  21058. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  21059. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  21060. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  21061. res.ErrMsg = gzresSeven10265Two.ErrMsg
  21062. res.Cainfo = gzresSeven10265Two.Cainfo
  21063. res.WarnMsg = gzresSeven10265Two.WarnMsg
  21064. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21065. //res.Infcode = infocode
  21066. } else {
  21067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21068. utils.ErrorLog("解析失败:%v", err)
  21069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21070. return
  21071. }
  21072. }
  21073. }
  21074. }
  21075. if res.Infcode == -1 {
  21076. errlog := &models.HisOrderError{
  21077. UserOrgId: adminUser.CurrentOrgId,
  21078. Ctime: time.Now().Unix(),
  21079. Mtime: time.Now().Unix(),
  21080. Number: chrg_bchno,
  21081. ErrMsg: res.ErrMsg,
  21082. Status: 1,
  21083. PatientId: id,
  21084. RecordTime: recordDateTime,
  21085. Stage: 6,
  21086. }
  21087. service.CreateErrMsgLog(errlog)
  21088. c.ServeSuccessJSON(map[string]interface{}{
  21089. "failed_code": -10,
  21090. "msg": res.ErrMsg,
  21091. })
  21092. return
  21093. } else {
  21094. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  21095. order.OrderStatus = 2
  21096. order.Status = 1
  21097. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  21098. order.SetlId = res.Output.Setlinfo.SetlID
  21099. order.PsnNo = res.Output.Setlinfo.PsnNo
  21100. order.PsnName = res.Output.Setlinfo.PsnName
  21101. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  21102. order.Certno = res.Output.Setlinfo.Certno
  21103. order.Gend = res.Output.Setlinfo.Gend
  21104. order.Naty = res.Output.Setlinfo.Naty
  21105. order.Age = res.Output.Setlinfo.Age
  21106. order.Insutype = res.Output.Setlinfo.Insutype
  21107. order.PsnType = res.Output.Setlinfo.PsnType
  21108. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  21109. order.SetlTime = res.Output.Setlinfo.SetlTime
  21110. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  21111. if res.Output.Setlinfo.MedType == "140101" {
  21112. order.MedType = "14"
  21113. } else {
  21114. if res.Output.Setlinfo.MedType == "110104" {
  21115. order.MedType = "11"
  21116. } else {
  21117. order.MedType = res.Output.Setlinfo.MedType
  21118. }
  21119. }
  21120. if reg_type == 1112 {
  21121. order.MedType = "1112"
  21122. }
  21123. if reg_type == 1111 {
  21124. order.MedType = "1111"
  21125. }
  21126. order.ClrType = res.Output.Setlinfo.ClrType
  21127. if adminUser.CurrentOrgId == 10480 {
  21128. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  21129. order.ClrType = "11"
  21130. } else {
  21131. order.ClrType = "9903"
  21132. }
  21133. }
  21134. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  21135. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  21136. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  21137. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  21138. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  21139. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  21140. order.HifpPay = res.Output.Setlinfo.HifpPay
  21141. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  21142. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  21143. order.HifesPay = res.Output.Setlinfo.HifesPay
  21144. order.HifobPay = res.Output.Setlinfo.HifobPay
  21145. order.MafPay = res.Output.Setlinfo.MafPay
  21146. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  21147. order.OthPay = res.Output.Setlinfo.OthPay
  21148. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  21149. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  21150. order.AcctPay = res.Output.Setlinfo.AcctPay
  21151. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  21152. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  21153. order.Balc = res.Output.Setlinfo.Balc
  21154. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  21155. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  21156. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  21157. //order.ClrType = res.Output.Setlinfo.ClrType
  21158. order.ClrWay = res.Output.Setlinfo.ClrWay
  21159. order.Creator = order.Creator
  21160. order.Modify = roles.AdminUserId
  21161. order.RequestLog = src_resquest
  21162. order.FaPiaoNumber = fapiao_number
  21163. order.FaPiaoCode = fapiao_code
  21164. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21165. //detailStr := string(setlDetail)
  21166. //order.SetlDetail = detailStr
  21167. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21168. err = service.UpDateOrder(order)
  21169. if err == nil {
  21170. //判断是否使用了押金
  21171. if dec_way == "true" {
  21172. tmpstring := strconv.FormatInt(order.ID, 10)
  21173. order.Decimal = decimal
  21174. service.UpDateOrder(order)
  21175. //扣押金
  21176. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21177. if errmsg != nil {
  21178. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21179. return
  21180. }
  21181. }
  21182. c.ServeSuccessJSON(map[string]interface{}{
  21183. "msg": "结算成功",
  21184. })
  21185. } else {
  21186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21187. return
  21188. }
  21189. }
  21190. } else {
  21191. adminUser := c.GetAdminUserInfo()
  21192. errlog := &models.HisOrderError{
  21193. UserOrgId: adminUser.CurrentOrgId,
  21194. Ctime: time.Now().Unix(),
  21195. Mtime: time.Now().Unix(),
  21196. ErrMsg: res.ErrMsg,
  21197. Status: 1,
  21198. PatientId: id,
  21199. RecordTime: recordDateTime,
  21200. Stage: 4,
  21201. }
  21202. service.CreateErrMsgLog(errlog)
  21203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  21204. return
  21205. }
  21206. } else {
  21207. adminUser := c.GetAdminUserInfo()
  21208. errlog := &models.HisOrderError{
  21209. UserOrgId: adminUser.CurrentOrgId,
  21210. Ctime: time.Now().Unix(),
  21211. Mtime: time.Now().Unix(),
  21212. ErrMsg: res.ErrMsg,
  21213. Status: 1,
  21214. PatientId: id,
  21215. RecordTime: recordDateTime,
  21216. Stage: 4,
  21217. }
  21218. service.CreateErrMsgLog(errlog)
  21219. c.ServeSuccessJSON(map[string]interface{}{
  21220. "failed_code": -10,
  21221. "msg": res.ErrMsg,
  21222. })
  21223. return
  21224. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  21225. //return
  21226. }
  21227. }
  21228. }
  21229. } else if tempOrder.ID > 0 {
  21230. if tempOrder.IsPre == 1 {
  21231. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  21232. var rf []*ResultFive
  21233. json.Unmarshal([]byte(his.Iinfo), &rf)
  21234. chrg_bchno := tempOrder.Number
  21235. cert_no := his.Certno
  21236. var insutypes []string
  21237. var insutype string
  21238. var is390 int = 0
  21239. var is310 int = 0
  21240. for _, item := range rf {
  21241. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21242. insutypes = append(insutypes, item.Insutype)
  21243. }
  21244. }
  21245. if len(insutypes) == 1 {
  21246. insutype = insutypes[0]
  21247. } else {
  21248. for _, i := range insutypes {
  21249. if i == "390" {
  21250. is390 = 1
  21251. }
  21252. if i == "310" {
  21253. is310 = 1
  21254. }
  21255. }
  21256. }
  21257. if is390 == 1 {
  21258. insutype = "390"
  21259. }
  21260. if is310 == 1 {
  21261. insutype = "310"
  21262. }
  21263. if len(insutypes) == 0 {
  21264. insutype = "310"
  21265. }
  21266. if len(insutypes) == 2 {
  21267. insutype = strconv.FormatInt(his.SocialType, 10)
  21268. }
  21269. //insutype = "390"
  21270. if his.IdCardType == 1 {
  21271. // cert_no = his.MedicalInsuranceNumber
  21272. cert_no = his.Certno
  21273. } else {
  21274. cert_no = his.Certno
  21275. }
  21276. var res ResultSeven
  21277. var ahres ResultSevenAH
  21278. var resSeven10265 ResultSeven10265
  21279. var gzresSeven10265Two GZResultSeven10265Two
  21280. var src_resquest string
  21281. var result2 string
  21282. if miConfig.MdtrtareaAdmvs == "450721" {
  21283. res2 := c.GetoleInfo()
  21284. if res2.Infcode == 0 {
  21285. var result string
  21286. var request_log string
  21287. var result_log string
  21288. if res2.Output.MdtrtCertType == "02" {
  21289. 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)
  21290. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  21291. } else if res2.Output.MdtrtCertType == "01" {
  21292. 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)
  21293. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  21294. } else {
  21295. 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)
  21296. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  21297. }
  21298. var dat map[string]interface{}
  21299. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21300. fmt.Println(dat)
  21301. } else {
  21302. fmt.Println(err)
  21303. }
  21304. userJSONBytes, _ := json.Marshal(dat)
  21305. var res5 ResultTwo
  21306. //var resTwo10265 ResultTwo10265
  21307. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  21308. utils.ErrorLog("解析失败:%v", err)
  21309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21310. return
  21311. }
  21312. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  21313. if res5.Infcode == -1 {
  21314. c.ServeSuccessJSON(map[string]interface{}{
  21315. "failed_code": -10,
  21316. "msg": res5.ErrMsg,
  21317. })
  21318. return
  21319. }
  21320. var insutypes []string
  21321. var insutype string
  21322. var is390 int = 0
  21323. var is310 int = 0
  21324. for _, item := range res5.Output.Iinfo {
  21325. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21326. insutypes = append(insutypes, item.Insutype)
  21327. }
  21328. }
  21329. if len(insutypes) == 1 {
  21330. insutype = insutypes[0]
  21331. } else {
  21332. for _, i := range insutypes {
  21333. if i == "390" {
  21334. is390 = 1
  21335. }
  21336. if i == "310" {
  21337. is310 = 1
  21338. }
  21339. }
  21340. }
  21341. if is390 == 1 {
  21342. insutype = "390"
  21343. }
  21344. if is310 == 1 {
  21345. insutype = "310"
  21346. }
  21347. if len(insutypes) == 0 {
  21348. insutype = "310"
  21349. }
  21350. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  21351. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  21352. infoStr := string(Iinfos)
  21353. idetinfoStr := string(Idetinfos)
  21354. psn := &models.HisPsn{
  21355. PsnNo: res5.Output.Baseinfo.PsnNo,
  21356. PatientId: id,
  21357. Certno: res5.Output.Baseinfo.Certno,
  21358. Gend: res5.Output.Baseinfo.Gend,
  21359. Naty: res5.Output.Baseinfo.Naty,
  21360. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  21361. PsnName: res5.Output.Baseinfo.PsnName,
  21362. Idetinfo: idetinfoStr,
  21363. Insuinfo: infoStr,
  21364. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  21365. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21366. VerifyNumber: res2.Output.EcToken,
  21367. }
  21368. service.CreateHisPsn(psn)
  21369. if res2.Output.MdtrtCertType == "01" {
  21370. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21371. token := res2.Output.EcToken
  21372. 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)
  21373. } else if res2.Output.MdtrtCertType == "02" {
  21374. 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)
  21375. } else {
  21376. 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)
  21377. }
  21378. var dat2 map[string]interface{}
  21379. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  21380. fmt.Println(dat2)
  21381. } else {
  21382. fmt.Println(err)
  21383. }
  21384. userJSONBytes3, _ := json.Marshal(dat2)
  21385. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  21386. utils.ErrorLog("解析失败:%v", err)
  21387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21388. return
  21389. }
  21390. saveLog(result2, src_resquest, "2207", "结算")
  21391. } else {
  21392. c.ServeSuccessJSON(map[string]interface{}{
  21393. "failed_code": -10,
  21394. "msg": res2.ErrMsg,
  21395. })
  21396. return
  21397. }
  21398. } else if miConfig.MdtrtareaAdmvs == "421300" {
  21399. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21400. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21401. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21402. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21403. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21404. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21405. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  21406. resp, requestErr := http.Get(api)
  21407. if requestErr != nil {
  21408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21409. return
  21410. }
  21411. body, ioErr := ioutil.ReadAll(resp.Body)
  21412. if ioErr != nil {
  21413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21415. return
  21416. }
  21417. var respJSON map[string]interface{}
  21418. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21421. return
  21422. }
  21423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21424. result, _ := json.Marshal(respJSON)
  21425. fmt.Println("log")
  21426. fmt.Println(string(result))
  21427. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21428. utils.ErrorLog("解析失败:%v", err)
  21429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21430. return
  21431. }
  21432. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21433. if reg_type == 11 && his.Insutype == "390" {
  21434. reg_type = 110104
  21435. }
  21436. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21437. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21438. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21439. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21440. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21441. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21442. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  21443. resp, requestErr := http.Get(api)
  21444. if requestErr != nil {
  21445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21446. return
  21447. }
  21448. body, ioErr := ioutil.ReadAll(resp.Body)
  21449. if ioErr != nil {
  21450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21452. return
  21453. }
  21454. var respJSON map[string]interface{}
  21455. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21458. return
  21459. }
  21460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21461. result, _ := json.Marshal(respJSON)
  21462. fmt.Println("log")
  21463. fmt.Println(string(result))
  21464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21465. utils.ErrorLog("解析失败:%v", err)
  21466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21467. return
  21468. }
  21469. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21470. if reg_type == 11 && his.Insutype == "390" {
  21471. reg_type = 110104
  21472. }
  21473. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21474. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21475. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21476. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21477. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21478. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21479. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  21480. resp, requestErr := http.Get(api)
  21481. if requestErr != nil {
  21482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21483. return
  21484. }
  21485. body, ioErr := ioutil.ReadAll(resp.Body)
  21486. if ioErr != nil {
  21487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21489. return
  21490. }
  21491. var respJSON map[string]interface{}
  21492. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21495. return
  21496. }
  21497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21498. result, _ := json.Marshal(respJSON)
  21499. fmt.Println("log")
  21500. fmt.Println(string(result))
  21501. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21502. utils.ErrorLog("解析失败:%v", err)
  21503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21504. return
  21505. }
  21506. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21507. if reg_type == 11 && his.Insutype == "390" {
  21508. reg_type = 110104
  21509. }
  21510. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21511. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21512. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21514. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21515. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21516. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  21517. resp, requestErr := http.Get(api)
  21518. if requestErr != nil {
  21519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21520. return
  21521. }
  21522. body, ioErr := ioutil.ReadAll(resp.Body)
  21523. if ioErr != nil {
  21524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21526. return
  21527. }
  21528. var respJSON map[string]interface{}
  21529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21532. return
  21533. }
  21534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21535. result, _ := json.Marshal(respJSON)
  21536. fmt.Println("log")
  21537. fmt.Println(string(result))
  21538. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21539. utils.ErrorLog("解析失败:%v", err)
  21540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21541. return
  21542. }
  21543. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21544. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  21545. if result3101.Infcode == "0" {
  21546. if len(result3101.Output.Result) > 0 {
  21547. var errMsgs []string
  21548. for _, item := range result3101.Output.Result {
  21549. errMsgs = append(errMsgs, item.VolaCont)
  21550. }
  21551. c.ServeSuccessJSON(map[string]interface{}{
  21552. "failed_code": -10,
  21553. "msg": errMsgs,
  21554. })
  21555. return
  21556. } else {
  21557. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21558. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21559. bas := strings.Split(psn_info.CardInfo, "|")
  21560. if his.IdCardType == 1 {
  21561. cert_no = bas[2]
  21562. } else if his.IdCardType == 3 {
  21563. cert_no = his.Certno
  21564. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  21565. } else if his.IdCardType == 4 {
  21566. cert_no = his.Certno
  21567. psn_info.VerifyNumber = psn_info.VerifyNumber
  21568. }
  21569. //江苏地区国家医保医疗类别
  21570. //职工透析:医疗类别选特殊情况门诊9933
  21571. //居民血透门慢: 医疗类别选门诊慢病1402
  21572. //var med_type string
  21573. //if his.Insutype == "310" {
  21574. // if reg_type == 14 {
  21575. // med_type = "9933"
  21576. // } else if reg_type == 11 {
  21577. // med_type = "11"
  21578. //
  21579. // }
  21580. //} else if his.Insutype == "390" {
  21581. // if reg_type == 14 {
  21582. // med_type = "1402"
  21583. // } else if reg_type == 11 {
  21584. // med_type = "11"
  21585. // }
  21586. //}
  21587. var api string
  21588. if miConfig.MdtrtareaAdmvs == "320921" {
  21589. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21590. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21591. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21592. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21593. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21594. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21595. "&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
  21596. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21597. } else {
  21598. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21599. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21600. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21601. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21602. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21603. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21604. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21605. "&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
  21606. }
  21607. resp, requestErr := http.Get(api)
  21608. if requestErr != nil {
  21609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21610. return
  21611. }
  21612. body, ioErr := ioutil.ReadAll(resp.Body)
  21613. if ioErr != nil {
  21614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21616. return
  21617. }
  21618. var respJSON map[string]interface{}
  21619. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21622. return
  21623. }
  21624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21625. result, _ := json.Marshal(respJSON)
  21626. fmt.Println("log")
  21627. fmt.Println(string(result))
  21628. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21629. utils.ErrorLog("解析失败:%v", err)
  21630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21631. return
  21632. }
  21633. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21634. res.Output = resSeven10265.Output
  21635. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21636. res.ErrMsg = resSeven10265.ErrMsg
  21637. res.Cainfo = resSeven10265.Cainfo
  21638. res.WarnMsg = resSeven10265.WarnMsg
  21639. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21640. res.Infcode = infocode
  21641. }
  21642. }
  21643. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21644. psn_info, _ := service.GetPsnByPatientId(id)
  21645. var verify_number string
  21646. if psn_info.IdCardType == 4 {
  21647. verify_number = psn_info.VerifyNumber
  21648. } else if psn_info.IdCardType == 1 {
  21649. bas := strings.Split(psn_info.CardInfo, "|")
  21650. cardNumber := bas[2]
  21651. verify_number = cardNumber
  21652. } else {
  21653. verify_number = psn_info.Certno
  21654. psn_info.IdCardType = 2
  21655. }
  21656. var api string
  21657. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21658. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21659. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21660. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21661. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21662. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21663. "&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
  21664. resp, requestErr := http.Get(api)
  21665. if requestErr != nil {
  21666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21667. return
  21668. }
  21669. body, ioErr := ioutil.ReadAll(resp.Body)
  21670. if ioErr != nil {
  21671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21673. return
  21674. }
  21675. var respJSON map[string]interface{}
  21676. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21679. return
  21680. }
  21681. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21682. result, _ := json.Marshal(respJSON)
  21683. fmt.Println("log")
  21684. fmt.Println(string(result))
  21685. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21686. utils.ErrorLog("解析失败:%v", err)
  21687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21688. return
  21689. }
  21690. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21691. res.Output = resSeven10265.Output
  21692. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21693. res.ErrMsg = resSeven10265.ErrMsg
  21694. res.Cainfo = resSeven10265.Cainfo
  21695. res.WarnMsg = resSeven10265.WarnMsg
  21696. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21697. res.Infcode = infocode
  21698. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21699. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21700. var cert_no string
  21701. if his.IdCardType == 1 {
  21702. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  21703. } else {
  21704. cert_no = psn_info.VerifyNumber
  21705. }
  21706. 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)
  21707. var dat map[string]interface{}
  21708. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21709. fmt.Println(dat)
  21710. } else {
  21711. fmt.Println(err)
  21712. }
  21713. saveLog(result2, src_resquest, "2207", "结算")
  21714. userJSONBytes, _ := json.Marshal(dat)
  21715. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21716. utils.ErrorLog("解析失败:%v", err)
  21717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21718. return
  21719. }
  21720. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21721. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21722. var cert_no string
  21723. var card_sn string
  21724. if his.IdCardType == 1 {
  21725. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  21726. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21727. bas := strings.Split(psn_info.CardInfo, "|")
  21728. card_sn = bas[3]
  21729. } else if his.IdCardType == 2 {
  21730. cert_no = his.IdCardNo
  21731. } else {
  21732. cert_no = psn_info.VerifyNumber
  21733. }
  21734. var rf []*ResultFive
  21735. json.Unmarshal([]byte(his.Iinfo), &rf)
  21736. var psn_type string
  21737. for _, item := range rf {
  21738. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  21739. psn_type = item.PsnType
  21740. }
  21741. }
  21742. 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)
  21743. var dat map[string]interface{}
  21744. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21745. fmt.Println(dat)
  21746. } else {
  21747. fmt.Println(err)
  21748. }
  21749. saveLog(result2, src_resquest, "2207", "结算")
  21750. userJSONBytes, _ := json.Marshal(dat)
  21751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21752. utils.ErrorLog("解析失败:%v", err)
  21753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21754. return
  21755. }
  21756. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21757. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21758. if his.IdCardType == 1 {
  21759. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21760. bas := strings.Split(psn_info.CardInfo, "|")
  21761. cert_no = bas[2]
  21762. } else if his.IdCardType == 3 {
  21763. cert_no = his.Certno
  21764. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  21765. } else if his.IdCardType == 4 {
  21766. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21767. cert_no = his.Certno
  21768. psn_info.VerifyNumber = psn_info.VerifyNumber
  21769. } else {
  21770. cert_no = his.Certno
  21771. psn_info.VerifyNumber = his.Certno
  21772. }
  21773. var api string
  21774. var med_type string
  21775. if his.Insutype == "390" {
  21776. if reg_type == 992102 {
  21777. med_type = "992102"
  21778. }
  21779. if reg_type == 140104 {
  21780. med_type = "140104"
  21781. }
  21782. if reg_type == 14 {
  21783. med_type = "14"
  21784. }
  21785. } else if his.Insutype == "310" {
  21786. if reg_type == 992102 {
  21787. med_type = "992102"
  21788. }
  21789. if reg_type == 14 {
  21790. med_type = "14"
  21791. }
  21792. }
  21793. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21794. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21795. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21796. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21797. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21798. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21799. "&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
  21800. resp, requestErr := http.Get(api)
  21801. if requestErr != nil {
  21802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21803. return
  21804. }
  21805. body, ioErr := ioutil.ReadAll(resp.Body)
  21806. if ioErr != nil {
  21807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21809. return
  21810. }
  21811. var respJSON map[string]interface{}
  21812. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21815. return
  21816. }
  21817. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21818. if status == "0" {
  21819. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21820. c.ServeSuccessJSON(map[string]interface{}{
  21821. "failed_code": -10,
  21822. "msg": err_msg,
  21823. })
  21824. return
  21825. }
  21826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21827. result, _ := json.Marshal(respJSON)
  21828. fmt.Println("log")
  21829. fmt.Println(string(result))
  21830. if err := json.Unmarshal(result, &ahres); err != nil {
  21831. utils.ErrorLog("解析失败:%v", err)
  21832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21833. return
  21834. }
  21835. res.InfRefmsgid = ahres.InfRefmsgid
  21836. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  21837. // 创建对应的Time类型
  21838. t := time.UnixMilli(timestamp)
  21839. // 格式化成指定的日期字符串
  21840. str := t.Format("2006-01-02 15:04:05")
  21841. res.Output.Setlinfo.SetlTime = str
  21842. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  21843. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  21844. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21845. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  21846. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  21847. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  21848. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21849. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  21850. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  21851. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  21852. res.Output.Setlinfo.ClrType = "11"
  21853. } else {
  21854. res.Output.Setlinfo.ClrType = "9903"
  21855. }
  21856. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  21857. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  21858. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21859. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  21860. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  21861. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  21862. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  21863. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  21864. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  21865. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21866. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  21867. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  21868. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  21869. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  21870. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  21871. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  21872. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  21873. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  21874. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  21875. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  21876. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  21877. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  21878. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  21879. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  21880. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  21881. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  21882. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  21883. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  21884. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  21885. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  21886. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  21887. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  21888. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  21889. res.Output.Setldetail = ahres.Output.Setldetail
  21890. res.ErrMsg = ahres.ErrMsg
  21891. res.Cainfo = ahres.Cainfo
  21892. res.WarnMsg = ahres.WarnMsg
  21893. res.Infcode = ahres.Infcode
  21894. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21895. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21896. var cert_no string
  21897. if his.IdCardType == 1 {
  21898. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  21899. } else if his.IdCardType == 2 {
  21900. cert_no = his.IdCardNo
  21901. } else {
  21902. cert_no = psn_info.VerifyNumber
  21903. }
  21904. 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, "")
  21905. var dat map[string]interface{}
  21906. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21907. fmt.Println(dat)
  21908. } else {
  21909. fmt.Println(err)
  21910. }
  21911. saveLog(result2, src_resquest, "2207", "结算")
  21912. userJSONBytes, _ := json.Marshal(dat)
  21913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21914. utils.ErrorLog("解析失败:%v", err)
  21915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21916. return
  21917. }
  21918. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21919. psn_info, _ := service.GetPsnByPatientId(id)
  21920. var verify_number string
  21921. if psn_info.IdCardType == 4 {
  21922. verify_number = psn_info.VerifyNumber
  21923. } else if psn_info.IdCardType == 1 {
  21924. bas := strings.Split(psn_info.CardInfo, "|")
  21925. cardNumber := bas[2]
  21926. verify_number = cardNumber
  21927. } else {
  21928. verify_number = psn_info.Certno
  21929. psn_info.IdCardType = 2
  21930. }
  21931. var api string
  21932. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21933. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21934. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21935. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21936. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21937. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21938. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  21939. resp, requestErr := http.Get(api)
  21940. if requestErr != nil {
  21941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21942. return
  21943. }
  21944. body, ioErr := ioutil.ReadAll(resp.Body)
  21945. if ioErr != nil {
  21946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21948. return
  21949. }
  21950. var respJSON map[string]interface{}
  21951. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21954. return
  21955. }
  21956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21957. result, _ := json.Marshal(respJSON)
  21958. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21959. utils.ErrorLog("解析失败:%v", err)
  21960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21961. return
  21962. }
  21963. } else {
  21964. var src_resquest string
  21965. if miConfig.Code == "H15049901371" {
  21966. //赤峰地区国家医保医疗类别
  21967. //职工透析:医疗类别选特殊情况门诊990502
  21968. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21969. var med_type string
  21970. if his.Insutype == "390" {
  21971. if reg_type == 14 {
  21972. med_type = "9933"
  21973. } else if reg_type == 11 {
  21974. med_type = "11"
  21975. }
  21976. } else if his.Insutype == "310" {
  21977. if reg_type == 14 {
  21978. med_type = "990502"
  21979. } else if reg_type == 11 {
  21980. med_type = "11"
  21981. }
  21982. }
  21983. 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)
  21984. } else {
  21985. if his.IdCardType == 4 {
  21986. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21987. token := psn_info.VerifyNumber
  21988. 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)
  21989. } else {
  21990. 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)
  21991. }
  21992. }
  21993. var dat map[string]interface{}
  21994. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21995. fmt.Println(dat)
  21996. } else {
  21997. fmt.Println(err)
  21998. }
  21999. saveLog(result2, src_resquest, "2207", "结算")
  22000. userJSONBytes, _ := json.Marshal(dat)
  22001. if miConfig.Code == "H15049901371" {
  22002. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22003. utils.ErrorLog("解析失败:%v", err)
  22004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22005. return
  22006. }
  22007. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22008. res.Output = resSeven10265.Output
  22009. res.ErrMsg = resSeven10265.ErrMsg
  22010. res.Cainfo = resSeven10265.Cainfo
  22011. res.WarnMsg = resSeven10265.WarnMsg
  22012. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22013. res.Infcode = infocode
  22014. } else {
  22015. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22016. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  22017. utils.ErrorLog("解析失败:%v", err)
  22018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22019. return
  22020. }
  22021. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  22022. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  22023. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  22024. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22025. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  22026. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  22027. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  22028. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22029. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  22030. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22031. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22032. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22033. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22034. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22035. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22036. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  22037. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  22038. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  22039. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  22040. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  22041. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22042. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  22043. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  22044. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  22045. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  22046. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  22047. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  22048. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  22049. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  22050. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22051. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  22052. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  22053. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  22054. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22055. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22056. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22057. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22058. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  22059. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22060. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  22061. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  22062. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  22063. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  22064. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  22065. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  22066. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  22067. res.ErrMsg = gzresSeven10265Two.ErrMsg
  22068. res.Cainfo = gzresSeven10265Two.Cainfo
  22069. res.WarnMsg = gzresSeven10265Two.WarnMsg
  22070. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22071. //res.Infcode = infocode
  22072. } else {
  22073. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22074. utils.ErrorLog("解析失败:%v", err)
  22075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22076. return
  22077. }
  22078. }
  22079. }
  22080. }
  22081. if res.Infcode != 0 {
  22082. errlog := &models.HisOrderError{
  22083. UserOrgId: adminUser.CurrentOrgId,
  22084. Ctime: time.Now().Unix(),
  22085. Mtime: time.Now().Unix(),
  22086. Number: chrg_bchno,
  22087. ErrMsg: res.ErrMsg,
  22088. Status: 1,
  22089. PatientId: id,
  22090. RecordTime: recordDateTime,
  22091. Stage: 6,
  22092. }
  22093. service.CreateErrMsgLog(errlog)
  22094. c.ServeSuccessJSON(map[string]interface{}{
  22095. "failed_code": -10,
  22096. "msg": res.ErrMsg,
  22097. })
  22098. return
  22099. } else {
  22100. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  22101. order.OrderStatus = 2
  22102. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  22103. order.SetlId = res.Output.Setlinfo.SetlID
  22104. order.PsnNo = res.Output.Setlinfo.PsnNo
  22105. order.PsnName = res.Output.Setlinfo.PsnName
  22106. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  22107. order.Certno = res.Output.Setlinfo.Certno
  22108. order.Gend = res.Output.Setlinfo.Gend
  22109. order.Naty = res.Output.Setlinfo.Naty
  22110. order.Age = res.Output.Setlinfo.Age
  22111. order.Insutype = res.Output.Setlinfo.Insutype
  22112. order.PsnType = res.Output.Setlinfo.PsnType
  22113. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  22114. order.SetlTime = res.Output.Setlinfo.SetlTime
  22115. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  22116. order.PayWays = pay_ways
  22117. order.AcctUsedFlag = acct_used_flag
  22118. order.WechatPay = wechat_pay
  22119. order.AliPay = ali_pay
  22120. order.JifenPay = jifen_pay
  22121. order.BandCardPay = band_card_pay
  22122. order.CashPay = cash_pay
  22123. order.OthDesc = oth_desc
  22124. //order.MedType = res.Output.Setlinfo.MedType
  22125. if reg_type == 1112 {
  22126. order.MedType = "1112"
  22127. }
  22128. if reg_type == 1111 {
  22129. order.MedType = "1111"
  22130. }
  22131. order.ClrType = res.Output.Setlinfo.ClrType
  22132. if adminUser.CurrentOrgId == 10480 {
  22133. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  22134. order.ClrType = "11"
  22135. } else {
  22136. order.ClrType = "9903"
  22137. }
  22138. }
  22139. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  22140. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  22141. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  22142. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  22143. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  22144. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  22145. order.HifpPay = res.Output.Setlinfo.HifpPay
  22146. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  22147. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  22148. order.HifesPay = res.Output.Setlinfo.HifesPay
  22149. order.HifobPay = res.Output.Setlinfo.HifobPay
  22150. order.MafPay = res.Output.Setlinfo.MafPay
  22151. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  22152. order.OthPay = res.Output.Setlinfo.OthPay
  22153. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  22154. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  22155. order.AcctPay = res.Output.Setlinfo.AcctPay
  22156. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  22157. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  22158. order.Balc = res.Output.Setlinfo.Balc
  22159. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  22160. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  22161. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  22162. order.ClrWay = res.Output.Setlinfo.ClrWay
  22163. order.Creator = order.Creator
  22164. order.Modify = roles.AdminUserId
  22165. order.RequestLog = src_resquest
  22166. order.Diagnosis = diagnosis_id
  22167. order.FaPiaoNumber = fapiao_number
  22168. order.FaPiaoCode = fapiao_code
  22169. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  22170. detailStr := string(setlDetail)
  22171. order.SetlDetail = detailStr
  22172. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  22173. err = service.UpDateOrder(order)
  22174. if err == nil {
  22175. //判断是否使用了押金
  22176. if dec_way == "true" {
  22177. tmpstring := strconv.FormatInt(order.ID, 10)
  22178. //扣押金
  22179. order.Decimal = decimal
  22180. service.UpDateOrder(order)
  22181. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  22182. if errmsg != nil {
  22183. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  22184. return
  22185. }
  22186. }
  22187. c.ServeSuccessJSON(map[string]interface{}{
  22188. "msg": "结算成功",
  22189. })
  22190. } else {
  22191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  22192. return
  22193. }
  22194. }
  22195. }
  22196. }
  22197. }
  22198. // 上传明细-预结算-
  22199. func (c *HisApiController) GetPreUploadInfo() {
  22200. id, _ := c.GetInt64("id")
  22201. record_time := c.GetString("record_time")
  22202. his_patient_id, _ := c.GetInt64("his_patient_id")
  22203. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  22204. admin_user_id, _ := c.GetInt64("admin_user_id")
  22205. diagnosis_id := c.GetString("diagnosis")
  22206. sick_type, _ := c.GetInt64("sick_type")
  22207. reg_type, _ := c.GetInt64("p_type")
  22208. begin_time := c.GetString("begin_time")
  22209. acct_used_flag := c.GetString("acct_used_flag")
  22210. id_str := c.GetString("ids")
  22211. ids_arr := strings.Split(id_str, ",")
  22212. timeLayout := "2006-01-02"
  22213. loc, _ := time.LoadLocation("Local")
  22214. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  22215. if err != nil {
  22216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22217. return
  22218. }
  22219. recordDateTime := theTime.Unix()
  22220. adminUser := c.GetAdminUserInfo()
  22221. diagnosis_ids := strings.Split(diagnosis_id, ",")
  22222. var config []*models.HisXtDiagnoseConfig
  22223. for _, item := range diagnosis_ids {
  22224. id, _ := strconv.ParseInt(item, 10, 64)
  22225. diagnosisConfig, _ := service.FindDiagnoseById(id)
  22226. config = append(config, &diagnosisConfig)
  22227. }
  22228. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  22229. sickConfig, _ := service.FindSickById(sick_type)
  22230. var prescriptions []*models.HisPrescription
  22231. var start_time int64
  22232. var end_time int64
  22233. var isSuccess bool = true
  22234. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22235. fmt.Println(his_patient_id)
  22236. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22237. timestamp := time.Now().Unix()
  22238. tempTime := time.Unix(timestamp, 0)
  22239. timeFormat := tempTime.Format("20060102150405")
  22240. chrgBchno := rand.Intn(100000) + 10000
  22241. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  22242. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22243. var patientPrescription models.HisPrescriptionInfo
  22244. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22245. if patientPrescription.ID == 0 {
  22246. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  22247. }
  22248. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22249. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  22250. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  22251. strconv.FormatInt(his.PatientId, 10)
  22252. var res2406 Result2406
  22253. //安徽单病种处理
  22254. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  22255. data := make(map[string]interface{})
  22256. client := &http.Client{}
  22257. data["psn_no"] = his.PsnNo
  22258. data["mdtrt_id"] = his.Number
  22259. data["operator"] = roles.UserName
  22260. data["cert_no"] = his.IdCardNo
  22261. data["org_name"] = miConfig.OrgName
  22262. data["psn_name"] = his.Name
  22263. data["ipt_otp_no"] = his.IptOtpNo
  22264. data["ipt_psn_sp_flag_type"] = "0901"
  22265. data["ipt_psn_sp_flag"] = "1"
  22266. data["fixmedins_code"] = miConfig.Code
  22267. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22268. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22269. data["url"] = miConfig.Url
  22270. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  22271. bytesData, _ := json.Marshal(data)
  22272. var req *http.Request
  22273. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  22274. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  22275. resp, _ := client.Do(req)
  22276. defer resp.Body.Close()
  22277. body, ioErr := ioutil.ReadAll(resp.Body)
  22278. if ioErr != nil {
  22279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22281. return
  22282. }
  22283. var respJSON map[string]interface{}
  22284. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22287. return
  22288. }
  22289. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22290. if status == "0" {
  22291. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22292. c.ServeSuccessJSON(map[string]interface{}{
  22293. "failed_code": -10,
  22294. "msg": err_msg,
  22295. })
  22296. return
  22297. }
  22298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22299. userJSONBytes, _ := json.Marshal(respJSON)
  22300. fmt.Println("log")
  22301. fmt.Println(string(userJSONBytes))
  22302. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  22303. utils.ErrorLog("解析失败:%v", err)
  22304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22305. return
  22306. }
  22307. }
  22308. if res2406.Infcode != 0 {
  22309. adminUser := c.GetAdminUserInfo()
  22310. errlog := &models.HisOrderError{
  22311. UserOrgId: adminUser.CurrentOrgId,
  22312. Ctime: time.Now().Unix(),
  22313. Mtime: time.Now().Unix(),
  22314. ErrMsg: res2406.ErrMsg,
  22315. Status: 1,
  22316. PatientId: id,
  22317. RecordTime: recordDateTime,
  22318. Stage: 3,
  22319. }
  22320. service.CreateErrMsgLog(errlog)
  22321. c.ServeSuccessJSON(map[string]interface{}{
  22322. "failed_code": -10,
  22323. "msg": res2406.ErrMsg,
  22324. })
  22325. return
  22326. }
  22327. var res2 ResultSix
  22328. var res3 GZResultSix
  22329. var resSix10265 ResultSix10265
  22330. //var time_stamp string
  22331. if miConfig.MdtrtareaAdmvs == "421300" {
  22332. data := make(map[string]interface{})
  22333. client := &http.Client{}
  22334. data["psn_no"] = his.PsnNo
  22335. data["mdtrt_id"] = his.Number
  22336. data["department"] = department.Name
  22337. data["org_name"] = miConfig.OrgName
  22338. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22339. data["doctor_id"] = doctor_info.DoctorNumber
  22340. data["doctor_name"] = roles.UserName
  22341. data["fixmedins_code"] = miConfig.Code
  22342. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22343. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22344. data["secret_key"] = miConfig.SecretKey
  22345. data["sick_code"] = sickConfig.CountryCode
  22346. data["sick_name"] = sickConfig.ClassName
  22347. data["begin_time"] = begin_time
  22348. data["dept"] = strconv.FormatInt(department.ID, 10)
  22349. data["config"] = config
  22350. data["opter"] = roles.UserName
  22351. fmt.Println(data)
  22352. bytesData, _ := json.Marshal(data)
  22353. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22354. resp, _ := client.Do(req)
  22355. defer resp.Body.Close()
  22356. body, ioErr := ioutil.ReadAll(resp.Body)
  22357. if ioErr != nil {
  22358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22360. return
  22361. }
  22362. var respJSON map[string]interface{}
  22363. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22366. return
  22367. }
  22368. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22369. userJSONBytes, _ := json.Marshal(respJSON)
  22370. fmt.Println("log")
  22371. fmt.Println(string(userJSONBytes))
  22372. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22373. utils.ErrorLog("解析失败:%v", err)
  22374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22375. return
  22376. }
  22377. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22378. data := make(map[string]interface{})
  22379. client := &http.Client{}
  22380. data["psn_no"] = his.PsnNo
  22381. data["mdtrt_id"] = his.Number
  22382. data["department"] = department.Name
  22383. data["org_name"] = miConfig.OrgName
  22384. if reg_type == 11 && his.Insutype == "390" {
  22385. data["med_type"] = "110104"
  22386. } else {
  22387. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22388. }
  22389. data["doctor_id"] = doctor_info.DoctorNumber
  22390. data["doctor_name"] = roles.UserName
  22391. data["fixmedins_code"] = miConfig.Code
  22392. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22393. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22394. data["secret_key"] = miConfig.SecretKey
  22395. data["sick_code"] = sickConfig.CountryCode
  22396. data["sick_name"] = sickConfig.ClassName
  22397. data["begin_time"] = begin_time
  22398. data["dept"] = strconv.FormatInt(department.ID, 10)
  22399. data["config"] = config
  22400. data["opter"] = roles.UserName
  22401. fmt.Println(data)
  22402. bytesData, _ := json.Marshal(data)
  22403. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22404. resp, _ := client.Do(req)
  22405. defer resp.Body.Close()
  22406. body, ioErr := ioutil.ReadAll(resp.Body)
  22407. if ioErr != nil {
  22408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22410. return
  22411. }
  22412. var respJSON map[string]interface{}
  22413. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22416. return
  22417. }
  22418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22419. userJSONBytes, _ := json.Marshal(respJSON)
  22420. fmt.Println("log")
  22421. fmt.Println(string(userJSONBytes))
  22422. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22423. utils.ErrorLog("解析失败:%v", err)
  22424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22425. return
  22426. }
  22427. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22428. data := make(map[string]interface{})
  22429. client := &http.Client{}
  22430. data["psn_no"] = his.PsnNo
  22431. data["mdtrt_id"] = his.Number
  22432. data["department"] = department.Name
  22433. data["org_name"] = miConfig.OrgName
  22434. if reg_type == 11 && his.Insutype == "390" {
  22435. data["med_type"] = "110104"
  22436. } else {
  22437. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22438. }
  22439. data["doctor_id"] = doctor_info.DoctorNumber
  22440. data["doctor_name"] = roles.UserName
  22441. data["fixmedins_code"] = miConfig.Code
  22442. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22443. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22444. data["secret_key"] = miConfig.SecretKey
  22445. data["sick_code"] = sickConfig.CountryCode
  22446. data["sick_name"] = sickConfig.ClassName
  22447. data["begin_time"] = begin_time
  22448. data["dept"] = strconv.FormatInt(department.ID, 10)
  22449. data["config"] = config
  22450. data["opter"] = roles.UserName
  22451. fmt.Println(data)
  22452. bytesData, _ := json.Marshal(data)
  22453. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  22454. resp, _ := client.Do(req)
  22455. defer resp.Body.Close()
  22456. body, ioErr := ioutil.ReadAll(resp.Body)
  22457. if ioErr != nil {
  22458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22460. return
  22461. }
  22462. var respJSON map[string]interface{}
  22463. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22466. return
  22467. }
  22468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22469. userJSONBytes, _ := json.Marshal(respJSON)
  22470. fmt.Println("log")
  22471. fmt.Println(string(userJSONBytes))
  22472. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22473. utils.ErrorLog("解析失败:%v", err)
  22474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22475. return
  22476. }
  22477. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22478. data := make(map[string]interface{})
  22479. client := &http.Client{}
  22480. data["psn_no"] = his.PsnNo
  22481. data["mdtrt_id"] = his.Number
  22482. data["department"] = department.Name
  22483. data["org_name"] = miConfig.OrgName
  22484. if reg_type == 11 && his.Insutype == "390" {
  22485. data["med_type"] = "110104"
  22486. } else {
  22487. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22488. }
  22489. data["doctor_id"] = doctor_info.DoctorNumber
  22490. data["doctor_name"] = roles.UserName
  22491. data["fixmedins_code"] = miConfig.Code
  22492. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22493. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22494. data["secret_key"] = miConfig.SecretKey
  22495. data["sick_code"] = sickConfig.CountryCode
  22496. data["sick_name"] = sickConfig.ClassName
  22497. data["begin_time"] = begin_time
  22498. data["dept"] = strconv.FormatInt(department.ID, 10)
  22499. data["config"] = config
  22500. data["opter"] = roles.UserName
  22501. fmt.Println(data)
  22502. bytesData, _ := json.Marshal(data)
  22503. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  22504. resp, _ := client.Do(req)
  22505. defer resp.Body.Close()
  22506. body, ioErr := ioutil.ReadAll(resp.Body)
  22507. if ioErr != nil {
  22508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22510. return
  22511. }
  22512. var respJSON map[string]interface{}
  22513. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22516. return
  22517. }
  22518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22519. userJSONBytes, _ := json.Marshal(respJSON)
  22520. fmt.Println("log")
  22521. fmt.Println(string(userJSONBytes))
  22522. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22523. utils.ErrorLog("解析失败:%v", err)
  22524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22525. return
  22526. }
  22527. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22528. data := make(map[string]interface{})
  22529. client := &http.Client{}
  22530. data["psn_no"] = his.PsnNo
  22531. data["mdtrt_id"] = his.Number
  22532. data["doctor"] = roles.UserName
  22533. data["department"] = department.Name
  22534. data["org_name"] = miConfig.OrgName
  22535. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22536. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  22537. data["fixmedins_code"] = miConfig.Code
  22538. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22539. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22540. data["secret_key"] = miConfig.SecretKey
  22541. data["sick_code"] = sickConfig.CountryCode
  22542. data["sick_name"] = sickConfig.ClassName
  22543. data["begin_time"] = begin_time
  22544. data["dept"] = strconv.FormatInt(department.ID, 10)
  22545. data["config"] = config
  22546. data["url"] = miConfig.Url
  22547. data["ak"] = miConfig.AccessKey
  22548. data["cainfo"] = miConfig.Cainfo
  22549. bytesData, _ := json.Marshal(data)
  22550. var req *http.Request
  22551. if miConfig.MdtrtareaAdmvs == "320921" {
  22552. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  22553. } else {
  22554. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  22555. }
  22556. resp, _ := client.Do(req)
  22557. defer resp.Body.Close()
  22558. body, ioErr := ioutil.ReadAll(resp.Body)
  22559. if ioErr != nil {
  22560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22562. return
  22563. }
  22564. var respJSON map[string]interface{}
  22565. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22568. return
  22569. }
  22570. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  22571. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  22572. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  22573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22574. userJSONBytes, _ := json.Marshal(respJSON)
  22575. fmt.Println("log")
  22576. fmt.Println(string(userJSONBytes))
  22577. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  22578. utils.ErrorLog("解析失败:%v", err)
  22579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22580. return
  22581. }
  22582. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22583. res2.Output = resSix10265.Output
  22584. res2.ErrMsg = resSix10265.ErrMsg
  22585. res2.Cainfo = resSix10265.Cainfo
  22586. res2.WarnMsg = resSix10265.WarnMsg
  22587. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22588. res2.Infcode = infocode
  22589. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22590. data := make(map[string]interface{})
  22591. client := &http.Client{}
  22592. data["psn_no"] = his.PsnNo
  22593. data["mdtrt_id"] = his.Number
  22594. data["doctor"] = roles.UserName
  22595. data["department"] = department.Name
  22596. data["org_name"] = miConfig.OrgName
  22597. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22598. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  22599. data["fixmedins_code"] = miConfig.Code
  22600. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22601. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22602. data["secret_key"] = miConfig.SecretKey
  22603. data["sick_code"] = sickConfig.CountryCode
  22604. data["sick_name"] = sickConfig.ClassName
  22605. data["begin_time"] = begin_time
  22606. data["dept"] = strconv.FormatInt(department.ID, 10)
  22607. data["config"] = config
  22608. //data["url"] = miConfig.Url
  22609. //data["ak"] = miConfig.AccessKey
  22610. data["cainfo"] = miConfig.Cainfo
  22611. fmt.Println(data)
  22612. bytesData, _ := json.Marshal(data)
  22613. var req *http.Request
  22614. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  22615. resp, _ := client.Do(req)
  22616. defer resp.Body.Close()
  22617. body, ioErr := ioutil.ReadAll(resp.Body)
  22618. if ioErr != nil {
  22619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22621. return
  22622. }
  22623. var respJSON map[string]interface{}
  22624. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22627. return
  22628. }
  22629. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  22630. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  22631. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  22632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22633. userJSONBytes, _ := json.Marshal(respJSON)
  22634. fmt.Println("log")
  22635. fmt.Println(string(userJSONBytes))
  22636. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  22637. utils.ErrorLog("解析失败:%v", err)
  22638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22639. return
  22640. }
  22641. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22642. res2.Output = resSix10265.Output
  22643. res2.ErrMsg = resSix10265.ErrMsg
  22644. res2.Cainfo = resSix10265.Cainfo
  22645. res2.WarnMsg = resSix10265.WarnMsg
  22646. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22647. res2.Infcode = infocode
  22648. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22649. 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)
  22650. saveLog(result, requestLog, "2203", "上传就诊信息")
  22651. var respJSON2 map[string]interface{}
  22652. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22655. return
  22656. }
  22657. userJSONBytes2, _ := json.Marshal(respJSON2)
  22658. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22659. utils.ErrorLog("解析失败:%v", err)
  22660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22661. return
  22662. }
  22663. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22664. var result string
  22665. var requestLog string
  22666. 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, "")
  22667. saveLog(result, requestLog, "2203", "上传就诊信息")
  22668. var respJSON2 map[string]interface{}
  22669. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22672. return
  22673. }
  22674. userJSONBytes2, _ := json.Marshal(respJSON2)
  22675. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22676. utils.ErrorLog("解析失败:%v", err)
  22677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22678. return
  22679. }
  22680. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22681. data := make(map[string]interface{})
  22682. client := &http.Client{}
  22683. data["psn_no"] = his.PsnNo
  22684. data["mdtrt_id"] = his.Number
  22685. data["operator"] = roles.UserName
  22686. data["department"] = department.Name
  22687. data["org_name"] = miConfig.OrgName
  22688. var med_type string
  22689. if his.Insutype == "390" {
  22690. if reg_type == 992102 {
  22691. med_type = "992102"
  22692. data["sick_code"] = "ZDZ940"
  22693. data["sick_name"] = "慢性肾衰竭"
  22694. }
  22695. if reg_type == 140104 {
  22696. med_type = "140104"
  22697. data["sick_code"] = sickConfig.CountryCode
  22698. data["sick_name"] = sickConfig.ClassName
  22699. }
  22700. if reg_type == 14 {
  22701. med_type = "140104"
  22702. data["sick_code"] = sickConfig.CountryCode
  22703. data["sick_name"] = sickConfig.ClassName
  22704. }
  22705. } else if his.Insutype == "310" {
  22706. if reg_type == 992102 {
  22707. med_type = "992102"
  22708. data["sick_code"] = "ZDZ940"
  22709. data["sick_name"] = "慢性肾衰竭"
  22710. }
  22711. if reg_type == 140104 {
  22712. med_type = "140104"
  22713. data["sick_code"] = sickConfig.CountryCode
  22714. data["sick_name"] = sickConfig.ClassName
  22715. }
  22716. if reg_type == 14 {
  22717. med_type = "14"
  22718. data["sick_code"] = sickConfig.CountryCode
  22719. data["sick_name"] = sickConfig.ClassName
  22720. }
  22721. }
  22722. data["med_type"] = med_type
  22723. data["doctor_number"] = doctor_info.DoctorNumber
  22724. data["doctor_name"] = doctor_info.UserName
  22725. data["fixmedins_code"] = miConfig.Code
  22726. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22727. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22728. data["secret_key"] = miConfig.SecretKey
  22729. data["begin_time"] = begin_time
  22730. data["dept"] = strconv.FormatInt(department.ID, 10)
  22731. data["config"] = config
  22732. data["url"] = miConfig.Url
  22733. data["ak"] = miConfig.AccessKey
  22734. data["cainfo"] = miConfig.Cainfo
  22735. bytesData, _ := json.Marshal(data)
  22736. var req *http.Request
  22737. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  22738. resp, _ := client.Do(req)
  22739. defer resp.Body.Close()
  22740. body, ioErr := ioutil.ReadAll(resp.Body)
  22741. if ioErr != nil {
  22742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22744. return
  22745. }
  22746. var respJSON map[string]interface{}
  22747. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22750. return
  22751. }
  22752. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22753. if status == "0" {
  22754. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22755. c.ServeSuccessJSON(map[string]interface{}{
  22756. "failed_code": -10,
  22757. "msg": err_msg,
  22758. })
  22759. return
  22760. }
  22761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22762. userJSONBytes, _ := json.Marshal(respJSON)
  22763. fmt.Println("log")
  22764. fmt.Println(string(userJSONBytes))
  22765. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22766. utils.ErrorLog("解析失败:%v", err)
  22767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22768. return
  22769. }
  22770. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22771. var result string
  22772. var requestLog string
  22773. 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, "")
  22774. saveLog(result, requestLog, "2203", "上传就诊信息")
  22775. var respJSON2 map[string]interface{}
  22776. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22779. return
  22780. }
  22781. userJSONBytes2, _ := json.Marshal(respJSON2)
  22782. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22783. utils.ErrorLog("解析失败:%v", err)
  22784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22785. return
  22786. }
  22787. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22788. data := make(map[string]interface{})
  22789. client := &http.Client{}
  22790. data["psn_no"] = his.PsnNo
  22791. data["mdtrt_id"] = his.Number
  22792. data["doctor"] = roles.UserName
  22793. data["department"] = department.Name
  22794. data["org_name"] = miConfig.OrgName
  22795. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22796. data["doctor_id"] = doctor_info.DoctorNumber
  22797. data["fixmedins_code"] = miConfig.Code
  22798. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22799. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22800. data["secret_key"] = miConfig.SecretKey
  22801. data["sick_code"] = sickConfig.CountryCode
  22802. data["sick_name"] = sickConfig.ClassName
  22803. data["begin_time"] = begin_time
  22804. data["new_doctor_name"] = doctor_info.UserName
  22805. data["dept"] = strconv.FormatInt(department.ID, 10)
  22806. data["config"] = config
  22807. bytesData, _ := json.Marshal(data)
  22808. var req *http.Request
  22809. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  22810. resp, _ := client.Do(req)
  22811. defer resp.Body.Close()
  22812. body, ioErr := ioutil.ReadAll(resp.Body)
  22813. if ioErr != nil {
  22814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22816. return
  22817. }
  22818. var respJSON map[string]interface{}
  22819. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22822. return
  22823. }
  22824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22825. userJSONBytes, _ := json.Marshal(respJSON)
  22826. fmt.Println("log")
  22827. fmt.Println(string(userJSONBytes))
  22828. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22829. utils.ErrorLog("解析失败:%v", err)
  22830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22831. return
  22832. }
  22833. } else {
  22834. var result string
  22835. var requestLog string
  22836. if miConfig.MdtrtareaAdmvs == "440781" { //
  22837. 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)
  22838. } else {
  22839. if miConfig.Code == "H15049901371" {
  22840. //赤峰地区国家医保医疗类别
  22841. //职工透析:医疗类别选特殊情况门诊990502
  22842. //居民定额血透门慢: 医疗类别选门诊慢病140104
  22843. var med_type string
  22844. if his.Insutype == "390" {
  22845. if reg_type == 14 {
  22846. med_type = "9933"
  22847. } else if reg_type == 11 {
  22848. med_type = "11"
  22849. }
  22850. } else if his.Insutype == "310" {
  22851. if reg_type == 14 {
  22852. med_type = "990502"
  22853. } else if reg_type == 11 {
  22854. med_type = "11"
  22855. }
  22856. }
  22857. 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)
  22858. } else {
  22859. 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)
  22860. }
  22861. saveLog(result, requestLog, "2203", "上传就诊信息")
  22862. var respJSON2 map[string]interface{}
  22863. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22866. return
  22867. }
  22868. userJSONBytes2, _ := json.Marshal(respJSON2)
  22869. if miConfig.Code == "H15049901371" {
  22870. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  22871. utils.ErrorLog("解析失败:%v", err)
  22872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22873. return
  22874. }
  22875. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22876. res2.Output = resSix10265.Output
  22877. res2.ErrMsg = resSix10265.ErrMsg
  22878. res2.Cainfo = resSix10265.Cainfo
  22879. res2.WarnMsg = resSix10265.WarnMsg
  22880. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22881. res2.Infcode = infocode
  22882. } else {
  22883. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22884. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  22885. utils.ErrorLog("解析失败:%v", err)
  22886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22887. return
  22888. }
  22889. res2.Infcode = res3.Infcode
  22890. } else {
  22891. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22892. utils.ErrorLog("解析失败:%v", err)
  22893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22894. return
  22895. }
  22896. }
  22897. }
  22898. }
  22899. }
  22900. if res2.Infcode == -1 {
  22901. adminUser := c.GetAdminUserInfo()
  22902. errlog := &models.HisOrderError{
  22903. UserOrgId: adminUser.CurrentOrgId,
  22904. Ctime: time.Now().Unix(),
  22905. Mtime: time.Now().Unix(),
  22906. ErrMsg: res2.ErrMsg,
  22907. Status: 1,
  22908. PatientId: id,
  22909. RecordTime: recordDateTime,
  22910. Stage: 3,
  22911. }
  22912. service.CreateErrMsgLog(errlog)
  22913. c.ServeSuccessJSON(map[string]interface{}{
  22914. "failed_code": -10,
  22915. "msg": res2.ErrMsg,
  22916. })
  22917. return
  22918. }
  22919. if res2.Infcode != 0 {
  22920. adminUser := c.GetAdminUserInfo()
  22921. errlog := &models.HisOrderError{
  22922. UserOrgId: adminUser.CurrentOrgId,
  22923. Ctime: time.Now().Unix(),
  22924. Mtime: time.Now().Unix(),
  22925. ErrMsg: res2.ErrMsg,
  22926. Status: 1,
  22927. PatientId: id,
  22928. RecordTime: recordDateTime,
  22929. Stage: 3,
  22930. }
  22931. service.CreateErrMsgLog(errlog)
  22932. c.ServeSuccessJSON(map[string]interface{}{
  22933. "failed_code": -10,
  22934. "msg": res2.ErrMsg,
  22935. })
  22936. return
  22937. } else {
  22938. his.Diagnosis = diagnosis_id
  22939. his.SickType = sickConfig.ID
  22940. his.PType = fmt.Sprintf("%d", reg_type)
  22941. service.UpdateHisPatientThree(&his)
  22942. data := make(map[string]interface{})
  22943. if settle_accounts_type == 1 { //日结
  22944. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  22945. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  22946. } else {
  22947. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  22948. }
  22949. data["pre"] = prescriptions
  22950. } else { //月结
  22951. start_time_str := c.GetString("start_time")
  22952. end_time_str := c.GetString("end_time")
  22953. timeLayout := "2006-01-02"
  22954. loc, _ := time.LoadLocation("Local")
  22955. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  22956. if err != nil {
  22957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22958. return
  22959. }
  22960. recordStartTime := theStartTime.Unix()
  22961. start_time = recordStartTime
  22962. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  22963. if err != nil {
  22964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22965. return
  22966. }
  22967. recordEndTime := theEndTime.Unix()
  22968. end_time = recordEndTime
  22969. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  22970. data["pre"] = prescriptions
  22971. }
  22972. client := &http.Client{}
  22973. data["psn_no"] = his.PsnNo
  22974. data["mdtrt_id"] = his.Number
  22975. data["chrg_bchno"] = chrg_bchno
  22976. data["org_name"] = miConfig.OrgName
  22977. data["doctor"] = doctor_info.UserName
  22978. data["doctor_id"] = doctor_info.DoctorNumber
  22979. data["dept"] = department.Name
  22980. data["fixmedins_code"] = miConfig.Code
  22981. data["opter"] = roles.UserName
  22982. data["dept_code"] = department.Number
  22983. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22984. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22985. data["secret_key"] = miConfig.SecretKey
  22986. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  22987. data["url"] = miConfig.Url
  22988. data["ak"] = miConfig.AccessKey
  22989. data["new_doctor_name"] = patientPrescription.Doctor
  22990. if his.Insutype == "390" {
  22991. if reg_type == 992102 {
  22992. data["diag_code"] = "ZDZ940"
  22993. }
  22994. if reg_type == 140104 {
  22995. data["diag_code"] = sickConfig.CountryCode
  22996. }
  22997. if reg_type == 14 {
  22998. data["diag_code"] = sickConfig.CountryCode
  22999. }
  23000. } else if his.Insutype == "310" {
  23001. if reg_type == 992102 {
  23002. data["diag_code"] = "ZDZ940"
  23003. }
  23004. if reg_type == 14 {
  23005. data["diag_code"] = sickConfig.CountryCode
  23006. }
  23007. }
  23008. data["cainfo"] = miConfig.Cainfo
  23009. data["opter"] = roles.UserName
  23010. var ids []int64
  23011. for _, item := range prescriptions {
  23012. ids = append(ids, item.ID)
  23013. }
  23014. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23015. if config.IsOpen == 1 { //对接了医保,走医保流程
  23016. var res ResultFour
  23017. var resFour10265 ResultFour10265
  23018. if miConfig.MdtrtareaAdmvs == "421300" {
  23019. bytesData, _ := json.Marshal(data)
  23020. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23021. resp, _ := client.Do(req)
  23022. defer resp.Body.Close()
  23023. body, ioErr := ioutil.ReadAll(resp.Body)
  23024. if ioErr != nil {
  23025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23027. return
  23028. }
  23029. var respJSON map[string]interface{}
  23030. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23033. return
  23034. }
  23035. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23036. userJSONBytes, _ := json.Marshal(respJSON)
  23037. fmt.Println("log")
  23038. fmt.Println(string(userJSONBytes))
  23039. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23040. utils.ErrorLog("解析失败:%v", err)
  23041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23042. return
  23043. }
  23044. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23045. bytesData, _ := json.Marshal(data)
  23046. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23047. resp, _ := client.Do(req)
  23048. defer resp.Body.Close()
  23049. body, ioErr := ioutil.ReadAll(resp.Body)
  23050. if ioErr != nil {
  23051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23053. return
  23054. }
  23055. var respJSON map[string]interface{}
  23056. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23059. return
  23060. }
  23061. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23062. userJSONBytes, _ := json.Marshal(respJSON)
  23063. fmt.Println("log")
  23064. fmt.Println(string(userJSONBytes))
  23065. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23066. utils.ErrorLog("解析失败:%v", err)
  23067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23068. return
  23069. }
  23070. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23071. bytesData, _ := json.Marshal(data)
  23072. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23073. resp, _ := client.Do(req)
  23074. defer resp.Body.Close()
  23075. body, ioErr := ioutil.ReadAll(resp.Body)
  23076. if ioErr != nil {
  23077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23079. return
  23080. }
  23081. var respJSON map[string]interface{}
  23082. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23085. return
  23086. }
  23087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23088. userJSONBytes, _ := json.Marshal(respJSON)
  23089. fmt.Println("log")
  23090. fmt.Println(string(userJSONBytes))
  23091. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23092. utils.ErrorLog("解析失败:%v", err)
  23093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23094. return
  23095. }
  23096. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23097. bytesData, _ := json.Marshal(data)
  23098. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23099. resp, _ := client.Do(req)
  23100. defer resp.Body.Close()
  23101. body, ioErr := ioutil.ReadAll(resp.Body)
  23102. if ioErr != nil {
  23103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23105. return
  23106. }
  23107. var respJSON map[string]interface{}
  23108. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23111. return
  23112. }
  23113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23114. userJSONBytes, _ := json.Marshal(respJSON)
  23115. fmt.Println("log")
  23116. fmt.Println(string(userJSONBytes))
  23117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23118. utils.ErrorLog("解析失败:%v", err)
  23119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23120. return
  23121. }
  23122. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23123. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  23124. if result3101.Infcode == "0" {
  23125. if len(result3101.Output.Result) > 0 {
  23126. var errMsgs []string
  23127. for _, item := range result3101.Output.Result {
  23128. errMsgs = append(errMsgs, item.VolaCont)
  23129. }
  23130. c.ServeSuccessJSON(map[string]interface{}{
  23131. "failed_code": -10,
  23132. "msg": errMsgs,
  23133. })
  23134. return
  23135. } else {
  23136. if miConfig.MdtrtareaAdmvs == "320921" {
  23137. data["doctor_id"] = "D320923012139"
  23138. } else {
  23139. data["doctor_id"] = "D371621008686"
  23140. }
  23141. bytesData, _ := json.Marshal(data)
  23142. var req *http.Request
  23143. if miConfig.MdtrtareaAdmvs == "320921" {
  23144. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23145. } else {
  23146. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23147. }
  23148. resp, _ := client.Do(req)
  23149. defer resp.Body.Close()
  23150. body, ioErr := ioutil.ReadAll(resp.Body)
  23151. if ioErr != nil {
  23152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23154. return
  23155. }
  23156. var respJSON map[string]interface{}
  23157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23160. return
  23161. }
  23162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23163. userJSONBytes, _ := json.Marshal(respJSON)
  23164. fmt.Println("log")
  23165. fmt.Println(string(userJSONBytes))
  23166. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23167. utils.ErrorLog("解析失败:%v", err)
  23168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23169. return
  23170. }
  23171. res.InfRefmsgid = resFour10265.InfRefmsgid
  23172. res.Output = resFour10265.Output
  23173. res.ErrMsg = resFour10265.ErrMsg
  23174. res.Cainfo = resFour10265.Cainfo
  23175. res.WarnMsg = resFour10265.WarnMsg
  23176. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23177. res.Infcode = infocode
  23178. }
  23179. }
  23180. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23181. var pagesize int = 5
  23182. var start int = 1
  23183. var stop int
  23184. var pagecount int
  23185. var curpage int
  23186. data["doctor_id"] = doctor_info.DoctorNumber
  23187. var res2 ResultFour
  23188. //var result res.
  23189. //总页数,向上取整,注意除之前要先转换类型为float64
  23190. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  23191. for curpage = 1; curpage <= pagecount; curpage++ {
  23192. if curpage == 1 {
  23193. start = 1
  23194. } else {
  23195. start = (curpage-1)*pagesize + 1
  23196. }
  23197. stop = curpage * pagesize
  23198. if stop > len(prescriptions) {
  23199. stop = len(prescriptions)
  23200. }
  23201. //var requestLog string
  23202. data["pre"] = prescriptions[start-1 : stop]
  23203. fmt.Println(data["pre"])
  23204. bytesData, _ := json.Marshal(data)
  23205. var req *http.Request
  23206. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  23207. resp, _ := client.Do(req)
  23208. defer resp.Body.Close()
  23209. body, ioErr := ioutil.ReadAll(resp.Body)
  23210. if ioErr != nil {
  23211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23213. return
  23214. }
  23215. var respJSON map[string]interface{}
  23216. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23219. return
  23220. }
  23221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23222. userJSONBytes, _ := json.Marshal(respJSON)
  23223. fmt.Println("log")
  23224. fmt.Println(string(userJSONBytes))
  23225. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23226. utils.ErrorLog("解析失败:%v", err)
  23227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23228. return
  23229. }
  23230. res.InfRefmsgid = resFour10265.InfRefmsgid
  23231. res.Output = resFour10265.Output
  23232. res.ErrMsg = resFour10265.ErrMsg
  23233. res.Cainfo = resFour10265.Cainfo
  23234. res.WarnMsg = resFour10265.WarnMsg
  23235. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23236. res.Infcode = infocode
  23237. if infocode == 0 {
  23238. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  23239. } else {
  23240. isSuccess = false
  23241. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  23242. res.Infcode = -1
  23243. res.ErrMsg = resFour10265.ErrMsg
  23244. errlog := &models.HisOrderError{
  23245. UserOrgId: adminUser.CurrentOrgId,
  23246. Ctime: time.Now().Unix(),
  23247. Mtime: time.Now().Unix(),
  23248. Number: chrg_bchno,
  23249. ErrMsg: "",
  23250. Status: 1,
  23251. PatientId: id,
  23252. RecordTime: recordDateTime,
  23253. Stage: 4,
  23254. }
  23255. service.CreateErrMsgLog(errlog)
  23256. }
  23257. }
  23258. if isSuccess {
  23259. res.Infcode = 0
  23260. res.Output.Result = res2.Output.Result
  23261. } else {
  23262. order := &models.HisOrder{
  23263. UserOrgId: adminUser.CurrentOrgId,
  23264. HisPatientId: his.ID,
  23265. PatientId: his.PatientId,
  23266. SettleAccountsDate: recordDateTime,
  23267. Ctime: time.Now().Unix(),
  23268. Mtime: time.Now().Unix(),
  23269. MdtrtId: his.Number,
  23270. PsnNo: his.PsnNo,
  23271. MedType: strconv.FormatInt(reg_type, 10),
  23272. Status: 1,
  23273. Number: chrg_bchno,
  23274. Infcode: res.Infcode,
  23275. WarnMsg: res.WarnMsg,
  23276. Cainfo: res.Cainfo,
  23277. ErrMsg: res.ErrMsg,
  23278. RespondTime: res.RefmsgTime,
  23279. InfRefmsgid: res.InfRefmsgid,
  23280. OrderStatus: 1,
  23281. IsMedicineInsurance: 1,
  23282. SettleType: settle_accounts_type,
  23283. SettleStartTime: start_time,
  23284. SettleEndTime: end_time,
  23285. Creator: roles.AdminUserId,
  23286. Modify: roles.AdminUserId,
  23287. PType: 2,
  23288. Diagnosis: diagnosis_id,
  23289. }
  23290. err = service.CreateOrder(order)
  23291. if err != nil {
  23292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23293. return
  23294. }
  23295. c.ServeSuccessJSON(map[string]interface{}{
  23296. "failed_code": -10,
  23297. "msg": res2.ErrMsg,
  23298. })
  23299. return
  23300. }
  23301. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23302. 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)
  23303. var dat map[string]interface{}
  23304. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23305. fmt.Println(dat)
  23306. } else {
  23307. fmt.Println(err)
  23308. }
  23309. saveLog(result, request_log, "2204", "上传费用明细")
  23310. userJSONBytes, _ := json.Marshal(dat)
  23311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23312. utils.ErrorLog("解析失败:%v", err)
  23313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23314. return
  23315. }
  23316. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23317. 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, "", "")
  23318. var dat map[string]interface{}
  23319. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23320. fmt.Println(dat)
  23321. } else {
  23322. fmt.Println(err)
  23323. }
  23324. saveLog(result, request_log, "2204", "上传费用明细")
  23325. userJSONBytes, _ := json.Marshal(dat)
  23326. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23327. utils.ErrorLog("解析失败:%v", err)
  23328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23329. return
  23330. }
  23331. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23332. bytesData, _ := json.Marshal(data)
  23333. var req *http.Request
  23334. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  23335. resp, _ := client.Do(req)
  23336. defer resp.Body.Close()
  23337. body, ioErr := ioutil.ReadAll(resp.Body)
  23338. if ioErr != nil {
  23339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23341. return
  23342. }
  23343. var respJSON map[string]interface{}
  23344. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23347. return
  23348. }
  23349. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23350. if status == "0" {
  23351. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23352. c.ServeSuccessJSON(map[string]interface{}{
  23353. "failed_code": -10,
  23354. "msg": err_msg,
  23355. })
  23356. return
  23357. }
  23358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23359. userJSONBytes, _ := json.Marshal(respJSON)
  23360. fmt.Println("log")
  23361. fmt.Println(string(userJSONBytes))
  23362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23363. utils.ErrorLog("解析失败:%v", err)
  23364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23365. return
  23366. }
  23367. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23368. 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, "", "")
  23369. var dat map[string]interface{}
  23370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23371. fmt.Println(dat)
  23372. } else {
  23373. fmt.Println(err)
  23374. }
  23375. saveLog(result, request_log, "2204", "上传费用明细")
  23376. userJSONBytes, _ := json.Marshal(dat)
  23377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23378. utils.ErrorLog("解析失败:%v", err)
  23379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23380. return
  23381. }
  23382. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23383. bytesData, _ := json.Marshal(data)
  23384. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  23385. resp, _ := client.Do(req)
  23386. defer resp.Body.Close()
  23387. body, ioErr := ioutil.ReadAll(resp.Body)
  23388. if ioErr != nil {
  23389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23391. return
  23392. }
  23393. var respJSON map[string]interface{}
  23394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23397. return
  23398. }
  23399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23400. userJSONBytes, _ := json.Marshal(respJSON)
  23401. fmt.Println("log")
  23402. fmt.Println(string(userJSONBytes))
  23403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23404. utils.ErrorLog("解析失败:%v", err)
  23405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23406. return
  23407. }
  23408. } else {
  23409. if miConfig.MdtrtareaAdmvs == "441202" {
  23410. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  23411. if result3101.Infcode == 0 {
  23412. if len(result3101.Output.Result) > 0 {
  23413. var errMsgs []string
  23414. for _, item := range result3101.Output.Result {
  23415. errMsgs = append(errMsgs, item.VolaCont)
  23416. }
  23417. c.ServeSuccessJSON(map[string]interface{}{
  23418. "failed_code": -10,
  23419. "msg": errMsgs,
  23420. })
  23421. return
  23422. } else {
  23423. 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)
  23424. var dat map[string]interface{}
  23425. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23426. fmt.Println(dat)
  23427. } else {
  23428. fmt.Println(err)
  23429. }
  23430. saveLog(result, request_log, "2204", "上传费用明细")
  23431. userJSONBytes, _ := json.Marshal(dat)
  23432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23433. utils.ErrorLog("解析失败:%v", err)
  23434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23435. return
  23436. }
  23437. }
  23438. } else {
  23439. c.ServeSuccessJSON(map[string]interface{}{
  23440. "failed_code": -10,
  23441. "msg": result3101.ErrMsg,
  23442. })
  23443. return
  23444. }
  23445. } else {
  23446. if miConfig.Code == "H15049901371" {
  23447. 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)
  23448. var dat map[string]interface{}
  23449. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23450. fmt.Println(dat)
  23451. } else {
  23452. fmt.Println(err)
  23453. }
  23454. saveLog(result, request_log, "2204", "上传费用明细")
  23455. userJSONBytes, _ := json.Marshal(dat)
  23456. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23457. utils.ErrorLog("解析失败:%v", err)
  23458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23459. return
  23460. }
  23461. res.InfRefmsgid = resFour10265.InfRefmsgid
  23462. res.Output = resFour10265.Output
  23463. res.ErrMsg = resFour10265.ErrMsg
  23464. res.Cainfo = resFour10265.Cainfo
  23465. res.WarnMsg = resFour10265.WarnMsg
  23466. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23467. res.Infcode = infocode
  23468. } else {
  23469. 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)
  23470. var dat map[string]interface{}
  23471. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23472. fmt.Println(dat)
  23473. } else {
  23474. fmt.Println(err)
  23475. }
  23476. saveLog(result, request_log, "2204", "上传费用明细")
  23477. userJSONBytes, _ := json.Marshal(dat)
  23478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23479. utils.ErrorLog("解析失败:%v", err)
  23480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23481. return
  23482. }
  23483. }
  23484. }
  23485. }
  23486. var total_two float64
  23487. if res.Infcode == 0 {
  23488. order := &models.HisOrder{
  23489. UserOrgId: adminUser.CurrentOrgId,
  23490. HisPatientId: his.ID,
  23491. PatientId: his.PatientId,
  23492. SettleAccountsDate: recordDateTime,
  23493. Ctime: time.Now().Unix(),
  23494. Mtime: time.Now().Unix(),
  23495. MdtrtId: his.Number,
  23496. PsnNo: his.PsnNo,
  23497. MedType: strconv.FormatInt(reg_type, 10),
  23498. Status: 1,
  23499. Number: chrg_bchno,
  23500. Infcode: res.Infcode,
  23501. WarnMsg: res.WarnMsg,
  23502. Cainfo: res.Cainfo,
  23503. ErrMsg: res.ErrMsg,
  23504. RespondTime: res.RefmsgTime,
  23505. InfRefmsgid: res.InfRefmsgid,
  23506. OrderStatus: 1,
  23507. IsMedicineInsurance: 1,
  23508. SettleType: settle_accounts_type,
  23509. SettleStartTime: start_time,
  23510. SettleEndTime: end_time,
  23511. Creator: roles.AdminUserId,
  23512. Modify: roles.AdminUserId,
  23513. PType: 2,
  23514. Diagnosis: diagnosis_id,
  23515. }
  23516. err = service.CreateOrder(order)
  23517. if err != nil {
  23518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23519. return
  23520. }
  23521. for _, item := range res.Output.Result {
  23522. temp := strings.Split(item.FeedetlSn, "-")
  23523. var advice_id int64 = 0
  23524. var project_id int64 = 0
  23525. var types int64 = 0
  23526. id, _ := strconv.ParseInt(temp[2], 10, 64)
  23527. types, _ = strconv.ParseInt(temp[1], 10, 64)
  23528. if temp[1] == "1" {
  23529. advice_id = id
  23530. project_id = 0
  23531. } else if temp[1] == "2" {
  23532. advice_id = 0
  23533. project_id = id
  23534. }
  23535. total_two = total_two + item.DetItemFeeSumamt
  23536. info := &models.HisOrderInfo{
  23537. OrderNumber: order.Number,
  23538. FeedetlSn: item.FeedetlSn,
  23539. UploadDate: time.Now().Unix(),
  23540. AdviceId: advice_id,
  23541. DetItemFeeSumamt: item.DetItemFeeSumamt,
  23542. Cnt: item.Cnt,
  23543. Pric: float64(item.Pric),
  23544. PatientId: his.PatientId,
  23545. PricUplmtAmt: item.PricUplmtAmt,
  23546. SelfpayProp: item.SelfpayProp,
  23547. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  23548. OverlmtAmt: item.OverlmtAmt,
  23549. PreselfpayAmt: item.PreselfpayAmt,
  23550. BasMednFlag: item.BasMednFlag,
  23551. MedChrgitmType: item.MedChrgitmType,
  23552. HiNegoDrugFlag: item.HiNegoDrugFlag,
  23553. Status: 1,
  23554. Memo: item.Memo,
  23555. Mtime: time.Now().Unix(),
  23556. InscpScpAmt: item.InscpScpAmt,
  23557. DrtReimFlag: item.DrtReimFlag,
  23558. Ctime: time.Now().Unix(),
  23559. ListSpItemFlag: item.ListSpItemFlag,
  23560. ChldMedcFlag: item.ChldMedcFlag,
  23561. LmtUsedFlag: item.LmtUsedFlag,
  23562. ChrgitmLv: item.ChrgitmLv,
  23563. UserOrgId: adminUser.CurrentOrgId,
  23564. HisPatientId: his.ID,
  23565. OrderId: order.ID,
  23566. ProjectId: project_id,
  23567. Type: types,
  23568. }
  23569. service.CreateOrderInfo(info)
  23570. }
  23571. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  23572. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  23573. var total float64
  23574. for _, item := range prescriptions {
  23575. if item.Type == 1 { //药品
  23576. for _, subItem := range item.HisDoctorAdviceInfo {
  23577. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23578. total_one := price * subItem.PrescribingNumber
  23579. fmt.Println("subItem")
  23580. fmt.Println(subItem.Price)
  23581. fmt.Println("price")
  23582. fmt.Println(price)
  23583. fmt.Println("total_one")
  23584. fmt.Println(total_one)
  23585. total = total + total_one
  23586. fmt.Println(total)
  23587. }
  23588. }
  23589. if item.Type == 2 { //项目
  23590. for _, subItem := range item.HisPrescriptionProject {
  23591. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  23592. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23593. total_one := price * cnt
  23594. total = total + total_one
  23595. }
  23596. }
  23597. }
  23598. allTotal := fmt.Sprintf("%.2f", total)
  23599. if res.Infcode == 0 {
  23600. var rf []*ResultFive
  23601. json.Unmarshal([]byte(his.Iinfo), &rf)
  23602. chrg_bchno := chrg_bchno
  23603. cert_no := his.Certno
  23604. var insutypes []string
  23605. var insutype string
  23606. var is390 int = 0
  23607. var is310 int = 0
  23608. for _, item := range rf {
  23609. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23610. insutypes = append(insutypes, item.Insutype)
  23611. }
  23612. }
  23613. if len(insutypes) == 1 {
  23614. insutype = insutypes[0]
  23615. } else {
  23616. for _, i := range insutypes {
  23617. if i == "390" {
  23618. is390 = 1
  23619. }
  23620. if i == "310" {
  23621. is310 = 1
  23622. }
  23623. }
  23624. }
  23625. if is390 == 1 {
  23626. insutype = "390"
  23627. }
  23628. if is310 == 1 {
  23629. insutype = "310"
  23630. }
  23631. if len(insutypes) == 0 {
  23632. insutype = "390"
  23633. }
  23634. if len(insutypes) == 2 {
  23635. insutype = strconv.FormatInt(his.SocialType, 10)
  23636. }
  23637. //insutype = "390"
  23638. if his.IdCardType == 1 {
  23639. cert_no = his.MedicalInsuranceNumber
  23640. } else {
  23641. cert_no = his.Certno
  23642. }
  23643. var res ResultSeven
  23644. var ahres ResultSevenAH
  23645. var resSeven10265 ResultSeven10265
  23646. var resSeven10265Two ResultSeven10265Two
  23647. var gzresSeven10265Two GZResultSeven10265Two
  23648. if miConfig.MdtrtareaAdmvs == "421300" {
  23649. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  23650. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23651. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23652. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23653. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23654. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23655. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23656. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23657. resp, requestErr := http.Get(api)
  23658. if requestErr != nil {
  23659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23660. return
  23661. }
  23662. body, ioErr := ioutil.ReadAll(resp.Body)
  23663. if ioErr != nil {
  23664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23666. return
  23667. }
  23668. var respJSON map[string]interface{}
  23669. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23672. return
  23673. }
  23674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23675. result, _ := json.Marshal(respJSON)
  23676. fmt.Println("log")
  23677. fmt.Println(string(result))
  23678. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23679. utils.ErrorLog("解析失败:%v", err)
  23680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23681. return
  23682. }
  23683. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23684. if reg_type == 11 && his.Insutype == "390" {
  23685. reg_type = 110104
  23686. }
  23687. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23688. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23689. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23690. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23691. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23692. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23693. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23694. resp, requestErr := http.Get(api)
  23695. if requestErr != nil {
  23696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23697. return
  23698. }
  23699. body, ioErr := ioutil.ReadAll(resp.Body)
  23700. if ioErr != nil {
  23701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23703. return
  23704. }
  23705. var respJSON map[string]interface{}
  23706. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23709. return
  23710. }
  23711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23712. result, _ := json.Marshal(respJSON)
  23713. fmt.Println("log")
  23714. fmt.Println(string(result))
  23715. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23716. utils.ErrorLog("解析失败:%v", err)
  23717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23718. return
  23719. }
  23720. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23721. if reg_type == 11 && his.Insutype == "390" {
  23722. reg_type = 110104
  23723. }
  23724. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23725. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23726. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23727. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23728. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23729. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23730. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23731. resp, requestErr := http.Get(api)
  23732. if requestErr != nil {
  23733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23734. return
  23735. }
  23736. body, ioErr := ioutil.ReadAll(resp.Body)
  23737. if ioErr != nil {
  23738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23740. return
  23741. }
  23742. var respJSON map[string]interface{}
  23743. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23746. return
  23747. }
  23748. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23749. result, _ := json.Marshal(respJSON)
  23750. fmt.Println("log")
  23751. fmt.Println(string(result))
  23752. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23753. utils.ErrorLog("解析失败:%v", err)
  23754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23755. return
  23756. }
  23757. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23758. if reg_type == 11 && his.Insutype == "390" {
  23759. reg_type = 110104
  23760. }
  23761. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23762. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23763. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23764. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23765. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23766. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23767. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23768. resp, requestErr := http.Get(api)
  23769. if requestErr != nil {
  23770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23771. return
  23772. }
  23773. body, ioErr := ioutil.ReadAll(resp.Body)
  23774. if ioErr != nil {
  23775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23777. return
  23778. }
  23779. var respJSON map[string]interface{}
  23780. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23783. return
  23784. }
  23785. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23786. result, _ := json.Marshal(respJSON)
  23787. fmt.Println("log")
  23788. fmt.Println(string(result))
  23789. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23790. utils.ErrorLog("解析失败:%v", err)
  23791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23792. return
  23793. }
  23794. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23795. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23796. if result3101.Infcode == "0" {
  23797. if len(result3101.Output.Result) > 0 {
  23798. var errMsgs []string
  23799. for _, item := range result3101.Output.Result {
  23800. errMsgs = append(errMsgs, item.VolaCont)
  23801. }
  23802. c.ServeSuccessJSON(map[string]interface{}{
  23803. "failed_code": -10,
  23804. "msg": errMsgs,
  23805. })
  23806. return
  23807. } else {
  23808. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23809. if his.IdCardType != 4 {
  23810. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23811. bas := strings.Split(psn_info.CardInfo, "|")
  23812. if his.IdCardType == 1 {
  23813. cert_no = bas[2]
  23814. } else {
  23815. cert_no = bas[1]
  23816. }
  23817. } else {
  23818. cert_no = his.Certno
  23819. }
  23820. //江苏地区国家医保医疗类别
  23821. //职工透析:医疗类别选特殊情况门诊9933
  23822. //居民血透门慢: 医疗类别选门诊慢病1402
  23823. //var med_type string
  23824. //if his.Insutype == "310" {
  23825. // if reg_type == 14 {
  23826. // med_type = "9933"
  23827. // } else if reg_type == 11 {
  23828. // med_type = "11"
  23829. //
  23830. // }
  23831. //} else if his.Insutype == "390" {
  23832. // if reg_type == 14 {
  23833. // med_type = "1402"
  23834. // } else if reg_type == 11 {
  23835. // med_type = "11"
  23836. // }
  23837. //}
  23838. var api string
  23839. if miConfig.MdtrtareaAdmvs == "320921" {
  23840. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23841. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23842. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23843. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23844. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23845. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23846. "&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
  23847. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23848. } else {
  23849. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23850. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23851. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23852. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23853. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23854. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23855. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23856. "&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
  23857. }
  23858. resp, requestErr := http.Get(api)
  23859. if requestErr != nil {
  23860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23861. return
  23862. }
  23863. body, ioErr := ioutil.ReadAll(resp.Body)
  23864. if ioErr != nil {
  23865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23867. return
  23868. }
  23869. var respJSON map[string]interface{}
  23870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23873. return
  23874. }
  23875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23876. result, _ := json.Marshal(respJSON)
  23877. fmt.Println("log")
  23878. fmt.Println(string(result))
  23879. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  23880. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23881. utils.ErrorLog("解析失败:%v", err)
  23882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23883. return
  23884. }
  23885. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23886. res.Output = resSeven10265.Output
  23887. res.ErrMsg = resSeven10265.ErrMsg
  23888. res.Cainfo = resSeven10265.Cainfo
  23889. res.WarnMsg = resSeven10265.WarnMsg
  23890. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23891. res.Infcode = infocode
  23892. } else {
  23893. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  23894. utils.ErrorLog("解析失败:%v", err)
  23895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23896. return
  23897. }
  23898. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  23899. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  23900. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  23901. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  23902. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23903. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  23904. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  23905. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  23906. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  23907. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  23908. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  23909. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23910. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  23911. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  23912. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23913. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23914. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  23915. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  23916. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  23917. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  23918. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  23919. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23920. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  23921. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  23922. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  23923. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  23924. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  23925. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  23926. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  23927. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  23928. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23929. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  23930. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  23931. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  23932. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23933. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23934. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23935. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23936. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  23937. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23938. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  23939. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  23940. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  23941. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  23942. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  23943. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  23944. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  23945. res.ErrMsg = resSeven10265Two.ErrMsg
  23946. res.Cainfo = resSeven10265Two.Cainfo
  23947. res.WarnMsg = resSeven10265Two.WarnMsg
  23948. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23949. res.Infcode = infocode
  23950. }
  23951. }
  23952. }
  23953. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23954. psn_info, _ := service.GetPsnByPatientId(id)
  23955. var verify_number string
  23956. if psn_info.IdCardType == 4 {
  23957. verify_number = psn_info.VerifyNumber
  23958. } else if psn_info.IdCardType == 1 {
  23959. bas := strings.Split(psn_info.CardInfo, "|")
  23960. cardNumber := bas[2]
  23961. verify_number = cardNumber
  23962. } else {
  23963. psn_info.IdCardType = 2
  23964. verify_number = psn_info.Certno
  23965. }
  23966. var api string
  23967. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23968. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23969. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23970. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23971. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  23972. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23973. "&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
  23974. resp, requestErr := http.Get(api)
  23975. if requestErr != nil {
  23976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23977. return
  23978. }
  23979. body, ioErr := ioutil.ReadAll(resp.Body)
  23980. if ioErr != nil {
  23981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23983. return
  23984. }
  23985. var respJSON map[string]interface{}
  23986. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23989. return
  23990. }
  23991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23992. result, _ := json.Marshal(respJSON)
  23993. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23994. utils.ErrorLog("解析失败:%v", err)
  23995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23996. return
  23997. }
  23998. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23999. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  24000. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  24001. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  24002. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  24003. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  24004. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  24005. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  24006. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  24007. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  24008. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  24009. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  24010. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  24011. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  24012. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  24013. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  24014. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  24015. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  24016. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  24017. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  24018. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24019. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  24020. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  24021. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  24022. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  24023. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  24024. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  24025. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  24026. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  24027. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  24028. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  24029. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  24030. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  24031. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  24032. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  24033. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  24034. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  24035. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  24036. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  24037. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  24038. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  24039. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  24040. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  24041. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  24042. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  24043. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  24044. res.ErrMsg = resSeven10265.ErrMsg
  24045. res.Cainfo = resSeven10265.Cainfo
  24046. res.WarnMsg = resSeven10265.WarnMsg
  24047. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24048. res.Infcode = infocode
  24049. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24050. acct_used_flag := "1"
  24051. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  24052. var result string
  24053. var request_log string
  24054. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  24055. 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)
  24056. } else {
  24057. 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)
  24058. }
  24059. var dat map[string]interface{}
  24060. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24061. fmt.Println(dat)
  24062. } else {
  24063. fmt.Println(err)
  24064. }
  24065. saveLog(result, request_log, "2206", "预结算")
  24066. userJSONBytes, _ := json.Marshal(dat)
  24067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24068. utils.ErrorLog("解析失败:%v", err)
  24069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24070. return
  24071. }
  24072. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24073. var result string
  24074. var request_log string
  24075. if his.IdCardType == 2 {
  24076. 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, "")
  24077. } else if his.IdCardType == 1 {
  24078. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24079. bas := strings.Split(psn_info.CardInfo, "|")
  24080. basNumber := bas[2]
  24081. card_sn := bas[3]
  24082. var rf []*ResultFive
  24083. json.Unmarshal([]byte(his.Iinfo), &rf)
  24084. var psn_type string
  24085. for _, item := range rf {
  24086. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  24087. psn_type = item.PsnType
  24088. }
  24089. }
  24090. 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)
  24091. } else {
  24092. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24093. 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, "")
  24094. }
  24095. var dat map[string]interface{}
  24096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24097. fmt.Println(dat)
  24098. } else {
  24099. fmt.Println(err)
  24100. }
  24101. saveLog(result, request_log, "2206", "预结算")
  24102. userJSONBytes, _ := json.Marshal(dat)
  24103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24104. utils.ErrorLog("解析失败:%v", err)
  24105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24106. return
  24107. }
  24108. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24109. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24110. if his.IdCardType == 4 {
  24111. psn_info.VerifyNumber = psn_info.VerifyNumber
  24112. cert_no = psn_info.Certno
  24113. } else if his.IdCardType == 2 {
  24114. cert_no = psn_info.Certno
  24115. psn_info.VerifyNumber = psn_info.Certno
  24116. } else {
  24117. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24118. bas := strings.Split(psn_info.CardInfo, "|")
  24119. if his.IdCardType == 1 {
  24120. cert_no = bas[2]
  24121. } else {
  24122. cert_no = bas[1]
  24123. }
  24124. }
  24125. var api string
  24126. var med_type string
  24127. if his.Insutype == "390" {
  24128. if reg_type == 992102 {
  24129. med_type = "992102"
  24130. }
  24131. if reg_type == 140104 {
  24132. med_type = "140104"
  24133. }
  24134. if reg_type == 14 {
  24135. med_type = "140104"
  24136. }
  24137. } else if his.Insutype == "310" {
  24138. if reg_type == 992102 {
  24139. med_type = "992102"
  24140. }
  24141. if reg_type == 14 {
  24142. med_type = "14"
  24143. }
  24144. }
  24145. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24146. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24147. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24148. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24149. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24150. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24151. "&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
  24152. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24153. resp, requestErr := http.Get(api)
  24154. if requestErr != nil {
  24155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24156. return
  24157. }
  24158. body, ioErr := ioutil.ReadAll(resp.Body)
  24159. if ioErr != nil {
  24160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24162. return
  24163. }
  24164. var respJSON map[string]interface{}
  24165. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24168. return
  24169. }
  24170. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24171. if status == "0" {
  24172. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24173. c.ServeSuccessJSON(map[string]interface{}{
  24174. "failed_code": -10,
  24175. "msg": err_msg,
  24176. })
  24177. return
  24178. }
  24179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24180. result, _ := json.Marshal(respJSON)
  24181. fmt.Println("log")
  24182. fmt.Println(string(result))
  24183. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  24184. utils.ErrorLog("解析失败:%v", err)
  24185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24186. return
  24187. }
  24188. res.InfRefmsgid = ahres.InfRefmsgid
  24189. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  24190. // 创建对应的Time类型
  24191. t := time.UnixMilli(timestamp)
  24192. // 格式化成指定的日期字符串
  24193. str := t.Format("2006-01-02 15:04:05")
  24194. res.Output.Setlinfo.SetlTime = str
  24195. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  24196. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  24197. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24198. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  24199. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  24200. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  24201. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24202. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  24203. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  24204. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  24205. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  24206. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  24207. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24208. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  24209. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  24210. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  24211. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  24212. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  24213. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  24214. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24215. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  24216. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  24217. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  24218. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  24219. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  24220. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  24221. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  24222. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  24223. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  24224. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  24225. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  24226. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  24227. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  24228. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  24229. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  24230. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  24231. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  24232. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  24233. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  24234. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  24235. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  24236. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  24237. //res.Output.Setldetail = ahres.Output.Setldetail
  24238. res.ErrMsg = ahres.ErrMsg
  24239. res.Cainfo = ahres.Cainfo
  24240. res.WarnMsg = ahres.WarnMsg
  24241. res.Infcode = ahres.Infcode
  24242. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24243. var result string
  24244. var request_log string
  24245. if his.IdCardType == 2 {
  24246. 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")
  24247. } else if his.IdCardType == 1 {
  24248. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24249. bas := strings.Split(psn_info.CardInfo, "|")
  24250. basNumber := bas[2]
  24251. card_sn := bas[3]
  24252. 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")
  24253. } else {
  24254. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24255. 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")
  24256. }
  24257. var dat map[string]interface{}
  24258. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24259. fmt.Println(dat)
  24260. } else {
  24261. fmt.Println(err)
  24262. }
  24263. saveLog(result, request_log, "2206", "预结算")
  24264. userJSONBytes, _ := json.Marshal(dat)
  24265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24266. utils.ErrorLog("解析失败:%v", err)
  24267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24268. return
  24269. }
  24270. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24271. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24272. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24273. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24274. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24275. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24276. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24277. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  24278. resp, requestErr := http.Get(api)
  24279. if requestErr != nil {
  24280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24281. return
  24282. }
  24283. body, ioErr := ioutil.ReadAll(resp.Body)
  24284. if ioErr != nil {
  24285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24287. return
  24288. }
  24289. var respJSON map[string]interface{}
  24290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24293. return
  24294. }
  24295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24296. result, _ := json.Marshal(respJSON)
  24297. fmt.Println("log")
  24298. fmt.Println(string(result))
  24299. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24300. utils.ErrorLog("解析失败:%v", err)
  24301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24302. return
  24303. }
  24304. } else {
  24305. if miConfig.MdtrtareaAdmvs == "441202" {
  24306. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  24307. if result3101.Infcode == 0 {
  24308. if len(result3101.Output.Result) > 0 {
  24309. var errMsgs []string
  24310. for _, item := range result3101.Output.Result {
  24311. errMsgs = append(errMsgs, item.VolaCont)
  24312. }
  24313. c.ServeSuccessJSON(map[string]interface{}{
  24314. "failed_code": -10,
  24315. "msg": errMsgs,
  24316. })
  24317. return
  24318. } else {
  24319. var result string
  24320. var request_log string
  24321. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24322. allTotal = fmt.Sprintf("%.2f", total_two)
  24323. if his.IdCardType == 4 {
  24324. 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)
  24325. } else {
  24326. 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)
  24327. }
  24328. var dat map[string]interface{}
  24329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24330. fmt.Println(dat)
  24331. } else {
  24332. fmt.Println(err)
  24333. }
  24334. saveLog(result, request_log, "2206", "预结算")
  24335. //userJSONBytes, _ := json.Marshal(dat)
  24336. //
  24337. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24338. // utils.ErrorLog("解析失败:%v", err)
  24339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24340. // return
  24341. //}
  24342. userJSONBytes, _ := json.Marshal(dat)
  24343. if miConfig.Code == "H15049901371" {
  24344. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24345. utils.ErrorLog("解析失败:%v", err)
  24346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24347. return
  24348. }
  24349. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24350. res.Output = resSeven10265.Output
  24351. res.ErrMsg = resSeven10265.ErrMsg
  24352. res.Cainfo = resSeven10265.Cainfo
  24353. res.WarnMsg = resSeven10265.WarnMsg
  24354. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24355. res.Infcode = infocode
  24356. } else {
  24357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24358. utils.ErrorLog("解析失败:%v", err)
  24359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24360. return
  24361. }
  24362. }
  24363. }
  24364. } else {
  24365. c.ServeSuccessJSON(map[string]interface{}{
  24366. "failed_code": -10,
  24367. "msg": result3101.ErrMsg,
  24368. })
  24369. return
  24370. }
  24371. } else {
  24372. var result string
  24373. var request_log string
  24374. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24375. allTotal = fmt.Sprintf("%.2f", total_two)
  24376. if his.IdCardType == 4 {
  24377. 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)
  24378. } else {
  24379. 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)
  24380. }
  24381. var dat map[string]interface{}
  24382. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24383. fmt.Println(dat)
  24384. } else {
  24385. fmt.Println(err)
  24386. }
  24387. saveLog(result, request_log, "2206", "预结算")
  24388. //userJSONBytes, _ := json.Marshal(dat)
  24389. //
  24390. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24391. // utils.ErrorLog("解析失败:%v", err)
  24392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24393. // return
  24394. //}
  24395. userJSONBytes, _ := json.Marshal(dat)
  24396. if miConfig.Code == "H15049901371" {
  24397. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24398. utils.ErrorLog("解析失败:%v", err)
  24399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24400. return
  24401. }
  24402. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24403. res.Output = resSeven10265.Output
  24404. res.ErrMsg = resSeven10265.ErrMsg
  24405. res.Cainfo = resSeven10265.Cainfo
  24406. res.WarnMsg = resSeven10265.WarnMsg
  24407. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24408. res.Infcode = infocode
  24409. } else {
  24410. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24411. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  24412. utils.ErrorLog("解析失败:%v", err)
  24413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24414. return
  24415. }
  24416. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  24417. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  24418. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  24419. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24420. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  24421. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  24422. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  24423. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24424. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  24425. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24426. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24427. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24428. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24429. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24430. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  24431. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  24432. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  24433. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  24434. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  24435. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  24436. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24437. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  24438. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  24439. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  24440. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  24441. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  24442. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  24443. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  24444. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  24445. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  24446. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  24447. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  24448. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  24449. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  24450. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  24451. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  24452. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  24453. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  24454. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24455. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  24456. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  24457. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  24458. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  24459. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  24460. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  24461. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  24462. res.ErrMsg = gzresSeven10265Two.ErrMsg
  24463. res.Cainfo = gzresSeven10265Two.Cainfo
  24464. res.WarnMsg = gzresSeven10265Two.WarnMsg
  24465. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  24466. //res.Infcode = infocode
  24467. } else {
  24468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24469. utils.ErrorLog("解析失败:%v", err)
  24470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24471. return
  24472. }
  24473. }
  24474. }
  24475. }
  24476. }
  24477. utils.ErrorLog("解析失败:%v", res.Infcode)
  24478. if res.Infcode == -1 {
  24479. errlog := &models.HisOrderError{
  24480. UserOrgId: adminUser.CurrentOrgId,
  24481. Ctime: time.Now().Unix(),
  24482. Mtime: time.Now().Unix(),
  24483. Number: chrg_bchno,
  24484. ErrMsg: res.ErrMsg,
  24485. Status: 1,
  24486. PatientId: id,
  24487. RecordTime: recordDateTime,
  24488. Stage: 20,
  24489. }
  24490. service.CreateErrMsgLog(errlog)
  24491. c.ServeSuccessJSON(map[string]interface{}{
  24492. "failed_code": -10,
  24493. "msg": res.ErrMsg,
  24494. })
  24495. return
  24496. }
  24497. if res.Infcode != 0 {
  24498. errlog := &models.HisOrderError{
  24499. UserOrgId: adminUser.CurrentOrgId,
  24500. Ctime: time.Now().Unix(),
  24501. Mtime: time.Now().Unix(),
  24502. Number: chrg_bchno,
  24503. ErrMsg: res.ErrMsg,
  24504. Status: 1,
  24505. PatientId: id,
  24506. RecordTime: recordDateTime,
  24507. Stage: 20,
  24508. }
  24509. service.CreateErrMsgLog(errlog)
  24510. c.ServeSuccessJSON(map[string]interface{}{
  24511. "failed_code": -10,
  24512. "msg": res.ErrMsg,
  24513. })
  24514. return
  24515. } else {
  24516. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  24517. order.OrderStatus = 1
  24518. order.IsPre = 1
  24519. order.Status = 1
  24520. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  24521. order.SetlId = res.Output.Setlinfo.SetlID
  24522. order.PsnNo = res.Output.Setlinfo.PsnNo
  24523. order.PsnName = res.Output.Setlinfo.PsnName
  24524. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  24525. order.Certno = res.Output.Setlinfo.Certno
  24526. order.Gend = res.Output.Setlinfo.Gend
  24527. order.Naty = res.Output.Setlinfo.Naty
  24528. order.Age = res.Output.Setlinfo.Age
  24529. order.Insutype = res.Output.Setlinfo.Insutype
  24530. order.PsnType = res.Output.Setlinfo.PsnType
  24531. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  24532. order.SetlTime = res.Output.Setlinfo.SetlTime
  24533. order.AcctUsedFlag = acct_used_flag
  24534. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  24535. if res.Output.Setlinfo.MedType == "140101" {
  24536. order.MedType = "14"
  24537. } else {
  24538. if res.Output.Setlinfo.MedType == "110104" {
  24539. order.MedType = "11"
  24540. } else {
  24541. order.MedType = res.Output.Setlinfo.MedType
  24542. }
  24543. }
  24544. if res.Output.Setlinfo.MedType == "992102" {
  24545. order.MedType = "992102"
  24546. }
  24547. if res.Output.Setlinfo.MedType == "140104" {
  24548. order.MedType = "140104"
  24549. }
  24550. if res.Output.Setlinfo.MedType == "14" {
  24551. order.MedType = "14"
  24552. }
  24553. if reg_type == 1112 {
  24554. order.MedType = "1112"
  24555. }
  24556. if reg_type == 1111 {
  24557. order.MedType = "1111"
  24558. }
  24559. order.ClrType = res.Output.Setlinfo.ClrType
  24560. if adminUser.CurrentOrgId == 10480 {
  24561. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  24562. order.ClrType = "11"
  24563. } else {
  24564. order.ClrType = "9903"
  24565. }
  24566. }
  24567. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  24568. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  24569. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  24570. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  24571. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  24572. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  24573. order.HifpPay = res.Output.Setlinfo.HifpPay
  24574. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  24575. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  24576. order.HifesPay = res.Output.Setlinfo.HifesPay
  24577. order.HifobPay = res.Output.Setlinfo.HifobPay
  24578. order.MafPay = res.Output.Setlinfo.MafPay
  24579. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  24580. order.OthPay = res.Output.Setlinfo.OthPay
  24581. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  24582. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  24583. order.AcctPay = res.Output.Setlinfo.AcctPay
  24584. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  24585. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  24586. order.Balc = res.Output.Setlinfo.Balc
  24587. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  24588. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  24589. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  24590. order.ClrWay = res.Output.Setlinfo.ClrWay
  24591. order.Creator = order.Creator
  24592. order.Modify = roles.AdminUserId
  24593. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  24594. //detailStr := string(setlDetail)
  24595. //order.SetlDetail = detailStr
  24596. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  24597. err = service.UpDateOrder(order)
  24598. if err == nil {
  24599. c.ServeSuccessJSON(map[string]interface{}{
  24600. "msg": "预结算成功",
  24601. })
  24602. } else {
  24603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  24604. return
  24605. }
  24606. }
  24607. } else {
  24608. adminUser := c.GetAdminUserInfo()
  24609. errlog := &models.HisOrderError{
  24610. UserOrgId: adminUser.CurrentOrgId,
  24611. Ctime: time.Now().Unix(),
  24612. Mtime: time.Now().Unix(),
  24613. ErrMsg: res.ErrMsg,
  24614. Status: 1,
  24615. PatientId: id,
  24616. RecordTime: recordDateTime,
  24617. Stage: 4,
  24618. }
  24619. service.CreateErrMsgLog(errlog)
  24620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  24621. return
  24622. }
  24623. } else {
  24624. if miConfig.MdtrtareaAdmvs == "150499" {
  24625. order := &models.HisOrder{
  24626. UserOrgId: adminUser.CurrentOrgId,
  24627. HisPatientId: his.ID,
  24628. PatientId: his.PatientId,
  24629. SettleAccountsDate: recordDateTime,
  24630. Ctime: time.Now().Unix(),
  24631. Mtime: time.Now().Unix(),
  24632. MdtrtId: his.Number,
  24633. PsnNo: his.PsnNo,
  24634. MedType: strconv.FormatInt(reg_type, 10),
  24635. Status: 1,
  24636. Number: chrg_bchno,
  24637. Infcode: res.Infcode,
  24638. WarnMsg: res.WarnMsg,
  24639. Cainfo: res.Cainfo,
  24640. ErrMsg: res.ErrMsg,
  24641. RespondTime: res.RefmsgTime,
  24642. InfRefmsgid: res.InfRefmsgid,
  24643. OrderStatus: 1,
  24644. IsMedicineInsurance: 1,
  24645. SettleType: settle_accounts_type,
  24646. SettleStartTime: start_time,
  24647. SettleEndTime: end_time,
  24648. Creator: roles.AdminUserId,
  24649. Modify: roles.AdminUserId,
  24650. PType: 2,
  24651. Diagnosis: diagnosis_id,
  24652. }
  24653. err = service.CreateOrder(order)
  24654. if err != nil {
  24655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  24656. return
  24657. }
  24658. }
  24659. adminUser := c.GetAdminUserInfo()
  24660. errlog := &models.HisOrderError{
  24661. UserOrgId: adminUser.CurrentOrgId,
  24662. Ctime: time.Now().Unix(),
  24663. Mtime: time.Now().Unix(),
  24664. ErrMsg: res.ErrMsg,
  24665. Status: 1,
  24666. PatientId: id,
  24667. RecordTime: recordDateTime,
  24668. Stage: 4,
  24669. }
  24670. service.CreateErrMsgLog(errlog)
  24671. c.ServeSuccessJSON(map[string]interface{}{
  24672. "failed_code": -10,
  24673. "msg": res.ErrMsg,
  24674. })
  24675. return
  24676. }
  24677. }
  24678. }
  24679. }
  24680. // 退款
  24681. func (c *HisApiController) Refund() {
  24682. order_id, _ := c.GetInt64("order_id")
  24683. admin_user_id, _ := c.GetInt64("admin_user_id")
  24684. adminUser := c.GetAdminUserInfo()
  24685. var order models.HisOrder
  24686. order, _ = service.GetHisOrderByID(order_id)
  24687. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24688. if order.ID == 0 {
  24689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24690. return
  24691. }
  24692. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24693. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24694. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24695. if config.IsOpen == 1 { //对接了医保,走医保流程
  24696. var res ResultSixteen
  24697. var ahres ResultSevenAH
  24698. var resSixteen10265 ResultSixteen10265
  24699. var resSixteen10265Two ResultSixteen10265Two
  24700. var gz ResultgzSixteen10265Two
  24701. var src_resquest string
  24702. var result string
  24703. if miConfig.MdtrtareaAdmvs == "421300" {
  24704. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  24705. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24706. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24707. resp3, requestErr3 := http.Get(api3)
  24708. if requestErr3 != nil {
  24709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24710. return
  24711. }
  24712. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24713. if ioErr3 != nil {
  24714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24716. return
  24717. }
  24718. var respJSON3 map[string]interface{}
  24719. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24722. return
  24723. }
  24724. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24725. userJSONBytes3, _ := json.Marshal(respJSON3)
  24726. fmt.Println("log")
  24727. fmt.Println(string(userJSONBytes3))
  24728. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24729. utils.ErrorLog("解析失败:%v", err)
  24730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24731. return
  24732. }
  24733. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24734. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  24735. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24736. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24737. resp3, requestErr3 := http.Get(api3)
  24738. if requestErr3 != nil {
  24739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24740. return
  24741. }
  24742. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24743. if ioErr3 != nil {
  24744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24746. return
  24747. }
  24748. var respJSON3 map[string]interface{}
  24749. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24752. return
  24753. }
  24754. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24755. userJSONBytes3, _ := json.Marshal(respJSON3)
  24756. fmt.Println("log")
  24757. fmt.Println(string(userJSONBytes3))
  24758. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24759. utils.ErrorLog("解析失败:%v", err)
  24760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24761. return
  24762. }
  24763. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24764. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  24765. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24766. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24767. resp3, requestErr3 := http.Get(api3)
  24768. if requestErr3 != nil {
  24769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24770. return
  24771. }
  24772. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24773. if ioErr3 != nil {
  24774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24776. return
  24777. }
  24778. var respJSON3 map[string]interface{}
  24779. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24782. return
  24783. }
  24784. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24785. userJSONBytes3, _ := json.Marshal(respJSON3)
  24786. fmt.Println("log")
  24787. fmt.Println(string(userJSONBytes3))
  24788. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24789. utils.ErrorLog("解析失败:%v", err)
  24790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24791. return
  24792. }
  24793. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24794. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  24795. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24796. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24797. resp3, requestErr3 := http.Get(api3)
  24798. if requestErr3 != nil {
  24799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24800. return
  24801. }
  24802. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24803. if ioErr3 != nil {
  24804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24806. return
  24807. }
  24808. var respJSON3 map[string]interface{}
  24809. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24812. return
  24813. }
  24814. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24815. userJSONBytes3, _ := json.Marshal(respJSON3)
  24816. fmt.Println("log")
  24817. fmt.Println(string(userJSONBytes3))
  24818. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24819. utils.ErrorLog("解析失败:%v", err)
  24820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24821. return
  24822. }
  24823. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24824. var api3 string
  24825. if miConfig.MdtrtareaAdmvs == "320921" {
  24826. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  24827. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24828. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24829. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24830. } else {
  24831. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24832. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  24833. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24834. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24835. }
  24836. resp3, requestErr3 := http.Get(api3)
  24837. if requestErr3 != nil {
  24838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24839. return
  24840. }
  24841. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24842. if ioErr3 != nil {
  24843. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24845. return
  24846. }
  24847. var respJSON3 map[string]interface{}
  24848. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24851. return
  24852. }
  24853. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24854. userJSONBytes3, _ := json.Marshal(respJSON3)
  24855. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  24856. utils.ErrorLog("解析失败:%v", err)
  24857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24858. return
  24859. }
  24860. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24861. res.Output = resSixteen10265.Output
  24862. res.ErrMsg = resSixteen10265.ErrMsg
  24863. res.Cainfo = resSixteen10265.Cainfo
  24864. res.WarnMsg = resSixteen10265.WarnMsg
  24865. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24866. res.Infcode = infocode
  24867. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24868. var api3 string
  24869. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  24870. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24871. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24872. resp3, requestErr3 := http.Get(api3)
  24873. if requestErr3 != nil {
  24874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24875. return
  24876. }
  24877. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24878. if ioErr3 != nil {
  24879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24881. return
  24882. }
  24883. var respJSON3 map[string]interface{}
  24884. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24887. return
  24888. }
  24889. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24890. userJSONBytes3, _ := json.Marshal(respJSON3)
  24891. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  24892. utils.ErrorLog("解析失败:%v", err)
  24893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24894. return
  24895. }
  24896. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24897. res.Output = resSixteen10265.Output
  24898. res.ErrMsg = resSixteen10265.ErrMsg
  24899. res.Cainfo = resSixteen10265.Cainfo
  24900. res.WarnMsg = resSixteen10265.WarnMsg
  24901. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24902. res.Infcode = infocode
  24903. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24904. 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)
  24905. var dat map[string]interface{}
  24906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24907. fmt.Println(dat)
  24908. } else {
  24909. fmt.Println(err)
  24910. }
  24911. saveLog(result, src_resquest, "2208", "退费")
  24912. userJSONBytes, _ := json.Marshal(dat)
  24913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24914. utils.ErrorLog("解析失败:%v", err)
  24915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24916. return
  24917. }
  24918. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24919. 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, "")
  24920. var dat map[string]interface{}
  24921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24922. fmt.Println(dat)
  24923. } else {
  24924. fmt.Println(err)
  24925. }
  24926. saveLog(result, src_resquest, "2208", "退费")
  24927. userJSONBytes, _ := json.Marshal(dat)
  24928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24929. utils.ErrorLog("解析失败:%v", err)
  24930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24931. return
  24932. }
  24933. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24934. var api3 string
  24935. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  24936. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24937. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24938. resp3, requestErr3 := http.Get(api3)
  24939. if requestErr3 != nil {
  24940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24941. return
  24942. }
  24943. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24944. if ioErr3 != nil {
  24945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24947. return
  24948. }
  24949. var respJSON3 map[string]interface{}
  24950. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24953. return
  24954. }
  24955. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24956. if status == "0" {
  24957. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24958. c.ServeSuccessJSON(map[string]interface{}{
  24959. "failed_code": -10,
  24960. "msg": err_msg,
  24961. })
  24962. return
  24963. }
  24964. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24965. userJSONBytes3, _ := json.Marshal(respJSON3)
  24966. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24967. // utils.ErrorLog("解析失败:%v", err)
  24968. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24969. // return
  24970. //}
  24971. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  24972. utils.ErrorLog("解析失败:%v", err)
  24973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24974. return
  24975. }
  24976. res.InfRefmsgid = ahres.InfRefmsgid
  24977. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  24978. // 创建对应的Time类型
  24979. t := time.UnixMilli(timestamp)
  24980. // 格式化成指定的日期字符串
  24981. str := t.Format("2006-01-02 15:04:05")
  24982. res.Output.Setlinfo.SetlTime = str
  24983. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  24984. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  24985. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24986. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  24987. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  24988. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  24989. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24990. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  24991. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  24992. //
  24993. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  24994. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  24995. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  24996. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24997. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  24998. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  24999. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  25000. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  25001. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  25002. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  25003. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25004. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  25005. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  25006. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  25007. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  25008. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  25009. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  25010. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  25011. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  25012. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  25013. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  25014. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  25015. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  25016. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  25017. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  25018. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  25019. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  25020. //res.Output.Setldetail = ahres.Output.Setldetail
  25021. res.ErrMsg = ahres.ErrMsg
  25022. res.Cainfo = ahres.Cainfo
  25023. res.WarnMsg = ahres.WarnMsg
  25024. res.Infcode = ahres.Infcode
  25025. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25026. 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, "")
  25027. var dat map[string]interface{}
  25028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25029. fmt.Println(dat)
  25030. } else {
  25031. fmt.Println(err)
  25032. }
  25033. saveLog(result, src_resquest, "2208", "退费")
  25034. userJSONBytes, _ := json.Marshal(dat)
  25035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25036. utils.ErrorLog("解析失败:%v", err)
  25037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25038. return
  25039. }
  25040. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25041. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  25042. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25043. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25044. resp3, requestErr3 := http.Get(api3)
  25045. if requestErr3 != nil {
  25046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25047. return
  25048. }
  25049. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25050. if ioErr3 != nil {
  25051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25053. return
  25054. }
  25055. var respJSON3 map[string]interface{}
  25056. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25059. return
  25060. }
  25061. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25062. userJSONBytes3, _ := json.Marshal(respJSON3)
  25063. fmt.Println("log")
  25064. fmt.Println(string(userJSONBytes3))
  25065. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  25066. utils.ErrorLog("解析失败:%v", err)
  25067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25068. return
  25069. }
  25070. } else {
  25071. if miConfig.Code == "H15049901371" {
  25072. 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)
  25073. var dat map[string]interface{}
  25074. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25075. fmt.Println(dat)
  25076. } else {
  25077. fmt.Println(err)
  25078. }
  25079. saveLog(result, src_resquest, "2208", "退费")
  25080. userJSONBytes, _ := json.Marshal(dat)
  25081. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  25082. utils.ErrorLog("解析失败:%v", err)
  25083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25084. return
  25085. }
  25086. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  25087. res.Output = resSixteen10265.Output
  25088. res.ErrMsg = resSixteen10265.ErrMsg
  25089. res.Cainfo = resSixteen10265.Cainfo
  25090. res.WarnMsg = resSixteen10265.WarnMsg
  25091. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  25092. res.Infcode = infocode
  25093. } else {
  25094. 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)
  25095. var dat map[string]interface{}
  25096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25097. fmt.Println(dat)
  25098. } else {
  25099. fmt.Println(err)
  25100. }
  25101. saveLog(result, src_resquest, "2208", "退费")
  25102. userJSONBytes, _ := json.Marshal(dat)
  25103. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25104. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  25105. utils.ErrorLog("解析失败:%v", err)
  25106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25107. return
  25108. }
  25109. res.Infcode = gz.Infcode
  25110. } else {
  25111. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25112. utils.ErrorLog("解析失败:%v", err)
  25113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25114. return
  25115. }
  25116. }
  25117. }
  25118. }
  25119. if res.Infcode == 0 {
  25120. var res2 ResultSix
  25121. var resSix10265 ResultSix10265
  25122. if miConfig.MdtrtareaAdmvs == "421300" {
  25123. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25124. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25125. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25126. resp3, requestErr3 := http.Get(api3)
  25127. if requestErr3 != nil {
  25128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25129. return
  25130. }
  25131. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25132. if ioErr3 != nil {
  25133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25135. return
  25136. }
  25137. var respJSON3 map[string]interface{}
  25138. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25141. return
  25142. }
  25143. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25144. userJSONBytes3, _ := json.Marshal(respJSON3)
  25145. fmt.Println("log")
  25146. fmt.Println(string(userJSONBytes3))
  25147. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25148. utils.ErrorLog("解析失败:%v", err)
  25149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25150. return
  25151. }
  25152. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25153. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25154. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25155. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25156. resp3, requestErr3 := http.Get(api3)
  25157. if requestErr3 != nil {
  25158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25159. return
  25160. }
  25161. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25162. if ioErr3 != nil {
  25163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25165. return
  25166. }
  25167. var respJSON3 map[string]interface{}
  25168. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25171. return
  25172. }
  25173. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25174. userJSONBytes3, _ := json.Marshal(respJSON3)
  25175. fmt.Println("log")
  25176. fmt.Println(string(userJSONBytes3))
  25177. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25178. utils.ErrorLog("解析失败:%v", err)
  25179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25180. return
  25181. }
  25182. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25183. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25184. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25185. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25186. resp3, requestErr3 := http.Get(api3)
  25187. if requestErr3 != nil {
  25188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25189. return
  25190. }
  25191. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25192. if ioErr3 != nil {
  25193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25195. return
  25196. }
  25197. var respJSON3 map[string]interface{}
  25198. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25201. return
  25202. }
  25203. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25204. userJSONBytes3, _ := json.Marshal(respJSON3)
  25205. fmt.Println("log")
  25206. fmt.Println(string(userJSONBytes3))
  25207. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25208. utils.ErrorLog("解析失败:%v", err)
  25209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25210. return
  25211. }
  25212. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25213. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25214. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25215. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25216. resp3, requestErr3 := http.Get(api3)
  25217. if requestErr3 != nil {
  25218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25219. return
  25220. }
  25221. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25222. if ioErr3 != nil {
  25223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25225. return
  25226. }
  25227. var respJSON3 map[string]interface{}
  25228. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25231. return
  25232. }
  25233. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25234. userJSONBytes3, _ := json.Marshal(respJSON3)
  25235. fmt.Println("log")
  25236. fmt.Println(string(userJSONBytes3))
  25237. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25238. utils.ErrorLog("解析失败:%v", err)
  25239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25240. return
  25241. }
  25242. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25243. var api3 string
  25244. if miConfig.MdtrtareaAdmvs == "320921" {
  25245. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25246. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25247. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25248. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25249. } else {
  25250. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25251. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25252. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25253. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25254. }
  25255. resp3, requestErr3 := http.Get(api3)
  25256. if requestErr3 != nil {
  25257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25258. return
  25259. }
  25260. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25261. if ioErr3 != nil {
  25262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25264. return
  25265. }
  25266. var respJSON3 map[string]interface{}
  25267. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25270. return
  25271. }
  25272. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25273. userJSONBytes3, _ := json.Marshal(respJSON3)
  25274. fmt.Println("log")
  25275. fmt.Println(string(userJSONBytes3))
  25276. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25277. utils.ErrorLog("解析失败:%v", err)
  25278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25279. return
  25280. }
  25281. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25282. res2.Output = resSix10265.Output
  25283. res2.ErrMsg = resSix10265.ErrMsg
  25284. res2.Cainfo = resSix10265.Cainfo
  25285. res2.WarnMsg = resSix10265.WarnMsg
  25286. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25287. res2.Infcode = infocode
  25288. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25289. var api3 string
  25290. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25291. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25292. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25293. resp3, requestErr3 := http.Get(api3)
  25294. if requestErr3 != nil {
  25295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25296. return
  25297. }
  25298. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25299. if ioErr3 != nil {
  25300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25302. return
  25303. }
  25304. var respJSON3 map[string]interface{}
  25305. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25308. return
  25309. }
  25310. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25311. userJSONBytes3, _ := json.Marshal(respJSON3)
  25312. fmt.Println("log")
  25313. fmt.Println(string(userJSONBytes3))
  25314. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25315. utils.ErrorLog("解析失败:%v", err)
  25316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25317. return
  25318. }
  25319. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25320. res2.Output = resSix10265.Output
  25321. res2.ErrMsg = resSix10265.ErrMsg
  25322. res2.Cainfo = resSix10265.Cainfo
  25323. res2.WarnMsg = resSix10265.WarnMsg
  25324. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25325. res2.Infcode = infocode
  25326. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25327. 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)
  25328. var dat map[string]interface{}
  25329. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25330. fmt.Println(dat)
  25331. } else {
  25332. fmt.Println(err)
  25333. }
  25334. saveLog(result2, src_request, "2205", "撤销明细")
  25335. userJSONBytes, _ := json.Marshal(dat)
  25336. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25337. utils.ErrorLog("解析失败:%v", err)
  25338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25339. return
  25340. }
  25341. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25342. 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, "")
  25343. var dat map[string]interface{}
  25344. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25345. fmt.Println(dat)
  25346. } else {
  25347. fmt.Println(err)
  25348. }
  25349. saveLog(result2, src_request, "2205", "撤销明细")
  25350. userJSONBytes, _ := json.Marshal(dat)
  25351. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25352. utils.ErrorLog("解析失败:%v", err)
  25353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25354. return
  25355. }
  25356. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25357. var api3 string
  25358. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  25359. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25360. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25361. resp3, requestErr3 := http.Get(api3)
  25362. if requestErr3 != nil {
  25363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25364. return
  25365. }
  25366. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25367. if ioErr3 != nil {
  25368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25370. return
  25371. }
  25372. var respJSON3 map[string]interface{}
  25373. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25376. return
  25377. }
  25378. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25379. if status == "0" {
  25380. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25381. c.ServeSuccessJSON(map[string]interface{}{
  25382. "failed_code": -10,
  25383. "msg": err_msg,
  25384. })
  25385. return
  25386. }
  25387. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25388. userJSONBytes3, _ := json.Marshal(respJSON3)
  25389. fmt.Println("log")
  25390. fmt.Println(string(userJSONBytes3))
  25391. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25392. utils.ErrorLog("解析失败:%v", err)
  25393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25394. return
  25395. }
  25396. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25397. 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, "")
  25398. var dat map[string]interface{}
  25399. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25400. fmt.Println(dat)
  25401. } else {
  25402. fmt.Println(err)
  25403. }
  25404. saveLog(result2, src_request, "2205", "撤销明细")
  25405. userJSONBytes, _ := json.Marshal(dat)
  25406. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25407. utils.ErrorLog("解析失败:%v", err)
  25408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25409. return
  25410. }
  25411. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25412. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  25413. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25414. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25415. resp3, requestErr3 := http.Get(api3)
  25416. if requestErr3 != nil {
  25417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25418. return
  25419. }
  25420. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25421. if ioErr3 != nil {
  25422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25424. return
  25425. }
  25426. var respJSON3 map[string]interface{}
  25427. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25430. return
  25431. }
  25432. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25433. userJSONBytes3, _ := json.Marshal(respJSON3)
  25434. fmt.Println("log")
  25435. fmt.Println(string(userJSONBytes3))
  25436. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25437. utils.ErrorLog("解析失败:%v", err)
  25438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25439. return
  25440. }
  25441. } else {
  25442. if miConfig.Code == "H15049901371" {
  25443. 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)
  25444. var dat map[string]interface{}
  25445. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25446. fmt.Println(dat)
  25447. } else {
  25448. fmt.Println(err)
  25449. }
  25450. saveLog(result2, src_request, "2205", "撤销明细")
  25451. userJSONBytes, _ := json.Marshal(dat)
  25452. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  25453. utils.ErrorLog("解析失败:%v", err)
  25454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25455. return
  25456. }
  25457. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25458. res2.Output = resSix10265.Output
  25459. res2.ErrMsg = resSix10265.ErrMsg
  25460. res2.Cainfo = resSix10265.Cainfo
  25461. res2.WarnMsg = resSix10265.WarnMsg
  25462. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25463. res2.Infcode = infocode
  25464. } else {
  25465. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25466. res2.Infcode = 0
  25467. } else {
  25468. 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)
  25469. var dat map[string]interface{}
  25470. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25471. fmt.Println(dat)
  25472. } else {
  25473. fmt.Println(err)
  25474. }
  25475. saveLog(result2, src_request, "2205", "撤销明细")
  25476. userJSONBytes, _ := json.Marshal(dat)
  25477. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25478. utils.ErrorLog("解析失败:%v", err)
  25479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25480. return
  25481. }
  25482. }
  25483. }
  25484. }
  25485. if res2.Infcode == -1 {
  25486. c.ServeSuccessJSON(map[string]interface{}{
  25487. "failed_code": -10,
  25488. "msg": res2.ErrMsg,
  25489. })
  25490. return
  25491. }
  25492. if res2.Infcode == 0 {
  25493. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  25494. if err == nil {
  25495. //当押金不为零时产生退费记录
  25496. if order.Decimal != 0 {
  25497. tmp := strconv.FormatInt(order.ID, 10)
  25498. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  25499. if err != nil {
  25500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25501. return
  25502. }
  25503. }
  25504. c.ServeSuccessJSON(map[string]interface{}{
  25505. "msg": "退费成功",
  25506. })
  25507. } else {
  25508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25509. return
  25510. }
  25511. } else {
  25512. c.ServeSuccessJSON(map[string]interface{}{
  25513. "failed_code": -10,
  25514. "msg": res2.ErrMsg,
  25515. })
  25516. }
  25517. } else {
  25518. c.ServeSuccessJSON(map[string]interface{}{
  25519. "failed_code": -10,
  25520. "msg": res.ErrMsg,
  25521. })
  25522. }
  25523. }
  25524. }
  25525. func (c *HisApiController) RefundNumber() {
  25526. record_time := c.GetString("record_time")
  25527. //patient_id, _ := c.GetInt64("patient_id")
  25528. admin_user_id, _ := c.GetInt64("admin_user_id")
  25529. his_patient_id, _ := c.GetInt64("id")
  25530. timeLayout := "2006-01-02"
  25531. loc, _ := time.LoadLocation("Local")
  25532. adminUser := c.GetAdminUserInfo()
  25533. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25534. fmt.Println(err)
  25535. if err != nil {
  25536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25537. return
  25538. }
  25539. recordDateTime := theTime.Unix()
  25540. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25541. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  25542. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25543. //order, _ := service.GetHisOrderByID(order_id)
  25544. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25545. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25546. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25547. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  25548. if count > 0 {
  25549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  25550. return
  25551. }
  25552. if config.IsOpen == 1 { //对接了医保,走医保流程
  25553. var res2 ResultSix
  25554. var res3 GZResultSix
  25555. var resSix10265 ResultSix10265
  25556. if miConfig.MdtrtareaAdmvs == "421300" {
  25557. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  25558. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25559. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25560. resp3, requestErr3 := http.Get(api3)
  25561. if requestErr3 != nil {
  25562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25563. return
  25564. }
  25565. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25566. if ioErr3 != nil {
  25567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25569. return
  25570. }
  25571. var respJSON3 map[string]interface{}
  25572. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25575. return
  25576. }
  25577. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25578. userJSONBytes3, _ := json.Marshal(respJSON3)
  25579. fmt.Println("log")
  25580. fmt.Println(string(userJSONBytes3))
  25581. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25582. utils.ErrorLog("解析失败:%v", err)
  25583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25584. return
  25585. }
  25586. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25587. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  25588. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25589. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25590. resp3, requestErr3 := http.Get(api3)
  25591. if requestErr3 != nil {
  25592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25593. return
  25594. }
  25595. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25596. if ioErr3 != nil {
  25597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25599. return
  25600. }
  25601. var respJSON3 map[string]interface{}
  25602. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25605. return
  25606. }
  25607. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25608. userJSONBytes3, _ := json.Marshal(respJSON3)
  25609. fmt.Println("log")
  25610. fmt.Println(string(userJSONBytes3))
  25611. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25612. utils.ErrorLog("解析失败:%v", err)
  25613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25614. return
  25615. }
  25616. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25617. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  25618. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25619. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25620. resp3, requestErr3 := http.Get(api3)
  25621. if requestErr3 != nil {
  25622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25623. return
  25624. }
  25625. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25626. if ioErr3 != nil {
  25627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25629. return
  25630. }
  25631. var respJSON3 map[string]interface{}
  25632. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25635. return
  25636. }
  25637. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25638. userJSONBytes3, _ := json.Marshal(respJSON3)
  25639. fmt.Println("log")
  25640. fmt.Println(string(userJSONBytes3))
  25641. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25642. utils.ErrorLog("解析失败:%v", err)
  25643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25644. return
  25645. }
  25646. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25647. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  25648. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25649. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25650. resp3, requestErr3 := http.Get(api3)
  25651. if requestErr3 != nil {
  25652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25653. return
  25654. }
  25655. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25656. if ioErr3 != nil {
  25657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25659. return
  25660. }
  25661. var respJSON3 map[string]interface{}
  25662. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25665. return
  25666. }
  25667. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25668. userJSONBytes3, _ := json.Marshal(respJSON3)
  25669. fmt.Println("log")
  25670. fmt.Println(string(userJSONBytes3))
  25671. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25672. utils.ErrorLog("解析失败:%v", err)
  25673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25674. return
  25675. }
  25676. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25677. var api3 string
  25678. if miConfig.MdtrtareaAdmvs == "320921" {
  25679. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  25680. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25681. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25682. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25683. } else {
  25684. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25685. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  25686. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25687. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25688. }
  25689. resp3, requestErr3 := http.Get(api3)
  25690. if requestErr3 != nil {
  25691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25692. return
  25693. }
  25694. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25695. if ioErr3 != nil {
  25696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25698. return
  25699. }
  25700. var respJSON3 map[string]interface{}
  25701. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25704. return
  25705. }
  25706. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25707. userJSONBytes3, _ := json.Marshal(respJSON3)
  25708. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25709. utils.ErrorLog("解析失败:%v", err)
  25710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25711. return
  25712. }
  25713. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25714. res2.Output = resSix10265.Output
  25715. res2.ErrMsg = resSix10265.ErrMsg
  25716. res2.Cainfo = resSix10265.Cainfo
  25717. res2.WarnMsg = resSix10265.WarnMsg
  25718. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25719. res2.Infcode = infocode
  25720. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25721. var api3 string
  25722. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  25723. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25725. resp3, requestErr3 := http.Get(api3)
  25726. if requestErr3 != nil {
  25727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25728. return
  25729. }
  25730. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25731. if ioErr3 != nil {
  25732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25734. return
  25735. }
  25736. var respJSON3 map[string]interface{}
  25737. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25740. return
  25741. }
  25742. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25743. userJSONBytes3, _ := json.Marshal(respJSON3)
  25744. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25745. utils.ErrorLog("解析失败:%v", err)
  25746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25747. return
  25748. }
  25749. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25750. res2.Output = resSix10265.Output
  25751. res2.ErrMsg = resSix10265.ErrMsg
  25752. res2.Cainfo = resSix10265.Cainfo
  25753. res2.WarnMsg = resSix10265.WarnMsg
  25754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25755. res2.Infcode = infocode
  25756. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25757. 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)
  25758. var dat map[string]interface{}
  25759. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25760. fmt.Println(dat)
  25761. } else {
  25762. fmt.Println(err)
  25763. }
  25764. saveLog(result, request, "2202", "退号")
  25765. userJSONBytes, _ := json.Marshal(dat)
  25766. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25767. utils.ErrorLog("解析失败:%v", err)
  25768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25769. return
  25770. }
  25771. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25772. 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, "")
  25773. var dat map[string]interface{}
  25774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25775. fmt.Println(dat)
  25776. } else {
  25777. fmt.Println(err)
  25778. }
  25779. saveLog(result, request, "2202", "退号")
  25780. userJSONBytes, _ := json.Marshal(dat)
  25781. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25782. utils.ErrorLog("解析失败:%v", err)
  25783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25784. return
  25785. }
  25786. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25787. var api3 string
  25788. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  25789. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25790. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25791. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25792. resp3, requestErr3 := http.Get(api3)
  25793. if requestErr3 != nil {
  25794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25795. return
  25796. }
  25797. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25798. if ioErr3 != nil {
  25799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25801. return
  25802. }
  25803. var respJSON3 map[string]interface{}
  25804. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25807. return
  25808. }
  25809. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25810. if status == "0" {
  25811. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25812. c.ServeSuccessJSON(map[string]interface{}{
  25813. "failed_code": -10,
  25814. "msg": err_msg,
  25815. })
  25816. return
  25817. }
  25818. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25819. userJSONBytes3, _ := json.Marshal(respJSON3)
  25820. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25821. utils.ErrorLog("解析失败:%v", err)
  25822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25823. return
  25824. }
  25825. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  25826. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25827. 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, "")
  25828. var dat map[string]interface{}
  25829. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25830. fmt.Println(dat)
  25831. } else {
  25832. fmt.Println(err)
  25833. }
  25834. saveLog(result, request, "2202", "退号")
  25835. userJSONBytes, _ := json.Marshal(dat)
  25836. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25837. utils.ErrorLog("解析失败:%v", err)
  25838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25839. return
  25840. }
  25841. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25842. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  25843. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25844. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25845. resp3, requestErr3 := http.Get(api3)
  25846. if requestErr3 != nil {
  25847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25848. return
  25849. }
  25850. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25851. if ioErr3 != nil {
  25852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25854. return
  25855. }
  25856. var respJSON3 map[string]interface{}
  25857. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25860. return
  25861. }
  25862. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25863. userJSONBytes3, _ := json.Marshal(respJSON3)
  25864. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25865. utils.ErrorLog("解析失败:%v", err)
  25866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25867. return
  25868. }
  25869. } else {
  25870. var api3 string
  25871. if miConfig.Code == "H15049901371" {
  25872. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  25873. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25874. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25875. } else {
  25876. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  25877. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25878. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25879. }
  25880. resp3, requestErr3 := http.Get(api3)
  25881. if requestErr3 != nil {
  25882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25883. return
  25884. }
  25885. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25886. if ioErr3 != nil {
  25887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25889. return
  25890. }
  25891. var respJSON3 map[string]interface{}
  25892. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25895. return
  25896. }
  25897. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25898. userJSONBytes3, _ := json.Marshal(respJSON3)
  25899. if miConfig.Code == "H15049901371" {
  25900. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25901. utils.ErrorLog("解析失败:%v", err)
  25902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25903. return
  25904. }
  25905. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25906. res2.Output = resSix10265.Output
  25907. res2.ErrMsg = resSix10265.ErrMsg
  25908. res2.Cainfo = resSix10265.Cainfo
  25909. res2.WarnMsg = resSix10265.WarnMsg
  25910. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25911. res2.Infcode = infocode
  25912. } else {
  25913. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25914. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  25915. utils.ErrorLog("解析失败:%v", err)
  25916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25917. return
  25918. }
  25919. res2.Infcode = res3.Infcode
  25920. } else {
  25921. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25922. utils.ErrorLog("解析失败:%v", err)
  25923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25924. return
  25925. }
  25926. }
  25927. }
  25928. }
  25929. if res2.Infcode == -1 {
  25930. utils.ErrorLog("解析失败:%v", res2.Infcode)
  25931. c.ServeSuccessJSON(map[string]interface{}{
  25932. "failed_code": -10,
  25933. "msg": res2.ErrMsg,
  25934. })
  25935. return
  25936. }
  25937. if res2.Infcode == 0 {
  25938. if err == nil {
  25939. c.ServeSuccessJSON(map[string]interface{}{
  25940. "msg": "退号成功",
  25941. })
  25942. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  25943. } else {
  25944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25945. return
  25946. }
  25947. }
  25948. } else {
  25949. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  25950. //if err == nil {
  25951. // c.ServeSuccessJSON(map[string]interface{}{
  25952. // "msg": "退费成功",
  25953. // })
  25954. //} else {
  25955. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25956. // return
  25957. //}
  25958. }
  25959. }
  25960. func (c *HisApiController) RefundDetail() {
  25961. order_id, _ := c.GetInt64("order_id")
  25962. admin_user_id, _ := c.GetInt64("admin_user_id")
  25963. //his_patient_id, _ := c.GetInt64("his_patient_id")
  25964. number := c.GetString("number")
  25965. record_time := c.GetString("record_time")
  25966. patient_id, _ := c.GetInt64("patient_id")
  25967. //med_type, _ := c.GetInt64("med_type")
  25968. timeLayout := "2006-01-02"
  25969. loc, _ := time.LoadLocation("Local")
  25970. adminUser := c.GetAdminUserInfo()
  25971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25972. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25973. fmt.Println(err)
  25974. if err != nil {
  25975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25976. return
  25977. }
  25978. recordDateTime := theTime.Unix()
  25979. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25980. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25981. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25982. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25983. var order models.HisOrder
  25984. order, _ = service.GetHisOrderByID(order_id)
  25985. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25986. if config.IsOpen == 1 { //对接了医保,走医保流程
  25987. var res2 ResultSix
  25988. if miConfig.MdtrtareaAdmvs == "421300" {
  25989. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25990. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25991. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25992. resp3, requestErr3 := http.Get(api3)
  25993. if requestErr3 != nil {
  25994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25995. return
  25996. }
  25997. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25998. if ioErr3 != nil {
  25999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26001. return
  26002. }
  26003. var respJSON3 map[string]interface{}
  26004. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26007. return
  26008. }
  26009. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26010. userJSONBytes3, _ := json.Marshal(respJSON3)
  26011. fmt.Println("log")
  26012. fmt.Println(string(userJSONBytes3))
  26013. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26014. utils.ErrorLog("解析失败:%v", err)
  26015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26016. return
  26017. }
  26018. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26019. if err == nil {
  26020. c.ServeSuccessJSON(map[string]interface{}{
  26021. "msg": "撤销明细成功",
  26022. })
  26023. return
  26024. } else {
  26025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26026. return
  26027. }
  26028. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26029. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  26030. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26031. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26032. resp3, requestErr3 := http.Get(api3)
  26033. if requestErr3 != nil {
  26034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26035. return
  26036. }
  26037. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26038. if ioErr3 != nil {
  26039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26041. return
  26042. }
  26043. var respJSON3 map[string]interface{}
  26044. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26047. return
  26048. }
  26049. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26050. userJSONBytes3, _ := json.Marshal(respJSON3)
  26051. fmt.Println("log")
  26052. fmt.Println(string(userJSONBytes3))
  26053. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26054. utils.ErrorLog("解析失败:%v", err)
  26055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26056. return
  26057. }
  26058. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26059. if err == nil {
  26060. c.ServeSuccessJSON(map[string]interface{}{
  26061. "msg": "撤销明细成功",
  26062. })
  26063. return
  26064. } else {
  26065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26066. return
  26067. }
  26068. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26069. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  26070. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26071. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26072. resp3, requestErr3 := http.Get(api3)
  26073. if requestErr3 != nil {
  26074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26075. return
  26076. }
  26077. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26078. if ioErr3 != nil {
  26079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26081. return
  26082. }
  26083. var respJSON3 map[string]interface{}
  26084. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26087. return
  26088. }
  26089. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26090. userJSONBytes3, _ := json.Marshal(respJSON3)
  26091. fmt.Println("log")
  26092. fmt.Println(string(userJSONBytes3))
  26093. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26094. utils.ErrorLog("解析失败:%v", err)
  26095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26096. return
  26097. }
  26098. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26099. if err == nil {
  26100. c.ServeSuccessJSON(map[string]interface{}{
  26101. "msg": "撤销明细成功",
  26102. })
  26103. return
  26104. } else {
  26105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26106. return
  26107. }
  26108. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26109. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  26110. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26111. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26112. resp3, requestErr3 := http.Get(api3)
  26113. if requestErr3 != nil {
  26114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26115. return
  26116. }
  26117. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26118. if ioErr3 != nil {
  26119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26121. return
  26122. }
  26123. var respJSON3 map[string]interface{}
  26124. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26127. return
  26128. }
  26129. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26130. userJSONBytes3, _ := json.Marshal(respJSON3)
  26131. fmt.Println("log")
  26132. fmt.Println(string(userJSONBytes3))
  26133. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26134. utils.ErrorLog("解析失败:%v", err)
  26135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26136. return
  26137. }
  26138. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26139. if err == nil {
  26140. c.ServeSuccessJSON(map[string]interface{}{
  26141. "msg": "撤销明细成功",
  26142. })
  26143. return
  26144. } else {
  26145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26146. return
  26147. }
  26148. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26149. var resSix10265 ResultSix10265
  26150. var api3 string
  26151. if miConfig.MdtrtareaAdmvs == "320921" {
  26152. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  26153. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26154. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26155. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26156. } else {
  26157. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26158. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  26159. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26160. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26161. }
  26162. resp3, requestErr3 := http.Get(api3)
  26163. utils.ErrorLog("接口: %v", requestErr3)
  26164. if requestErr3 != nil {
  26165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26166. return
  26167. }
  26168. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26169. if ioErr3 != nil {
  26170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26172. return
  26173. }
  26174. var respJSON3 map[string]interface{}
  26175. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26178. return
  26179. }
  26180. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26181. userJSONBytes3, _ := json.Marshal(respJSON3)
  26182. fmt.Println("log")
  26183. fmt.Println(string(userJSONBytes3))
  26184. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  26185. utils.ErrorLog("解析失败:%v", err)
  26186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26187. return
  26188. }
  26189. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26190. res2.Output = resSix10265.Output
  26191. res2.ErrMsg = resSix10265.ErrMsg
  26192. res2.Cainfo = resSix10265.Cainfo
  26193. res2.WarnMsg = resSix10265.WarnMsg
  26194. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26195. res2.Infcode = infocode
  26196. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26197. if err == nil {
  26198. c.ServeSuccessJSON(map[string]interface{}{
  26199. "msg": "撤销明细成功",
  26200. })
  26201. return
  26202. } else {
  26203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26204. return
  26205. }
  26206. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26207. var api3 string
  26208. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  26209. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26210. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26211. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26212. resp3, requestErr3 := http.Get(api3)
  26213. utils.ErrorLog("接口: %v", requestErr3)
  26214. if requestErr3 != nil {
  26215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26216. return
  26217. }
  26218. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26219. if ioErr3 != nil {
  26220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26222. return
  26223. }
  26224. var respJSON3 map[string]interface{}
  26225. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26228. return
  26229. }
  26230. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  26231. if status == "0" {
  26232. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  26233. c.ServeSuccessJSON(map[string]interface{}{
  26234. "failed_code": -10,
  26235. "msg": err_msg,
  26236. })
  26237. return
  26238. }
  26239. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26240. userJSONBytes3, _ := json.Marshal(respJSON3)
  26241. fmt.Println("log")
  26242. fmt.Println(string(userJSONBytes3))
  26243. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26244. utils.ErrorLog("解析失败:%v", err)
  26245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26246. return
  26247. }
  26248. fmt.Println(res2.Infcode)
  26249. if res2.Infcode == -1 {
  26250. c.ServeSuccessJSON(map[string]interface{}{
  26251. "failed_code": -10,
  26252. "msg": res2.ErrMsg,
  26253. })
  26254. return
  26255. }
  26256. if res2.Infcode == 0 {
  26257. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26258. if err == nil {
  26259. c.ServeSuccessJSON(map[string]interface{}{
  26260. "msg": "撤销明细成功",
  26261. })
  26262. return
  26263. } else {
  26264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26265. return
  26266. }
  26267. } else {
  26268. c.ServeSuccessJSON(map[string]interface{}{
  26269. "failed_code": -10,
  26270. "msg": res2.ErrMsg,
  26271. })
  26272. }
  26273. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26274. if err == nil {
  26275. c.ServeSuccessJSON(map[string]interface{}{
  26276. "msg": "撤销明细成功",
  26277. })
  26278. return
  26279. } else {
  26280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26281. return
  26282. }
  26283. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26284. var resSix10265 ResultSix10265
  26285. var api3 string
  26286. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  26287. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26288. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26289. resp3, requestErr3 := http.Get(api3)
  26290. if requestErr3 != nil {
  26291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26292. return
  26293. }
  26294. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26295. if ioErr3 != nil {
  26296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26298. return
  26299. }
  26300. var respJSON3 map[string]interface{}
  26301. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26304. return
  26305. }
  26306. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26307. userJSONBytes3, _ := json.Marshal(respJSON3)
  26308. fmt.Println("log")
  26309. fmt.Println(string(userJSONBytes3))
  26310. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  26311. utils.ErrorLog("解析失败:%v", err)
  26312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26313. return
  26314. }
  26315. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26316. res2.Output = resSix10265.Output
  26317. res2.ErrMsg = resSix10265.ErrMsg
  26318. res2.Cainfo = resSix10265.Cainfo
  26319. res2.WarnMsg = resSix10265.WarnMsg
  26320. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26321. res2.Infcode = infocode
  26322. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26323. if err == nil {
  26324. c.ServeSuccessJSON(map[string]interface{}{
  26325. "msg": "撤销明细成功",
  26326. })
  26327. return
  26328. } else {
  26329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26330. return
  26331. }
  26332. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26333. 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)
  26334. var dat map[string]interface{}
  26335. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26336. fmt.Println(dat)
  26337. } else {
  26338. fmt.Println(err)
  26339. }
  26340. saveLog(result2, src_request, "2205", "撤销明细")
  26341. userJSONBytes, _ := json.Marshal(dat)
  26342. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26343. utils.ErrorLog("解析失败:%v", err)
  26344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26345. return
  26346. }
  26347. if res2.Infcode == 0 {
  26348. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26349. if err == nil {
  26350. c.ServeSuccessJSON(map[string]interface{}{
  26351. "msg": "撤销明细成功",
  26352. })
  26353. return
  26354. } else {
  26355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26356. return
  26357. }
  26358. } else {
  26359. c.ServeSuccessJSON(map[string]interface{}{
  26360. "failed_code": -10,
  26361. "msg": res2.ErrMsg,
  26362. })
  26363. }
  26364. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26365. 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, "")
  26366. var dat map[string]interface{}
  26367. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26368. fmt.Println(dat)
  26369. } else {
  26370. fmt.Println(err)
  26371. }
  26372. saveLog(result2, src_request, "2205", "撤销明细")
  26373. userJSONBytes, _ := json.Marshal(dat)
  26374. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26375. utils.ErrorLog("解析失败:%v", err)
  26376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26377. return
  26378. }
  26379. if res2.Infcode == 0 {
  26380. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26381. if err == nil {
  26382. c.ServeSuccessJSON(map[string]interface{}{
  26383. "msg": "撤销明细成功",
  26384. })
  26385. return
  26386. } else {
  26387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26388. return
  26389. }
  26390. } else {
  26391. c.ServeSuccessJSON(map[string]interface{}{
  26392. "failed_code": -10,
  26393. "msg": res2.ErrMsg,
  26394. })
  26395. }
  26396. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26397. 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, "")
  26398. var dat map[string]interface{}
  26399. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26400. fmt.Println(dat)
  26401. } else {
  26402. fmt.Println(err)
  26403. }
  26404. saveLog(result2, src_request, "2205", "撤销明细")
  26405. userJSONBytes, _ := json.Marshal(dat)
  26406. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26407. utils.ErrorLog("解析失败:%v", err)
  26408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26409. return
  26410. }
  26411. if res2.Infcode == 0 {
  26412. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26413. if err == nil {
  26414. c.ServeSuccessJSON(map[string]interface{}{
  26415. "msg": "撤销明细成功",
  26416. })
  26417. return
  26418. } else {
  26419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26420. return
  26421. }
  26422. } else {
  26423. c.ServeSuccessJSON(map[string]interface{}{
  26424. "failed_code": -10,
  26425. "msg": res2.ErrMsg,
  26426. })
  26427. }
  26428. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26429. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  26430. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26431. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26432. resp2, requestErr2 := http.Get(api2)
  26433. if requestErr2 != nil {
  26434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26435. return
  26436. }
  26437. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  26438. if ioErr2 != nil {
  26439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  26440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26441. return
  26442. }
  26443. var respJSON2 map[string]interface{}
  26444. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  26445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26447. return
  26448. }
  26449. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26450. userJSONBytes3, _ := json.Marshal(respJSON2)
  26451. fmt.Println("log")
  26452. fmt.Println(string(userJSONBytes3))
  26453. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26454. utils.ErrorLog("解析失败:%v", err)
  26455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26456. return
  26457. }
  26458. if res2.Infcode == 0 {
  26459. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26460. if err == nil {
  26461. c.ServeSuccessJSON(map[string]interface{}{
  26462. "msg": "撤销明细成功",
  26463. })
  26464. return
  26465. } else {
  26466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26467. return
  26468. }
  26469. } else {
  26470. c.ServeSuccessJSON(map[string]interface{}{
  26471. "failed_code": -10,
  26472. "msg": res2.ErrMsg,
  26473. })
  26474. }
  26475. } else {
  26476. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  26477. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26478. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  26479. resp2, requestErr2 := http.Get(api2)
  26480. if requestErr2 != nil {
  26481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26482. return
  26483. }
  26484. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  26485. if ioErr2 != nil {
  26486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  26487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26488. return
  26489. }
  26490. var respJSON2 map[string]interface{}
  26491. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  26492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26494. return
  26495. }
  26496. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26497. if err == nil {
  26498. c.ServeSuccessJSON(map[string]interface{}{
  26499. "msg": "撤销明细成功",
  26500. })
  26501. return
  26502. } else {
  26503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26504. return
  26505. }
  26506. }
  26507. } else {
  26508. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26509. if err == nil {
  26510. c.ServeSuccessJSON(map[string]interface{}{
  26511. "msg": "退费成功",
  26512. })
  26513. } else {
  26514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26515. return
  26516. }
  26517. }
  26518. }
  26519. // 对账
  26520. func (c *HisApiController) GetCheckAccount() {
  26521. start_time := c.GetString("start_time")
  26522. end_time := c.GetString("end_time")
  26523. insutype := c.GetString("insutype")
  26524. clr_type := c.GetString("clr_type")
  26525. clr_org := c.GetString("clr_optins")
  26526. admin_user_id, _ := c.GetInt64("admin_user_id")
  26527. adminUser := c.GetAdminUserInfo()
  26528. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26529. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26530. if len(clr_org) == 0 {
  26531. clr_org = miConfig.InsuplcAdmdvs
  26532. }
  26533. timeLayout := "2006-01-02"
  26534. loc, _ := time.LoadLocation("Local")
  26535. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26536. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  26537. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  26538. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  26539. fixmedins_setl_cnt := int64(len(orders))
  26540. var medfee_sumamt float64
  26541. var acct_pay float64
  26542. var fund_pay_sumamt float64
  26543. for _, item := range orders {
  26544. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  26545. acct_pay = acct_pay + item.AcctPay
  26546. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  26547. }
  26548. var user_name string
  26549. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26550. if role.ID == 0 {
  26551. user_name = "xxx"
  26552. } else {
  26553. user_name = role.UserName
  26554. }
  26555. var res ResultEight
  26556. var res10188 ResultEightFor10188
  26557. if config.IsOpen == 1 {
  26558. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26559. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  26560. "insutype=" + insutype +
  26561. "&clr_type=" + clr_type +
  26562. "&setl_optins=" + clr_org +
  26563. "&stmt_begndate=" + start_time +
  26564. "&stm_enddate=" + end_time +
  26565. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26566. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26567. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26568. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  26569. "&fixmedins_code=" + miConfig.Code +
  26570. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26571. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26572. "&secret_key=" + miConfig.SecretKey +
  26573. "&org_name=" + miConfig.OrgName +
  26574. "&doctor=" + user_name +
  26575. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26576. fmt.Println(api)
  26577. resp, requestErr := http.Get(api)
  26578. if requestErr != nil {
  26579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26580. return
  26581. }
  26582. body, ioErr := ioutil.ReadAll(resp.Body)
  26583. fmt.Println(body)
  26584. if ioErr != nil {
  26585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26587. return
  26588. }
  26589. var respJSON map[string]interface{}
  26590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26593. return
  26594. }
  26595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26596. userJSONBytes, _ := json.Marshal(respJSON)
  26597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26598. utils.ErrorLog("解析失败:%v", err)
  26599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26600. return
  26601. }
  26602. res.InfRefmsgid = res10188.InfRefmsgid
  26603. res.Output = res10188.Output
  26604. res.ErrMsg = res10188.ErrMsg
  26605. res.Cainfo = res10188.Cainfo
  26606. res.WarnMsg = res10188.WarnMsg
  26607. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  26608. res.Infcode = infocode
  26609. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26610. if clr_type != "9903" {
  26611. clr_type = "99" // 就诊 ID(来自2201接口返回)
  26612. }
  26613. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  26614. "insutype=" + insutype +
  26615. "&clr_type=" + clr_type +
  26616. "&setl_optins=" + clr_org +
  26617. "&stmt_begndate=" + start_time +
  26618. "&stm_enddate=" + end_time +
  26619. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26620. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26621. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26622. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  26623. "&fixmedins_code=" + miConfig.Code +
  26624. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26625. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26626. "&secret_key=" + miConfig.SecretKey +
  26627. "&org_name=" + miConfig.OrgName +
  26628. "&doctor=" + user_name
  26629. resp, requestErr := http.Get(api)
  26630. if requestErr != nil {
  26631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26632. return
  26633. }
  26634. body, ioErr := ioutil.ReadAll(resp.Body)
  26635. if ioErr != nil {
  26636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26638. return
  26639. }
  26640. var respJSON map[string]interface{}
  26641. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26644. return
  26645. }
  26646. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26647. result, _ := json.Marshal(respJSON)
  26648. fmt.Println("log")
  26649. fmt.Println(string(result))
  26650. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  26651. utils.ErrorLog("解析失败:%v", err)
  26652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26653. return
  26654. }
  26655. res.InfRefmsgid = res10188.InfRefmsgid
  26656. res.Output = res10188.Output
  26657. res.ErrMsg = res10188.ErrMsg
  26658. res.Cainfo = res10188.Cainfo
  26659. res.WarnMsg = res10188.WarnMsg
  26660. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  26661. res.Infcode = infocode
  26662. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26663. var baseParams models.BaseParams
  26664. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26665. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  26666. baseParams.SecretKey = miConfig.SecretKey
  26667. baseParams.OrgName = miConfig.OrgName
  26668. baseParams.FixmedinsCode = miConfig.Code
  26669. baseParams.EncKey = miConfig.EncKey
  26670. baseParams.AppSecret = miConfig.AppSecret
  26671. baseParams.SignKey = miConfig.SignKey
  26672. baseParams.AppID = miConfig.Code
  26673. baseParams.Doctor = role.UserName
  26674. baseParams.RequestUrl = miConfig.Url
  26675. businessParams := models.BusinessParams{
  26676. Insutype: insutype,
  26677. ClrType: clr_type,
  26678. SetlOptins: clr_org,
  26679. StmtBegndate: start_time,
  26680. StmtEnddate: end_time,
  26681. MedfeeSumamt: medfee_sumamt,
  26682. FundPaySumamt: fund_pay_sumamt,
  26683. AcctPay: acct_pay,
  26684. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26685. }
  26686. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  26687. fmt.Println(requestLog)
  26688. fmt.Println(result)
  26689. fmt.Println(err_msg)
  26690. var dat map[string]interface{}
  26691. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26692. fmt.Println(dat)
  26693. } else {
  26694. fmt.Println(err)
  26695. }
  26696. userJSONBytes, _ := json.Marshal(dat)
  26697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26698. utils.ErrorLog("解析失败:%v", err)
  26699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26700. return
  26701. }
  26702. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26703. var baseParams models.BaseParams
  26704. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26705. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  26706. baseParams.SecretKey = miConfig.SecretKey
  26707. baseParams.OrgName = miConfig.OrgName
  26708. baseParams.FixmedinsCode = miConfig.Code
  26709. baseParams.EncKey = miConfig.EncKey
  26710. baseParams.AppSecret = miConfig.AppSecret
  26711. baseParams.SignKey = miConfig.SignKey
  26712. baseParams.AppID = miConfig.Code
  26713. baseParams.Doctor = role.UserName
  26714. baseParams.RequestUrl = miConfig.Url
  26715. baseParams.AccessKey = miConfig.AccessKey
  26716. businessParams := models.BusinessParams{
  26717. Insutype: insutype,
  26718. ClrType: clr_type,
  26719. SetlOptins: "430822",
  26720. StmtBegndate: start_time,
  26721. StmtEnddate: end_time,
  26722. MedfeeSumamt: medfee_sumamt,
  26723. FundPaySumamt: fund_pay_sumamt,
  26724. AcctPay: acct_pay,
  26725. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26726. }
  26727. 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)
  26728. fmt.Println(requestLog)
  26729. fmt.Println(result)
  26730. var dat map[string]interface{}
  26731. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26732. fmt.Println(dat)
  26733. } else {
  26734. fmt.Println(err)
  26735. }
  26736. userJSONBytes, _ := json.Marshal(dat)
  26737. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26738. utils.ErrorLog("解析失败:%v", err)
  26739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26740. return
  26741. }
  26742. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26743. var baseParams models.BaseParams
  26744. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26745. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  26746. baseParams.SecretKey = miConfig.SecretKey
  26747. baseParams.OrgName = miConfig.OrgName
  26748. baseParams.FixmedinsCode = miConfig.Code
  26749. baseParams.EncKey = miConfig.EncKey
  26750. baseParams.AppSecret = miConfig.AppSecret
  26751. baseParams.SignKey = miConfig.SignKey
  26752. baseParams.AppID = miConfig.Code
  26753. baseParams.Doctor = role.UserName
  26754. baseParams.RequestUrl = miConfig.Url
  26755. businessParams := models.BusinessParams{
  26756. Insutype: insutype,
  26757. ClrType: clr_type,
  26758. SetlOptins: clr_org,
  26759. StmtBegndate: start_time,
  26760. StmtEnddate: end_time,
  26761. MedfeeSumamt: medfee_sumamt,
  26762. FundPaySumamt: fund_pay_sumamt,
  26763. AcctPay: acct_pay,
  26764. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26765. }
  26766. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  26767. fmt.Println(requestLog)
  26768. fmt.Println(result)
  26769. fmt.Println(err_msg)
  26770. var dat map[string]interface{}
  26771. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26772. fmt.Println(dat)
  26773. } else {
  26774. fmt.Println(err)
  26775. }
  26776. userJSONBytes, _ := json.Marshal(dat)
  26777. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26778. utils.ErrorLog("解析失败:%v", err)
  26779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26780. return
  26781. }
  26782. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26783. if len(clr_type) == 0 {
  26784. clr_type = "11"
  26785. }
  26786. api := miConfig.Url + "gdyb/ten?" +
  26787. "insutype=" + insutype +
  26788. "&clr_type=" + clr_type +
  26789. "&setl_optins=" + clr_org +
  26790. "&stmt_begndate=" + start_time +
  26791. "&stm_enddate=" + end_time +
  26792. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26793. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26794. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26795. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26796. "&fixmedins_code=" + miConfig.Code +
  26797. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26798. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26799. "&secret_key=" + miConfig.SecretKey +
  26800. "&org_name=" + miConfig.OrgName +
  26801. "&doctor=" + user_name
  26802. fmt.Println(api)
  26803. resp, requestErr := http.Get(api)
  26804. if requestErr != nil {
  26805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26806. return
  26807. }
  26808. body, ioErr := ioutil.ReadAll(resp.Body)
  26809. fmt.Println(body)
  26810. if ioErr != nil {
  26811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26813. return
  26814. }
  26815. var respJSON map[string]interface{}
  26816. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26819. return
  26820. }
  26821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26822. userJSONBytes, _ := json.Marshal(respJSON)
  26823. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26824. utils.ErrorLog("解析失败:%v", err)
  26825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26826. return
  26827. }
  26828. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26829. var baseParams models.BaseParams
  26830. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26831. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  26832. baseParams.SecretKey = miConfig.SecretKey
  26833. baseParams.OrgName = miConfig.OrgName
  26834. baseParams.FixmedinsCode = miConfig.Code
  26835. baseParams.EncKey = miConfig.EncKey
  26836. baseParams.AppSecret = miConfig.AppSecret
  26837. baseParams.SignKey = miConfig.SignKey
  26838. baseParams.AppID = miConfig.Code
  26839. baseParams.Doctor = role.UserName
  26840. baseParams.RequestUrl = miConfig.Url
  26841. if clr_type == "9903" {
  26842. clr_type = "9901"
  26843. }
  26844. businessParams := models.BusinessParams{
  26845. Insutype: insutype,
  26846. ClrType: clr_type,
  26847. SetlOptins: "360302",
  26848. StmtBegndate: start_time,
  26849. StmtEnddate: end_time,
  26850. MedfeeSumamt: 0,
  26851. FundPaySumamt: 0,
  26852. AcctPay: 0,
  26853. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26854. }
  26855. 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))
  26856. fmt.Println(requestLog)
  26857. fmt.Println(result)
  26858. var dat map[string]interface{}
  26859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26860. fmt.Println(dat)
  26861. } else {
  26862. fmt.Println(err)
  26863. }
  26864. userJSONBytes, _ := json.Marshal(dat)
  26865. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26866. utils.ErrorLog("解析失败:%v", err)
  26867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26868. return
  26869. }
  26870. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26871. var api string
  26872. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  26873. "&clr_type=" + clr_type +
  26874. "&setl_optins=" + clr_org +
  26875. "&stmt_begndate=" + start_time +
  26876. "&stm_enddate=" + end_time +
  26877. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26878. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26879. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26880. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  26881. "&fixmedins_code=" + miConfig.Code +
  26882. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26883. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26884. "&secret_key=" + miConfig.SecretKey +
  26885. "&org_name=" + miConfig.OrgName +
  26886. "&doctor=" + user_name + "&url=" + miConfig.Url
  26887. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26888. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26889. resp, requestErr := http.Get(api)
  26890. if requestErr != nil {
  26891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26892. return
  26893. }
  26894. body, ioErr := ioutil.ReadAll(resp.Body)
  26895. if ioErr != nil {
  26896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26898. return
  26899. }
  26900. var respJSON map[string]interface{}
  26901. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26904. return
  26905. }
  26906. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26907. if status == "0" {
  26908. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26909. c.ServeSuccessJSON(map[string]interface{}{
  26910. "failed_code": -10,
  26911. "msg": err_msg,
  26912. })
  26913. return
  26914. }
  26915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26916. userJSONBytes, _ := json.Marshal(respJSON)
  26917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26918. utils.ErrorLog("解析失败:%v", err)
  26919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26920. return
  26921. }
  26922. } else {
  26923. if len(clr_type) == 0 {
  26924. clr_type = "11"
  26925. }
  26926. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26927. "insutype=" + insutype +
  26928. "&clr_type=" + clr_type +
  26929. "&setl_optins=" + clr_org +
  26930. "&stmt_begndate=" + start_time +
  26931. "&stm_enddate=" + end_time +
  26932. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26933. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26934. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26935. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26936. "&fixmedins_code=" + miConfig.Code +
  26937. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26938. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26939. "&secret_key=" + miConfig.SecretKey +
  26940. "&org_name=" + miConfig.OrgName +
  26941. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  26942. fmt.Println(api)
  26943. resp, requestErr := http.Get(api)
  26944. if requestErr != nil {
  26945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26946. return
  26947. }
  26948. body, ioErr := ioutil.ReadAll(resp.Body)
  26949. fmt.Println(body)
  26950. if ioErr != nil {
  26951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26953. return
  26954. }
  26955. var respJSON map[string]interface{}
  26956. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26959. return
  26960. }
  26961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26962. userJSONBytes, _ := json.Marshal(respJSON)
  26963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26964. utils.ErrorLog("解析失败:%v", err)
  26965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26966. return
  26967. }
  26968. }
  26969. if res.Infcode == 0 {
  26970. if res.Output.Stmtinfo.StmtRslt == "0" {
  26971. micc := &models.MedicalInsuranceCostCompare{
  26972. StartTime: startime.Unix(),
  26973. EndTime: endtime.Unix(),
  26974. Insutype: insutype,
  26975. CheckType: 1,
  26976. Num: fixmedins_setl_cnt,
  26977. Mtime: time.Now().Unix(),
  26978. Status: 1,
  26979. UserOrgId: adminUser.CurrentOrgId,
  26980. CostTotal: medfee_sumamt,
  26981. FuncTotal: fund_pay_sumamt,
  26982. PsnPay: acct_pay,
  26983. Creator: admin_user_id,
  26984. Ctime: time.Now().Unix(),
  26985. ClrType: clr_type,
  26986. }
  26987. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  26988. if err == nil {
  26989. c.ServeSuccessJSON(map[string]interface{}{
  26990. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26991. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26992. })
  26993. } else {
  26994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26995. }
  26996. } else {
  26997. c.ServeSuccessJSON(map[string]interface{}{
  26998. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26999. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  27000. })
  27001. }
  27002. } else {
  27003. c.ServeSuccessJSON(map[string]interface{}{
  27004. "failed_code": -10,
  27005. "msg": res.ErrMsg,
  27006. })
  27007. }
  27008. }
  27009. }
  27010. func (c *HisApiController) Check310() {
  27011. adminUser := c.GetAdminUserInfo()
  27012. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27013. var user_name string
  27014. user_name = "高慧裕"
  27015. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  27016. "insutype=" + "310" +
  27017. "&clr_type=" + "" +
  27018. "&setl_optins=" + "441202" +
  27019. "&stmt_begndate=" + "2022-03-01" +
  27020. "&stm_enddate=" + "2022-03-31" +
  27021. "&medfee_sumamt=" + "194930.12" +
  27022. "&fund_pay_sumamt=" + "188741.46" +
  27023. "&acct_pay=" + "0" +
  27024. "&fixmedins_setl_cnt=" + "452" +
  27025. "&fixmedins_code=" + miConfig.Code +
  27026. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  27027. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27028. "&secret_key=" + miConfig.SecretKey +
  27029. "&org_name=" + miConfig.OrgName +
  27030. "&doctor=" + user_name
  27031. fmt.Println(api)
  27032. resp, requestErr := http.Get(api)
  27033. if requestErr != nil {
  27034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27035. return
  27036. }
  27037. body, ioErr := ioutil.ReadAll(resp.Body)
  27038. fmt.Println(body)
  27039. if ioErr != nil {
  27040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27042. return
  27043. }
  27044. var respJSON map[string]interface{}
  27045. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27048. return
  27049. }
  27050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27051. userJSONBytes, _ := json.Marshal(respJSON)
  27052. var res ResultEight
  27053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27054. utils.ErrorLog("解析失败:%v", err)
  27055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27056. return
  27057. }
  27058. }
  27059. func (c *HisApiController) Check390() {
  27060. adminUser := c.GetAdminUserInfo()
  27061. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27062. var user_name string
  27063. user_name = "高慧裕"
  27064. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  27065. "insutype=" + "390" +
  27066. "&clr_type=" + "" +
  27067. "&setl_optins=" + "441202" +
  27068. "&stmt_begndate=" + "2022-03-01" +
  27069. "&stm_enddate=" + "2022-03-31" +
  27070. "&medfee_sumamt=" + "1068448.89" +
  27071. "&fund_pay_sumamt=" + "1014677.62" +
  27072. "&acct_pay=" + "0" +
  27073. "&fixmedins_setl_cnt=" + "1950" +
  27074. "&fixmedins_code=" + miConfig.Code +
  27075. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  27076. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27077. "&secret_key=" + miConfig.SecretKey +
  27078. "&org_name=" + miConfig.OrgName +
  27079. "&doctor=" + user_name
  27080. fmt.Println(api)
  27081. resp, requestErr := http.Get(api)
  27082. if requestErr != nil {
  27083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27084. return
  27085. }
  27086. body, ioErr := ioutil.ReadAll(resp.Body)
  27087. fmt.Println(body)
  27088. if ioErr != nil {
  27089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27091. return
  27092. }
  27093. var respJSON map[string]interface{}
  27094. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27097. return
  27098. }
  27099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27100. userJSONBytes, _ := json.Marshal(respJSON)
  27101. var res ResultEight
  27102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27103. utils.ErrorLog("解析失败:%v", err)
  27104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27105. return
  27106. }
  27107. }
  27108. // 对账明细
  27109. func (c *HisApiController) GetCheckDetailAccount() {
  27110. start_time := c.GetString("start_time")
  27111. end_time := c.GetString("end_time")
  27112. admin_user_id, _ := c.GetInt64("admin_user_id")
  27113. adminUser := c.GetAdminUserInfo()
  27114. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27115. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27116. timeLayout := "2006-01-02"
  27117. loc, _ := time.LoadLocation("Local")
  27118. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  27119. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  27120. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  27121. rand.Seed(time.Now().UnixNano())
  27122. num := rand.Intn(30000)
  27123. Mkdir(miConfig.OrgName)
  27124. file := strconv.FormatInt(int64(num), 10)
  27125. file_name := file + ".txt"
  27126. zip_name := file + ".zip"
  27127. zip_path := miConfig.OrgName + "/" + zip_name
  27128. file_path := miConfig.OrgName + "/" + file_name
  27129. decimal.DivisionPrecision = 2
  27130. var medfee_sumamt float64
  27131. var psn_cash_pay float64
  27132. var fund_pay_sumamt float64
  27133. fixmedins_setl_cnt := int64(len(orders))
  27134. for _, item := range orders {
  27135. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  27136. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  27137. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  27138. }
  27139. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  27140. defer f.Close()
  27141. if err != nil {
  27142. fmt.Println(err.Error())
  27143. } else {
  27144. for _, item := range orders {
  27145. var refd_setl_flag string
  27146. if item.OrderStatus == 2 {
  27147. refd_setl_flag = "0"
  27148. var str string
  27149. str = item.SetlId + " " +
  27150. item.MdtrtId + " " +
  27151. item.PsnNo + " " +
  27152. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  27153. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  27154. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  27155. _, err = f.Write([]byte(str))
  27156. }
  27157. if item.OrderStatus == 3 {
  27158. var str string
  27159. str = item.SetlId + " " +
  27160. item.MdtrtId + " " +
  27161. item.PsnNo + " " +
  27162. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  27163. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  27164. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  27165. _, err = f.Write([]byte(str))
  27166. var str2 string
  27167. str2 = item.SetlId + " " +
  27168. item.MdtrtId + " " +
  27169. item.PsnNo + " " +
  27170. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  27171. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  27172. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  27173. _, err = f.Write([]byte(str2))
  27174. }
  27175. }
  27176. }
  27177. Zip(file_path, zip_path)
  27178. fmt.Println(ReadFile(zip_path))
  27179. fmt.Println(string(ReadFile(zip_path)))
  27180. if config.IsOpen == 1 {
  27181. var user_name string
  27182. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27183. if role.ID == 0 {
  27184. user_name = "管理员"
  27185. } else {
  27186. user_name = role.UserName
  27187. }
  27188. baseParams := models.BaseParams{
  27189. SecretKey: miConfig.SecretKey,
  27190. FixmedinsCode: miConfig.Code,
  27191. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27192. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27193. OrgName: miConfig.OrgName,
  27194. Doctor: user_name,
  27195. }
  27196. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  27197. var dat map[string]interface{}
  27198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27199. fmt.Println(dat)
  27200. } else {
  27201. fmt.Println(err)
  27202. }
  27203. userJSONBytes, _ := json.Marshal(dat)
  27204. var res ResultNine
  27205. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27206. utils.ErrorLog("解析失败:%v", err)
  27207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27208. return
  27209. }
  27210. if res.Infcode == 0 {
  27211. fileNo := res.Output.FileQuryNo
  27212. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  27213. "file_qury_no=" + fileNo +
  27214. "&setl_optins=" + "定点医保中心" +
  27215. "&stmt_begndate=" + start_time +
  27216. "&stm_enddate=" + end_time +
  27217. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  27218. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  27219. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  27220. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  27221. "&fixmedins_code=" + miConfig.Code +
  27222. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  27223. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27224. "&secret_key=" + miConfig.SecretKey +
  27225. "&org_name=" + miConfig.OrgName +
  27226. "&doctor=" + user_name
  27227. resp, requestErr := http.Get(api)
  27228. if requestErr != nil {
  27229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27230. return
  27231. }
  27232. body, ioErr := ioutil.ReadAll(resp.Body)
  27233. if ioErr != nil {
  27234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27236. return
  27237. }
  27238. var respJSON map[string]interface{}
  27239. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27242. return
  27243. }
  27244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27245. userJSONBytes, _ := json.Marshal(respJSON)
  27246. var res ResultTen
  27247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27248. utils.ErrorLog("解析失败:%v", err)
  27249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27250. return
  27251. }
  27252. if res.Infcode == 0 {
  27253. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  27254. micc := &models.MedicalInsuranceCostCompare{
  27255. StartTime: startime.Unix(),
  27256. EndTime: endtime.Unix(),
  27257. Insutype: "0",
  27258. CheckType: 2,
  27259. Num: fixmedins_setl_cnt,
  27260. Mtime: time.Now().Unix(),
  27261. Status: 1,
  27262. UserOrgId: adminUser.CurrentOrgId,
  27263. CostTotal: medfee_sumamt,
  27264. FuncTotal: fund_pay_sumamt,
  27265. PsnPay: psn_cash_pay,
  27266. Creator: admin_user_id,
  27267. Ctime: time.Now().Unix(),
  27268. }
  27269. service.CreateMedicalInsuranceCostCompareRecord(micc)
  27270. c.ServeSuccessJSON(map[string]interface{}{
  27271. "msg": "明细对账成功",
  27272. })
  27273. }
  27274. } else {
  27275. }
  27276. }
  27277. }
  27278. type CustomOrderInfo struct {
  27279. Name string
  27280. Spec string
  27281. Unit string
  27282. Count float64
  27283. Price float64
  27284. Total float64
  27285. }
  27286. func (c *HisApiController) GetBatchSettleAccounts() {
  27287. admin_user_id, _ := c.GetInt64("admin_user_id")
  27288. order_ids := c.GetString("order_ids")
  27289. order_ids_arr := strings.Split(order_ids, ",")
  27290. data3 := []map[string]interface{}{}
  27291. for _, item := range order_ids_arr {
  27292. id, _ := strconv.ParseInt(item, 10, 64)
  27293. order_id := id
  27294. adminUser := c.GetAdminUserInfo()
  27295. order, _ := service.GetHisOrderByID(order_id)
  27296. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27297. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  27298. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  27299. orderInfos = append(orderInfos, orderInfos_two...)
  27300. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  27301. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  27302. var diagnosis_ids []string
  27303. if his.ID > 0 {
  27304. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  27305. } else {
  27306. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  27307. }
  27308. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  27309. var dia_config []*models.HisXtDiagnoseConfig
  27310. var name string
  27311. for _, item := range diagnosis_ids {
  27312. id, _ := strconv.ParseInt(item, 10, 64)
  27313. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27314. dia_config = append(dia_config, &diagnosisConfig)
  27315. if len(name) == 0 {
  27316. name = diagnosisConfig.ClassName
  27317. }
  27318. //} else {
  27319. // name = name + "," + diagnosisConfig.ClassName
  27320. //}
  27321. }
  27322. var bedCostTotal float64 = 0 //床位总费
  27323. var bedCostSelfTotal float64 = 0 //床位自费
  27324. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  27325. var bedSelfTotal float64 = 0 //床位部分项目自费
  27326. var bedInscpTotal float64 = 0 //床位部分项目自费
  27327. var operationCostTotal float64 = 0 //手术费
  27328. var operationCostSelfTotal float64 = 0 //手术费
  27329. var operationCostPartSelfTotal float64 = 0 //手术费
  27330. var operationSelfTotal float64 = 0 //床位部分项目自费
  27331. var operationInscpTotal float64 = 0 //床位部分项目自费
  27332. var otherCostTotal float64 = 0 //其他费用
  27333. var otherCostSelfTotal float64 = 0 //其他费用
  27334. var otherCostPartSelfTotal float64 = 0 //其他费用
  27335. var otherSelfTotal float64 = 0 //床位部分项目自费
  27336. var otherInscpTotal float64 = 0 //床位部分项目自费
  27337. var materialCostTotal float64 = 0 //材料费
  27338. var materialCostSelfTotal float64 = 0 //材料费
  27339. var materialCostPartSelfTotal float64 = 0 //材料费
  27340. var materialSelfTotal float64 = 0 //床位部分项目自费
  27341. var materialInscpTotal float64 = 0 //床位部分项目自费
  27342. var westernMedicineCostTotal float64 = 0 //西药费
  27343. var westernMedicineCostSelfTotal float64 = 0 //西药费
  27344. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  27345. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  27346. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  27347. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  27348. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  27349. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  27350. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  27351. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  27352. var checkCostTotal float64 = 0 //检查费
  27353. var checkCostSelfTotal float64 = 0 //检查费
  27354. var checkCostPartSelfTotal float64 = 0 //检查费
  27355. var checkSelfTotal float64 = 0 //床位部分项目自费
  27356. var checkInscpTotal float64 = 0 //床位部分项目自费
  27357. var laboratoryCostTotal float64 = 0 //化验费
  27358. var laboratoryCostSelfTotal float64 = 0 //化验费
  27359. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  27360. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  27361. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  27362. var treatCostTotal float64 = 0 //治疗费用
  27363. var treatCostSelfTotal float64 = 0 //治疗费用
  27364. var treatCostPartSelfTotal float64 = 0 //治疗费用
  27365. var treatSelfTotal float64 = 0 //床位部分项目自费
  27366. var treatInscpTotal float64 = 0 //床位部分项目自费
  27367. decimal.DivisionPrecision = 2
  27368. for _, item := range orderInfos {
  27369. if item.MedChrgitmType == "01" { //床位费
  27370. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27371. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27372. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27373. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27374. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27375. }
  27376. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  27377. if item.MedChrgitmType == "03" { //检查费
  27378. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27379. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27380. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27381. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27382. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27383. }
  27384. } else {
  27385. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  27386. fmt.Println("------------")
  27387. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27388. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27389. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27390. }
  27391. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  27392. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27393. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27394. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27395. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27396. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27397. }
  27398. }
  27399. if item.MedChrgitmType == "04" { //化验费
  27400. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27401. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27402. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27403. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27404. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27405. }
  27406. if item.MedChrgitmType == "05" { //治疗费
  27407. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27408. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27409. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27410. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27411. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27412. }
  27413. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  27414. fmt.Println("------------")
  27415. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27416. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27417. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27418. }
  27419. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  27420. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27421. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27422. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27423. }
  27424. //if item.MedChrgitmType == "06" { //手术费
  27425. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27426. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27427. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27428. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27429. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27430. //
  27431. //}
  27432. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  27433. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27434. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27435. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27436. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27437. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27438. }
  27439. if item.MedChrgitmType == "09" { //西药费
  27440. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27441. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27442. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27443. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27444. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27445. }
  27446. if item.MedChrgitmType == "11" { //中成费
  27447. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27448. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27449. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27450. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27451. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27452. }
  27453. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  27454. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27455. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27456. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27457. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27458. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27459. }
  27460. }
  27461. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27462. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27463. var user_name string
  27464. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27465. if role.ID == 0 {
  27466. user_name = "管理员"
  27467. } else {
  27468. user_name = role.UserName
  27469. }
  27470. baseParams := models.BaseParams{
  27471. SecretKey: miConfig.SecretKey,
  27472. FixmedinsCode: miConfig.Code,
  27473. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27474. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27475. OrgName: miConfig.OrgName,
  27476. Doctor: user_name,
  27477. RequestUrl: miConfig.Url,
  27478. AccessKey: miConfig.AccessKey,
  27479. }
  27480. businessParams := models.BusinessParams{
  27481. PsnNo: order.PsnNo,
  27482. MdtrtId: order.MdtrtId,
  27483. SetlId: order.SetlId,
  27484. }
  27485. var res ResultEleven
  27486. var resEleven10265 ResultEleven10265
  27487. if config.IsOpen == 1 {
  27488. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27489. result := service.Gdyb5203(baseParams, businessParams)
  27490. service.Gdyb5204(baseParams, businessParams)
  27491. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27492. var dat map[string]interface{}
  27493. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27494. fmt.Println(dat)
  27495. } else {
  27496. fmt.Println(err)
  27497. }
  27498. userJSONBytes, _ := json.Marshal(dat)
  27499. if miConfig.Code == "H15049901371" {
  27500. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27501. utils.ErrorLog("解析失败:%v", err)
  27502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27503. return
  27504. }
  27505. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27506. res.Output = resEleven10265.Output
  27507. res.ErrMsg = resEleven10265.ErrMsg
  27508. res.Cainfo = resEleven10265.Cainfo
  27509. res.WarnMsg = resEleven10265.WarnMsg
  27510. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27511. res.Infcode = infocode
  27512. } else {
  27513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27514. utils.ErrorLog("解析失败:%v", err)
  27515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27516. return
  27517. }
  27518. }
  27519. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27520. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27521. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27522. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27523. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27524. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27525. var doctor_name string
  27526. if roles.ID == 0 {
  27527. doctor_name = "管理员"
  27528. } else {
  27529. doctor_name = roles.UserName
  27530. }
  27531. yiliao_leibie := ""
  27532. switch order.MedType {
  27533. case "11":
  27534. yiliao_leibie = "普通门诊"
  27535. break
  27536. case "12":
  27537. yiliao_leibie = "门诊挂号"
  27538. break
  27539. case "13":
  27540. yiliao_leibie = "急诊"
  27541. break
  27542. case "14":
  27543. yiliao_leibie = "门诊特殊病"
  27544. break
  27545. case "15":
  27546. yiliao_leibie = "门诊统筹"
  27547. break
  27548. case "16":
  27549. yiliao_leibie = "门诊慢性病"
  27550. break
  27551. case "21":
  27552. yiliao_leibie = "普通住院"
  27553. break
  27554. }
  27555. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27556. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  27557. if res.Infcode == 0 {
  27558. data2 := map[string]interface{}{
  27559. "diagnosis": name,
  27560. "order_infos": orderInfos,
  27561. "number": order.MdtrtId,
  27562. "date": order.SettleAccountsDate,
  27563. "charge_admin": charge_admin,
  27564. "printor_admin": printor_admin,
  27565. "info": res.Output.Setlinfo,
  27566. "order": order,
  27567. "bedCostTotal": bedCostTotal,
  27568. "bedCostSelfTotal": bedCostSelfTotal,
  27569. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27570. "bedSelfTotal": bedSelfTotal,
  27571. "bedInscpTotal": bedInscpTotal,
  27572. "operationCostTotal": operationCostTotal,
  27573. "operationCostSelfTotal": operationCostSelfTotal,
  27574. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27575. "operationSelfTotal": operationSelfTotal,
  27576. "operationInscpTotal": operationInscpTotal,
  27577. "otherCostTotal": otherCostTotal,
  27578. "otherCostSelfTotal": otherCostSelfTotal,
  27579. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27580. "otherSelfTotal": otherSelfTotal,
  27581. "otherInscpTotal": otherInscpTotal,
  27582. "materialCostTotal": materialCostTotal,
  27583. "materialCostSelfTotal": materialCostSelfTotal,
  27584. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27585. "materialSelfTotal": materialSelfTotal,
  27586. "materialInscpTotal": materialInscpTotal,
  27587. "westernMedicineCostTotal": westernMedicineCostTotal,
  27588. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27589. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27590. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27591. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27592. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27593. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27594. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27595. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27596. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27597. "checkCostTotal": checkCostTotal,
  27598. "checkCostSelfTotal": checkCostSelfTotal,
  27599. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27600. "checkSelfTotal": checkSelfTotal,
  27601. "checkInscpTotal": checkInscpTotal,
  27602. "laboratoryCostTotal": laboratoryCostTotal,
  27603. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27604. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27605. "laboratorySelfTotal": laboratorySelfTotal,
  27606. "laboratoryInscpTotal": laboratoryInscpTotal,
  27607. "treatCostTotal": treatCostTotal,
  27608. "treatCostSelfTotal": treatCostSelfTotal,
  27609. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27610. "treatSelfTotal": treatSelfTotal,
  27611. "treatInscpTotal": treatInscpTotal,
  27612. "doctor_info": doctor_info,
  27613. "doctor_code": adminRole_two.DoctorCode,
  27614. "doctor_name": doctor_name,
  27615. "health_card_no": order.PsnNo,
  27616. "department": departments.Name,
  27617. "yiliao_leibie": yiliao_leibie,
  27618. "after_money": order.AccountPrice,
  27619. "patient": patient,
  27620. "org_name": miConfig.OrgName,
  27621. "org_code": miConfig.Code,
  27622. "order_number": order.Number,
  27623. "his_hospital": his_hospital,
  27624. "his": his,
  27625. "dia_config": dia_config,
  27626. "psn_cash_pay": order.PsnCashPay,
  27627. //"check_order_info": cus_slice,
  27628. }
  27629. data3 = append(data3, data2)
  27630. }
  27631. }
  27632. }
  27633. c.ServeSuccessJSON(map[string]interface{}{
  27634. "infos": data3,
  27635. })
  27636. }
  27637. func (c *HisApiController) GetSettleAccounts() {
  27638. //id, _ := c.GetInt64("id")
  27639. //record_time := c.GetString("record_time")
  27640. order_id, _ := c.GetInt64("order_id")
  27641. admin_user_id, _ := c.GetInt64("admin_user_id")
  27642. //timeLayout := "2006-01-02"
  27643. //loc, _ := time.LoadLocation("Local")
  27644. //
  27645. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27646. //if err != nil {
  27647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27648. // return
  27649. //}Hbyb5203
  27650. //recordDateTime := theTime.Unix()
  27651. adminUser := c.GetAdminUserInfo()
  27652. order, _ := service.GetHisOrderByID(order_id)
  27653. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27654. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  27655. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  27656. orderInfos = append(orderInfos, orderInfos_two...)
  27657. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  27658. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  27659. var diagnosis_ids []string
  27660. if his.ID > 0 {
  27661. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  27662. } else {
  27663. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  27664. }
  27665. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  27666. var dia_config []*models.HisXtDiagnoseConfig
  27667. var name string
  27668. for _, item := range diagnosis_ids {
  27669. id, _ := strconv.ParseInt(item, 10, 64)
  27670. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27671. dia_config = append(dia_config, &diagnosisConfig)
  27672. if len(name) == 0 {
  27673. name = diagnosisConfig.ClassName
  27674. } else {
  27675. name = name + "," + diagnosisConfig.ClassName
  27676. }
  27677. }
  27678. if patient.UserOrgId == 10215 {
  27679. name = "慢性肾功能不全(血透治疗)"
  27680. }
  27681. var bedCostTotal float64 = 0 //床位总费
  27682. var bedCostSelfTotal float64 = 0 //床位自费
  27683. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  27684. var bedSelfTotal float64 = 0 //床位部分项目自费
  27685. var bedInscpTotal float64 = 0 //床位部分项目自费
  27686. var operationCostTotal float64 = 0 //手术费
  27687. var operationCostSelfTotal float64 = 0 //手术费
  27688. var operationCostPartSelfTotal float64 = 0 //手术费
  27689. var operationSelfTotal float64 = 0 //床位部分项目自费
  27690. var operationInscpTotal float64 = 0 //床位部分项目自费
  27691. var otherCostTotal float64 = 0 //其他费用
  27692. var otherCostSelfTotal float64 = 0 //其他费用
  27693. var otherCostPartSelfTotal float64 = 0 //其他费用
  27694. var otherSelfTotal float64 = 0 //床位部分项目自费
  27695. var otherInscpTotal float64 = 0 //床位部分项目自费
  27696. var materialCostTotal float64 = 0 //材料费
  27697. var materialCostSelfTotal float64 = 0 //材料费
  27698. var materialCostPartSelfTotal float64 = 0 //材料费
  27699. var materialSelfTotal float64 = 0 //床位部分项目自费
  27700. var materialInscpTotal float64 = 0 //床位部分项目自费
  27701. var westernMedicineCostTotal float64 = 0 //西药费
  27702. var westernMedicineCostSelfTotal float64 = 0 //西药费
  27703. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  27704. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  27705. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  27706. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  27707. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  27708. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  27709. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  27710. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  27711. var checkCostTotal float64 = 0 //检查费
  27712. var checkCostSelfTotal float64 = 0 //检查费
  27713. var checkCostPartSelfTotal float64 = 0 //检查费
  27714. var checkSelfTotal float64 = 0 //床位部分项目自费
  27715. var checkInscpTotal float64 = 0 //床位部分项目自费
  27716. var laboratoryCostTotal float64 = 0 //化验费
  27717. var laboratoryCostSelfTotal float64 = 0 //化验费
  27718. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  27719. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  27720. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  27721. var treatCostTotal float64 = 0 //治疗费用
  27722. var treatCostSelfTotal float64 = 0 //治疗费用
  27723. var treatCostPartSelfTotal float64 = 0 //治疗费用
  27724. var treatSelfTotal float64 = 0 //床位部分项目自费
  27725. var treatInscpTotal float64 = 0 //床位部分项目自费
  27726. decimal.DivisionPrecision = 2
  27727. for _, item := range orderInfos {
  27728. if item.MedChrgitmType == "01" { //床位费
  27729. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27730. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27731. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27732. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27733. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27734. }
  27735. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  27736. if item.MedChrgitmType == "03" { //检查费
  27737. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27738. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27739. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27740. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27741. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27742. }
  27743. } else {
  27744. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  27745. fmt.Println("------------")
  27746. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27747. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27748. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27749. }
  27750. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  27751. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27752. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27753. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27754. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27755. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27756. }
  27757. }
  27758. if item.MedChrgitmType == "04" { //化验费
  27759. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27760. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27761. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27762. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27763. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27764. }
  27765. if item.MedChrgitmType == "05" { //治疗费
  27766. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27767. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27768. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27769. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27770. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27771. }
  27772. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  27773. fmt.Println("------------")
  27774. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27775. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27776. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27777. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27778. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27779. }
  27780. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  27781. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27782. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27783. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27784. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27785. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27786. }
  27787. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  27788. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27789. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27790. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27791. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27792. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27793. }
  27794. if item.MedChrgitmType == "09" { //西药费
  27795. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27796. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27797. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27798. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27799. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27800. }
  27801. if item.MedChrgitmType == "11" { //中成费
  27802. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27803. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27804. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27805. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27806. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27807. }
  27808. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  27809. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27810. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27811. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27812. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27813. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27814. }
  27815. }
  27816. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27817. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27818. var user_name string
  27819. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27820. if role.ID == 0 {
  27821. user_name = "管理员"
  27822. } else {
  27823. user_name = role.UserName
  27824. }
  27825. baseParams := models.BaseParams{
  27826. SecretKey: miConfig.SecretKey,
  27827. FixmedinsCode: miConfig.Code,
  27828. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27829. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27830. OrgName: miConfig.OrgName,
  27831. Doctor: user_name,
  27832. RequestUrl: miConfig.Url,
  27833. AccessKey: miConfig.AccessKey,
  27834. }
  27835. businessParams := models.BusinessParams{
  27836. PsnNo: order.PsnNo,
  27837. MdtrtId: order.MdtrtId,
  27838. SetlId: order.SetlId,
  27839. }
  27840. var res ResultEleven
  27841. var resah ResultElevenah
  27842. var resEleven10265 ResultEleven10265
  27843. if config.IsOpen == 1 {
  27844. if miConfig.MdtrtareaAdmvs == "421300" {
  27845. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27846. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27847. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27848. resp, requestErr := http.Get(api)
  27849. if requestErr != nil {
  27850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27851. return
  27852. }
  27853. body, ioErr := ioutil.ReadAll(resp.Body)
  27854. if ioErr != nil {
  27855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27857. return
  27858. }
  27859. var respJSON map[string]interface{}
  27860. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27863. return
  27864. }
  27865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27866. result, _ := json.Marshal(respJSON)
  27867. fmt.Println("log")
  27868. fmt.Println(string(result))
  27869. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27870. utils.ErrorLog("解析失败:%v", err)
  27871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27872. return
  27873. }
  27874. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27875. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27876. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27877. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27878. resp, requestErr := http.Get(api)
  27879. if requestErr != nil {
  27880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27881. return
  27882. }
  27883. body, ioErr := ioutil.ReadAll(resp.Body)
  27884. if ioErr != nil {
  27885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27887. return
  27888. }
  27889. var respJSON map[string]interface{}
  27890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27893. return
  27894. }
  27895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27896. result, _ := json.Marshal(respJSON)
  27897. fmt.Println("log")
  27898. fmt.Println(string(result))
  27899. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27900. utils.ErrorLog("解析失败:%v", err)
  27901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27902. return
  27903. }
  27904. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27905. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27906. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27907. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27908. resp, requestErr := http.Get(api)
  27909. if requestErr != nil {
  27910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27911. return
  27912. }
  27913. body, ioErr := ioutil.ReadAll(resp.Body)
  27914. if ioErr != nil {
  27915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27917. return
  27918. }
  27919. var respJSON map[string]interface{}
  27920. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27923. return
  27924. }
  27925. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27926. result, _ := json.Marshal(respJSON)
  27927. fmt.Println("log")
  27928. fmt.Println(string(result))
  27929. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27930. utils.ErrorLog("解析失败:%v", err)
  27931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27932. return
  27933. }
  27934. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27935. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27936. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27937. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  27938. resp, requestErr := http.Get(api)
  27939. if requestErr != nil {
  27940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27941. return
  27942. }
  27943. body, ioErr := ioutil.ReadAll(resp.Body)
  27944. if ioErr != nil {
  27945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27947. return
  27948. }
  27949. var respJSON map[string]interface{}
  27950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27953. return
  27954. }
  27955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27956. result, _ := json.Marshal(respJSON)
  27957. fmt.Println("log")
  27958. fmt.Println(string(result))
  27959. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27960. utils.ErrorLog("解析失败:%v", err)
  27961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27962. return
  27963. }
  27964. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27965. var api string
  27966. if miConfig.MdtrtareaAdmvs == "320921" {
  27967. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27968. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27969. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27970. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27971. } else {
  27972. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27973. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27974. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27975. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27976. }
  27977. resp, requestErr := http.Get(api)
  27978. if requestErr != nil {
  27979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27980. return
  27981. }
  27982. body, ioErr := ioutil.ReadAll(resp.Body)
  27983. if ioErr != nil {
  27984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27986. return
  27987. }
  27988. var respJSON map[string]interface{}
  27989. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27992. return
  27993. }
  27994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27995. result, _ := json.Marshal(respJSON)
  27996. fmt.Println("log")
  27997. fmt.Println(string(result))
  27998. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27999. utils.ErrorLog("解析失败:%v", err)
  28000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28001. return
  28002. }
  28003. res.InfRefmsgid = resEleven10265.InfRefmsgid
  28004. res.Output = resEleven10265.Output
  28005. res.ErrMsg = resEleven10265.ErrMsg
  28006. res.Cainfo = resEleven10265.Cainfo
  28007. res.WarnMsg = resEleven10265.WarnMsg
  28008. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  28009. res.Infcode = infocode
  28010. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28011. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  28012. saveLog(result, requestLog, "5203", "结算单")
  28013. var dat map[string]interface{}
  28014. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28015. fmt.Println(dat)
  28016. } else {
  28017. fmt.Println(err)
  28018. }
  28019. userJSONBytes, _ := json.Marshal(dat)
  28020. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28021. utils.ErrorLog("解析失败:%v", err)
  28022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28023. return
  28024. }
  28025. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28026. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  28027. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  28028. fmt.Println(result3)
  28029. fmt.Println(requestLog3)
  28030. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  28031. fmt.Println(result2)
  28032. fmt.Println(requestLog2)
  28033. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  28034. saveLog(result, requestLog, "5203", "结算单")
  28035. var dat map[string]interface{}
  28036. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28037. fmt.Println(dat)
  28038. } else {
  28039. fmt.Println(err)
  28040. }
  28041. userJSONBytes, _ := json.Marshal(dat)
  28042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28043. utils.ErrorLog("解析失败:%v", err)
  28044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28045. return
  28046. }
  28047. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28048. var api string
  28049. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  28050. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  28051. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28052. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28053. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28054. resp, requestErr := http.Get(api)
  28055. if requestErr != nil {
  28056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28057. return
  28058. }
  28059. body, ioErr := ioutil.ReadAll(resp.Body)
  28060. if ioErr != nil {
  28061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28063. return
  28064. }
  28065. var respJSON map[string]interface{}
  28066. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28069. return
  28070. }
  28071. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28072. if status == "0" {
  28073. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28074. c.ServeSuccessJSON(map[string]interface{}{
  28075. "failed_code": -10,
  28076. "msg": err_msg,
  28077. })
  28078. return
  28079. }
  28080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28081. result, _ := json.Marshal(respJSON)
  28082. fmt.Println("log")
  28083. fmt.Println(string(result))
  28084. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  28085. utils.ErrorLog("解析失败:%v", err)
  28086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28087. return
  28088. }
  28089. res.InfRefmsgid = resah.InfRefmsgid
  28090. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28091. // 创建对应的Time类型
  28092. t := time.UnixMilli(timestamp)
  28093. // 格式化成指定的日期字符串
  28094. str := t.Format("2006-01-02 15:04:05")
  28095. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28096. // 创建对应的Time类型
  28097. t3 := time.UnixMilli(timestamp2)
  28098. // 格式化成指定的日期字符串
  28099. str2 := t3.Format("2006-01-02 15:04:05")
  28100. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  28101. // 创建对应的Time类型
  28102. t4 := time.UnixMilli(timestamp3)
  28103. // 格式化成指定的日期字符串
  28104. str3 := t4.Format("2006-01-02 15:04:05")
  28105. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  28106. // 创建对应的Time类型
  28107. t5 := time.UnixMilli(timestamp4)
  28108. // 格式化成指定的日期字符串
  28109. str5 := t5.Format("2006-01-02 15:04:05")
  28110. res.Output.Setlinfo.Brdy = str2
  28111. res.Output.Setlinfo.SetlTime = str
  28112. res.Output.Setlinfo.Begndate = str3
  28113. res.Output.Setlinfo.Enddate = str5
  28114. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  28115. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  28116. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  28117. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  28118. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  28119. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  28120. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  28121. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  28122. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  28123. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  28124. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  28125. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  28126. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28127. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  28128. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  28129. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  28130. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  28131. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  28132. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  28133. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  28134. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  28135. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  28136. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  28137. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  28138. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  28139. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28140. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  28141. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  28142. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  28143. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  28144. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28145. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  28146. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  28147. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  28148. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  28149. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  28150. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  28151. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  28152. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  28153. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  28154. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  28155. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  28156. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  28157. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  28158. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  28159. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28160. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  28161. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  28162. //res.Output.Setldetail = resah.Output.Setldetail
  28163. res.ErrMsg = resah.ErrMsg
  28164. res.Cainfo = resah.Cainfo
  28165. res.WarnMsg = resah.WarnMsg
  28166. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28167. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  28168. saveLog(result, requestLog, "5203", "结算单")
  28169. var dat map[string]interface{}
  28170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28171. fmt.Println(dat)
  28172. } else {
  28173. fmt.Println(err)
  28174. }
  28175. userJSONBytes, _ := json.Marshal(dat)
  28176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28177. utils.ErrorLog("解析失败:%v", err)
  28178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28179. return
  28180. }
  28181. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28182. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  28183. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  28184. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28185. resp, requestErr := http.Get(api)
  28186. if requestErr != nil {
  28187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28188. return
  28189. }
  28190. body, ioErr := ioutil.ReadAll(resp.Body)
  28191. if ioErr != nil {
  28192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28194. return
  28195. }
  28196. var respJSON map[string]interface{}
  28197. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28200. return
  28201. }
  28202. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28203. result, _ := json.Marshal(respJSON)
  28204. fmt.Println("log")
  28205. fmt.Println(string(result))
  28206. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  28207. utils.ErrorLog("解析失败:%v", err)
  28208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28209. return
  28210. }
  28211. res.InfRefmsgid = resEleven10265.InfRefmsgid
  28212. res.Output = resEleven10265.Output
  28213. res.ErrMsg = resEleven10265.ErrMsg
  28214. res.Cainfo = resEleven10265.Cainfo
  28215. res.WarnMsg = resEleven10265.WarnMsg
  28216. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  28217. res.Infcode = infocode
  28218. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28219. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  28220. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  28221. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28222. resp, requestErr := http.Get(api)
  28223. if requestErr != nil {
  28224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28225. return
  28226. }
  28227. body, ioErr := ioutil.ReadAll(resp.Body)
  28228. if ioErr != nil {
  28229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28231. return
  28232. }
  28233. var respJSON map[string]interface{}
  28234. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28237. return
  28238. }
  28239. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28240. result, _ := json.Marshal(respJSON)
  28241. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28242. utils.ErrorLog("解析失败:%v", err)
  28243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28244. return
  28245. }
  28246. } else if miConfig.MdtrtareaAdmvs == "450721" {
  28247. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  28248. //return
  28249. } else {
  28250. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  28251. if len(his.InsuplcAdmdvs) == 0 {
  28252. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  28253. } else {
  28254. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  28255. }
  28256. result := service.Gdyb5203(baseParams, businessParams)
  28257. //service.Gdyb5204(baseParams, businessParams)
  28258. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  28259. var dat map[string]interface{}
  28260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28261. fmt.Println(dat)
  28262. } else {
  28263. fmt.Println(err)
  28264. }
  28265. userJSONBytes, _ := json.Marshal(dat)
  28266. if miConfig.Code == "H15049901371" {
  28267. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  28268. utils.ErrorLog("解析失败:%v", err)
  28269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28270. return
  28271. }
  28272. res.InfRefmsgid = resEleven10265.InfRefmsgid
  28273. res.Output = resEleven10265.Output
  28274. res.ErrMsg = resEleven10265.ErrMsg
  28275. res.Cainfo = resEleven10265.Cainfo
  28276. res.WarnMsg = resEleven10265.WarnMsg
  28277. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  28278. res.Infcode = infocode
  28279. } else {
  28280. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28281. utils.ErrorLog("解析失败:%v", err)
  28282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28283. return
  28284. }
  28285. }
  28286. }
  28287. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28288. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  28289. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  28290. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  28291. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  28292. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28293. var doctor_name string
  28294. if roles.ID == 0 {
  28295. doctor_name = "管理员"
  28296. } else {
  28297. doctor_name = roles.UserName
  28298. }
  28299. yiliao_leibie := ""
  28300. switch order.MedType {
  28301. case "11":
  28302. yiliao_leibie = "普通门诊"
  28303. break
  28304. case "12":
  28305. yiliao_leibie = "门诊挂号"
  28306. break
  28307. case "13":
  28308. yiliao_leibie = "急诊"
  28309. break
  28310. case "14":
  28311. yiliao_leibie = "门诊特殊病"
  28312. break
  28313. case "15":
  28314. yiliao_leibie = "门诊统筹"
  28315. break
  28316. case "16":
  28317. yiliao_leibie = "门诊慢性病"
  28318. break
  28319. case "21":
  28320. yiliao_leibie = "普通住院"
  28321. break
  28322. }
  28323. //var rf []CustomFundPay
  28324. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  28325. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28326. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  28327. if res.Infcode == 0 {
  28328. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  28329. c.ServeSuccessJSON(map[string]interface{}{
  28330. "diagnosis": name,
  28331. "order_infos": orderInfos,
  28332. "number": order.MdtrtId,
  28333. "date": order.SettleAccountsDate,
  28334. "charge_admin": charge_admin,
  28335. "printor_admin": printor_admin,
  28336. "info": res.Output.Setlinfo,
  28337. "order": order,
  28338. "bedCostTotal": bedCostTotal,
  28339. "bedCostSelfTotal": bedCostSelfTotal,
  28340. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  28341. "bedSelfTotal": bedSelfTotal,
  28342. "bedInscpTotal": bedInscpTotal,
  28343. "operationCostTotal": operationCostTotal,
  28344. "operationCostSelfTotal": operationCostSelfTotal,
  28345. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  28346. "operationSelfTotal": operationSelfTotal,
  28347. "operationInscpTotal": operationInscpTotal,
  28348. "otherCostTotal": otherCostTotal,
  28349. "otherCostSelfTotal": otherCostSelfTotal,
  28350. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  28351. "otherSelfTotal": otherSelfTotal,
  28352. "otherInscpTotal": otherInscpTotal,
  28353. "materialCostTotal": materialCostTotal,
  28354. "materialCostSelfTotal": materialCostSelfTotal,
  28355. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  28356. "materialSelfTotal": materialSelfTotal,
  28357. "materialInscpTotal": materialInscpTotal,
  28358. "westernMedicineCostTotal": westernMedicineCostTotal,
  28359. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  28360. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  28361. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  28362. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  28363. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  28364. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  28365. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  28366. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  28367. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  28368. "checkCostTotal": checkCostTotal,
  28369. "checkCostSelfTotal": checkCostSelfTotal,
  28370. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  28371. "checkSelfTotal": checkSelfTotal,
  28372. "checkInscpTotal": checkInscpTotal,
  28373. "laboratoryCostTotal": laboratoryCostTotal,
  28374. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  28375. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  28376. "laboratorySelfTotal": laboratorySelfTotal,
  28377. "laboratoryInscpTotal": laboratoryInscpTotal,
  28378. "treatCostTotal": treatCostTotal,
  28379. "treatCostSelfTotal": treatCostSelfTotal,
  28380. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  28381. "treatSelfTotal": treatSelfTotal,
  28382. "treatInscpTotal": treatInscpTotal,
  28383. "doctor_info": doctor_info,
  28384. "doctor_code": adminRole_two.DoctorCode,
  28385. "doctor_name": doctor_name,
  28386. "health_card_no": order.PsnNo,
  28387. "department": departments.Name,
  28388. "yiliao_leibie": yiliao_leibie,
  28389. "after_money": order.AccountPrice,
  28390. "patient": patient,
  28391. "org_name": miConfig.OrgName,
  28392. "org_code": miConfig.Code,
  28393. "order_number": order.Number,
  28394. "his_hospital": his_hospital,
  28395. "his": his,
  28396. "dia_config": dia_config,
  28397. "psn_cash_pay": order.PsnCashPay,
  28398. //"funds": rf,
  28399. //"check_order_info": cus_slice,
  28400. })
  28401. } else {
  28402. c.ServeSuccessJSON(map[string]interface{}{
  28403. "diagnosis": name,
  28404. "order_infos": orderInfos,
  28405. "number": order.MdtrtId,
  28406. "date": order.SettleAccountsDate,
  28407. "charge_admin": charge_admin,
  28408. "printor_admin": printor_admin,
  28409. "info": order,
  28410. "order": order,
  28411. "bedCostTotal": bedCostTotal,
  28412. "bedCostSelfTotal": bedCostSelfTotal,
  28413. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  28414. "bedSelfTotal": bedSelfTotal,
  28415. "bedInscpTotal": bedInscpTotal,
  28416. "operationCostTotal": operationCostTotal,
  28417. "operationCostSelfTotal": operationCostSelfTotal,
  28418. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  28419. "operationSelfTotal": operationSelfTotal,
  28420. "operationInscpTotal": operationInscpTotal,
  28421. "otherCostTotal": otherCostTotal,
  28422. "otherCostSelfTotal": otherCostSelfTotal,
  28423. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  28424. "otherSelfTotal": otherSelfTotal,
  28425. "otherInscpTotal": otherInscpTotal,
  28426. "materialCostTotal": materialCostTotal,
  28427. "materialCostSelfTotal": materialCostSelfTotal,
  28428. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  28429. "materialSelfTotal": materialSelfTotal,
  28430. "materialInscpTotal": materialInscpTotal,
  28431. "westernMedicineCostTotal": westernMedicineCostTotal,
  28432. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  28433. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  28434. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  28435. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  28436. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  28437. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  28438. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  28439. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  28440. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  28441. "checkCostTotal": checkCostTotal,
  28442. "checkCostSelfTotal": checkCostSelfTotal,
  28443. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  28444. "checkSelfTotal": checkSelfTotal,
  28445. "checkInscpTotal": checkInscpTotal,
  28446. "laboratoryCostTotal": laboratoryCostTotal,
  28447. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  28448. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  28449. "laboratorySelfTotal": laboratorySelfTotal,
  28450. "laboratoryInscpTotal": laboratoryInscpTotal,
  28451. "treatCostTotal": treatCostTotal,
  28452. "treatCostSelfTotal": treatCostSelfTotal,
  28453. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  28454. "treatSelfTotal": treatSelfTotal,
  28455. "treatInscpTotal": treatInscpTotal,
  28456. "doctor_info": doctor_info,
  28457. "doctor_code": adminRole_two.DoctorCode,
  28458. "doctor_name": doctor_name,
  28459. "health_card_no": order.PsnNo,
  28460. "department": departments.Name,
  28461. "yiliao_leibie": yiliao_leibie,
  28462. "after_money": order.AccountPrice,
  28463. "patient": patient,
  28464. "org_name": miConfig.OrgName,
  28465. "org_code": miConfig.Code,
  28466. "order_number": order.Number,
  28467. "his_hospital": his_hospital,
  28468. "his": his,
  28469. "dia_config": dia_config,
  28470. "psn_cash_pay": order.PsnCashPay,
  28471. //"funds": rf,
  28472. //"check_order_info": cus_slice,
  28473. })
  28474. }
  28475. }
  28476. }
  28477. }
  28478. //func (c *HisApiController) CheckTreatment() {
  28479. // patient_id, _ := c.GetInt64("patient_id")
  28480. // id_card_no := c.GetString("id_card_no")
  28481. // insutype := c.GetString("insutype")
  28482. // med_type := c.GetString("med_type")
  28483. // admin_user_id, _ := c.GetInt64("admin_user_id")
  28484. //
  28485. // adminUser := c.GetAdminUserInfo()
  28486. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28487. //
  28488. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28489. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28490. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28491. //
  28492. // if miConfig.MdtrtareaAdmvs == "421300" {
  28493. // var res ResultTwo
  28494. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  28495. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28496. // "&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)
  28497. // resp, requestErr := http.Get(api)
  28498. // if requestErr != nil {
  28499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28500. // return
  28501. // }
  28502. //
  28503. // body, ioErr := ioutil.ReadAll(resp.Body)
  28504. // if ioErr != nil {
  28505. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28507. // return
  28508. // }
  28509. // var respJSON map[string]interface{}
  28510. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28511. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28512. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28513. // return
  28514. // }
  28515. //
  28516. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28517. // result, _ := json.Marshal(respJSON)
  28518. //
  28519. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  28520. // utils.ErrorLog("解析失败:%v", err)
  28521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28522. // return
  28523. // }
  28524. //
  28525. // if res.Infcode == 0 {
  28526. //
  28527. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  28528. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28529. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  28530. // resp, requestErr := http.Get(api)
  28531. // if requestErr != nil {
  28532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28533. // return
  28534. // }
  28535. //
  28536. // body, ioErr := ioutil.ReadAll(resp.Body)
  28537. // if ioErr != nil {
  28538. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28540. // return
  28541. // }
  28542. // var respJSON map[string]interface{}
  28543. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28544. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28546. // return
  28547. // }
  28548. // var res Result2001
  28549. //
  28550. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28551. // result2, _ := json.Marshal(respJSON)
  28552. //
  28553. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  28554. // utils.ErrorLog("解析失败:%v", err)
  28555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28556. // return
  28557. // }
  28558. //
  28559. // if res.Infcode == 0 {
  28560. // c.ServeSuccessJSON(map[string]interface{}{
  28561. // "msg": res.Output.Trtinfo,
  28562. // })
  28563. // }
  28564. //
  28565. // } else {
  28566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28567. // return
  28568. // }
  28569. //
  28570. // } else {
  28571. //
  28572. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28573. // var dat map[string]interface{}
  28574. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28575. // fmt.Println(dat)
  28576. // } else {
  28577. // fmt.Println(err)
  28578. // }
  28579. // userJSONBytes, _ := json.Marshal(dat)
  28580. // var res ResultTwo
  28581. // var res10265 ResultTwo10265
  28582. // if miConfig.Code == "H15049901371" {
  28583. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28584. // utils.ErrorLog("解析失败:%v", err)
  28585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28586. // return
  28587. // }
  28588. // res.ErrMsg = res10265.ErrMsg
  28589. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28590. // res.Infcode = infocode
  28591. // res.Output = res10265.Output
  28592. // res.InfRefmsgid = res10265.InfRefmsgid
  28593. // } else {
  28594. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28595. // utils.ErrorLog("解析失败:%v", err)
  28596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28597. // return
  28598. // }
  28599. // }
  28600. //
  28601. // var user_name string
  28602. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  28603. // if role.ID == 0 {
  28604. // user_name = "xxx"
  28605. // } else {
  28606. // user_name = role.UserName
  28607. // }
  28608. //
  28609. // baseParams := models.BaseParams{
  28610. // SecretKey: miConfig.SecretKey,
  28611. // FixmedinsCode: miConfig.Code,
  28612. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28613. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28614. // OrgName: miConfig.OrgName,
  28615. // Doctor: user_name,
  28616. // }
  28617. //
  28618. // if config.IsOpen == 1 {
  28619. // if miConfig.Code == "H15049901371" {
  28620. // if med_type == "14" {
  28621. // if insutype == "390" {
  28622. // med_type = "9933"
  28623. // } else if insutype == "310" {
  28624. // med_type = "990502"
  28625. // }
  28626. // } else if med_type == "11" {
  28627. // med_type = "11"
  28628. // }
  28629. // }
  28630. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  28631. // var dat map[string]interface{}
  28632. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28633. // fmt.Println(dat)
  28634. // } else {
  28635. // fmt.Println(err)
  28636. // }
  28637. // var res Result2001
  28638. // var res10265 Result2001Org10265
  28639. // if miConfig.Code == "H15049901371" {
  28640. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28641. // utils.ErrorLog("解析失败:%v", err)
  28642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28643. // return
  28644. // }
  28645. // res.ErrMsg = res10265.ErrMsg
  28646. // res.Output = res10265.Output
  28647. // res.InfRefmsgid = res10265.InfRefmsgid
  28648. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28649. // res.Infcode = infocode
  28650. // } else {
  28651. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  28652. // utils.ErrorLog("解析失败:%v", err)
  28653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28654. // return
  28655. // }
  28656. // }
  28657. // if res.Infcode == 0 {
  28658. // c.ServeSuccessJSON(map[string]interface{}{
  28659. // "msg": res.Output.Trtinfo,
  28660. // })
  28661. // }
  28662. // }
  28663. // }
  28664. //}
  28665. //func (c *HisApiController) PutRecord() {
  28666. // id, _ := c.GetInt64("id")
  28667. // record_time := c.GetString("record_time")
  28668. // timeLayout := "2006-01-02"
  28669. // loc, _ := time.LoadLocation("Local")
  28670. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28671. // if err != nil {
  28672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28673. // return
  28674. // }
  28675. // recordDateTime := theTime.Unix()
  28676. //
  28677. // adminInfo := c.GetAdminUserInfo()
  28678. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  28679. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28680. //
  28681. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  28682. //
  28683. // fmt.Println(miConfig.SecretKey)
  28684. //
  28685. // if patient == nil {
  28686. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28687. // return
  28688. // }
  28689. // if len(patient.IdCardNo) == 0 {
  28690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  28691. // return
  28692. // }
  28693. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  28694. // if config.IsOpen == 1 {
  28695. // 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
  28696. // resp, requestErr := http.Get(api)
  28697. // if requestErr != nil {
  28698. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28699. // return
  28700. // }
  28701. // defer resp.Body.Close()
  28702. // body, ioErr := ioutil.ReadAll(resp.Body)
  28703. // if ioErr != nil {
  28704. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28706. // return
  28707. // }
  28708. // var respJSON map[string]interface{}
  28709. //
  28710. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28711. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28713. // return
  28714. // }
  28715. //
  28716. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28717. // userJSONBytes, _ := json.Marshal(userJSON)
  28718. // var res ResultTwo
  28719. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28720. // utils.ErrorLog("解析失败:%v", err)
  28721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28722. // return
  28723. // }
  28724. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28725. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28726. // infoStr := string(Iinfos)
  28727. // idetinfoStr := string(Idetinfos)
  28728. //
  28729. // if res.Infcode == 0 {
  28730. // his := models.VMHisPatient{
  28731. // Status: 1,
  28732. // Ctime: time.Now().Unix(),
  28733. // Mtime: time.Now().Unix(),
  28734. // PsnNo: res.Output.Baseinfo.PsnNo,
  28735. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  28736. // Certno: res.Output.Baseinfo.Certno,
  28737. // PsnName: res.Output.Baseinfo.PsnName,
  28738. // Gend: res.Output.Baseinfo.Gend,
  28739. // Naty: res.Output.Baseinfo.Naty,
  28740. // Brdy: res.Output.Baseinfo.Brdy,
  28741. // Age: res.Output.Baseinfo.Age,
  28742. // Iinfo: infoStr,
  28743. // Idetinfo: idetinfoStr,
  28744. // PatientId: patient.ID,
  28745. // RecordDate: theTime.Unix(),
  28746. // UserOrgId: adminInfo.CurrentOrgId,
  28747. // AdminUserId: adminInfo.AdminUser.Id,
  28748. // IsReturn: 1,
  28749. // }
  28750. //
  28751. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  28752. // //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")
  28753. // //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")
  28754. //
  28755. // //var dat map[string]interface{}
  28756. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28757. // // fmt.Println(dat)
  28758. // //} else {
  28759. // // fmt.Println(err)
  28760. // //}
  28761. //
  28762. // var dat2 map[string]interface{}
  28763. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28764. // fmt.Println(dat2)
  28765. // } else {
  28766. // fmt.Println(err)
  28767. // }
  28768. //
  28769. // } else {
  28770. // adminUser := c.GetAdminUserInfo()
  28771. // errlog := &models.HisOrderError{
  28772. // UserOrgId: adminUser.CurrentOrgId,
  28773. // Ctime: time.Now().Unix(),
  28774. // Mtime: time.Now().Unix(),
  28775. // ErrMsg: res.ErrMsg,
  28776. // Status: 1,
  28777. // PatientId: id,
  28778. // RecordTime: recordDateTime,
  28779. // Stage: 1,
  28780. // }
  28781. // service.CreateErrMsgLog(errlog)
  28782. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  28783. // return
  28784. // }
  28785. // }
  28786. //
  28787. //}
  28788. //func (c *HisApiController) GetUploadDiag() {
  28789. // id, _ := c.GetInt64("id")
  28790. // record_time := c.GetString("record_time")
  28791. //
  28792. // diagnosis_id, _ := c.GetInt64("diagnosis")
  28793. // sick_type, _ := c.GetInt64("sick_type")
  28794. // reg_type, _ := c.GetInt64("reg_type")
  28795. //
  28796. // timeLayout := "2006-01-02"
  28797. // loc, _ := time.LoadLocation("Local")
  28798. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28799. // if err != nil {
  28800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28801. // return
  28802. // }
  28803. //
  28804. // var patientPrescription models.HisPrescriptionInfo
  28805. // recordDateTime := theTime.Unix()
  28806. // adminInfo := c.GetAdminUserInfo()
  28807. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28808. //
  28809. // if patientPrescription.ID == 0 {
  28810. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28811. // }
  28812. //
  28813. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  28814. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28815. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28816. // sickConfig, _ := service.FindSickById(sick_type)
  28817. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28818. //
  28819. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  28820. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  28821. // "&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 +
  28822. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  28823. // resp2, requestErr2 := http.Get(api2)
  28824. // if requestErr2 != nil {
  28825. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28826. // return
  28827. // }
  28828. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  28829. // if ioErr2 != nil {
  28830. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  28831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28832. // return
  28833. // }
  28834. // var respJSON2 map[string]interface{}
  28835. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  28836. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28838. // return
  28839. // }
  28840. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28841. // userJSONBytes2, _ := json.Marshal(respJSON2)
  28842. //
  28843. // var res2 ResultSix
  28844. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28845. // utils.ErrorLog("解析失败:%v", err)
  28846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28847. // return
  28848. // }
  28849. // if res2.Infcode != 0 {
  28850. // adminUser := c.GetAdminUserInfo()
  28851. // errlog := &models.HisOrderError{
  28852. // UserOrgId: adminUser.CurrentOrgId,
  28853. // Ctime: time.Now().Unix(),
  28854. // Mtime: time.Now().Unix(),
  28855. // ErrMsg: res2.ErrMsg,
  28856. // Status: 1,
  28857. // PatientId: id,
  28858. // RecordTime: recordDateTime,
  28859. // Stage: 3,
  28860. // }
  28861. // service.CreateErrMsgLog(errlog)
  28862. //
  28863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  28864. // return
  28865. // }
  28866. //
  28867. // c.ServeSuccessJSON(map[string]interface{}{
  28868. // "msg": "上传成功",
  28869. // })
  28870. //
  28871. //}
  28872. type QueryResult struct {
  28873. ID int64
  28874. Name string
  28875. Code string
  28876. List_type_code string
  28877. }
  28878. func (c *HisApiController) GetCheckCode() {
  28879. ids_str := c.GetString("ids")
  28880. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  28881. ids_arr := strings.Split(ids_str, ",")
  28882. var queryResult []QueryResult
  28883. ids := make([]int64, 0)
  28884. for _, item := range ids_arr {
  28885. id, _ := strconv.ParseInt(item, 10, 64)
  28886. ids = append(ids, id)
  28887. }
  28888. if record_type == 1 {
  28889. drugs, _ := service.GetBatchDrugList(ids)
  28890. for _, item := range drugs {
  28891. result := QueryResult{
  28892. ID: item.ID,
  28893. Name: item.DrugName,
  28894. Code: item.MedicalInsuranceNumber,
  28895. List_type_code: "101",
  28896. }
  28897. queryResult = append(queryResult, result)
  28898. }
  28899. } else if record_type == 2 {
  28900. goods, _ := service.GetBatchGoodInformationList(ids)
  28901. fmt.Println(goods)
  28902. for _, item := range goods {
  28903. result := QueryResult{
  28904. ID: item.ID,
  28905. Name: item.GoodName,
  28906. Code: item.SocialSecurityDirectoryCode,
  28907. List_type_code: "301",
  28908. }
  28909. queryResult = append(queryResult, result)
  28910. }
  28911. } else if record_type == 3 {
  28912. projects, _ := service.GetBathchMyPorjecgList(ids)
  28913. for _, item := range projects {
  28914. result := QueryResult{
  28915. ID: item.ID,
  28916. Name: item.ProjectName,
  28917. Code: item.MedicalCode,
  28918. List_type_code: "201",
  28919. }
  28920. queryResult = append(queryResult, result)
  28921. }
  28922. }
  28923. admin_user_id, _ := c.GetInt64("admin_user_id")
  28924. adminUser := c.GetAdminUserInfo()
  28925. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28926. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28927. var user_name string
  28928. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28929. if role.ID == 0 {
  28930. user_name = "管理员"
  28931. } else {
  28932. user_name = role.UserName
  28933. }
  28934. baseParams := models.BaseParams{
  28935. SecretKey: miConfig.SecretKey,
  28936. FixmedinsCode: miConfig.Code,
  28937. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28938. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28939. OrgName: miConfig.OrgName,
  28940. Doctor: user_name,
  28941. }
  28942. var result string
  28943. if miConfig.MdtrtareaAdmvs == "430800" {
  28944. for _, item := range queryResult {
  28945. if record_type == 1 {
  28946. 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)
  28947. } else if record_type == 2 {
  28948. fmt.Println(item.Code)
  28949. 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)
  28950. } else if record_type == 3 {
  28951. 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)
  28952. }
  28953. var dat map[string]interface{}
  28954. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28955. fmt.Println(dat)
  28956. } else {
  28957. fmt.Println(err)
  28958. }
  28959. userJSONBytes, _ := json.Marshal(dat)
  28960. var res ResultSix
  28961. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28962. utils.ErrorLog("解析失败:%v", err)
  28963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28964. return
  28965. }
  28966. if res.Infcode == 0 {
  28967. if record_type == 1 {
  28968. service.UpdateBaseDrugById(item.ID)
  28969. } else if record_type == 2 {
  28970. service.UpdateGoodInformaitonByDetail(item.ID)
  28971. } else if record_type == 3 {
  28972. service.UpdateProjectById(item.ID)
  28973. }
  28974. c.ServeSuccessJSON(map[string]interface{}{
  28975. "failed_code": 0,
  28976. "msg": "目录对照成功",
  28977. })
  28978. } else {
  28979. c.ServeSuccessJSON(map[string]interface{}{
  28980. "failed_code": -10,
  28981. "msg": res.ErrMsg,
  28982. })
  28983. }
  28984. }
  28985. } else {
  28986. for _, item := range queryResult {
  28987. var result string
  28988. if record_type == 1 {
  28989. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28990. } else if record_type == 2 {
  28991. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28992. } else if record_type == 3 {
  28993. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28994. }
  28995. var dat map[string]interface{}
  28996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28997. fmt.Println(dat)
  28998. } else {
  28999. fmt.Println(err)
  29000. }
  29001. userJSONBytes, _ := json.Marshal(dat)
  29002. var res ResultSix
  29003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29004. utils.ErrorLog("解析失败:%v", err)
  29005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29006. return
  29007. }
  29008. if res.Infcode == 0 {
  29009. if record_type == 1 {
  29010. service.UpdateBaseDrugById(item.ID)
  29011. } else if record_type == 2 {
  29012. service.UpdateGoodInformaitonByDetail(item.ID)
  29013. } else if record_type == 3 {
  29014. service.UpdateProjectById(item.ID)
  29015. }
  29016. c.ServeSuccessJSON(map[string]interface{}{
  29017. "failed_code": 0,
  29018. "msg": "目录对照成功",
  29019. })
  29020. } else {
  29021. c.ServeSuccessJSON(map[string]interface{}{
  29022. "failed_code": -10,
  29023. "msg": res.ErrMsg,
  29024. })
  29025. }
  29026. }
  29027. }
  29028. }
  29029. func (c *HisApiController) UnCheckCode() {
  29030. ids_str := c.GetString("ids")
  29031. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  29032. admin_user_id, _ := c.GetInt64("admin_user_id")
  29033. ids_arr := strings.Split(ids_str, ",")
  29034. var queryResult []QueryResult
  29035. ids := make([]int64, 0)
  29036. for _, item := range ids_arr {
  29037. id, _ := strconv.ParseInt(item, 10, 64)
  29038. ids = append(ids, id)
  29039. }
  29040. if record_type == 1 {
  29041. drugs, _ := service.GetBatchDrugList(ids)
  29042. for _, item := range drugs {
  29043. result := QueryResult{
  29044. ID: item.ID,
  29045. Name: item.DrugName,
  29046. Code: item.MedicalInsuranceNumber,
  29047. List_type_code: "101",
  29048. }
  29049. queryResult = append(queryResult, result)
  29050. }
  29051. } else if record_type == 2 {
  29052. goods, _ := service.GetBatchGoodInformationList(ids)
  29053. for _, item := range goods {
  29054. result := QueryResult{
  29055. ID: item.ID,
  29056. Name: item.GoodName,
  29057. Code: item.SocialSecurityDirectoryCode,
  29058. List_type_code: "301",
  29059. }
  29060. queryResult = append(queryResult, result)
  29061. }
  29062. } else if record_type == 3 {
  29063. projects, _ := service.GetBathchMyPorjecgList(ids)
  29064. for _, item := range projects {
  29065. result := QueryResult{
  29066. ID: item.ID,
  29067. Name: item.ProjectName,
  29068. Code: item.MedicalCode,
  29069. List_type_code: "201",
  29070. }
  29071. queryResult = append(queryResult, result)
  29072. }
  29073. }
  29074. adminUser := c.GetAdminUserInfo()
  29075. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29076. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29077. var user_name string
  29078. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29079. if role.ID == 0 {
  29080. user_name = "xxx"
  29081. } else {
  29082. user_name = role.UserName
  29083. }
  29084. baseParams := &models.BaseParams{
  29085. SecretKey: miConfig.SecretKey,
  29086. FixmedinsCode: miConfig.Code,
  29087. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  29088. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  29089. OrgName: miConfig.OrgName,
  29090. Doctor: user_name,
  29091. }
  29092. if config.IsOpen == 1 {
  29093. if miConfig.MdtrtareaAdmvs == "430800" {
  29094. for _, item := range queryResult {
  29095. var result string
  29096. if record_type == 1 {
  29097. 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)
  29098. } else if record_type == 2 {
  29099. fmt.Println(item.Code)
  29100. 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)
  29101. } else if record_type == 3 {
  29102. 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)
  29103. }
  29104. var dat map[string]interface{}
  29105. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29106. fmt.Println(dat)
  29107. } else {
  29108. fmt.Println(err)
  29109. }
  29110. userJSONBytes, _ := json.Marshal(dat)
  29111. var res ResultSix
  29112. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29113. utils.ErrorLog("解析失败:%v", err)
  29114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29115. return
  29116. }
  29117. if res.Infcode == 0 {
  29118. if record_type == 1 {
  29119. service.UpdateBaseDrugById(item.ID)
  29120. } else if record_type == 2 {
  29121. service.UpdateGoodInformaitonByDetail(item.ID)
  29122. } else if record_type == 3 {
  29123. service.UpdateProjectById(item.ID)
  29124. }
  29125. c.ServeSuccessJSON(map[string]interface{}{
  29126. "failed_code": 0,
  29127. "msg": "目录对照成功",
  29128. })
  29129. } else {
  29130. c.ServeSuccessJSON(map[string]interface{}{
  29131. "failed_code": -10,
  29132. "msg": res.ErrMsg,
  29133. })
  29134. }
  29135. }
  29136. } else {
  29137. for _, item := range queryResult {
  29138. var result string
  29139. if record_type == 1 {
  29140. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  29141. } else if record_type == 2 {
  29142. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  29143. } else if record_type == 3 {
  29144. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  29145. }
  29146. var dat2 map[string]interface{}
  29147. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  29148. fmt.Println(dat2)
  29149. } else {
  29150. fmt.Println(err)
  29151. }
  29152. userJSONBytes, _ := json.Marshal(dat2)
  29153. var res ResultSix
  29154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29155. utils.ErrorLog("解析失败:%v", err)
  29156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29157. return
  29158. }
  29159. if res.Infcode == 0 {
  29160. if record_type == 1 {
  29161. service.UpdateDrugByIdDetail(item.ID)
  29162. } else if record_type == 2 {
  29163. service.UpdateGoodInfoById(item.ID)
  29164. } else if record_type == 3 {
  29165. service.UpdateMyProjectById(item.ID)
  29166. }
  29167. c.ServeSuccessJSON(map[string]interface{}{
  29168. "failed_code": 0,
  29169. "msg": "撤销目录对照成功",
  29170. })
  29171. } else {
  29172. c.ServeSuccessJSON(map[string]interface{}{
  29173. "failed_code": -10,
  29174. "msg": res.ErrMsg,
  29175. })
  29176. }
  29177. }
  29178. }
  29179. }
  29180. }
  29181. func (c *HisApiController) GetPatientInfo() {
  29182. id_card_no := c.GetString("id_card_no")
  29183. admin_user_id, _ := c.GetInt64("admin_user_id")
  29184. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  29185. if patient.ID == 0 {
  29186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  29187. return
  29188. }
  29189. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  29190. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29191. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  29192. var res ResultTwo
  29193. var res10265 ResultTwo10265
  29194. if config.IsOpen == 1 {
  29195. if miConfig.MdtrtareaAdmvs == "150499" {
  29196. //请求内网数据
  29197. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  29198. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  29199. "&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
  29200. resp, requestErr := http.Get(api)
  29201. if requestErr != nil {
  29202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29203. return
  29204. }
  29205. body, ioErr := ioutil.ReadAll(resp.Body)
  29206. if ioErr != nil {
  29207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29209. return
  29210. }
  29211. var respJSON map[string]interface{}
  29212. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29215. return
  29216. }
  29217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29218. result_byte, _ := json.Marshal(respJSON)
  29219. result := string(result_byte)
  29220. var dat map[string]interface{}
  29221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29222. fmt.Println(dat)
  29223. } else {
  29224. fmt.Println(err)
  29225. }
  29226. userJSONBytes, _ := json.Marshal(dat)
  29227. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  29228. utils.ErrorLog("解析失败:%v", err)
  29229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29230. return
  29231. }
  29232. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29233. res.Infcode = Infcode
  29234. res.ErrMsg = res10265.ErrMsg
  29235. res.Output = res10265.Output
  29236. res.InfRefmsgid = res10265.InfRefmsgid
  29237. res.RespondTime = res10265.RespondTime
  29238. res.WarnInfo = res10265.WarnInfo
  29239. } else {
  29240. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  29241. var dat map[string]interface{}
  29242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29243. fmt.Println(dat)
  29244. } else {
  29245. fmt.Println(err)
  29246. }
  29247. userJSONBytes, _ := json.Marshal(dat)
  29248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29249. utils.ErrorLog("解析失败:%v", err)
  29250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29251. return
  29252. }
  29253. }
  29254. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29255. // utils.ErrorLog("解析失败:%v", err)
  29256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29257. // return
  29258. //}
  29259. for index, item := range res.Output.Iinfo {
  29260. if item.PsnInsuStas == "2" {
  29261. fmt.Println("--------")
  29262. res.Output.Iinfo[index].Insutype = "300"
  29263. res.Output.Iinfo[index].PsnInsuStas = "1"
  29264. }
  29265. }
  29266. fmt.Println(res.Output.Iinfo)
  29267. if res.Infcode != 0 {
  29268. c.ServeSuccessJSON(map[string]interface{}{
  29269. "failed_code": -10,
  29270. "msg": res.ErrMsg,
  29271. })
  29272. } else {
  29273. c.ServeSuccessJSON(map[string]interface{}{
  29274. "failed_code": 0,
  29275. "info": res,
  29276. })
  29277. }
  29278. }
  29279. }
  29280. func (c *HisApiController) PsnPutOnRecord() {
  29281. record_type, _ := c.GetInt64("type")
  29282. patient_id, _ := c.GetInt64("patient_id")
  29283. admin_user_id, _ := c.GetInt64("admin_user_id")
  29284. start_time := c.GetString("start_time")
  29285. end_time := c.GetString("end_time")
  29286. adminUser := c.GetAdminUserInfo()
  29287. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29288. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29289. var patients []*models.Patients
  29290. if record_type == 1 { //全部备案
  29291. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  29292. patients = append(patients, patient...)
  29293. } else { //单个备案
  29294. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  29295. patients = append(patients, patient)
  29296. }
  29297. var user_name string
  29298. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29299. if role.ID == 0 {
  29300. user_name = "xxx"
  29301. } else {
  29302. user_name = role.UserName
  29303. }
  29304. if config.IsOpen == 1 {
  29305. for _, item := range patients {
  29306. 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
  29307. resp, requestErr := http.Get(api)
  29308. if requestErr != nil {
  29309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29310. return
  29311. }
  29312. defer resp.Body.Close()
  29313. body, ioErr := ioutil.ReadAll(resp.Body)
  29314. if ioErr != nil {
  29315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29317. return
  29318. }
  29319. var respJSON map[string]interface{}
  29320. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29323. return
  29324. }
  29325. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29326. userJSONBytes, _ := json.Marshal(userJSON)
  29327. var res ResultTwo
  29328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29329. utils.ErrorLog("解析失败:%v", err)
  29330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29331. return
  29332. }
  29333. if res.Infcode == 0 {
  29334. 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)
  29335. var dat map[string]interface{}
  29336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29337. fmt.Println(dat)
  29338. } else {
  29339. fmt.Println(err)
  29340. }
  29341. userJSONBytes, _ := json.Marshal(dat)
  29342. var res2 ResultThirteen
  29343. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29344. utils.ErrorLog("解析失败:%v", err)
  29345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29346. return
  29347. }
  29348. if res2.Infcode == 0 {
  29349. psnResult := &models.GdybPsnRecord{
  29350. UserOrgId: adminUser.CurrentOrgId,
  29351. PatientId: item.ID,
  29352. PsnNo: res.Output.Baseinfo.PsnNo,
  29353. Ctime: time.Now().Unix(),
  29354. Mtime: time.Now().Unix(),
  29355. Status: 1,
  29356. IsCancel: 1,
  29357. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  29358. }
  29359. service.CreatePsnRecord(psnResult)
  29360. } else {
  29361. c.ServeSuccessJSON(map[string]interface{}{
  29362. "failed_code": -10,
  29363. "msg": res2.ErrMsg,
  29364. })
  29365. return
  29366. }
  29367. }
  29368. }
  29369. }
  29370. }
  29371. func (c *HisApiController) PsnUnPutOnRecord() {
  29372. id, _ := c.GetInt64("id")
  29373. //record_type, _ := c.GetInt64("type")
  29374. admin_user_id, _ := c.GetInt64("admin_user_id")
  29375. adminUser := c.GetAdminUserInfo()
  29376. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29377. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29378. var user_name string
  29379. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29380. if role.ID == 0 {
  29381. user_name = "xxx"
  29382. } else {
  29383. user_name = role.UserName
  29384. }
  29385. psn_record, _ := service.GetPsnRecordById(id)
  29386. if psn_record.ID == 0 {
  29387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  29388. return
  29389. }
  29390. if config.IsOpen == 1 {
  29391. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  29392. var dat map[string]interface{}
  29393. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29394. fmt.Println(dat)
  29395. } else {
  29396. fmt.Println(err)
  29397. }
  29398. userJSONBytes, _ := json.Marshal(dat)
  29399. var res ResultFourteen
  29400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29401. utils.ErrorLog("解析失败:%v", err)
  29402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29403. return
  29404. }
  29405. if res.Infcode == 0 {
  29406. psn_record.IsCancel = 2
  29407. service.CreatePsnRecord(&psn_record)
  29408. } else {
  29409. c.ServeSuccessJSON(map[string]interface{}{
  29410. "failed_code": -10,
  29411. "msg": res.ErrMsg,
  29412. })
  29413. return
  29414. }
  29415. }
  29416. }
  29417. func (c *HisApiController) PsnPutNCDSOnRecord() {
  29418. patient_id, _ := c.GetInt64("patient_id")
  29419. insutype_two := c.GetString("insutype")
  29420. psn_no := c.GetString("psn_no")
  29421. doctor_id, _ := c.GetInt64("doctor_id")
  29422. sick_id, _ := c.GetInt64("sick_id")
  29423. department_id, _ := c.GetInt64("department_id")
  29424. start_time := c.GetString("start_time")
  29425. end_time := c.GetString("end_time")
  29426. check_time := c.GetString("check_time")
  29427. hospital_code := c.GetString("hospital_code")
  29428. hospital_name := c.GetString("hospital_name")
  29429. adminUser := c.GetAdminUserInfo()
  29430. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  29431. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29432. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29433. sick, _ := service.FindSickById(sick_id)
  29434. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  29435. if len(hospital_code) == 0 {
  29436. hospital_code = miConfig.Code
  29437. }
  29438. if len(hospital_name) == 0 {
  29439. hospital_name = miConfig.OrgName
  29440. }
  29441. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  29442. var res ResultTwo
  29443. var res10265 ResultTwo10265
  29444. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29445. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  29446. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  29447. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  29448. "&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
  29449. resp, requestErr := http.Get(api)
  29450. if requestErr != nil {
  29451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29452. return
  29453. }
  29454. body, ioErr := ioutil.ReadAll(resp.Body)
  29455. if ioErr != nil {
  29456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29458. return
  29459. }
  29460. var respJSON map[string]interface{}
  29461. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29464. return
  29465. }
  29466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29467. result, _ := json.Marshal(respJSON)
  29468. fmt.Println("log")
  29469. fmt.Println(string(result))
  29470. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29471. utils.ErrorLog("解析失败:%v", err)
  29472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29473. return
  29474. }
  29475. res.ErrMsg = res10265.ErrMsg
  29476. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29477. res.Infcode = infocode
  29478. res.Output = res10265.Output
  29479. res.InfRefmsgid = res10265.InfRefmsgid
  29480. } else {
  29481. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  29482. if miConfig.Code == "H15049901371" {
  29483. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29484. utils.ErrorLog("解析失败:%v", err)
  29485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29486. return
  29487. }
  29488. res.ErrMsg = res10265.ErrMsg
  29489. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29490. res.Infcode = infocode
  29491. res.Output = res10265.Output
  29492. res.InfRefmsgid = res10265.InfRefmsgid
  29493. } else {
  29494. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29495. utils.ErrorLog("解析失败:%v", err)
  29496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29497. return
  29498. }
  29499. }
  29500. }
  29501. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29502. infoStr := string(Iinfos)
  29503. var rf []*ResultFive
  29504. json.Unmarshal([]byte(infoStr), &rf)
  29505. var insuplc_admdvs string
  29506. var insutype string
  29507. var is390 int = 0
  29508. var is310 int = 0
  29509. var insutypes []*ResultFive
  29510. for _, item := range rf {
  29511. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29512. insutypes = append(insutypes, item)
  29513. }
  29514. }
  29515. if len(insutypes) == 1 {
  29516. insutype = insutypes[0].Insutype
  29517. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  29518. } else {
  29519. for _, i := range insutypes {
  29520. if i.Insutype == "390" {
  29521. is390 = 1
  29522. }
  29523. if i.Insutype == "310" {
  29524. is310 = 1
  29525. }
  29526. }
  29527. }
  29528. if is390 == 1 {
  29529. insutype = "390"
  29530. }
  29531. if is310 == 1 {
  29532. insutype = "310"
  29533. }
  29534. if len(insutypes) == 2 {
  29535. insutype = insutype_two
  29536. }
  29537. if len(insutypes) == 0 {
  29538. insutype = "310"
  29539. }
  29540. insutype = insutype_two
  29541. fmt.Println(insutype)
  29542. for _, item := range rf {
  29543. fmt.Println(item.Insutype)
  29544. fmt.Println(insutype)
  29545. if item.Insutype == insutype {
  29546. fmt.Println(item.Insutype)
  29547. fmt.Println(insutype)
  29548. insuplc_admdvs = item.InsuplcAdmdvs
  29549. }
  29550. }
  29551. fmt.Println(insuplc_admdvs)
  29552. var res2 ResultThirteen
  29553. var res10265_2 ResultThirteen10265
  29554. if config.IsOpen == 1 {
  29555. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29556. } else {
  29557. if miConfig.MdtrtareaAdmvs == "150499" {
  29558. //
  29559. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  29560. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  29561. // "&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
  29562. //resp, requestErr := http.Get(api)
  29563. //if requestErr != nil {
  29564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29565. // return
  29566. //}
  29567. //
  29568. //body, ioErr := ioutil.ReadAll(resp.Body)
  29569. //if ioErr != nil {
  29570. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29572. // return
  29573. //}
  29574. //var respJSON map[string]interface{}
  29575. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29576. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29578. // return
  29579. //}
  29580. //
  29581. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29582. //result, _ := json.Marshal(respJSON)
  29583. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  29584. // utils.ErrorLog("解析失败:%v", err)
  29585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29586. // return
  29587. //}
  29588. //infocode = resThree.Infcode
  29589. //result, _ := json.Marshal(respJSON)
  29590. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  29591. // utils.ErrorLog("解析失败:%v", err)
  29592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29593. // return
  29594. //}
  29595. //
  29596. //resThree.ErrMsg = resThree10265.ErrMsg
  29597. //
  29598. //resThree.Output = resThree10265.Output
  29599. //
  29600. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  29601. //
  29602. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  29603. //
  29604. } else {
  29605. 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)
  29606. var dat map[string]interface{}
  29607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29608. fmt.Println(dat)
  29609. } else {
  29610. fmt.Println(err)
  29611. }
  29612. userJSONBytes, _ := json.Marshal(dat)
  29613. if miConfig.Code == "H15049901371" {
  29614. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  29615. utils.ErrorLog("解析失败:%v", err)
  29616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29617. return
  29618. }
  29619. res2.ErrMsg = res10265_2.ErrMsg
  29620. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  29621. res2.Infcode = infocode
  29622. res2.Output = res10265_2.Output
  29623. res2.InfRefmsgid = res10265_2.InfRefmsgid
  29624. } else {
  29625. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29626. utils.ErrorLog("解析失败:%v", err)
  29627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29628. return
  29629. }
  29630. }
  29631. }
  29632. }
  29633. if res2.Infcode == 0 {
  29634. psnResult := &models.GdybPsnNcdsRecord{
  29635. UserOrgId: adminUser.CurrentOrgId,
  29636. PatientId: patient.ID,
  29637. PsnNo: psn_no,
  29638. DoctorId: doctor.AdminUserId,
  29639. DepartmentId: department_id,
  29640. SickType: sick_id,
  29641. Insutype: insutype,
  29642. Ctime: time.Now().Unix(),
  29643. Mtime: time.Now().Unix(),
  29644. Status: 1,
  29645. IsCancel: 1,
  29646. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  29647. }
  29648. service.CreatePsnNCDSRecord(psnResult)
  29649. c.ServeSuccessJSON(map[string]interface{}{
  29650. "failed_code": 0,
  29651. "msg": "备案成功",
  29652. "result": psnResult,
  29653. })
  29654. } else {
  29655. c.ServeSuccessJSON(map[string]interface{}{
  29656. "failed_code": -10,
  29657. "msg": res2.ErrMsg,
  29658. })
  29659. return
  29660. }
  29661. }
  29662. }
  29663. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  29664. id, _ := c.GetInt64("id")
  29665. admin_user_id, _ := c.GetInt64("admin_user_id")
  29666. adminUser := c.GetAdminUserInfo()
  29667. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29668. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29669. //config, _ := service.Ge(adminUser.CurrentOrgId)
  29670. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  29671. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29672. //var user_name string
  29673. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29674. //if role.ID == 0 {
  29675. // user_name = "xxx"
  29676. //} else {
  29677. // user_name = role.UserName
  29678. //}
  29679. psn_record, _ := service.GetPsnNCDSRecordById(id)
  29680. if psn_record.ID == 0 {
  29681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  29682. return
  29683. }
  29684. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  29685. var res ResultTwo
  29686. var res10265 ResultTwo10265
  29687. if miConfig.Code == "H15049901371" {
  29688. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29689. utils.ErrorLog("解析失败:%v", err)
  29690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29691. return
  29692. }
  29693. res.ErrMsg = res10265.ErrMsg
  29694. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29695. res.Infcode = infocode
  29696. res.Output = res10265.Output
  29697. res.InfRefmsgid = res10265.InfRefmsgid
  29698. } else {
  29699. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29700. utils.ErrorLog("解析失败:%v", err)
  29701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29702. return
  29703. }
  29704. }
  29705. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29706. infoStr := string(Iinfos)
  29707. var rf []*ResultFive
  29708. json.Unmarshal([]byte(infoStr), &rf)
  29709. var insuplc_admdvs string
  29710. var insutype string
  29711. var is390 int = 0
  29712. var is310 int = 0
  29713. var insutypes []*ResultFive
  29714. for _, item := range rf {
  29715. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29716. insutypes = append(insutypes, item)
  29717. }
  29718. }
  29719. if len(insutypes) == 1 {
  29720. insutype = insutypes[0].Insutype
  29721. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  29722. } else {
  29723. for _, i := range insutypes {
  29724. if i.Insutype == "390" {
  29725. is390 = 1
  29726. }
  29727. if i.Insutype == "310" {
  29728. is310 = 1
  29729. }
  29730. }
  29731. }
  29732. if is390 == 1 {
  29733. insutype = "390"
  29734. }
  29735. if is310 == 1 {
  29736. insutype = "310"
  29737. }
  29738. if len(insutypes) == 0 {
  29739. insutype = "310"
  29740. }
  29741. insutype = psn_record.Insutype
  29742. for _, item := range rf {
  29743. if item.Insutype == insutype {
  29744. insuplc_admdvs = item.InsuplcAdmdvs
  29745. }
  29746. }
  29747. if config.IsOpen == 1 {
  29748. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  29749. var dat map[string]interface{}
  29750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29751. fmt.Println(dat)
  29752. } else {
  29753. fmt.Println(err)
  29754. }
  29755. userJSONBytes, _ := json.Marshal(dat)
  29756. var res ResultFourteen
  29757. var res10265 ResultFourteen10265
  29758. if miConfig.Code == "H15049901371" {
  29759. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  29760. utils.ErrorLog("解析失败:%v", err)
  29761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29762. return
  29763. }
  29764. res.ErrMsg = res10265.ErrMsg
  29765. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29766. res.Infcode = infocode
  29767. res.Output = res10265.Output
  29768. res.InfRefmsgid = res10265.InfRefmsgid
  29769. } else {
  29770. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29771. utils.ErrorLog("解析失败:%v", err)
  29772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29773. return
  29774. }
  29775. }
  29776. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29777. // utils.ErrorLog("解析失败:%v", err)
  29778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29779. // return
  29780. //}
  29781. if res.Infcode == 0 {
  29782. psn_record.IsCancel = 2
  29783. service.CreatePsnNCDSRecord(&psn_record)
  29784. c.ServeSuccessJSON(map[string]interface{}{
  29785. "failed_code": 0,
  29786. "msg": "撤销备案成功",
  29787. })
  29788. } else {
  29789. c.ServeSuccessJSON(map[string]interface{}{
  29790. "failed_code": -10,
  29791. "msg": res.ErrMsg,
  29792. })
  29793. return
  29794. }
  29795. }
  29796. }
  29797. func (c *HisApiController) TestTest() {
  29798. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  29799. fmt.Println(patient.Iinfo)
  29800. }
  29801. type CustomData struct {
  29802. MsgId string
  29803. PsnNo string
  29804. Info string
  29805. }
  29806. func (c *HisApiController) ReversalData() {
  29807. var customData []*CustomData
  29808. custom := &CustomData{
  29809. MsgId: "H44022900158202103301714472004",
  29810. PsnNo: "44020000001101329945",
  29811. Info: "2207",
  29812. }
  29813. customData = append(customData, custom)
  29814. custom1 := &CustomData{
  29815. MsgId: "H4402290015820210330172057803",
  29816. PsnNo: "44020000001101161813",
  29817. Info: "2207",
  29818. }
  29819. customData = append(customData, custom1)
  29820. custom2 := &CustomData{
  29821. MsgId: "H44022900158202103301705198813",
  29822. PsnNo: "44190000133097375417",
  29823. Info: "2207",
  29824. }
  29825. customData = append(customData, custom2)
  29826. custom3 := &CustomData{
  29827. MsgId: "H44022900158202103301715524756",
  29828. PsnNo: "44020000001100187221",
  29829. Info: "2207",
  29830. }
  29831. customData = append(customData, custom3)
  29832. custom4 := &CustomData{
  29833. MsgId: "H44022900158202103301730376224",
  29834. PsnNo: "44020000001101959155",
  29835. Info: "2207",
  29836. }
  29837. customData = append(customData, custom4)
  29838. custom5 := &CustomData{
  29839. MsgId: "H44022900158202103301748008725",
  29840. PsnNo: "44020000001104246641",
  29841. Info: "2207",
  29842. }
  29843. customData = append(customData, custom5)
  29844. custom6 := &CustomData{
  29845. MsgId: "H44022900158202103301718096755",
  29846. PsnNo: "44020000001102211860",
  29847. Info: "2207",
  29848. }
  29849. customData = append(customData, custom6)
  29850. custom7 := &CustomData{
  29851. MsgId: "H44022900158202103301736551640",
  29852. PsnNo: "44020000001102687718",
  29853. Info: "2207",
  29854. }
  29855. customData = append(customData, custom7)
  29856. custom8 := &CustomData{
  29857. MsgId: "H44022900158202103301743097676",
  29858. PsnNo: "44020000001102127785",
  29859. Info: "2207",
  29860. }
  29861. customData = append(customData, custom8)
  29862. custom9 := &CustomData{
  29863. MsgId: "H44022900158202103301712304203",
  29864. PsnNo: "44020000001101518097",
  29865. Info: "2207",
  29866. }
  29867. customData = append(customData, custom9)
  29868. custom10 := &CustomData{
  29869. MsgId: "H44022900158202103301738448785",
  29870. PsnNo: "44020000001100500813",
  29871. Info: "2207",
  29872. }
  29873. customData = append(customData, custom10)
  29874. custom11 := &CustomData{
  29875. MsgId: "H44022900158202103301732455843",
  29876. PsnNo: "44020000001102690557",
  29877. Info: "2207",
  29878. }
  29879. customData = append(customData, custom11)
  29880. custom12 := &CustomData{
  29881. MsgId: "H44022900158202103301745421708",
  29882. PsnNo: "44020000001102211928",
  29883. Info: "2207",
  29884. }
  29885. customData = append(customData, custom12)
  29886. custom1212 := &CustomData{
  29887. MsgId: "H440229001582021033017351627",
  29888. PsnNo: "44020000001102481733",
  29889. Info: "2207",
  29890. }
  29891. customData = append(customData, custom1212)
  29892. custom13 := &CustomData{
  29893. MsgId: "H44022900158202103301740327951",
  29894. PsnNo: "44020000001103174866",
  29895. Info: "2207",
  29896. }
  29897. customData = append(customData, custom13)
  29898. custom14 := &CustomData{
  29899. MsgId: "H4402290015820210330174922668",
  29900. PsnNo: "44020000001102927272",
  29901. Info: "2207",
  29902. }
  29903. customData = append(customData, custom14)
  29904. custom15 := &CustomData{
  29905. MsgId: "H44022900158202103301752362273",
  29906. PsnNo: "44020000001102942890",
  29907. Info: "2207",
  29908. }
  29909. customData = append(customData, custom15)
  29910. custom16 := &CustomData{
  29911. MsgId: "H44022900158202103301751082917",
  29912. PsnNo: "44020000001101662162",
  29913. Info: "2207",
  29914. }
  29915. customData = append(customData, custom16)
  29916. custom17 := &CustomData{
  29917. MsgId: "H44022900158202103301754147728",
  29918. PsnNo: "44020000000229014511",
  29919. Info: "2207",
  29920. }
  29921. customData = append(customData, custom17)
  29922. adminUser := c.GetAdminUserInfo()
  29923. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29924. for _, item := range customData {
  29925. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29926. fmt.Println(result)
  29927. }
  29928. }
  29929. func (c *HisApiController) GetAllopatry() {
  29930. year := c.GetString("year")
  29931. month := c.GetString("month")
  29932. admin_user_id, _ := c.GetInt64("admin_user_id")
  29933. adminUser := c.GetAdminUserInfo()
  29934. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29935. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29936. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29937. var dat map[string]interface{}
  29938. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29939. fmt.Println(dat)
  29940. } else {
  29941. fmt.Println(err)
  29942. }
  29943. userJSONBytes, _ := json.Marshal(dat)
  29944. var res models.Result9001
  29945. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29946. utils.ErrorLog("解析失败:%v", err)
  29947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29948. return
  29949. }
  29950. fmt.Println(res.Output.Signinoutb)
  29951. fmt.Println(res.Output.Signinoutb.SignNo)
  29952. fmt.Println(string(userJSONBytes))
  29953. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29954. var dat3 map[string]interface{}
  29955. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  29956. fmt.Println(dat3)
  29957. } else {
  29958. fmt.Println(err)
  29959. }
  29960. userJSONBytes3, _ := json.Marshal(dat3)
  29961. var res3 models.Result3260
  29962. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29963. utils.ErrorLog("解析失败:%v", err)
  29964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29965. return
  29966. }
  29967. var curpage int
  29968. var pagesize int = 100
  29969. var start int = 1
  29970. //var stop int
  29971. //pagecount := 10
  29972. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  29973. var res22 []models.Result3260
  29974. for curpage = 1; curpage <= pagecount; curpage++ {
  29975. if curpage == 1 {
  29976. start = 0
  29977. } else {
  29978. start = (curpage-1)*pagesize + 1
  29979. }
  29980. fmt.Println(start)
  29981. //stop = curpage * pagesize
  29982. //if stop > int(res3.Output.Totalrow) {
  29983. // stop =int(res3.Output.Totalrow)
  29984. //}
  29985. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  29986. var dat2 map[string]interface{}
  29987. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29988. fmt.Println(dat)
  29989. } else {
  29990. fmt.Println(err)
  29991. }
  29992. userJSONBytes2, _ := json.Marshal(dat2)
  29993. var res2 models.Result3260
  29994. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29995. utils.ErrorLog("解析失败:%v", err)
  29996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29997. return
  29998. }
  29999. if res2.Infcode == 0 {
  30000. res22 = append(res22, res2)
  30001. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  30002. //var dat2 map[string]interface{}
  30003. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  30004. // fmt.Println(dat)
  30005. //} else {
  30006. // fmt.Println(err)
  30007. //}
  30008. //c.ServeSuccessJSON(map[string]interface{}{
  30009. // "list": res2.Output.Data,
  30010. //})
  30011. //continue
  30012. }
  30013. }
  30014. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  30015. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  30016. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  30017. //var dat2 map[string]interface{}
  30018. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  30019. // fmt.Println(dat)
  30020. //} else {
  30021. // fmt.Println(err)
  30022. //}
  30023. //userJSONBytes2, _ := json.Marshal(dat2)
  30024. //var res2 models.Result3260
  30025. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30026. // utils.ErrorLog("解析失败:%v", err)
  30027. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30028. // return
  30029. //}
  30030. //if res2.Infcode == 0 {
  30031. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  30032. // var dat2 map[string]interface{}
  30033. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  30034. // fmt.Println(dat)
  30035. // } else {
  30036. // fmt.Println(err)
  30037. // }
  30038. // c.ServeSuccessJSON(map[string]interface{}{
  30039. // "list": res2.Output.Data,
  30040. // })
  30041. //}
  30042. }
  30043. func (c *HisApiController) ComfirmAllopatry() {
  30044. year := c.GetString("year")
  30045. month := c.GetString("month")
  30046. admin_user_id, _ := c.GetInt64("admin_user_id")
  30047. adminUser := c.GetAdminUserInfo()
  30048. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30049. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30050. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  30051. var dat map[string]interface{}
  30052. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30053. fmt.Println(dat)
  30054. } else {
  30055. fmt.Println(err)
  30056. }
  30057. userJSONBytes, _ := json.Marshal(dat)
  30058. var res models.Result9001
  30059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30060. utils.ErrorLog("解析失败:%v", err)
  30061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30062. return
  30063. }
  30064. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  30065. var dat2 map[string]interface{}
  30066. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  30067. fmt.Println(dat)
  30068. } else {
  30069. fmt.Println(err)
  30070. }
  30071. userJSONBytes2, _ := json.Marshal(dat2)
  30072. var res2 models.Result3260
  30073. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30074. utils.ErrorLog("解析失败:%v", err)
  30075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30076. return
  30077. }
  30078. //if res2.Infcode == 0 {
  30079. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  30080. // var dat map[string]interface{}
  30081. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30082. // fmt.Println(dat)
  30083. // } else {
  30084. // fmt.Println(err)
  30085. // }
  30086. // userJSONBytes, _ := json.Marshal(dat)
  30087. // var res3 models.Result3261
  30088. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  30089. // utils.ErrorLog("解析失败:%v", err)
  30090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30091. // return
  30092. // }
  30093. //
  30094. // if res3.Infcode == 0 {
  30095. // record := &models.HisYidiClearRecord{
  30096. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  30097. // Ctime: time.Now().Unix(),
  30098. // Mtime: time.Now().Unix(),
  30099. // Status: 1,
  30100. // MsgId: msgId,
  30101. // }
  30102. // service.SaveClearRecord(record)
  30103. // c.ServeSuccessJSON(map[string]interface{}{
  30104. // "msg": "提取成功",
  30105. // })
  30106. // }
  30107. //}
  30108. }
  30109. func (c *HisApiController) RefundAllopatry() {
  30110. year := c.GetString("year")
  30111. month := c.GetString("month")
  30112. //id, _ := c.GetInt64("id")
  30113. admin_user_id, _ := c.GetInt64("admin_user_id")
  30114. adminUser := c.GetAdminUserInfo()
  30115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30116. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30117. //record, _ := service.GetClearRecordById(id)
  30118. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  30119. var dat map[string]interface{}
  30120. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30121. fmt.Println(dat)
  30122. } else {
  30123. fmt.Println(err)
  30124. }
  30125. userJSONBytes, _ := json.Marshal(dat)
  30126. var res models.Result9001
  30127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30128. utils.ErrorLog("解析失败:%v", err)
  30129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30130. return
  30131. }
  30132. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  30133. var dat2 map[string]interface{}
  30134. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  30135. fmt.Println(dat)
  30136. } else {
  30137. fmt.Println(err)
  30138. }
  30139. userJSONBytes2, _ := json.Marshal(dat2)
  30140. var empty ResultFourteen
  30141. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  30142. utils.ErrorLog("解析失败:%v", err)
  30143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30144. return
  30145. }
  30146. if empty.Infcode == 0 {
  30147. c.ServeSuccessJSON(map[string]interface{}{
  30148. "msg": "撤销成功",
  30149. })
  30150. return
  30151. }
  30152. }
  30153. func (c *HisApiController) ReversalOtherData() {
  30154. var customData []*CustomData
  30155. custom := &CustomData{
  30156. MsgId: "H44022900158202103301714472004",
  30157. PsnNo: "44020000001101329945",
  30158. Info: "2208",
  30159. }
  30160. customData = append(customData, custom)
  30161. custom1 := &CustomData{
  30162. MsgId: "H4402290015820210330172057803",
  30163. PsnNo: "44020000001101161813",
  30164. Info: "2208",
  30165. }
  30166. customData = append(customData, custom1)
  30167. custom2 := &CustomData{
  30168. MsgId: "H44022900158202103301705198813",
  30169. PsnNo: "44190000133097375417",
  30170. Info: "2208",
  30171. }
  30172. customData = append(customData, custom2)
  30173. custom3 := &CustomData{
  30174. MsgId: "H44022900158202103301715524756",
  30175. PsnNo: "44020000001100187221",
  30176. Info: "2208",
  30177. }
  30178. customData = append(customData, custom3)
  30179. custom4 := &CustomData{
  30180. MsgId: "H44022900158202103301730376224",
  30181. PsnNo: "44020000001101959155",
  30182. Info: "2208",
  30183. }
  30184. customData = append(customData, custom4)
  30185. custom5 := &CustomData{
  30186. MsgId: "H44022900158202103301748008725",
  30187. PsnNo: "44020000001104246641",
  30188. Info: "2208",
  30189. }
  30190. customData = append(customData, custom5)
  30191. custom6 := &CustomData{
  30192. MsgId: "H44022900158202103301718096755",
  30193. PsnNo: "44020000001102211860",
  30194. Info: "2208",
  30195. }
  30196. customData = append(customData, custom6)
  30197. custom7 := &CustomData{
  30198. MsgId: "H44022900158202103301736551640",
  30199. PsnNo: "44020000001102687718",
  30200. Info: "2208",
  30201. }
  30202. customData = append(customData, custom7)
  30203. custom8 := &CustomData{
  30204. MsgId: "H44022900158202103301743097676",
  30205. PsnNo: "44020000001102127785",
  30206. Info: "2208",
  30207. }
  30208. customData = append(customData, custom8)
  30209. custom9 := &CustomData{
  30210. MsgId: "H44022900158202103301712304203",
  30211. PsnNo: "44020000001101518097",
  30212. Info: "2208",
  30213. }
  30214. customData = append(customData, custom9)
  30215. custom10 := &CustomData{
  30216. MsgId: "H44022900158202103301738448785",
  30217. PsnNo: "44020000001100500813",
  30218. Info: "2208",
  30219. }
  30220. customData = append(customData, custom10)
  30221. custom11 := &CustomData{
  30222. MsgId: "H44022900158202103301732455843",
  30223. PsnNo: "44020000001102690557",
  30224. Info: "2208",
  30225. }
  30226. customData = append(customData, custom11)
  30227. custom12 := &CustomData{
  30228. MsgId: "H44022900158202103301745421708",
  30229. PsnNo: "44020000001102211928",
  30230. Info: "2208",
  30231. }
  30232. customData = append(customData, custom12)
  30233. custom1212 := &CustomData{
  30234. MsgId: "H440229001582021033017351627",
  30235. PsnNo: "44020000001102481733",
  30236. Info: "2208",
  30237. }
  30238. customData = append(customData, custom1212)
  30239. custom13 := &CustomData{
  30240. MsgId: "H44022900158202103301740327951",
  30241. PsnNo: "44020000001103174866",
  30242. Info: "2208",
  30243. }
  30244. customData = append(customData, custom13)
  30245. custom14 := &CustomData{
  30246. MsgId: "H4402290015820210330174922668",
  30247. PsnNo: "44020000001102927272",
  30248. Info: "2208",
  30249. }
  30250. customData = append(customData, custom14)
  30251. custom15 := &CustomData{
  30252. MsgId: "H44022900158202103301752362273",
  30253. PsnNo: "44020000001102942890",
  30254. Info: "2208",
  30255. }
  30256. customData = append(customData, custom15)
  30257. custom16 := &CustomData{
  30258. MsgId: "H44022900158202103301751082917",
  30259. PsnNo: "44020000001101662162",
  30260. Info: "2208",
  30261. }
  30262. customData = append(customData, custom16)
  30263. custom17 := &CustomData{
  30264. MsgId: "H44022900158202103301754147728",
  30265. PsnNo: "44020000000229014511",
  30266. Info: "2208",
  30267. }
  30268. customData = append(customData, custom17)
  30269. adminUser := c.GetAdminUserInfo()
  30270. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30271. for _, item := range customData {
  30272. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  30273. fmt.Println(result)
  30274. }
  30275. }
  30276. func PathExists(path string) (bool, error) {
  30277. _, err := os.Stat(path)
  30278. if err == nil {
  30279. return true, nil
  30280. }
  30281. if os.IsNotExist(err) {
  30282. return false, nil
  30283. }
  30284. return false, err
  30285. }
  30286. // 创建文件夹
  30287. func Mkdir(dir string) {
  30288. // 创建文件夹
  30289. exist, err := PathExists(dir)
  30290. if err != nil {
  30291. fmt.Println(err.Error())
  30292. } else {
  30293. if exist {
  30294. fmt.Println(dir + "文件夹已存在!")
  30295. } else {
  30296. // 文件夹名称,权限
  30297. err := os.Mkdir(dir, os.ModePerm)
  30298. if err != nil {
  30299. fmt.Println(dir+"文件夹创建失败:", err.Error())
  30300. } else {
  30301. fmt.Println(dir + "文件夹创建成功!")
  30302. }
  30303. }
  30304. }
  30305. }
  30306. // 压缩文件
  30307. func Zip(srcFile string, destZip string) error {
  30308. zipfile, err := os.Create(destZip)
  30309. if err != nil {
  30310. return err
  30311. }
  30312. defer zipfile.Close()
  30313. archive := zip.NewWriter(zipfile)
  30314. defer archive.Close()
  30315. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  30316. if err != nil {
  30317. return err
  30318. }
  30319. header, err := zip.FileInfoHeader(info)
  30320. if err != nil {
  30321. return err
  30322. }
  30323. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  30324. // header.Name = path
  30325. if info.IsDir() {
  30326. header.Name += "/"
  30327. } else {
  30328. header.Method = zip.Deflate
  30329. }
  30330. writer, err := archive.CreateHeader(header)
  30331. if err != nil {
  30332. return err
  30333. }
  30334. if !info.IsDir() {
  30335. file, err := os.Open(path)
  30336. if err != nil {
  30337. return err
  30338. }
  30339. defer file.Close()
  30340. _, err = io.Copy(writer, file)
  30341. }
  30342. return err
  30343. })
  30344. return err
  30345. }
  30346. func ReadFile(filePath string) []byte {
  30347. f, err := os.Open(filePath)
  30348. if err != nil {
  30349. fmt.Println("read file fail", err)
  30350. return nil
  30351. }
  30352. defer f.Close()
  30353. fd, err := ioutil.ReadAll(f)
  30354. if err != nil {
  30355. fmt.Println("read to fd fail", err)
  30356. return nil
  30357. }
  30358. return fd
  30359. }
  30360. func saveLogq(result string, request string, infno string, desc string) {
  30361. dir := "日志"
  30362. utils.Mkdir(dir)
  30363. month := time.Unix(1557042972, 0).Format("1")
  30364. year := time.Now().Format("2006")
  30365. month = time.Now().Format("01")
  30366. day := time.Now().Format("02")
  30367. hour := time.Now().Format("15")
  30368. min := time.Now().Format("04")
  30369. sec := time.Now().Format("05")
  30370. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  30371. file := year + month + day + "_log"
  30372. file_name := file + ".txt"
  30373. file_path := "日志" + "/" + file_name
  30374. exist, _ := utils.PathExists(file_path)
  30375. if exist { //存在
  30376. fmt.Println("存在")
  30377. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  30378. if err != nil {
  30379. fmt.Println("read fail")
  30380. }
  30381. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  30382. n, _ := f.Seek(0, 2)
  30383. _, err = f.WriteAt([]byte(content), n)
  30384. } else { //不存在
  30385. fmt.Println("文件不存在,创建文件")
  30386. f, err := os.Create("日志" + "/" + file_name)
  30387. defer f.Close()
  30388. if err != nil {
  30389. } else {
  30390. _, err = f.Write([]byte("记录日志"))
  30391. }
  30392. }
  30393. }
  30394. func saveLog(result string, request string, infno string, desc string) {
  30395. org_id, _ := beego.AppConfig.Int64("org_id")
  30396. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  30397. dir := miConfig.OrgName + "日志"
  30398. utils.Mkdir(dir)
  30399. month := time.Unix(1557042972, 0).Format("1")
  30400. year := time.Now().Format("2006")
  30401. month = time.Now().Format("01")
  30402. day := time.Now().Format("02")
  30403. hour := time.Now().Format("15")
  30404. min := time.Now().Format("04")
  30405. sec := time.Now().Format("05")
  30406. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  30407. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  30408. file_name := file + ".txt"
  30409. file_path := miConfig.OrgName + "日志" + "/" + file_name
  30410. exist, _ := utils.PathExists(file_path)
  30411. if exist { //存在
  30412. fmt.Println("存在")
  30413. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  30414. if err != nil {
  30415. fmt.Println("read fail")
  30416. }
  30417. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  30418. n, _ := f.Seek(0, 2)
  30419. _, err = f.WriteAt([]byte(content), n)
  30420. } else { //不存在
  30421. fmt.Println("文件不存在,创建文件")
  30422. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  30423. defer f.Close()
  30424. if err != nil {
  30425. } else {
  30426. _, err = f.Write([]byte("记录日志"))
  30427. }
  30428. }
  30429. }
  30430. type Charset string
  30431. const (
  30432. UTF8 = Charset("UTF-8")
  30433. GB18030 = Charset("GB18030")
  30434. )
  30435. func ConvertToString(src string, srcCode string, tagCode string) string {
  30436. srcCoder := mahonia.NewDecoder(srcCode)
  30437. srcResult := srcCoder.ConvertString(src)
  30438. tagCoder := mahonia.NewDecoder(tagCode)
  30439. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  30440. result := string(cdata)
  30441. return result
  30442. }
  30443. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  30444. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  30445. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  30446. var token string
  30447. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30448. var api string
  30449. if miConfig.MdtrtareaAdmvs == "320921" {
  30450. 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 +
  30451. "&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
  30452. fmt.Println(api)
  30453. } else {
  30454. 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 +
  30455. "&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
  30456. }
  30457. resp, requestErr := http.Get(api)
  30458. if requestErr != nil {
  30459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30460. return ""
  30461. }
  30462. body, ioErr := ioutil.ReadAll(resp.Body)
  30463. if ioErr != nil {
  30464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30466. return ""
  30467. }
  30468. var respJSON map[string]interface{}
  30469. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30472. return ""
  30473. }
  30474. var status string
  30475. status = respJSON["data"].(map[string]interface{})["status"].(string)
  30476. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  30477. var res ResultTwo //1101结果
  30478. var res10265 ResultTwo10265 //1101结果
  30479. if status == "0" { //读卡成功
  30480. var card_info string //卡信息
  30481. var busi_card_info string
  30482. token = respJSON["data"].(map[string]interface{})["token"].(string)
  30483. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  30484. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  30485. fmt.Println(card_info)
  30486. fmt.Println(busi_card_info)
  30487. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  30488. result, _ := json.Marshal(respJSON)
  30489. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  30490. utils.ErrorLog("解析失败:%v", err)
  30491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30492. return ""
  30493. }
  30494. res.ErrMsg = res10265.ErrMsg
  30495. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  30496. res.Infcode = infocode
  30497. res.Output = res10265.Output
  30498. res.InfRefmsgid = res10265.InfRefmsgid
  30499. if res.Infcode == 0 {
  30500. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  30501. if err == gorm.ErrRecordNotFound {
  30502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  30503. return ""
  30504. } else if err != nil {
  30505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  30506. return ""
  30507. } else {
  30508. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  30509. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  30510. infoStr := string(Iinfos)
  30511. idetinfoStr := string(Idetinfos)
  30512. psn := &models.HisPsn{
  30513. PsnNo: res.Output.Baseinfo.PsnNo,
  30514. PatientId: patient.ID,
  30515. Certno: res.Output.Baseinfo.Certno,
  30516. Gend: res.Output.Baseinfo.Gend,
  30517. Naty: res.Output.Baseinfo.Naty,
  30518. PsnCertType: res.Output.Baseinfo.PsnCertType,
  30519. PsnName: res.Output.Baseinfo.PsnName,
  30520. Idetinfo: idetinfoStr,
  30521. Insuinfo: infoStr,
  30522. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  30523. CardInfo: card_info,
  30524. VerifyNumber: token,
  30525. }
  30526. service.CreateHisPsn(psn)
  30527. return token
  30528. }
  30529. }
  30530. } else {
  30531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  30532. return ""
  30533. }
  30534. } else { //读卡失败
  30535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  30536. return ""
  30537. }
  30538. return token
  30539. }
  30540. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  30541. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  30542. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  30543. var token string
  30544. var api string
  30545. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  30546. "&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
  30547. fmt.Println(api)
  30548. resp, requestErr := http.Get(api)
  30549. if requestErr != nil {
  30550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30551. return ""
  30552. }
  30553. body, ioErr := ioutil.ReadAll(resp.Body)
  30554. if ioErr != nil {
  30555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30557. return ""
  30558. }
  30559. var respJSON map[string]interface{}
  30560. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30563. return ""
  30564. }
  30565. var status string
  30566. status = respJSON["data"].(map[string]interface{})["status"].(string)
  30567. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  30568. var res ResultTwo //1101结果
  30569. if status == "1" { //读卡成功
  30570. var card_info string //卡信息
  30571. var busi_card_info string
  30572. token = respJSON["data"].(map[string]interface{})["token"].(string)
  30573. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  30574. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  30575. fmt.Println(card_info)
  30576. fmt.Println(busi_card_info)
  30577. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  30578. result, _ := json.Marshal(respJSON)
  30579. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30580. utils.ErrorLog("解析失败:%v", err)
  30581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30582. return ""
  30583. }
  30584. if res.Infcode == 0 {
  30585. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  30586. if err == gorm.ErrRecordNotFound {
  30587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  30588. return ""
  30589. } else if err != nil {
  30590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  30591. return ""
  30592. } else {
  30593. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  30594. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  30595. infoStr := string(Iinfos)
  30596. idetinfoStr := string(Idetinfos)
  30597. psn := &models.HisPsn{
  30598. PsnNo: res.Output.Baseinfo.PsnNo,
  30599. PatientId: patient.ID,
  30600. Certno: res.Output.Baseinfo.Certno,
  30601. Gend: res.Output.Baseinfo.Gend,
  30602. Naty: res.Output.Baseinfo.Naty,
  30603. PsnCertType: res.Output.Baseinfo.PsnCertType,
  30604. PsnName: res.Output.Baseinfo.PsnName,
  30605. Idetinfo: idetinfoStr,
  30606. Insuinfo: infoStr,
  30607. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  30608. CardInfo: card_info,
  30609. VerifyNumber: token,
  30610. }
  30611. service.CreateHisPsn(psn)
  30612. return token
  30613. }
  30614. }
  30615. } else {
  30616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  30617. return ""
  30618. }
  30619. return token
  30620. }
  30621. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  30622. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  30623. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  30624. var token string
  30625. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30626. var api string
  30627. if miConfig.MdtrtareaAdmvs == "320921" {
  30628. 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 +
  30629. "&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
  30630. fmt.Println(api)
  30631. } else {
  30632. 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 +
  30633. "&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
  30634. }
  30635. resp, requestErr := http.Get(api)
  30636. if requestErr != nil {
  30637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30638. return ""
  30639. }
  30640. body, ioErr := ioutil.ReadAll(resp.Body)
  30641. if ioErr != nil {
  30642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30644. return ""
  30645. }
  30646. var respJSON map[string]interface{}
  30647. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30650. return ""
  30651. }
  30652. var status string
  30653. status = respJSON["data"].(map[string]interface{})["status"].(string)
  30654. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  30655. var res ResultTwo //1101结果
  30656. var res10265 ResultTwo10265 //1101结果
  30657. if status == "0" { //读卡成功
  30658. var card_info string //卡信息
  30659. var busi_card_info string
  30660. token = respJSON["data"].(map[string]interface{})["token"].(string)
  30661. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  30662. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  30663. fmt.Println(card_info)
  30664. fmt.Println(busi_card_info)
  30665. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  30666. result, _ := json.Marshal(respJSON)
  30667. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  30668. utils.ErrorLog("解析失败:%v", err)
  30669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30670. return ""
  30671. }
  30672. res.ErrMsg = res10265.ErrMsg
  30673. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  30674. res.Infcode = infocode
  30675. res.Output = res10265.Output
  30676. res.InfRefmsgid = res10265.InfRefmsgid
  30677. if res.Infcode == 0 {
  30678. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  30679. if err == gorm.ErrRecordNotFound {
  30680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  30681. return ""
  30682. } else if err != nil {
  30683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  30684. return ""
  30685. } else {
  30686. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  30687. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  30688. infoStr := string(Iinfos)
  30689. idetinfoStr := string(Idetinfos)
  30690. psn := &models.HisPsn{
  30691. PsnNo: res.Output.Baseinfo.PsnNo,
  30692. PatientId: patient.ID,
  30693. Certno: res.Output.Baseinfo.Certno,
  30694. Gend: res.Output.Baseinfo.Gend,
  30695. Naty: res.Output.Baseinfo.Naty,
  30696. PsnCertType: res.Output.Baseinfo.PsnCertType,
  30697. PsnName: res.Output.Baseinfo.PsnName,
  30698. Idetinfo: idetinfoStr,
  30699. Insuinfo: infoStr,
  30700. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  30701. CardInfo: card_info,
  30702. VerifyNumber: token,
  30703. }
  30704. service.CreateHisPsn(psn)
  30705. return token
  30706. }
  30707. }
  30708. } else {
  30709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  30710. return ""
  30711. }
  30712. } else { //读卡失败
  30713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  30714. return ""
  30715. }
  30716. return token
  30717. }
  30718. func DeleteExtraSpaceTwo(s string) string {
  30719. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  30720. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  30721. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  30722. reg, _ := regexp.Compile(regstr) //编译正则表达式
  30723. s2 := make([]byte, len(s1)) //定义字符数组切片
  30724. copy(s2, s1) //将字符串复制到切片
  30725. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  30726. for len(spc_index) > 0 { //找到适配项
  30727. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  30728. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  30729. }
  30730. return string(s2)
  30731. }
  30732. func Remove0000(s string) string {
  30733. str := make([]rune, 0, len(s))
  30734. for _, v := range []rune(s) {
  30735. if v == 0 {
  30736. continue
  30737. }
  30738. str = append(str, v)
  30739. }
  30740. return string(str)
  30741. }
  30742. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  30743. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  30744. readCard := DllDef.MustFindProc("EcQuery")
  30745. pCardInfo := make([]byte, 8192)
  30746. pBusiCardInfo := make([]byte, 8192)
  30747. data := make(map[string]interface{})
  30748. //pData := make(map[string]interface{})
  30749. inputData := make(map[string]interface{})
  30750. inputData["orgId"] = code
  30751. inputData["businessType"] = "01101"
  30752. inputData["operatorId"] = operator_id
  30753. inputData["operatorName"] = operator_name
  30754. inputData["officeId"] = "001"
  30755. inputData["officeName"] = "血透室"
  30756. //
  30757. data["data"] = inputData
  30758. data["transType"] = "ec.query"
  30759. data["orgId"] = code
  30760. bytesData, _ := json.Marshal(data)
  30761. pCardInfo = bytesData
  30762. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  30763. fmt.Println(ret2)
  30764. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  30765. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  30766. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  30767. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  30768. if ret2 != 0 {
  30769. return "", ""
  30770. }
  30771. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  30772. }
  30773. func DeleteExtraSpace(s string) string {
  30774. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  30775. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  30776. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  30777. reg, _ := regexp.Compile(regstr) //编译正则表达式
  30778. s2 := make([]byte, len(s1)) //定义字符数组切片
  30779. copy(s2, s1) //将字符串复制到切片
  30780. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  30781. for len(spc_index) > 0 { //找到适配项
  30782. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  30783. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  30784. }
  30785. return string(s2)
  30786. }
  30787. // 对账
  30788. func (c *HisApiController) Post3202() {
  30789. start_time := c.GetString("start_time")
  30790. end_time := c.GetString("end_time")
  30791. //insutype := c.GetString("insutype")
  30792. clr_type := c.GetString("clr_type")
  30793. clr_org := c.GetString("clr_optins")
  30794. admin_user_id, _ := c.GetInt64("admin_user_id")
  30795. adminUser := c.GetAdminUserInfo()
  30796. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30797. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30798. if len(clr_org) == 0 {
  30799. clr_org = miConfig.MdtrtareaAdmvs
  30800. }
  30801. timeLayout := "2006-01-02"
  30802. loc, _ := time.LoadLocation("Local")
  30803. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30804. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30805. var orders []*models.HisOrder
  30806. if clr_org == "421300" {
  30807. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30808. } else {
  30809. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30810. }
  30811. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30812. //fixmedins_setl_cnt := int64(len(orders))
  30813. var medfee_sumamt float64
  30814. var acct_pay float64
  30815. var fund_pay_sumamt float64
  30816. for _, item := range orders {
  30817. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30818. acct_pay = acct_pay + item.AcctPay
  30819. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30820. }
  30821. //var medfee_sumamt_two float64
  30822. //var acct_pay_two float64
  30823. //var fund_pay_sumamt_two float64
  30824. //for _, item := range orders_two {
  30825. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30826. // acct_pay_two = acct_pay_two + item.AcctPay
  30827. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30828. //}
  30829. //var user_name string
  30830. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30831. //if role.ID == 0 {
  30832. // user_name = "xxx"
  30833. //} else {
  30834. // user_name = role.UserName
  30835. //}
  30836. var res ResultSix
  30837. if config.IsOpen == 1 {
  30838. var bps []*models.BusinessParamsTwo
  30839. var bp models.BusinessParamsTwo
  30840. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30841. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30842. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  30843. bp.MedfeeSumamt = medfee_sumamt_str
  30844. bp.AcctPay = acct_pay_str
  30845. bp.FundPaySumamt = fund_pay_sumamt_str
  30846. bp.Insutype = ""
  30847. bp.StmtBegndate = start_time
  30848. bp.ClrType = clr_type
  30849. bp.SetlOptins = clr_org
  30850. bp.StmtEnddate = end_time
  30851. bps = append(bps, &bp)
  30852. data := make(map[string]interface{})
  30853. data["bps"] = bps
  30854. data["org_name"] = miConfig.OrgName
  30855. data["doctor"] = role.UserName
  30856. data["fixmedins_code"] = miConfig.Code
  30857. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30858. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30859. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30860. if miConfig.MdtrtareaAdmvs == "421300" {
  30861. client := &http.Client{}
  30862. bytesData, _ := json.Marshal(data)
  30863. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  30864. resp, _ := client.Do(req)
  30865. defer resp.Body.Close()
  30866. body, ioErr := ioutil.ReadAll(resp.Body)
  30867. if ioErr != nil {
  30868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30870. return
  30871. }
  30872. var respJSON map[string]interface{}
  30873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30876. return
  30877. }
  30878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30879. userJSONBytes, _ := json.Marshal(respJSON)
  30880. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30881. utils.ErrorLog("解析失败:%v", err)
  30882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30883. return
  30884. }
  30885. }
  30886. if miConfig.MdtrtareaAdmvs == "420200" {
  30887. client := &http.Client{}
  30888. bytesData, _ := json.Marshal(data)
  30889. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  30890. resp, _ := client.Do(req)
  30891. defer resp.Body.Close()
  30892. body, ioErr := ioutil.ReadAll(resp.Body)
  30893. if ioErr != nil {
  30894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30896. return
  30897. }
  30898. var respJSON map[string]interface{}
  30899. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30902. return
  30903. }
  30904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30905. userJSONBytes, _ := json.Marshal(respJSON)
  30906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30907. utils.ErrorLog("解析失败:%v", err)
  30908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30909. return
  30910. }
  30911. }
  30912. if miConfig.MdtrtareaAdmvs == "421182" {
  30913. client := &http.Client{}
  30914. bytesData, _ := json.Marshal(data)
  30915. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  30916. resp, _ := client.Do(req)
  30917. defer resp.Body.Close()
  30918. body, ioErr := ioutil.ReadAll(resp.Body)
  30919. if ioErr != nil {
  30920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30922. return
  30923. }
  30924. var respJSON map[string]interface{}
  30925. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30928. return
  30929. }
  30930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30931. userJSONBytes, _ := json.Marshal(respJSON)
  30932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30933. utils.ErrorLog("解析失败:%v", err)
  30934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30935. return
  30936. }
  30937. }
  30938. if res.Infcode == 0 {
  30939. c.ServeSuccessJSON(map[string]interface{}{
  30940. "msg": "发起成功",
  30941. })
  30942. } else {
  30943. c.ServeSuccessJSON(map[string]interface{}{
  30944. "failed_code": -10,
  30945. "msg": res.ErrMsg,
  30946. })
  30947. }
  30948. }
  30949. }
  30950. func (c *HisApiController) Post3202b() {
  30951. start_time := c.GetString("start_time")
  30952. end_time := c.GetString("end_time")
  30953. //insutype := c.GetString("insutype")
  30954. clr_type := c.GetString("clr_type")
  30955. clr_org := c.GetString("clr_optins")
  30956. admin_user_id, _ := c.GetInt64("admin_user_id")
  30957. adminUser := c.GetAdminUserInfo()
  30958. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30959. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30960. if len(clr_org) == 0 {
  30961. clr_org = miConfig.MdtrtareaAdmvs
  30962. }
  30963. timeLayout := "2006-01-02"
  30964. loc, _ := time.LoadLocation("Local")
  30965. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30966. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30967. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30968. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30969. //fixmedins_setl_cnt := int64(len(orders))
  30970. var medfee_sumamt float64
  30971. var acct_pay float64
  30972. var fund_pay_sumamt float64
  30973. for _, item := range orders {
  30974. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30975. acct_pay = acct_pay + item.AcctPay
  30976. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30977. }
  30978. //var medfee_sumamt_two float64
  30979. //var acct_pay_two float64
  30980. //var fund_pay_sumamt_two float64
  30981. //for _, item := range orders_two {
  30982. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30983. // acct_pay_two = acct_pay_two + item.AcctPay
  30984. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30985. //}
  30986. //var user_name string
  30987. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30988. //if role.ID == 0 {
  30989. // user_name = "xxx"
  30990. //} else {
  30991. // user_name = role.UserName
  30992. //}
  30993. var res ResultSix
  30994. if config.IsOpen == 1 {
  30995. var bps []*models.BusinessParamsTwo
  30996. var bp models.BusinessParamsTwo
  30997. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30998. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30999. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  31000. bp.MedfeeSumamt = medfee_sumamt_str
  31001. bp.AcctPay = acct_pay_str
  31002. bp.FundPaySumamt = fund_pay_sumamt_str
  31003. bp.Insutype = "390"
  31004. bp.StmtBegndate = start_time
  31005. bp.ClrType = clr_type
  31006. bp.SetlOptins = clr_org
  31007. bp.StmtEnddate = end_time
  31008. bps = append(bps, &bp)
  31009. data := make(map[string]interface{})
  31010. data["bps"] = bps
  31011. data["org_name"] = miConfig.OrgName
  31012. data["doctor"] = role.UserName
  31013. data["fixmedins_code"] = miConfig.Code
  31014. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31015. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31016. if miConfig.MdtrtareaAdmvs == "421300" {
  31017. client := &http.Client{}
  31018. bytesData, _ := json.Marshal(data)
  31019. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  31020. resp, _ := client.Do(req)
  31021. defer resp.Body.Close()
  31022. body, ioErr := ioutil.ReadAll(resp.Body)
  31023. if ioErr != nil {
  31024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31026. return
  31027. }
  31028. var respJSON map[string]interface{}
  31029. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31032. return
  31033. }
  31034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31035. userJSONBytes, _ := json.Marshal(respJSON)
  31036. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31037. utils.ErrorLog("解析失败:%v", err)
  31038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31039. return
  31040. }
  31041. }
  31042. if miConfig.MdtrtareaAdmvs == "420200" {
  31043. client := &http.Client{}
  31044. bytesData, _ := json.Marshal(data)
  31045. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  31046. resp, _ := client.Do(req)
  31047. defer resp.Body.Close()
  31048. body, ioErr := ioutil.ReadAll(resp.Body)
  31049. if ioErr != nil {
  31050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31052. return
  31053. }
  31054. var respJSON map[string]interface{}
  31055. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31058. return
  31059. }
  31060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31061. userJSONBytes, _ := json.Marshal(respJSON)
  31062. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31063. utils.ErrorLog("解析失败:%v", err)
  31064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31065. return
  31066. }
  31067. }
  31068. if miConfig.MdtrtareaAdmvs == "421182" {
  31069. client := &http.Client{}
  31070. bytesData, _ := json.Marshal(data)
  31071. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  31072. resp, _ := client.Do(req)
  31073. defer resp.Body.Close()
  31074. body, ioErr := ioutil.ReadAll(resp.Body)
  31075. if ioErr != nil {
  31076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31078. return
  31079. }
  31080. var respJSON map[string]interface{}
  31081. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31084. return
  31085. }
  31086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31087. userJSONBytes, _ := json.Marshal(respJSON)
  31088. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31089. utils.ErrorLog("解析失败:%v", err)
  31090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31091. return
  31092. }
  31093. }
  31094. if res.Infcode == 0 {
  31095. c.ServeSuccessJSON(map[string]interface{}{
  31096. "msg": "发起成功",
  31097. })
  31098. } else {
  31099. c.ServeSuccessJSON(map[string]interface{}{
  31100. "failed_code": -10,
  31101. "msg": res.ErrMsg,
  31102. })
  31103. }
  31104. }
  31105. }
  31106. func (c *HisApiController) Post1608() {
  31107. start_time := c.GetString("start_time")
  31108. end_time := c.GetString("end_time")
  31109. admin_user_id, _ := c.GetInt64("admin_user_id")
  31110. adminUser := c.GetAdminUserInfo()
  31111. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31112. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31113. timeLayout := "2006-01-02"
  31114. loc, _ := time.LoadLocation("Local")
  31115. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  31116. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  31117. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  31118. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  31119. fixmedins_setl_cnt := int64(len(orders))
  31120. var medfee_sumamt float64
  31121. var func_smamt float64
  31122. for _, item := range orders {
  31123. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  31124. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  31125. }
  31126. times := strings.Split(start_time, "-")
  31127. time_tows := strings.Split(end_time, "-")
  31128. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31129. var res ResultSix
  31130. if config.IsOpen == 1 {
  31131. //var bps []*models.BusinessParamsTwo
  31132. //var bp models.BusinessParamsTwo
  31133. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  31134. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  31135. data := make(map[string]interface{})
  31136. data["org_name"] = miConfig.OrgName
  31137. data["doctor"] = role.UserName
  31138. data["func_smamt"] = func_smamt_str
  31139. data["fixmedins_code"] = miConfig.Code
  31140. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31141. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31142. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  31143. data["medfee_sumamt"] = medfee_sumamt_str
  31144. data["start_time"] = times[0] + times[1] + times[2]
  31145. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  31146. if miConfig.MdtrtareaAdmvs == "421300" {
  31147. client := &http.Client{}
  31148. bytesData, _ := json.Marshal(data)
  31149. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  31150. resp, _ := client.Do(req)
  31151. defer resp.Body.Close()
  31152. body, ioErr := ioutil.ReadAll(resp.Body)
  31153. if ioErr != nil {
  31154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31156. return
  31157. }
  31158. var respJSON map[string]interface{}
  31159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31162. return
  31163. }
  31164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31165. userJSONBytes, _ := json.Marshal(respJSON)
  31166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31167. utils.ErrorLog("解析失败:%v", err)
  31168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31169. return
  31170. }
  31171. }
  31172. if miConfig.MdtrtareaAdmvs == "420200" {
  31173. client := &http.Client{}
  31174. bytesData, _ := json.Marshal(data)
  31175. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  31176. resp, _ := client.Do(req)
  31177. defer resp.Body.Close()
  31178. body, ioErr := ioutil.ReadAll(resp.Body)
  31179. if ioErr != nil {
  31180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31182. return
  31183. }
  31184. var respJSON map[string]interface{}
  31185. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31188. return
  31189. }
  31190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31191. userJSONBytes, _ := json.Marshal(respJSON)
  31192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31193. utils.ErrorLog("解析失败:%v", err)
  31194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31195. return
  31196. }
  31197. }
  31198. if miConfig.MdtrtareaAdmvs == "421182" {
  31199. client := &http.Client{}
  31200. bytesData, _ := json.Marshal(data)
  31201. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  31202. resp, _ := client.Do(req)
  31203. defer resp.Body.Close()
  31204. body, ioErr := ioutil.ReadAll(resp.Body)
  31205. if ioErr != nil {
  31206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31208. return
  31209. }
  31210. var respJSON map[string]interface{}
  31211. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31214. return
  31215. }
  31216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31217. userJSONBytes, _ := json.Marshal(respJSON)
  31218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31219. utils.ErrorLog("解析失败:%v", err)
  31220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31221. return
  31222. }
  31223. }
  31224. if res.Infcode == 0 {
  31225. c.ServeSuccessJSON(map[string]interface{}{
  31226. "msg": "发起成功",
  31227. })
  31228. } else {
  31229. c.ServeSuccessJSON(map[string]interface{}{
  31230. "failed_code": -10,
  31231. "msg": res.ErrMsg,
  31232. })
  31233. }
  31234. }
  31235. }
  31236. // 5.11.1.1【5262】结算信息按时间段查询
  31237. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  31238. admin_user_id, _ := c.GetInt64("admin_user_id")
  31239. adminUser := c.GetAdminUserInfo()
  31240. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31241. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31242. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31243. var res Result5262
  31244. if config.IsOpen == 1 {
  31245. if miConfig.MdtrtareaAdmvs == "421300" {
  31246. data := make(map[string]interface{})
  31247. data["bps"] = bp
  31248. data["org_name"] = miConfig.OrgName
  31249. data["doctor"] = role.UserName
  31250. data["fixmedins_code"] = miConfig.Code
  31251. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31252. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31253. data["page"] = strconv.FormatInt(page, 10)
  31254. data["limit"] = strconv.FormatInt(limit, 10)
  31255. fmt.Println(data)
  31256. client := &http.Client{}
  31257. bytesData, _ := json.Marshal(data)
  31258. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  31259. resp, _ := client.Do(req)
  31260. defer resp.Body.Close()
  31261. body, ioErr := ioutil.ReadAll(resp.Body)
  31262. if ioErr != nil {
  31263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31265. return
  31266. }
  31267. var respJSON map[string]interface{}
  31268. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31271. return
  31272. }
  31273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31274. userJSONBytes, _ := json.Marshal(respJSON)
  31275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31276. utils.ErrorLog("解析失败:%v", err)
  31277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31278. return
  31279. }
  31280. }
  31281. if miConfig.MdtrtareaAdmvs == "420200" {
  31282. data := make(map[string]interface{})
  31283. data["bps"] = bp
  31284. data["org_name"] = miConfig.OrgName
  31285. data["doctor"] = role.UserName
  31286. data["fixmedins_code"] = miConfig.Code
  31287. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31288. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31289. data["page"] = strconv.FormatInt(page, 10)
  31290. data["limit"] = strconv.FormatInt(limit, 10)
  31291. fmt.Println(data)
  31292. client := &http.Client{}
  31293. bytesData, _ := json.Marshal(data)
  31294. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  31295. resp, _ := client.Do(req)
  31296. defer resp.Body.Close()
  31297. body, ioErr := ioutil.ReadAll(resp.Body)
  31298. if ioErr != nil {
  31299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31301. return
  31302. }
  31303. var respJSON map[string]interface{}
  31304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31307. return
  31308. }
  31309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31310. userJSONBytes, _ := json.Marshal(respJSON)
  31311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31312. utils.ErrorLog("解析失败:%v", err)
  31313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31314. return
  31315. }
  31316. }
  31317. if miConfig.MdtrtareaAdmvs == "421182" {
  31318. data := make(map[string]interface{})
  31319. data["bps"] = bp
  31320. data["org_name"] = miConfig.OrgName
  31321. data["doctor"] = role.UserName
  31322. data["fixmedins_code"] = miConfig.Code
  31323. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31324. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31325. data["page"] = strconv.FormatInt(page, 10)
  31326. data["limit"] = strconv.FormatInt(limit, 10)
  31327. fmt.Println(data)
  31328. client := &http.Client{}
  31329. bytesData, _ := json.Marshal(data)
  31330. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  31331. resp, _ := client.Do(req)
  31332. defer resp.Body.Close()
  31333. body, ioErr := ioutil.ReadAll(resp.Body)
  31334. if ioErr != nil {
  31335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31337. return
  31338. }
  31339. var respJSON map[string]interface{}
  31340. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31343. return
  31344. }
  31345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31346. userJSONBytes, _ := json.Marshal(respJSON)
  31347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31348. utils.ErrorLog("解析失败:%v", err)
  31349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31350. return
  31351. }
  31352. }
  31353. if res.Infcode == 0 {
  31354. c.ServeSuccessJSON(map[string]interface{}{
  31355. "order": res.Output.Result,
  31356. "total": res.Output.PageInfo.RecordCounts,
  31357. })
  31358. } else {
  31359. c.ServeSuccessJSON(map[string]interface{}{
  31360. "failed_code": -10,
  31361. "msg": res.ErrMsg,
  31362. })
  31363. }
  31364. }
  31365. }
  31366. // 5.11.1.2【5267】异地结算信息时间段查询
  31367. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  31368. admin_user_id, _ := c.GetInt64("admin_user_id")
  31369. adminUser := c.GetAdminUserInfo()
  31370. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31371. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31372. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31373. var res Result5267
  31374. if config.IsOpen == 1 {
  31375. if miConfig.MdtrtareaAdmvs == "421300" {
  31376. data := make(map[string]interface{})
  31377. data["bps"] = bp
  31378. data["org_name"] = miConfig.OrgName
  31379. data["doctor"] = role.UserName
  31380. data["fixmedins_code"] = miConfig.Code
  31381. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31382. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31383. data["page"] = page
  31384. data["limit"] = limit
  31385. fmt.Println(data)
  31386. client := &http.Client{}
  31387. bytesData, _ := json.Marshal(data)
  31388. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  31389. resp, _ := client.Do(req)
  31390. defer resp.Body.Close()
  31391. body, ioErr := ioutil.ReadAll(resp.Body)
  31392. if ioErr != nil {
  31393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31395. return
  31396. }
  31397. var respJSON map[string]interface{}
  31398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31401. return
  31402. }
  31403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31404. userJSONBytes, _ := json.Marshal(respJSON)
  31405. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31406. utils.ErrorLog("解析失败:%v", err)
  31407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31408. return
  31409. }
  31410. }
  31411. if miConfig.MdtrtareaAdmvs == "420200" {
  31412. data := make(map[string]interface{})
  31413. data["bps"] = bp
  31414. data["org_name"] = miConfig.OrgName
  31415. data["doctor"] = role.UserName
  31416. data["fixmedins_code"] = miConfig.Code
  31417. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31418. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31419. data["page"] = page
  31420. data["limit"] = limit
  31421. fmt.Println(data)
  31422. client := &http.Client{}
  31423. bytesData, _ := json.Marshal(data)
  31424. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  31425. resp, _ := client.Do(req)
  31426. defer resp.Body.Close()
  31427. body, ioErr := ioutil.ReadAll(resp.Body)
  31428. if ioErr != nil {
  31429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31431. return
  31432. }
  31433. var respJSON map[string]interface{}
  31434. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31437. return
  31438. }
  31439. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31440. userJSONBytes, _ := json.Marshal(respJSON)
  31441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31442. utils.ErrorLog("解析失败:%v", err)
  31443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31444. return
  31445. }
  31446. }
  31447. if miConfig.MdtrtareaAdmvs == "421182" {
  31448. data := make(map[string]interface{})
  31449. data["bps"] = bp
  31450. data["org_name"] = miConfig.OrgName
  31451. data["doctor"] = role.UserName
  31452. data["fixmedins_code"] = miConfig.Code
  31453. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31454. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31455. data["page"] = page
  31456. data["limit"] = limit
  31457. fmt.Println(data)
  31458. client := &http.Client{}
  31459. bytesData, _ := json.Marshal(data)
  31460. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  31461. resp, _ := client.Do(req)
  31462. defer resp.Body.Close()
  31463. body, ioErr := ioutil.ReadAll(resp.Body)
  31464. if ioErr != nil {
  31465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31467. return
  31468. }
  31469. var respJSON map[string]interface{}
  31470. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31473. return
  31474. }
  31475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31476. userJSONBytes, _ := json.Marshal(respJSON)
  31477. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31478. utils.ErrorLog("解析失败:%v", err)
  31479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31480. return
  31481. }
  31482. }
  31483. if res.Infcode == 0 {
  31484. c.ServeSuccessJSON(map[string]interface{}{
  31485. "order": res.Output.Result,
  31486. "total": res.Output.PageInfo.RecordCounts,
  31487. })
  31488. } else {
  31489. c.ServeSuccessJSON(map[string]interface{}{
  31490. "failed_code": -10,
  31491. "msg": res.ErrMsg,
  31492. })
  31493. }
  31494. }
  31495. }
  31496. func (c *HisApiController) Post3501() {
  31497. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31498. data := make(map[string]interface{})
  31499. var struct3501s []models.Struct3501
  31500. var struct3501 models.Struct3501
  31501. struct3501.OrgName = miConfig.OrgName
  31502. struct3501.AccessKey = miConfig.AccessKey
  31503. struct3501.RequestUrl = miConfig.Url
  31504. struct3501.SecretKey = miConfig.SecretKey
  31505. struct3501.ManuDate = "2022-08-17"
  31506. struct3501.FixmedinsBchno = ""
  31507. struct3501.ManuLotnum = ""
  31508. struct3501.RxFlag = "0"
  31509. struct3501.ExpyEnd = "2022-08-17"
  31510. struct3501.Invdate = "2022-08-17"
  31511. struct3501.InvCnt = "20.25"
  31512. struct3501.Memo = ""
  31513. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31514. struct3501.FixmedinsHilistId = miConfig.Code
  31515. struct3501.FixmedinsHilistName = miConfig.OrgName
  31516. struct3501s = append(struct3501s, struct3501)
  31517. data["struct_3501s"] = struct3501s
  31518. client := &http.Client{}
  31519. bytesData, _ := json.Marshal(data)
  31520. var req *http.Request
  31521. if miConfig.MdtrtareaAdmvs == "320921" {
  31522. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31523. } else {
  31524. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31525. }
  31526. resp, _ := client.Do(req)
  31527. defer resp.Body.Close()
  31528. body, ioErr := ioutil.ReadAll(resp.Body)
  31529. if ioErr != nil {
  31530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31532. return
  31533. }
  31534. var respJSON map[string]interface{}
  31535. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31538. return
  31539. }
  31540. var res ResultSix
  31541. var resSix10265 ResultSix10265 //1101结果
  31542. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31543. result, _ := json.Marshal(respJSON)
  31544. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31545. utils.ErrorLog("解析失败:%v", err)
  31546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31547. return
  31548. }
  31549. res.InfRefmsgid = resSix10265.InfRefmsgid
  31550. res.Output = resSix10265.Output
  31551. res.ErrMsg = resSix10265.ErrMsg
  31552. res.Cainfo = resSix10265.Cainfo
  31553. res.WarnMsg = resSix10265.WarnMsg
  31554. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31555. res.Infcode = infocode
  31556. if infocode == 0 {
  31557. c.ServeSuccessJSON(map[string]interface{}{
  31558. "msg": "上传成功",
  31559. })
  31560. return
  31561. } else {
  31562. c.ServeSuccessJSON(map[string]interface{}{
  31563. "failed_code": -10,
  31564. "msg": res.ErrMsg,
  31565. })
  31566. return
  31567. }
  31568. }
  31569. func (c *HisApiController) Post3502() {
  31570. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31571. data := make(map[string]interface{})
  31572. var struct3502s []models.Struct3502
  31573. var struct3502 models.Struct3502
  31574. struct3502.OrgName = miConfig.OrgName
  31575. struct3502.AccessKey = miConfig.AccessKey
  31576. struct3502.RequestUrl = miConfig.Url
  31577. struct3502.SecretKey = miConfig.SecretKey
  31578. struct3502.ManuDate = "2022-08-15"
  31579. struct3502.FixmedinsBchno = ""
  31580. struct3502.ManuLotnum = ""
  31581. struct3502.RxFlag = "0"
  31582. struct3502.ExpyEnd = "2022-08-15"
  31583. struct3502.Invdate = "2022-08-15"
  31584. struct3502.InvCnt = "20.25"
  31585. struct3502.Memo = ""
  31586. struct3502.MedListCodg = "XB01ABD056B002020200517"
  31587. struct3502.FixmedinsHilistId = miConfig.Code
  31588. struct3502.FixmedinsHilistName = miConfig.OrgName
  31589. struct3502s = append(struct3502s, struct3502)
  31590. data["struct_3502s"] = struct3502s
  31591. client := &http.Client{}
  31592. bytesData, _ := json.Marshal(data)
  31593. var req *http.Request
  31594. if miConfig.MdtrtareaAdmvs == "320921" {
  31595. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31596. } else {
  31597. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31598. }
  31599. resp, _ := client.Do(req)
  31600. defer resp.Body.Close()
  31601. body, ioErr := ioutil.ReadAll(resp.Body)
  31602. if ioErr != nil {
  31603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31605. return
  31606. }
  31607. var respJSON map[string]interface{}
  31608. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31611. return
  31612. }
  31613. var res ResultSix
  31614. var resSix10265 ResultSix10265 //1101结果
  31615. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31616. result, _ := json.Marshal(respJSON)
  31617. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31618. utils.ErrorLog("解析失败:%v", err)
  31619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31620. return
  31621. }
  31622. res.InfRefmsgid = resSix10265.InfRefmsgid
  31623. res.Output = resSix10265.Output
  31624. res.ErrMsg = resSix10265.ErrMsg
  31625. res.Cainfo = resSix10265.Cainfo
  31626. res.WarnMsg = resSix10265.WarnMsg
  31627. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31628. res.Infcode = infocode
  31629. if infocode == 0 {
  31630. c.ServeSuccessJSON(map[string]interface{}{
  31631. "msg": "上传成功",
  31632. })
  31633. return
  31634. } else {
  31635. c.ServeSuccessJSON(map[string]interface{}{
  31636. "failed_code": -10,
  31637. "msg": res.ErrMsg,
  31638. })
  31639. return
  31640. }
  31641. }
  31642. func (c *HisApiController) Post3503() {
  31643. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31644. data := make(map[string]interface{})
  31645. var struct3501s []models.Struct3501
  31646. var struct3501 models.Struct3501
  31647. struct3501.OrgName = miConfig.OrgName
  31648. struct3501.AccessKey = miConfig.AccessKey
  31649. struct3501.RequestUrl = miConfig.Url
  31650. struct3501.SecretKey = miConfig.SecretKey
  31651. struct3501.ManuDate = "2022-08-15"
  31652. struct3501.FixmedinsBchno = ""
  31653. struct3501.ManuLotnum = ""
  31654. struct3501.RxFlag = "0"
  31655. struct3501.ExpyEnd = "2022-08-15"
  31656. struct3501.Invdate = "2022-08-15"
  31657. struct3501.InvCnt = "20.25"
  31658. struct3501.Memo = ""
  31659. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31660. struct3501.FixmedinsHilistId = miConfig.Code
  31661. struct3501.FixmedinsHilistName = miConfig.OrgName
  31662. struct3501s = append(struct3501s, struct3501)
  31663. data["struct_3501s"] = struct3501s
  31664. client := &http.Client{}
  31665. bytesData, _ := json.Marshal(data)
  31666. var req *http.Request
  31667. if miConfig.MdtrtareaAdmvs == "320921" {
  31668. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31669. } else {
  31670. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31671. }
  31672. resp, _ := client.Do(req)
  31673. defer resp.Body.Close()
  31674. body, ioErr := ioutil.ReadAll(resp.Body)
  31675. if ioErr != nil {
  31676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31678. return
  31679. }
  31680. var respJSON map[string]interface{}
  31681. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31684. return
  31685. }
  31686. var res ResultSix
  31687. var resSix10265 ResultSix10265 //1101结果
  31688. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31689. result, _ := json.Marshal(respJSON)
  31690. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31691. utils.ErrorLog("解析失败:%v", err)
  31692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31693. return
  31694. }
  31695. res.InfRefmsgid = resSix10265.InfRefmsgid
  31696. res.Output = resSix10265.Output
  31697. res.ErrMsg = resSix10265.ErrMsg
  31698. res.Cainfo = resSix10265.Cainfo
  31699. res.WarnMsg = resSix10265.WarnMsg
  31700. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31701. res.Infcode = infocode
  31702. if infocode == 0 {
  31703. c.ServeSuccessJSON(map[string]interface{}{
  31704. "msg": "上传成功",
  31705. })
  31706. return
  31707. } else {
  31708. c.ServeSuccessJSON(map[string]interface{}{
  31709. "failed_code": -10,
  31710. "msg": res.ErrMsg,
  31711. })
  31712. return
  31713. }
  31714. }
  31715. func (c *HisApiController) Post3504() {
  31716. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31717. data := make(map[string]interface{})
  31718. var struct3501s []models.Struct3501
  31719. var struct3501 models.Struct3501
  31720. struct3501.OrgName = miConfig.OrgName
  31721. struct3501.AccessKey = miConfig.AccessKey
  31722. struct3501.RequestUrl = miConfig.Url
  31723. struct3501.SecretKey = miConfig.SecretKey
  31724. struct3501.ManuDate = "2022-08-15"
  31725. struct3501.FixmedinsBchno = ""
  31726. struct3501.ManuLotnum = ""
  31727. struct3501.RxFlag = "0"
  31728. struct3501.ExpyEnd = "2022-08-15"
  31729. struct3501.Invdate = "2022-08-15"
  31730. struct3501.InvCnt = "20.25"
  31731. struct3501.Memo = ""
  31732. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31733. struct3501.FixmedinsHilistId = miConfig.Code
  31734. struct3501.FixmedinsHilistName = miConfig.OrgName
  31735. struct3501s = append(struct3501s, struct3501)
  31736. data["struct_3501s"] = struct3501s
  31737. client := &http.Client{}
  31738. bytesData, _ := json.Marshal(data)
  31739. var req *http.Request
  31740. if miConfig.MdtrtareaAdmvs == "320921" {
  31741. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31742. } else {
  31743. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31744. }
  31745. resp, _ := client.Do(req)
  31746. defer resp.Body.Close()
  31747. body, ioErr := ioutil.ReadAll(resp.Body)
  31748. if ioErr != nil {
  31749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31751. return
  31752. }
  31753. var respJSON map[string]interface{}
  31754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31757. return
  31758. }
  31759. var res ResultSix
  31760. var resSix10265 ResultSix10265 //1101结果
  31761. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31762. result, _ := json.Marshal(respJSON)
  31763. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31764. utils.ErrorLog("解析失败:%v", err)
  31765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31766. return
  31767. }
  31768. res.InfRefmsgid = resSix10265.InfRefmsgid
  31769. res.Output = resSix10265.Output
  31770. res.ErrMsg = resSix10265.ErrMsg
  31771. res.Cainfo = resSix10265.Cainfo
  31772. res.WarnMsg = resSix10265.WarnMsg
  31773. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31774. res.Infcode = infocode
  31775. if infocode == 0 {
  31776. c.ServeSuccessJSON(map[string]interface{}{
  31777. "msg": "上传成功",
  31778. })
  31779. return
  31780. } else {
  31781. c.ServeSuccessJSON(map[string]interface{}{
  31782. "failed_code": -10,
  31783. "msg": res.ErrMsg,
  31784. })
  31785. return
  31786. }
  31787. }
  31788. func (c *HisApiController) Post3505() {
  31789. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31790. data := make(map[string]interface{})
  31791. var struct3501s []models.Struct3501
  31792. var struct3501 models.Struct3501
  31793. struct3501.OrgName = miConfig.OrgName
  31794. struct3501.AccessKey = miConfig.AccessKey
  31795. struct3501.RequestUrl = miConfig.Url
  31796. struct3501.SecretKey = miConfig.SecretKey
  31797. struct3501.ManuDate = "2022-08-15"
  31798. struct3501.FixmedinsBchno = ""
  31799. struct3501.ManuLotnum = ""
  31800. struct3501.RxFlag = "0"
  31801. struct3501.ExpyEnd = "2022-08-15"
  31802. struct3501.Invdate = "2022-08-15"
  31803. struct3501.InvCnt = "20.25"
  31804. struct3501.Memo = ""
  31805. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31806. struct3501.FixmedinsHilistId = miConfig.Code
  31807. struct3501.FixmedinsHilistName = miConfig.OrgName
  31808. struct3501s = append(struct3501s, struct3501)
  31809. data["struct_3501s"] = struct3501s
  31810. client := &http.Client{}
  31811. bytesData, _ := json.Marshal(data)
  31812. var req *http.Request
  31813. if miConfig.MdtrtareaAdmvs == "320921" {
  31814. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31815. } else {
  31816. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31817. }
  31818. resp, _ := client.Do(req)
  31819. defer resp.Body.Close()
  31820. body, ioErr := ioutil.ReadAll(resp.Body)
  31821. if ioErr != nil {
  31822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31824. return
  31825. }
  31826. var respJSON map[string]interface{}
  31827. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31830. return
  31831. }
  31832. var res ResultSix
  31833. var resSix10265 ResultSix10265 //1101结果
  31834. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31835. result, _ := json.Marshal(respJSON)
  31836. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31837. utils.ErrorLog("解析失败:%v", err)
  31838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31839. return
  31840. }
  31841. res.InfRefmsgid = resSix10265.InfRefmsgid
  31842. res.Output = resSix10265.Output
  31843. res.ErrMsg = resSix10265.ErrMsg
  31844. res.Cainfo = resSix10265.Cainfo
  31845. res.WarnMsg = resSix10265.WarnMsg
  31846. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31847. res.Infcode = infocode
  31848. if infocode == 0 {
  31849. c.ServeSuccessJSON(map[string]interface{}{
  31850. "msg": "上传成功",
  31851. })
  31852. return
  31853. } else {
  31854. c.ServeSuccessJSON(map[string]interface{}{
  31855. "failed_code": -10,
  31856. "msg": res.ErrMsg,
  31857. })
  31858. return
  31859. }
  31860. }
  31861. func (c *HisApiController) Post3506() {
  31862. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31863. data := make(map[string]interface{})
  31864. var struct3501s []models.Struct3501
  31865. var struct3501 models.Struct3501
  31866. struct3501.OrgName = miConfig.OrgName
  31867. struct3501.AccessKey = miConfig.AccessKey
  31868. struct3501.RequestUrl = miConfig.Url
  31869. struct3501.SecretKey = miConfig.SecretKey
  31870. struct3501.ManuDate = "2022-08-15"
  31871. struct3501.FixmedinsBchno = ""
  31872. struct3501.ManuLotnum = ""
  31873. struct3501.RxFlag = "0"
  31874. struct3501.ExpyEnd = "2022-08-15"
  31875. struct3501.Invdate = "2022-08-15"
  31876. struct3501.InvCnt = "20.25"
  31877. struct3501.Memo = ""
  31878. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31879. struct3501.FixmedinsHilistId = miConfig.Code
  31880. struct3501.FixmedinsHilistName = miConfig.OrgName
  31881. struct3501s = append(struct3501s, struct3501)
  31882. data["struct_3501s"] = struct3501s
  31883. client := &http.Client{}
  31884. bytesData, _ := json.Marshal(data)
  31885. var req *http.Request
  31886. if miConfig.MdtrtareaAdmvs == "320921" {
  31887. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31888. } else {
  31889. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31890. }
  31891. resp, _ := client.Do(req)
  31892. defer resp.Body.Close()
  31893. body, ioErr := ioutil.ReadAll(resp.Body)
  31894. if ioErr != nil {
  31895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31897. return
  31898. }
  31899. var respJSON map[string]interface{}
  31900. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31903. return
  31904. }
  31905. var res ResultSix
  31906. var resSix10265 ResultSix10265 //1101结果
  31907. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31908. result, _ := json.Marshal(respJSON)
  31909. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31910. utils.ErrorLog("解析失败:%v", err)
  31911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31912. return
  31913. }
  31914. res.InfRefmsgid = resSix10265.InfRefmsgid
  31915. res.Output = resSix10265.Output
  31916. res.ErrMsg = resSix10265.ErrMsg
  31917. res.Cainfo = resSix10265.Cainfo
  31918. res.WarnMsg = resSix10265.WarnMsg
  31919. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31920. res.Infcode = infocode
  31921. if infocode == 0 {
  31922. c.ServeSuccessJSON(map[string]interface{}{
  31923. "msg": "上传成功",
  31924. })
  31925. return
  31926. } else {
  31927. c.ServeSuccessJSON(map[string]interface{}{
  31928. "failed_code": -10,
  31929. "msg": res.ErrMsg,
  31930. })
  31931. return
  31932. }
  31933. }
  31934. func (c *HisApiController) Post3507() {
  31935. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31936. data := make(map[string]interface{})
  31937. var struct3501s []models.Struct3501
  31938. var struct3501 models.Struct3501
  31939. struct3501.OrgName = miConfig.OrgName
  31940. struct3501.AccessKey = miConfig.AccessKey
  31941. struct3501.RequestUrl = miConfig.Url
  31942. struct3501.SecretKey = miConfig.SecretKey
  31943. struct3501.ManuDate = "2022-08-15"
  31944. struct3501.FixmedinsBchno = ""
  31945. struct3501.ManuLotnum = ""
  31946. struct3501.RxFlag = "0"
  31947. struct3501.ExpyEnd = "2022-08-15"
  31948. struct3501.Invdate = "2022-08-15"
  31949. struct3501.InvCnt = "20.25"
  31950. struct3501.Memo = ""
  31951. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31952. struct3501.FixmedinsHilistId = miConfig.Code
  31953. struct3501.FixmedinsHilistName = miConfig.OrgName
  31954. struct3501s = append(struct3501s, struct3501)
  31955. data["struct_3501s"] = struct3501s
  31956. client := &http.Client{}
  31957. bytesData, _ := json.Marshal(data)
  31958. var req *http.Request
  31959. if miConfig.MdtrtareaAdmvs == "320921" {
  31960. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31961. } else {
  31962. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31963. }
  31964. resp, _ := client.Do(req)
  31965. defer resp.Body.Close()
  31966. body, ioErr := ioutil.ReadAll(resp.Body)
  31967. if ioErr != nil {
  31968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31970. return
  31971. }
  31972. var respJSON map[string]interface{}
  31973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31976. return
  31977. }
  31978. var res ResultSix
  31979. var resSix10265 ResultSix10265 //1101结果
  31980. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31981. result, _ := json.Marshal(respJSON)
  31982. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31983. utils.ErrorLog("解析失败:%v", err)
  31984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31985. return
  31986. }
  31987. res.InfRefmsgid = resSix10265.InfRefmsgid
  31988. res.Output = resSix10265.Output
  31989. res.ErrMsg = resSix10265.ErrMsg
  31990. res.Cainfo = resSix10265.Cainfo
  31991. res.WarnMsg = resSix10265.WarnMsg
  31992. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31993. res.Infcode = infocode
  31994. if infocode == 0 {
  31995. c.ServeSuccessJSON(map[string]interface{}{
  31996. "msg": "上传成功",
  31997. })
  31998. return
  31999. } else {
  32000. c.ServeSuccessJSON(map[string]interface{}{
  32001. "failed_code": -10,
  32002. "msg": res.ErrMsg,
  32003. })
  32004. return
  32005. }
  32006. }
  32007. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  32008. // WebSocket服务器地址
  32009. serverURL := "ws://127.0.0.1:8899"
  32010. // 解析WebSocket服务器地址
  32011. u, err := url.Parse(serverURL)
  32012. if err != nil {
  32013. }
  32014. // 建立WebSocket连接
  32015. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  32016. if err != nil {
  32017. }
  32018. defer conn.Close()
  32019. input2 := make(map[string]interface{})
  32020. input := make(map[string]interface{})
  32021. inputData := make(map[string]interface{})
  32022. inputData["orgId"] = code
  32023. inputData["businessType"] = "01101"
  32024. inputData["operatorId"] = operator_id
  32025. inputData["operatorName"] = operator_name
  32026. inputData["officeId"] = "001"
  32027. inputData["officeName"] = "血透室"
  32028. inputData["deviceType"] = ""
  32029. input["data"] = inputData
  32030. input["orgId"] = code
  32031. input["transType"] = "ec.query"
  32032. //if md == ""
  32033. if md[:4] == "4403" {
  32034. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32035. } else if md[:4] == "4401" {
  32036. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32037. } else {
  32038. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32039. }
  32040. input2["indata"] = input
  32041. fmt.Println(input2)
  32042. bytesData, _ := json.Marshal(input2)
  32043. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  32044. if err != nil {
  32045. fmt.Println(err)
  32046. }
  32047. // 接收消息
  32048. _, receivedMessage, err := conn.ReadMessage()
  32049. if err != nil {
  32050. fmt.Println(err)
  32051. }
  32052. return "", string(receivedMessage)
  32053. }
  32054. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  32055. // WebSocket服务器地址
  32056. serverURL := "ws://127.0.0.1:8899"
  32057. // 解析WebSocket服务器地址
  32058. u, err := url.Parse(serverURL)
  32059. if err != nil {
  32060. }
  32061. // 建立WebSocket连接
  32062. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  32063. if err != nil {
  32064. }
  32065. defer conn.Close()
  32066. input2 := make(map[string]interface{})
  32067. input := make(map[string]interface{})
  32068. inputData := make(map[string]interface{})
  32069. inputData["orgId"] = code
  32070. inputData["businessType"] = "01103"
  32071. inputData["operatorId"] = operator_id
  32072. inputData["operatorName"] = operator_name
  32073. inputData["officeId"] = "001"
  32074. inputData["officeName"] = "血透室"
  32075. inputData["deviceType"] = ""
  32076. input["data"] = inputData
  32077. input["orgId"] = code
  32078. input["transType"] = "ec.query"
  32079. //if md ==
  32080. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  32081. input2["indata"] = input
  32082. fmt.Println(input2)
  32083. bytesData, _ := json.Marshal(input2)
  32084. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  32085. if err != nil {
  32086. fmt.Println(err)
  32087. }
  32088. // 接收消息
  32089. _, receivedMessage, err := conn.ReadMessage()
  32090. if err != nil {
  32091. fmt.Println(err)
  32092. }
  32093. return "", string(receivedMessage)
  32094. }
  32095. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  32096. // WebSocket服务器地址
  32097. serverURL := "ws://127.0.0.1:8899"
  32098. // 解析WebSocket服务器地址
  32099. u, err := url.Parse(serverURL)
  32100. if err != nil {
  32101. }
  32102. // 建立WebSocket连接
  32103. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  32104. if err != nil {
  32105. }
  32106. defer conn.Close()
  32107. input2 := make(map[string]interface{})
  32108. input := make(map[string]interface{})
  32109. inputData := make(map[string]interface{})
  32110. inputData["orgId"] = code
  32111. inputData["businessType"] = "01101"
  32112. inputData["operatorId"] = operator_id
  32113. inputData["operatorName"] = operator_name
  32114. inputData["officeId"] = "001"
  32115. inputData["officeName"] = "血透室"
  32116. inputData["deviceType"] = ""
  32117. input["data"] = inputData
  32118. input["orgId"] = code
  32119. input["transType"] = "ec.query"
  32120. //if md == ""
  32121. if md[:4] == "4403" {
  32122. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32123. } else if md[:4] == "4401" {
  32124. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32125. } else {
  32126. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32127. }
  32128. input2["indata"] = input
  32129. fmt.Println(input2)
  32130. bytesData, _ := json.Marshal(input2)
  32131. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  32132. if err != nil {
  32133. fmt.Println(err)
  32134. }
  32135. // 接收消息
  32136. _, receivedMessage, err := conn.ReadMessage()
  32137. if err != nil {
  32138. fmt.Println(err)
  32139. }
  32140. return "", string(receivedMessage)
  32141. }
  32142. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  32143. // WebSocket服务器地址
  32144. serverURL := "ws://127.0.0.1:8899"
  32145. // 解析WebSocket服务器地址
  32146. u, err := url.Parse(serverURL)
  32147. if err != nil {
  32148. }
  32149. // 建立WebSocket连接
  32150. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  32151. if err != nil {
  32152. }
  32153. defer conn.Close()
  32154. input2 := make(map[string]interface{})
  32155. input := make(map[string]interface{})
  32156. inputData := make(map[string]interface{})
  32157. inputData["orgId"] = code
  32158. inputData["businessType"] = "01301"
  32159. inputData["operatorId"] = operator_id
  32160. inputData["operatorName"] = operator_name
  32161. inputData["officeId"] = "001"
  32162. inputData["officeName"] = "血透室"
  32163. inputData["deviceType"] = ""
  32164. input["data"] = inputData
  32165. input["orgId"] = code
  32166. input["transType"] = "ec.query"
  32167. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32168. input2["indata"] = input
  32169. bytesData, _ := json.Marshal(input2)
  32170. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  32171. if err != nil {
  32172. fmt.Println(err)
  32173. }
  32174. // 接收消息
  32175. _, receivedMessage, err := conn.ReadMessage()
  32176. if err != nil {
  32177. fmt.Println(err)
  32178. }
  32179. return "", string(receivedMessage)
  32180. }
  32181. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  32182. newArr = make([]string, 0)
  32183. for i := 0; i < len(arr); i++ {
  32184. repeat := false
  32185. for j := i + 1; j < len(arr); j++ {
  32186. if arr[i] == arr[j] {
  32187. repeat = true
  32188. break
  32189. }
  32190. }
  32191. if !repeat {
  32192. newArr = append(newArr, arr[i])
  32193. }
  32194. }
  32195. return
  32196. }
  32197. func getBirthdateAndAge(idNumber string) (string, int, error) {
  32198. if len(idNumber) != 18 {
  32199. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  32200. }
  32201. // 提取出生日期
  32202. year, err := strconv.Atoi(idNumber[6:10])
  32203. if err != nil {
  32204. return "", 0, err
  32205. }
  32206. month, err := strconv.Atoi(idNumber[10:12])
  32207. if err != nil {
  32208. return "", 0, err
  32209. }
  32210. day, err := strconv.Atoi(idNumber[12:14])
  32211. if err != nil {
  32212. return "", 0, err
  32213. }
  32214. // 格式化生日字符串
  32215. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  32216. birthdateFormatted := birthdate.Format("2006-01-02")
  32217. // 计算年龄
  32218. today := time.Now()
  32219. age := today.Year() - birthdate.Year()
  32220. if today.YearDay() < birthdate.YearDay() {
  32221. age--
  32222. }
  32223. return birthdateFormatted, age, nil
  32224. }