his_api_controller.go 1.3MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. "gdyb/controllers"
  13. "gdyb/enums"
  14. "gdyb/models"
  15. "gdyb/service"
  16. "gdyb/utils"
  17. "github.com/astaxie/beego"
  18. "github.com/axgle/mahonia"
  19. "github.com/gorilla/websocket"
  20. "github.com/jinzhu/gorm"
  21. "github.com/shopspring/decimal"
  22. "github.com/go-ole/go-ole/oleutil"
  23. "io"
  24. "io/ioutil"
  25. //"math"
  26. "math/rand"
  27. "net/http"
  28. "net/url"
  29. "os"
  30. "path/filepath"
  31. "regexp"
  32. "strconv"
  33. "strings"
  34. "syscall"
  35. "time"
  36. "unsafe"
  37. )
  38. type HisApiController struct {
  39. controllers.BaseAuthAPIController
  40. }
  41. func HisManagerApiRegistRouters() {
  42. //挂号
  43. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  44. //上传就诊信息-上传明细-结算
  45. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  46. //查询
  47. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  48. //对总账
  49. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  50. //对明细
  51. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  52. //退费,退明细
  53. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  54. //退号
  55. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  56. //退明细
  57. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  58. //上传就诊信息-上传明细-预结算
  59. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  60. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  61. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  62. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  63. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  64. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  65. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  66. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  67. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  68. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  69. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  70. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  71. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  72. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  73. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  74. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  75. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  76. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  77. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  78. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  79. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  80. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  81. beego.Router("/api/check", &HisApiController{}, "get:Check")
  82. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  83. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  84. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  85. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  86. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  87. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  88. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  89. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  90. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  91. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  92. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  93. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  94. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  95. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  96. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  97. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  98. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  99. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  100. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  101. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  102. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  103. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  104. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  108. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  109. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  110. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  111. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  112. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  113. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  114. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  115. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  116. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  136. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  137. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  138. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  139. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  140. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  141. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  142. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  143. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  144. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  145. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  146. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  147. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  148. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  149. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  150. //库盘和变更
  151. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  152. //删除库盘和变更
  153. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  154. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  155. //药品变更
  156. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  157. }
  158. func (c *HisApiController) FJ3501AND3502() {
  159. ids := c.GetString("ids")
  160. admin_user_id, _ := c.GetInt64("admin_user_id")
  161. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  162. id_arr := strings.Split(ids, ",")
  163. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  164. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  165. //库盘
  166. var errs []string
  167. for _, drug := range drugs {
  168. if drug.IsPc == 0 && drug.IsBg == 0 {
  169. var res2 ResultSix
  170. var res3 ResultSix
  171. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  172. var struct3501 models.Struct3501
  173. struct3501.OrgName = miConfig.OrgName
  174. struct3501.AccessKey = miConfig.AccessKey
  175. struct3501.Opter = roles.UserName
  176. struct3501.RequestUrl = miConfig.Url
  177. struct3501.Url = miConfig.Url
  178. struct3501.AppId = miConfig.Cainfo
  179. struct3501.AppSecret = miConfig.AppSecret
  180. struct3501.Enckey = miConfig.EncKey
  181. struct3501.SignKey = miConfig.SignKey
  182. struct3501.SecretKey = miConfig.SecretKey
  183. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  184. struct3501.FixmedinsHilistId = miConfig.Code
  185. struct3501.FixmedinsHilistName = miConfig.OrgName
  186. struct3501.RxFlag = "0"
  187. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  188. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  189. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  190. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  191. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  192. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  193. struct3501.FixmedinsBchno = number
  194. memo := make(map[string]interface{})
  195. memo["pric"] = drug.Price
  196. bytesData, _ := json.Marshal(memo)
  197. struct3501.Memo = string(bytesData)
  198. result1, result2, _ := service.FJyb3501(struct3501)
  199. saveLog(result1, result2, "3501", "3501")
  200. //saveLog(result, requestLog, "2201", "挂号")
  201. var respJSON2 map[string]interface{}
  202. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  205. return
  206. }
  207. userJSONBytes2, _ := json.Marshal(respJSON2)
  208. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  209. utils.ErrorLog("解析失败:%v", err)
  210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  211. return
  212. }
  213. if res2.Infcode != -1 {
  214. drug.IsPc = 1
  215. drug.Bchno = number
  216. drug.PcDate = time.Now().Format("2006-01-02")
  217. err := service.SaveW(drug)
  218. if err == nil {
  219. var struct3502 models.Struct3502
  220. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  221. struct3502.FixmedinsHilistId = miConfig.Code
  222. struct3502.FixmedinsHilistName = miConfig.OrgName
  223. struct3502.FixmedinsCode = miConfig.Code
  224. struct3502.RxFlag = "0"
  225. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  226. struct3502.OrgName = miConfig.OrgName
  227. struct3502.Opter = roles.UserName
  228. struct3502.AccessKey = miConfig.AccessKey
  229. struct3502.RequestUrl = miConfig.Url
  230. struct3502.SecretKey = miConfig.SecretKey
  231. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  232. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  233. struct3502.Url = miConfig.Url
  234. struct3502.AppId = miConfig.Cainfo
  235. struct3502.AppSecret = miConfig.AppSecret
  236. struct3502.Enckey = miConfig.EncKey
  237. struct3502.SignKey = miConfig.SignKey
  238. struct3502.SecretKey = miConfig.SecretKey
  239. struct3502.Memo = ""
  240. struct3502.InvChgType = "108"
  241. struct3502.FixmedinsBchno = drug.Bchno
  242. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  243. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  244. result11, result22, _ := service.FJyb3502(struct3502)
  245. saveLog(result11, result22, "3502", "3502")
  246. var respJSON3 map[string]interface{}
  247. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  250. return
  251. }
  252. userJSONBytes3, _ := json.Marshal(respJSON3)
  253. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  254. utils.ErrorLog("解析失败:%v", err)
  255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  256. return
  257. }
  258. if res3.Infcode == -1 {
  259. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  260. c.ServeSuccessJSON(map[string]interface{}{
  261. "failed_code": -10,
  262. "msg": res3.ErrMsg,
  263. })
  264. } else {
  265. drug.IsBg = 1
  266. service.SaveW(drug)
  267. }
  268. }
  269. } else {
  270. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  271. }
  272. }
  273. //变更
  274. if drug.IsPc == 1 && drug.IsBg == 0 {
  275. var res3 ResultSix
  276. var struct3502 models.Struct3502
  277. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  278. struct3502.FixmedinsHilistId = miConfig.Code
  279. struct3502.FixmedinsHilistName = miConfig.OrgName
  280. struct3502.FixmedinsCode = miConfig.Code
  281. struct3502.Opter = roles.UserName
  282. struct3502.RxFlag = "0"
  283. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  284. struct3502.OrgName = miConfig.OrgName
  285. struct3502.AccessKey = miConfig.AccessKey
  286. struct3502.RequestUrl = miConfig.Url
  287. struct3502.SecretKey = miConfig.SecretKey
  288. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  289. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  290. struct3502.InvChgType = "108"
  291. struct3502.Url = miConfig.Url
  292. struct3502.AppId = miConfig.Cainfo
  293. struct3502.AppSecret = miConfig.AppSecret
  294. struct3502.Enckey = miConfig.EncKey
  295. struct3502.SignKey = miConfig.SignKey
  296. struct3502.SecretKey = miConfig.SecretKey
  297. struct3502.FixmedinsBchno = drug.Bchno
  298. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  299. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  300. result1, result2, _ := service.FJyb3502(struct3502)
  301. saveLog(result1, result2, "3502", "3502")
  302. var respJSON3 map[string]interface{}
  303. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  306. return
  307. }
  308. userJSONBytes3, _ := json.Marshal(respJSON3)
  309. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  310. utils.ErrorLog("解析失败:%v", err)
  311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  312. return
  313. }
  314. if res3.Infcode == -1 {
  315. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  316. } else {
  317. drug.IsBg = 1
  318. //drug.Bchno = number
  319. //drug.PcDate = time.Now().Format("2006-01-02")
  320. service.SaveW(drug)
  321. }
  322. }
  323. }
  324. if len(errs) == 0 {
  325. c.ServeSuccessJSON(map[string]interface{}{
  326. "msg": "盘存变更成功",
  327. })
  328. } else {
  329. c.ServeSuccessJSON(map[string]interface{}{
  330. "failed_code": -10,
  331. "msg": errs,
  332. })
  333. }
  334. }
  335. func (c *HisApiController) DeletePCandBG() {
  336. ids := c.GetString("ids")
  337. id_arr := strings.Split(ids, ",")
  338. admin_user_id, _ := c.GetInt64("admin_user_id")
  339. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  340. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  341. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  342. var err []string
  343. for _, item := range drugs {
  344. if item.IsPc == 1 && item.IsBg == 1 {
  345. var res FJ3507Result
  346. var res2 FJ3507Result
  347. var struct3507 models.Struct3507
  348. struct3507.FixmedinsBchno = item.Bchno
  349. struct3507.InvDataType = "1"
  350. struct3507.Opter = roles.UserName
  351. struct3507.OrgName = miConfig.OrgName
  352. struct3507.AccessKey = miConfig.AccessKey
  353. struct3507.RequestUrl = miConfig.Url
  354. struct3507.FixmedinsCode = miConfig.Code
  355. struct3507.SecretKey = miConfig.SecretKey
  356. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  357. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  358. struct3507.Url = miConfig.Url
  359. struct3507.AppId = miConfig.Cainfo
  360. struct3507.AppSecret = miConfig.AppSecret
  361. struct3507.Enckey = miConfig.EncKey
  362. struct3507.SignKey = miConfig.SignKey
  363. struct3507.SecretKey = miConfig.SecretKey
  364. result, result1, _ := service.FJyb3507(struct3507)
  365. saveLog(result, result1, "3507", "3507")
  366. var respJSON2 map[string]interface{}
  367. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  370. return
  371. }
  372. userJSONBytes2, _ := json.Marshal(respJSON2)
  373. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  374. utils.ErrorLog("解析失败:%v", err)
  375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  376. return
  377. }
  378. if res.Infcode != -1 {
  379. item.IsPc = 0
  380. err2 := service.SaveW(item)
  381. if err2 == nil {
  382. var struct3507_2 models.Struct3507
  383. struct3507_2.OrgName = miConfig.OrgName
  384. struct3507_2.AccessKey = miConfig.AccessKey
  385. struct3507_2.RequestUrl = miConfig.Url
  386. struct3507_2.Opter = roles.UserName
  387. struct3507_2.FixmedinsCode = miConfig.Code
  388. struct3507_2.SecretKey = miConfig.SecretKey
  389. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  390. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  391. struct3507_2.Url = miConfig.Url
  392. struct3507_2.AppId = miConfig.Cainfo
  393. struct3507_2.AppSecret = miConfig.AppSecret
  394. struct3507_2.Enckey = miConfig.EncKey
  395. struct3507_2.SignKey = miConfig.SignKey
  396. struct3507_2.SecretKey = miConfig.SecretKey
  397. struct3507_2.FixmedinsBchno = item.Bchno
  398. struct3507_2.InvDataType = "2"
  399. result11, result22, _ := service.FJyb3507(struct3507_2)
  400. saveLog(result11, result22, "3507", "3507")
  401. var respJSON3 map[string]interface{}
  402. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  405. return
  406. }
  407. userJSONBytes3, _ := json.Marshal(respJSON3)
  408. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  409. utils.ErrorLog("解析失败:%v", err)
  410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  411. return
  412. }
  413. if res2.Infcode != -1 {
  414. item.IsBg = 0
  415. item.Bchno = ""
  416. item.PcDate = ""
  417. service.SaveW(item)
  418. } else {
  419. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  420. }
  421. }
  422. } else {
  423. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  424. }
  425. }
  426. if item.IsPc == 1 && item.IsBg == 0 {
  427. var res FJ3507Result
  428. var struct3507 models.Struct3507
  429. struct3507.FixmedinsBchno = item.Bchno
  430. struct3507.InvDataType = "2"
  431. struct3507.Opter = roles.UserName
  432. struct3507.FixmedinsCode = miConfig.Code
  433. struct3507.OrgName = miConfig.OrgName
  434. struct3507.AccessKey = miConfig.AccessKey
  435. struct3507.RequestUrl = miConfig.Url
  436. struct3507.SecretKey = miConfig.SecretKey
  437. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  438. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  439. struct3507.Url = miConfig.Url
  440. struct3507.AppId = miConfig.Cainfo
  441. struct3507.AppSecret = miConfig.AppSecret
  442. struct3507.Enckey = miConfig.EncKey
  443. struct3507.SignKey = miConfig.SignKey
  444. struct3507.SecretKey = miConfig.SecretKey
  445. result, result1, _ := service.FJyb3507(struct3507)
  446. saveLog(result, result1, "3507", "3507")
  447. var respJSON3 map[string]interface{}
  448. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  451. return
  452. }
  453. userJSONBytes3, _ := json.Marshal(respJSON3)
  454. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  455. utils.ErrorLog("解析失败:%v", err)
  456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  457. return
  458. }
  459. if res.Infcode != -1 {
  460. item.IsBg = 0
  461. item.Bchno = ""
  462. item.PcDate = ""
  463. service.SaveW(item)
  464. } else {
  465. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  466. }
  467. }
  468. }
  469. if len(err) == 0 {
  470. c.ServeSuccessJSON(map[string]interface{}{
  471. "msg": "删除盘存变更成功",
  472. })
  473. } else {
  474. c.ServeSuccessJSON(map[string]interface{}{
  475. "failed_code": -10,
  476. "msg": err,
  477. })
  478. }
  479. }
  480. func (c *HisApiController) DeleteXSandBG() {
  481. ids := c.GetString("ids")
  482. id_arr := strings.Split(ids, ",")
  483. admin_user_id, _ := c.GetInt64("admin_user_id")
  484. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  485. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  486. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  487. for _, item := range drugs {
  488. if item.IsPc == 1 && item.IsBg == 1 {
  489. var struct3507 models.Struct3507
  490. struct3507.FixmedinsBchno =
  491. struct3507.InvDataType = "1"
  492. struct3507.Opter = roles.UserName
  493. struct3507.OrgName = miConfig.OrgName
  494. struct3507.AccessKey = miConfig.AccessKey
  495. struct3507.RequestUrl = miConfig.Url
  496. struct3507.SecretKey = miConfig.SecretKey
  497. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  498. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  499. struct3507.Url = miConfig.Url
  500. struct3507.AppId = miConfig.Cainfo
  501. struct3507.AppSecret = miConfig.AppSecret
  502. struct3507.Enckey = miConfig.EncKey
  503. struct3507.SignKey = miConfig.SignKey
  504. struct3507.SecretKey = miConfig.SecretKey
  505. struct3507.FixmedinsBchno = ""
  506. struct3507.InvDataType = "1"
  507. service.FJyb3507(struct3507)
  508. var struct3507_2 models.Struct3507
  509. struct3507_2.OrgName = miConfig.OrgName
  510. struct3507_2.AccessKey = miConfig.AccessKey
  511. struct3507_2.RequestUrl = miConfig.Url
  512. struct3507_2.SecretKey = miConfig.SecretKey
  513. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  514. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  515. struct3507_2.FixmedinsBchno = ""
  516. struct3507_2.InvDataType = "2"
  517. struct3507_2.Url = miConfig.Url
  518. struct3507_2.AppId = miConfig.Cainfo
  519. struct3507_2.AppSecret = miConfig.AppSecret
  520. struct3507_2.Enckey = miConfig.EncKey
  521. struct3507_2.SignKey = miConfig.SignKey
  522. struct3507_2.SecretKey = miConfig.SecretKey
  523. struct3507_2.FixmedinsBchno = ""
  524. struct3507_2.InvDataType = "1"
  525. service.FJyb3507(struct3507_2)
  526. }
  527. if item.IsPc == 1 && item.IsBg == 0 {
  528. var struct3507 models.Struct3507
  529. struct3507.OrgName = miConfig.OrgName
  530. struct3507.AccessKey = miConfig.AccessKey
  531. struct3507.RequestUrl = miConfig.Url
  532. struct3507.SecretKey = miConfig.SecretKey
  533. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  534. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  535. struct3507.FixmedinsBchno = ""
  536. struct3507.InvDataType = "1"
  537. service.FJyb3507(struct3507)
  538. }
  539. }
  540. }
  541. func (c *HisApiController) ChangeDrug() {
  542. ids := c.GetString("ids")
  543. id_arr := strings.Split(ids, ",")
  544. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  545. admin_user_id, _ := c.GetInt64("admin_user_id")
  546. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  547. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  548. var err []string
  549. for _, item := range flows {
  550. var res3 ResultSix
  551. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  552. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  553. if prescription.OrderStatus == 2 {
  554. //已经结算
  555. //判断是否已经销售
  556. if item.IsSale == 1 { //是否已经销售,1是 0否
  557. //是否已经变更 1是 0否
  558. if item.IsChange == 0 { //没变更,进行变更操作
  559. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  560. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  561. var respJSON3 map[string]interface{}
  562. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  565. return
  566. }
  567. userJSONBytes3, _ := json.Marshal(respJSON3)
  568. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  569. utils.ErrorLog("解析失败:%v", err)
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  571. return
  572. }
  573. if res3.Infcode != -1{
  574. item.IsChange = 1
  575. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  576. service.SaveDF2(item)
  577. }else{
  578. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  579. }
  580. }
  581. } else { //没销售,
  582. var res FJ3507Result
  583. //进行商品销售接口
  584. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles)
  585. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  586. var respJSON3 map[string]interface{}
  587. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  590. return
  591. }
  592. userJSONBytes3, _ := json.Marshal(respJSON3)
  593. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  594. utils.ErrorLog("解析失败:%v", err)
  595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  596. return
  597. }
  598. if res.Infcode != -1 {
  599. item.IsSale = 1
  600. item.SaleDate = time.Now().Format("2006-01-02")
  601. err5 := service.SaveDF(item)
  602. if err5 == nil {
  603. if item.IsChange == 0 { //没变更,进行变更操作
  604. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  605. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  606. var respJSON3 map[string]interface{}
  607. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  610. return
  611. }
  612. userJSONBytes3, _ := json.Marshal(respJSON3)
  613. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  614. utils.ErrorLog("解析失败:%v", err)
  615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  616. return
  617. }
  618. if res3.Infcode != -1 {
  619. item.IsChange = 1
  620. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  621. service.SaveDF2(item)
  622. } else {
  623. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  624. }
  625. }
  626. }
  627. }else{
  628. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  629. }
  630. }
  631. } else { //还没结算
  632. if item.IsChange == 0 { //没变更,进行变更操作
  633. result, result2 :=ChangeStock(item.Count, item, miConfig, "107", roles)
  634. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  635. var respJSON3 map[string]interface{}
  636. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  639. return
  640. }
  641. userJSONBytes3, _ := json.Marshal(respJSON3)
  642. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  643. utils.ErrorLog("解析失败:%v", err)
  644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  645. return
  646. }
  647. if res3.Infcode != -1{
  648. item.IsChange = 1
  649. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  650. service.SaveDF2(item)
  651. }else{
  652. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  653. }
  654. }
  655. }
  656. } else if item.ConsumableType == 7 {
  657. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  658. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  659. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  660. //判断是否已经销售
  661. if item.IsSale == 1 { //是否已经销售,1是 0否
  662. //是否已经变更 1是 0否
  663. if item.IsChange == 0 { //没变更,进行变更操作
  664. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  665. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  666. var respJSON3 map[string]interface{}
  667. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. userJSONBytes3, _ := json.Marshal(respJSON3)
  673. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  674. utils.ErrorLog("解析失败:%v", err)
  675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  676. return
  677. }
  678. if res3.Infcode != -1{
  679. item.IsChange = 1
  680. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  681. service.SaveDF2(item)
  682. }else{
  683. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  684. }
  685. }
  686. } else { //没销售,
  687. //进行商品销售退货接口
  688. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "",roles)
  689. saveLog(result111,result222,"3506","销售退货")
  690. if item.IsChange == 0 { //没变更,进行变更操作
  691. result, result2 :=ChangeStock(item.Count, item, miConfig, "107", roles)
  692. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  693. var respJSON3 map[string]interface{}
  694. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. userJSONBytes3, _ := json.Marshal(respJSON3)
  700. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  701. utils.ErrorLog("解析失败:%v", err)
  702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  703. return
  704. }
  705. if res3.Infcode != -1{
  706. item.IsChange = 1
  707. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  708. service.SaveDF2(item)
  709. }else{
  710. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  711. }
  712. }
  713. }
  714. } else { //还没结算
  715. if item.IsChange == 0 { //没变更,进行变更操作
  716. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  717. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  718. var respJSON3 map[string]interface{}
  719. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  722. return
  723. }
  724. userJSONBytes3, _ := json.Marshal(respJSON3)
  725. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  726. utils.ErrorLog("解析失败:%v", err)
  727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  728. return
  729. }
  730. if res3.Infcode != -1{
  731. item.IsChange = 1
  732. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  733. service.SaveDF2(item)
  734. }else{
  735. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  736. }
  737. }
  738. }
  739. } else { //其他方式
  740. if item.IsChange == 0 { //没变更,进行变更操作
  741. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  742. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  743. var respJSON3 map[string]interface{}
  744. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. userJSONBytes3, _ := json.Marshal(respJSON3)
  750. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  751. utils.ErrorLog("解析失败:%v", err)
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. if res3.Infcode != -1{
  756. item.IsChange = 1
  757. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  758. service.SaveDF2(item)
  759. }else{
  760. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  761. }
  762. }
  763. }
  764. }
  765. }
  766. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string,string){
  767. var struct3502 models.Struct3502
  768. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  769. struct3502.FixmedinsHilistId = miConfig.Code
  770. struct3502.FixmedinsHilistName = miConfig.OrgName
  771. struct3502.FixmedinsCode = miConfig.Code
  772. struct3502.Opter = role.UserName
  773. struct3502.RxFlag = "0"
  774. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  775. struct3502.OrgName = miConfig.OrgName
  776. struct3502.AccessKey = miConfig.AccessKey
  777. struct3502.RequestUrl = miConfig.Url
  778. struct3502.SecretKey = miConfig.SecretKey
  779. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  780. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  781. struct3502.Url = miConfig.Url
  782. struct3502.AppId = miConfig.Cainfo
  783. struct3502.AppSecret = miConfig.AppSecret
  784. struct3502.Enckey = miConfig.EncKey
  785. struct3502.SignKey = miConfig.SignKey
  786. struct3502.SecretKey = miConfig.SecretKey
  787. struct3502.InvChgType = chgType
  788. struct3502.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
  789. struct3502.Cnt = strconv.FormatInt(count, 10)
  790. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  791. result1, result2, _ := service.FJyb3502(struct3502)
  792. return result1,result2
  793. }
  794. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string, string){
  795. var struct3505 models.Struct3505
  796. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  797. struct3505.FixmedinsHilistId = miConfig.Code
  798. struct3505.FixmedinsHilistName = miConfig.OrgName
  799. struct3505.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
  800. struct3505.FixmedinsCode = miConfig.Code
  801. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  802. struct3505.PrscDrName =roles.UserName
  803. struct3505.PharName = "刘水山"
  804. struct3505.PharPracCertNo = "2015026350260000002611351127"
  805. order := service.GetHisOrderByNumber(pre.BatchNumber)
  806. struct3505.SetlId = order.SetlId
  807. struct3505.MdtrtSn = order.MdtrtId
  808. struct3505.ManuLotnum = drug.Number
  809. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02 15:04:05")
  810. struct3505.ExpyEnd = ""
  811. struct3505.RxFlag = "0"
  812. struct3505.TrdnFlag = "1"
  813. struct3505.RtalDocno = order.Number
  814. struct3505.Url = miConfig.Url
  815. struct3505.AppId = miConfig.Cainfo
  816. struct3505.AppSecret = miConfig.AppSecret
  817. struct3505.Enckey = miConfig.EncKey
  818. struct3505.SignKey = miConfig.SignKey
  819. struct3505.SecretKey = miConfig.SecretKey
  820. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  821. struct3505.SelRetnCnt = strValue
  822. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  823. struct3505.SelRetnOpterName = role.UserName
  824. if order.IsMedicineInsurance == 1 {
  825. struct3505.MdtrtSetlType = "1"
  826. } else {
  827. struct3505.MdtrtSetlType = "2"
  828. }
  829. struct3505.OrgName = miConfig.OrgName
  830. struct3505.AccessKey = miConfig.AccessKey
  831. struct3505.RequestUrl = miConfig.Url
  832. struct3505.SecretKey = miConfig.SecretKey
  833. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  834. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  835. result1, result2, _ := service.FJyb3505(struct3505)
  836. return result1,result2
  837. }
  838. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string,role models.UserAdminRole) (string,string){
  839. var struct3506 models.Struct3506
  840. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  841. struct3506.FixmedinsHilistId = miConfig.Code
  842. struct3506.FixmedinsHilistName = miConfig.OrgName
  843. struct3506.FixmedinsCode = miConfig.Code
  844. struct3506.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
  845. struct3506.Opter = role.UserName
  846. order := service.GetHisOrderByNumber(pre.BatchNumber)
  847. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  848. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  849. struct3506.MdtrtSn = order.MdtrtId
  850. struct3506.ExpyEnd = ""
  851. struct3506.RxFlag = "0"
  852. struct3506.TrdnFlag = "1"
  853. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  854. struct3506.SelRetnCnt = strValue
  855. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  856. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  857. struct3506.SelRetnOpterName = role.UserName
  858. struct3506.OrgName = miConfig.OrgName
  859. struct3506.AccessKey = miConfig.AccessKey
  860. struct3506.RequestUrl = miConfig.Url
  861. struct3506.SecretKey = miConfig.SecretKey
  862. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  863. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  864. struct3506.Url = miConfig.Url
  865. struct3506.AppId = miConfig.Cainfo
  866. struct3506.AppSecret = miConfig.AppSecret
  867. struct3506.Enckey = miConfig.EncKey
  868. struct3506.SignKey = miConfig.SignKey
  869. struct3506.SecretKey = miConfig.SecretKey
  870. result1, result2, _ := service.FJyb3506(struct3506)
  871. return result1,result2
  872. }
  873. func (c *HisApiController) Get1318() {
  874. adminUser := c.GetAdminUserInfo()
  875. admin_user_id, _ := c.GetInt64("admin_user_id")
  876. code := c.GetString("code")
  877. code = ""
  878. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  879. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  880. api := ""
  881. if miConfig.MdtrtareaAdmvs == "320921" {
  882. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  883. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  884. } else {
  885. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  886. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  887. }
  888. resp, requestErr := http.Get(api)
  889. if requestErr != nil {
  890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  891. return
  892. }
  893. body, ioErr := ioutil.ReadAll(resp.Body)
  894. if ioErr != nil {
  895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  897. return
  898. }
  899. var respJSON map[string]interface{}
  900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  903. return
  904. }
  905. //var res Result2406
  906. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  907. result, _ := json.Marshal(respJSON)
  908. if err := json.Unmarshal([]byte(result), &res); err != nil {
  909. utils.ErrorLog("解析失败:%v", err)
  910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. }
  913. if res.Infcode == "0" {
  914. c.ServeSuccessJSON(map[string]interface{}{
  915. "result": "",
  916. })
  917. } else {
  918. c.ServeSuccessJSON(map[string]interface{}{
  919. "failed_code": -10,
  920. "msg": res.ErrMsg,
  921. })
  922. */return
  923. //}
  924. }
  925. func (c *HisApiController) Get2503() {
  926. adminUser := c.GetAdminUserInfo()
  927. admin_user_id, _ := c.GetInt64("admin_user_id")
  928. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  929. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  930. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  931. }
  932. func (c *HisApiController) Get2406() {
  933. id, _ := c.GetInt64("id")
  934. record_time := c.GetString("record_time")
  935. his_patient_id, _ := c.GetInt64("his_patient_id")
  936. admin_user_id, _ := c.GetInt64("admin_user_id")
  937. diagnosis_id := c.GetString("diagnosis")
  938. timeLayout := "2006-01-02"
  939. loc, _ := time.LoadLocation("Local")
  940. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  941. if err != nil {
  942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  943. return
  944. }
  945. recordDateTime := theTime.Unix()
  946. adminUser := c.GetAdminUserInfo()
  947. diagnosis_ids := strings.Split(diagnosis_id, ",")
  948. var config []*models.HisXtDiagnoseConfig
  949. for _, item := range diagnosis_ids {
  950. id, _ := strconv.ParseInt(item, 10, 64)
  951. diagnosisConfig, _ := service.FindDiagnoseById(id)
  952. config = append(config, &diagnosisConfig)
  953. }
  954. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  955. fmt.Println(his_patient_id)
  956. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  957. //timestamp := time.Now().Unix()
  958. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  959. var patientPrescription models.HisPrescriptionInfo
  960. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  961. if patientPrescription.ID == 0 {
  962. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  963. }
  964. var res2 Result2406
  965. if miConfig.MdtrtareaAdmvs == "341203" {
  966. data := make(map[string]interface{})
  967. client := &http.Client{}
  968. data["psn_no"] = his.PsnNo
  969. data["mdtrt_id"] = his.Number
  970. data["operator"] = roles.UserName
  971. data["cert_no"] = his.IdCardNo
  972. data["org_name"] = miConfig.OrgName
  973. data["psn_name"] = his.Name
  974. data["ipt_otp_no"] = his.IptOtpNo
  975. data["ipt_psn_sp_flag_type"] = "0901"
  976. data["ipt_psn_sp_flag"] = "1"
  977. data["fixmedins_code"] = miConfig.Code
  978. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  979. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  980. data["url"] = miConfig.Url
  981. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  982. bytesData, _ := json.Marshal(data)
  983. var req *http.Request
  984. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  985. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  986. resp, _ := client.Do(req)
  987. defer resp.Body.Close()
  988. body, ioErr := ioutil.ReadAll(resp.Body)
  989. if ioErr != nil {
  990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  992. return
  993. }
  994. var respJSON map[string]interface{}
  995. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  998. return
  999. }
  1000. status := respJSON["data"].(map[string]interface{})["status"].(string)
  1001. if status == "0" {
  1002. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  1003. c.ServeSuccessJSON(map[string]interface{}{
  1004. "failed_code": -10,
  1005. "msg": err_msg,
  1006. })
  1007. return
  1008. }
  1009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1010. userJSONBytes, _ := json.Marshal(respJSON)
  1011. fmt.Println("log")
  1012. fmt.Println(string(userJSONBytes))
  1013. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1014. utils.ErrorLog("解析失败:%v", err)
  1015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1016. return
  1017. }
  1018. }
  1019. if res2.Infcode != 0 {
  1020. adminUser := c.GetAdminUserInfo()
  1021. errlog := &models.HisOrderError{
  1022. UserOrgId: adminUser.CurrentOrgId,
  1023. Ctime: time.Now().Unix(),
  1024. Mtime: time.Now().Unix(),
  1025. ErrMsg: res2.ErrMsg,
  1026. Status: 1,
  1027. PatientId: id,
  1028. RecordTime: recordDateTime,
  1029. Stage: 3,
  1030. }
  1031. service.CreateErrMsgLog(errlog)
  1032. c.ServeSuccessJSON(map[string]interface{}{
  1033. "failed_code": -10,
  1034. "msg": res2.ErrMsg,
  1035. })
  1036. return
  1037. } else {
  1038. c.ServeSuccessJSON(map[string]interface{}{
  1039. "msg": "上传成功",
  1040. })
  1041. return
  1042. }
  1043. }
  1044. func (c *HisApiController) Get4105() {
  1045. }
  1046. func (c *HisApiController) Post5302() {
  1047. patient_id, _ := c.GetInt64("id")
  1048. admin_user_id, _ := c.GetInt64("admin_user_id")
  1049. p, _ := service.GetHisPatientById(patient_id)
  1050. adminUser := c.GetAdminUserInfo()
  1051. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1052. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1053. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  1054. }
  1055. func (c *HisApiController) Get4104() {
  1056. }
  1057. type Output struct {
  1058. CertNo string `json:"certno"`
  1059. PsnName string `json:"psn_name"`
  1060. CardNo string `json:"card_no"`
  1061. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1062. CardSN string `json:"card_sn"`
  1063. PsnCertType string `json:"psn_cert_type"`
  1064. MdtrtCertNo string `json:"mdtrt_cert_no"`
  1065. MdtrtCertType string `json:"mdtrt_cert_type"`
  1066. QRCode string `json:"qrCode"`
  1067. EcToken string `json:"ecToken"`
  1068. }
  1069. type AHResponse struct {
  1070. Body AHBody `json:"body"`
  1071. Code int `json:"code"`
  1072. CSBCode int `json:"csbCode"`
  1073. Message string `json:"message"`
  1074. RequestID string `json:"requestId"`
  1075. State struct{} `json:"state"`
  1076. }
  1077. type AHBody struct {
  1078. ErrMsg string `json:"err_msg"`
  1079. InfRefMsgID string `json:"inf_refmsgid"`
  1080. InfCode int `json:"infcode"`
  1081. Output struct {
  1082. Result []struct {
  1083. BasMednFlag string `json:"bas_medn_flag"`
  1084. ChldMedcFlag string `json:"chld_medc_flag"`
  1085. ChrgitmLv string `json:"chrgitm_lv"`
  1086. Cnt float64 `json:"cnt"`
  1087. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1088. DrtReimFlag string `json:"drt_reim_flag"`
  1089. FeedetlSn string `json:"feedetl_sn"`
  1090. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1091. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1092. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1093. ListSpItemFlag string `json:"list_sp_item_flag"`
  1094. LmtUsedFlag string `json:"lmt_used_flag"`
  1095. MedChrgitmType string `json:"med_chrgitm_type"`
  1096. Memo string `json:"memo"`
  1097. OverlmtAmt float64 `json:"overlmt_amt"`
  1098. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1099. Pric float64 `json:"pric"`
  1100. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1101. SelfpayProp float64 `json:"selfpay_prop"`
  1102. } `json:"result"`
  1103. } `json:"output"`
  1104. }
  1105. type Response struct {
  1106. Output Output `json:"output"`
  1107. Infcode int `json:"infcode"`
  1108. InfRefMsgID string `json:"inf_refmsgid"`
  1109. RefMsgTime string `json:"refmsg_time"`
  1110. RespondTime string `json:"respond_time"`
  1111. ErrMsg string `json:"err_msg"`
  1112. WarnMsg string `json:"warn_msg"`
  1113. SignType string `json:"signtype"`
  1114. CAInfo string `json:"cainfo"`
  1115. }
  1116. func (c *HisApiController) Getquerydata() {
  1117. query_type, _ := c.GetInt64("type")
  1118. refd_setl_flag := c.GetString("refd_setl_flag")
  1119. med_type := c.GetString("med_type")
  1120. //admin_user_id,_ := c.GetInt64("admin_user_id")
  1121. cert_no := c.GetString("cert_no")
  1122. psn_no := c.GetString("psn_no")
  1123. start_time := c.GetString("start_time")
  1124. end_time := c.GetString("end_time")
  1125. page, _ := c.GetInt64("page")
  1126. limit, _ := c.GetInt64("limit")
  1127. var bp models.BusinessParams5262
  1128. bp.RefdSetlFlag = refd_setl_flag
  1129. bp.MedType = med_type
  1130. bp.Certno = cert_no
  1131. bp.Psnno = psn_no
  1132. bp.QBegntime = start_time
  1133. bp.QEndtime = end_time
  1134. if query_type == 1 { //本地
  1135. Post5262(c, bp, page, limit)
  1136. } else { //异地
  1137. Post5267(c, bp, page, limit)
  1138. }
  1139. }
  1140. func (c *HisApiController) Drugscheck() {
  1141. admin_user_id, _ := c.GetInt64("admin_user_id")
  1142. adminUser := c.GetAdminUserInfo()
  1143. var queryResult []QueryResult
  1144. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  1145. for _, item := range drugs {
  1146. result := QueryResult{
  1147. ID: item.ID,
  1148. Name: item.DrugName,
  1149. Code: item.MedicalInsuranceNumber,
  1150. List_type_code: "101",
  1151. }
  1152. queryResult = append(queryResult, result)
  1153. }
  1154. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1155. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1156. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1157. for _, item := range queryResult {
  1158. 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)
  1159. }
  1160. }
  1161. func (c *HisApiController) Goodcheck() {
  1162. admin_user_id, _ := c.GetInt64("admin_user_id")
  1163. adminUser := c.GetAdminUserInfo()
  1164. var queryResult []QueryResult
  1165. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  1166. for _, item := range goods {
  1167. result := QueryResult{
  1168. ID: item.ID,
  1169. Name: item.GoodName,
  1170. Code: item.SocialSecurityDirectoryCode,
  1171. List_type_code: "301",
  1172. }
  1173. queryResult = append(queryResult, result)
  1174. }
  1175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1176. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1177. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1178. for _, item := range queryResult {
  1179. 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)
  1180. //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)
  1181. }
  1182. }
  1183. func (c *HisApiController) Projectcheck() {
  1184. admin_user_id, _ := c.GetInt64("admin_user_id")
  1185. adminUser := c.GetAdminUserInfo()
  1186. var queryResult []QueryResult
  1187. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  1188. for _, item := range projects {
  1189. result := QueryResult{
  1190. ID: item.ID,
  1191. Name: item.ProjectName,
  1192. Code: item.MedicalCode,
  1193. List_type_code: "201",
  1194. }
  1195. queryResult = append(queryResult, result)
  1196. }
  1197. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1198. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1199. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1200. for _, item := range queryResult {
  1201. 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)
  1202. }
  1203. }
  1204. //func (c *HisApiController)CancleDia(){
  1205. //
  1206. // id, _ := c.GetInt64("id")
  1207. // record_time := c.GetString("record_time")
  1208. // his_patient_id, _ := c.GetInt64("his_patient_id")
  1209. //
  1210. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1211. //
  1212. // diagnosis_id := c.GetString("diagnosis")
  1213. // sick_type, _ := c.GetInt64("sick_type")
  1214. // reg_type, _ := c.GetInt64("p_type")
  1215. // begin_time := c.GetString("begin_time")
  1216. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  1217. //
  1218. //
  1219. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  1220. //
  1221. // fmt.Println(acct_used_flag)
  1222. //
  1223. //
  1224. // timeLayout := "2006-01-02"
  1225. // loc, _ := time.LoadLocation("Local")
  1226. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1227. // if err != nil {
  1228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1229. // return
  1230. // }
  1231. // recordDateTime := theTime.Unix()
  1232. // adminUser := c.GetAdminUserInfo()
  1233. //
  1234. //
  1235. //
  1236. //
  1237. //
  1238. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1239. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1240. // var patientPrescription models.HisPrescriptionInfo
  1241. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1242. // if patientPrescription.ID == 0 {
  1243. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1244. // }
  1245. // //if patientPrescription.Do
  1246. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1247. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1248. //
  1249. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1250. //
  1251. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  1252. //
  1253. // var config []*models.HisXtDiagnoseConfig
  1254. // for _, item := range diagnosis_ids {
  1255. // id, _ := strconv.ParseInt(item, 10, 64)
  1256. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  1257. // config = append(config, &diagnosisConfig)
  1258. // }
  1259. //
  1260. // sickConfig, _ := service.FindSickById(sick_type)
  1261. //
  1262. //
  1263. // data := make(map[string]interface{})
  1264. // client := &http.Client{}
  1265. // data["psn_no"] = his.PsnNo
  1266. // data["mdtrt_id"] = his.Number
  1267. // data["doctor"] = roles.UserName
  1268. // data["department"] = department.Name
  1269. // data["org_name"] = miConfig.OrgName
  1270. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  1271. // data["doctor_id"] = doctor_info.DoctorNumber
  1272. // data["new_doctor_name"] = doctor_info.UserName
  1273. // data["fixmedins_code"] = miConfig.Code
  1274. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  1275. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1276. // data["secret_key"] = miConfig.SecretKey
  1277. // data["sick_code"] = sickConfig.CountryCode
  1278. // data["sick_name"] = sickConfig.ClassName
  1279. // data["url"] = miConfig.Url
  1280. // data["ak"] = miConfig.AccessKey
  1281. // data["begin_time"] = begin_time
  1282. // data["cainfo"] = miConfig.Cainfo
  1283. // data["is_vaild"] = "0"
  1284. //
  1285. // data["dept"] = strconv.FormatInt(department.ID, 10)
  1286. // data["config"] = config
  1287. // bytesData, _ := json.Marshal(data)
  1288. //
  1289. // var req *http.Request
  1290. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  1291. // resp, _ := client.Do(req)
  1292. // defer resp.Body.Close()
  1293. // body, ioErr := ioutil.ReadAll(resp.Body)
  1294. // if ioErr != nil {
  1295. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1297. // return
  1298. // }
  1299. // var respJSON map[string]interface{}
  1300. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1301. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1302. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1303. // return
  1304. // }
  1305. //
  1306. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1307. // userJSONBytes, _ := json.Marshal(respJSON)
  1308. // fmt.Println("log")
  1309. // fmt.Println(string(userJSONBytes))
  1310. //
  1311. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  1312. // utils.ErrorLog("解析失败:%v", err)
  1313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1314. // return
  1315. // }
  1316. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  1317. // res2.Output = ressix10265.Output
  1318. // res2.ErrMsg = ressix10265.ErrMsg
  1319. // res2.Cainfo = ressix10265.Cainfo
  1320. // res2.WarnMsg = ressix10265.WarnMsg
  1321. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  1322. // res2.Infcode = infocode
  1323. //
  1324. //}
  1325. func (c *HisApiController) Get4102() {
  1326. order_id, _ := c.GetInt64("order_id")
  1327. admin_user_id, _ := c.GetInt64("admin_user_id")
  1328. stas_type := c.GetString("stas_type")
  1329. order, _ := service.GetHisOrderByIDTwo(order_id)
  1330. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1331. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1332. var pp models.PublicParams
  1333. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1334. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1335. pp.FixmedinsName = miConfig.OrgName
  1336. pp.FixmedinsCode = miConfig.Code
  1337. pp.RequestUrl = miConfig.Url
  1338. pp.Cainfo = miConfig.Cainfo
  1339. pp.SecretKey = miConfig.SecretKey
  1340. pp.AccessKey = miConfig.AccessKey
  1341. pp.OpterName = curRoles.UserName
  1342. if miConfig.MdtrtareaAdmvs == "350500" {
  1343. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1344. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  1345. saveLog(result, request, "4102", "清单确认")
  1346. var dat map[string]interface{}
  1347. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1348. fmt.Println(dat)
  1349. } else {
  1350. fmt.Println(err)
  1351. }
  1352. var empty ResultFourteen
  1353. userJSONBytes, _ := json.Marshal(dat)
  1354. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1355. utils.ErrorLog("解析失败:%v", err)
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1357. return
  1358. }
  1359. if empty.Infcode == 0 {
  1360. c.ServeSuccessJSON(map[string]interface{}{
  1361. "msg": "确认成功",
  1362. })
  1363. return
  1364. }
  1365. } else {
  1366. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1367. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  1368. result3, request3 := service.Jxyb4105(pp)
  1369. saveLog(result, request, "4102", "清单确认")
  1370. saveLog(result2, request2, "4103", "清单确认")
  1371. saveLog(result3, request3, "4105", "清单统计")
  1372. var dat map[string]interface{}
  1373. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1374. fmt.Println(dat)
  1375. } else {
  1376. fmt.Println(err)
  1377. }
  1378. var empty ResultFourteen
  1379. userJSONBytes, _ := json.Marshal(dat)
  1380. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1381. utils.ErrorLog("解析失败:%v", err)
  1382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1383. return
  1384. }
  1385. if empty.Infcode == 0 {
  1386. c.ServeSuccessJSON(map[string]interface{}{
  1387. "msg": "确认成功",
  1388. })
  1389. return
  1390. }
  1391. }
  1392. }
  1393. // 对账权限查询
  1394. func (c *HisApiController) Get3260() {
  1395. admin_user_id, _ := c.GetInt64("admin_user_id")
  1396. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1397. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1398. var api string
  1399. var res models.JSResult3260
  1400. if miConfig.MdtrtareaAdmvs == "320921" {
  1401. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1402. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1403. } else {
  1404. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1405. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1406. }
  1407. resp, requestErr := http.Get(api)
  1408. if requestErr != nil {
  1409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1410. return
  1411. }
  1412. body, ioErr := ioutil.ReadAll(resp.Body)
  1413. if ioErr != nil {
  1414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1416. return
  1417. }
  1418. var respJSON map[string]interface{}
  1419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1422. return
  1423. }
  1424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1425. result, _ := json.Marshal(respJSON)
  1426. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1427. utils.ErrorLog("解析失败:%v", err)
  1428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1429. return
  1430. }
  1431. if res.Infcode == "0" {
  1432. c.ServeSuccessJSON(map[string]interface{}{
  1433. "result": res.Output.Data,
  1434. })
  1435. } else {
  1436. c.ServeSuccessJSON(map[string]interface{}{
  1437. "failed_code": -10,
  1438. "msg": res.ErrMsg,
  1439. })
  1440. return
  1441. }
  1442. }
  1443. func (c *HisApiController) Get3261() {
  1444. admin_user_id, _ := c.GetInt64("admin_user_id")
  1445. //month := c.GetString("month")
  1446. startTime := c.GetString("start_time")
  1447. //endTime, _ := c.GetString("end_time")
  1448. times := strings.Split(startTime, "-")
  1449. stmt_mon := times[0] + times[1]
  1450. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1451. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1452. var api string
  1453. var res models.JSResult3261
  1454. //var res10265 Result5301For10265
  1455. if miConfig.MdtrtareaAdmvs == "320921" {
  1456. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1457. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1458. } else {
  1459. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1460. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1461. }
  1462. resp, requestErr := http.Get(api)
  1463. if requestErr != nil {
  1464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1465. return
  1466. }
  1467. body, ioErr := ioutil.ReadAll(resp.Body)
  1468. if ioErr != nil {
  1469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1471. return
  1472. }
  1473. var respJSON map[string]interface{}
  1474. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1477. return
  1478. }
  1479. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1480. result, _ := json.Marshal(respJSON)
  1481. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1482. utils.ErrorLog("解析失败:%v", err)
  1483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1484. return
  1485. }
  1486. if res.Infcode == "0" {
  1487. c.ServeSuccessJSON(map[string]interface{}{
  1488. "result": res.Output,
  1489. })
  1490. } else {
  1491. c.ServeSuccessJSON(map[string]interface{}{
  1492. "failed_code": -10,
  1493. "msg": res.ErrMsg,
  1494. })
  1495. return
  1496. }
  1497. }
  1498. type TempFun struct {
  1499. FundKey string
  1500. FundCode string
  1501. }
  1502. func (c *HisApiController) Get3262() {
  1503. admin_user_id, _ := c.GetInt64("admin_user_id")
  1504. startTime := c.GetString("start_time")
  1505. endTime := c.GetString("end_time")
  1506. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1507. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1508. //timeLayout := "2006-01-02"
  1509. //loc, _ := time.LoadLocation("Local")
  1510. //var theStartTIme int64
  1511. //if len(startTime) > 0 {
  1512. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1513. // if err != nil {
  1514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1515. // return
  1516. // }
  1517. // theStartTIme = theTime.Unix()
  1518. //}
  1519. //var theEndtTIme int64
  1520. //if len(endTime) > 0 {
  1521. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1522. // if err != nil {
  1523. // utils.ErrorLog(err.Error())
  1524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1525. // return
  1526. // }
  1527. // theEndtTIme = theTime.Unix()
  1528. //}
  1529. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1530. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1531. for _, team := range datas {
  1532. fmt.Println(team.PsnTime)
  1533. for _, team_two := range datas_two {
  1534. fmt.Println(team_two.PsnTime)
  1535. if team.FundKey == team_two.FundKey {
  1536. fmt.Println(team_two.PsnTime)
  1537. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1538. fmt.Println(team.PsnTime)
  1539. }
  1540. }
  1541. }
  1542. fmt.Println("1111")
  1543. fmt.Println(datas)
  1544. fmt.Println("1111")
  1545. var twos []models.FixMonRecDetailFileInTwo
  1546. for _, team := range datas {
  1547. var two models.FixMonRecDetailFileInTwo
  1548. two.MedType = team.MedType
  1549. two.Insutype = team.Insutype
  1550. two.PsnType = team.PsnType
  1551. two.MedType = team.MedType
  1552. two.FixBlngAdmdvs = "999999"
  1553. two.InsuAdmdvs = "555555"
  1554. two.PsnTime = team.PsnTime
  1555. two.PsnCnt = team.PsnCnt
  1556. two.FundKey = team.FundKey
  1557. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1558. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1559. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1560. two.MedfeeSumAmt = ms
  1561. two.InscpAmt = ia
  1562. two.FundPaySumAmt = fps
  1563. twos = append(twos, two)
  1564. }
  1565. //startTime := c.GetString("start_time")
  1566. //endTime, _ := c.GetString("end_time")
  1567. times := strings.Split(startTime, "-")
  1568. stmt_mon := times[0] + times[1]
  1569. var funs []models.FundDetail
  1570. for _, item := range datas {
  1571. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1572. funs = append(funs, fun...)
  1573. }
  1574. var funInfos []models.Fund
  1575. //for _, item := range funs {
  1576. // var rf []models.FundInfo
  1577. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1578. // for _, subitem := range rf {
  1579. // var fund models.Fund
  1580. // fund.FundCode = subitem.FundPayType
  1581. // fund.FundName = subitem.FundPayTypeName
  1582. // fund.FundAmt = subitem.FundPayAmt
  1583. // fund.FundKey = item.FundKey
  1584. // fund.InsuAdmdvs = "555555"
  1585. // fund.FixBlngAdmdvs = "999999"
  1586. // funInfos = append(funInfos, fund)
  1587. // }
  1588. //}
  1589. var tempFuns []TempFun
  1590. for _, funInfo := range funInfos {
  1591. var tempFun TempFun
  1592. tempFun.FundKey = funInfo.FundKey
  1593. tempFun.FundCode = funInfo.FundCode
  1594. tempFuns = append(tempFuns, tempFun)
  1595. }
  1596. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1597. fmt.Println(tempFuns)
  1598. var funInfosTwo []models.Fund
  1599. decimal.DivisionPrecision = 2
  1600. for _, item := range tempFuns {
  1601. var fund models.Fund
  1602. for _, subItem := range funInfos {
  1603. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1604. fund.FundKey = subItem.FundKey
  1605. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1606. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1607. fund.FundName = subItem.FundName
  1608. fund.FundCode = subItem.FundCode
  1609. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1610. }
  1611. }
  1612. funInfosTwo = append(funInfosTwo, fund)
  1613. }
  1614. fmt.Println("funInfosTwo")
  1615. fmt.Println(funInfosTwo)
  1616. var upld_btch string
  1617. var empty models.JSResultEmpty
  1618. data := make(map[string]interface{})
  1619. data["org_name"] = miConfig.OrgName
  1620. data["doctor"] = curRoles.UserName
  1621. data["doctor_name"] = curRoles.UserName
  1622. data["fixmedins_code"] = miConfig.Code
  1623. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1624. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1625. data["secret_key"] = miConfig.SecretKey
  1626. data["url"] = miConfig.Url
  1627. data["ak"] = miConfig.AccessKey
  1628. data["cainfo"] = miConfig.Cainfo
  1629. data["datas"] = twos
  1630. data["fund"] = funInfosTwo
  1631. fmt.Println(twos)
  1632. month := time.Unix(1557042972, 0).Format("1")
  1633. year := time.Now().Format("2006")
  1634. month = time.Now().Format("01")
  1635. day := time.Now().Format("02")
  1636. hour := time.Now().Format("15")
  1637. min := time.Now().Format("04")
  1638. sec := time.Now().Format("05")
  1639. fix_fill_date := year + month + day + hour + min + sec
  1640. data["fix_fill_dept"] = miConfig.OrgName
  1641. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1642. data["fix_fill_psn"] = curRoles.UserName
  1643. data["fix_fill_date"] = fix_fill_date
  1644. data["stmt_loc"] = "2"
  1645. data["setl_mon"] = stmt_mon
  1646. upld_btch = "0"
  1647. data["upld_btch"] = upld_btch
  1648. //fmt.Println(data)
  1649. client := &http.Client{}
  1650. bytesData, _ := json.Marshal(data)
  1651. var req *http.Request
  1652. if miConfig.MdtrtareaAdmvs == "320921" {
  1653. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1654. } else {
  1655. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1656. }
  1657. resp, _ := client.Do(req)
  1658. defer resp.Body.Close()
  1659. body, ioErr := ioutil.ReadAll(resp.Body)
  1660. if ioErr != nil {
  1661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1663. }
  1664. var respJSON map[string]interface{}
  1665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1668. }
  1669. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1670. //fmt.Println(respJSON)
  1671. result, _ := json.Marshal(respJSON)
  1672. //fmt.Println(result)
  1673. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1674. utils.ErrorLog("解析失败:%v", err)
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1676. }
  1677. if empty.Infcode != "0" {
  1678. c.ServeSuccessJSON(map[string]interface{}{
  1679. "failed_code": -10,
  1680. "msg": empty.ErrMsg,
  1681. })
  1682. return
  1683. } else {
  1684. c.ServeSuccessJSON(map[string]interface{}{
  1685. "msg": "上传成功",
  1686. })
  1687. return
  1688. }
  1689. }
  1690. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1691. newArr = make([]TempFun, 0)
  1692. for i := 0; i < len(arr); i++ {
  1693. repeat := false
  1694. for j := i + 1; j < len(arr); j++ {
  1695. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1696. repeat = true
  1697. break
  1698. }
  1699. }
  1700. if !repeat {
  1701. newArr = append(newArr, arr[i])
  1702. }
  1703. }
  1704. return
  1705. }
  1706. func (c *HisApiController) Get3263() {
  1707. admin_user_id, _ := c.GetInt64("admin_user_id")
  1708. startTime := c.GetString("start_time")
  1709. //endTime, _ := c.GetString("end_time")
  1710. times := strings.Split(startTime, "-")
  1711. setl_mon := times[0] + times[1]
  1712. upld_btch := "0"
  1713. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1714. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1715. var result3263 models.JSResult3263
  1716. data := make(map[string]interface{})
  1717. data["org_name"] = miConfig.OrgName
  1718. data["doctor"] = curRoles.UserName
  1719. data["doctor_name"] = curRoles.UserName
  1720. data["fixmedins_code"] = miConfig.Code
  1721. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1722. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1723. data["secret_key"] = miConfig.SecretKey
  1724. data["url"] = miConfig.Url
  1725. data["ak"] = miConfig.AccessKey
  1726. data["cainfo"] = miConfig.Cainfo
  1727. data["setl_mon"] = setl_mon
  1728. data["stmt_loc"] = "2"
  1729. data["upld_btch"] = upld_btch
  1730. client := &http.Client{}
  1731. bytesData, _ := json.Marshal(data)
  1732. var req *http.Request
  1733. if miConfig.MdtrtareaAdmvs == "320921" {
  1734. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1735. } else {
  1736. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1737. }
  1738. resp, _ := client.Do(req)
  1739. defer resp.Body.Close()
  1740. body, ioErr := ioutil.ReadAll(resp.Body)
  1741. if ioErr != nil {
  1742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1744. }
  1745. var respJSON map[string]interface{}
  1746. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1749. }
  1750. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1751. fmt.Println(respJSON)
  1752. result, _ := json.Marshal(respJSON)
  1753. fmt.Println(result)
  1754. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1755. utils.ErrorLog("解析失败:%v", err)
  1756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1757. }
  1758. if result3263.Infcode != "0" {
  1759. c.ServeSuccessJSON(map[string]interface{}{
  1760. "failed_code": -10,
  1761. "msg": result3263.ErrMsg,
  1762. })
  1763. return
  1764. } else {
  1765. c.ServeSuccessJSON(map[string]interface{}{
  1766. "list": result3263.Output,
  1767. })
  1768. return
  1769. }
  1770. }
  1771. func (c *HisApiController) Get3264() {
  1772. admin_user_id, _ := c.GetInt64("admin_user_id")
  1773. startTime := c.GetString("start_time")
  1774. //endTime, _ := c.GetString("end_time")
  1775. times := strings.Split(startTime, "-")
  1776. setl_mon := times[0] + times[1]
  1777. upld_btch := "0"
  1778. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1779. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1780. //solidify_id := []
  1781. var result3263 models.JSResult3263
  1782. data := make(map[string]interface{})
  1783. data["org_name"] = miConfig.OrgName
  1784. data["doctor"] = curRoles.UserName
  1785. data["doctor_name"] = curRoles.UserName
  1786. data["fixmedins_code"] = miConfig.Code
  1787. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1788. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1789. data["secret_key"] = miConfig.SecretKey
  1790. data["url"] = miConfig.Url
  1791. data["ak"] = miConfig.AccessKey
  1792. data["cainfo"] = miConfig.Cainfo
  1793. data["setl_mon"] = setl_mon
  1794. data["stmt_loc"] = "2"
  1795. data["upld_btch"] = upld_btch
  1796. client := &http.Client{}
  1797. bytesData, _ := json.Marshal(data)
  1798. var req3263 *http.Request
  1799. if miConfig.MdtrtareaAdmvs == "320921" {
  1800. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1801. } else {
  1802. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1803. }
  1804. resp, _ := client.Do(req3263)
  1805. defer resp.Body.Close()
  1806. body, ioErr := ioutil.ReadAll(resp.Body)
  1807. if ioErr != nil {
  1808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1810. }
  1811. var respJSON3263 map[string]interface{}
  1812. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1815. }
  1816. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1817. fmt.Println(respJSON3263)
  1818. result, _ := json.Marshal(respJSON3263)
  1819. fmt.Println(result)
  1820. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1821. utils.ErrorLog("解析失败:%v", err)
  1822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. }
  1824. var ids []string
  1825. for _, item := range result3263.Output {
  1826. ids = append(ids, item.SolidifyID)
  1827. }
  1828. var empty models.JSResultEmpty
  1829. data2 := make(map[string]interface{})
  1830. data2["org_name"] = miConfig.OrgName
  1831. data2["doctor"] = curRoles.UserName
  1832. data2["doctor_name"] = curRoles.UserName
  1833. data2["fixmedins_code"] = miConfig.Code
  1834. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1835. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1836. data2["secret_key"] = miConfig.SecretKey
  1837. data2["url"] = miConfig.Url
  1838. data2["ak"] = miConfig.AccessKey
  1839. data2["cainfo"] = miConfig.Cainfo
  1840. data2["setl_mon"] = setl_mon
  1841. data2["stmt_loc"] = "2"
  1842. data2["upld_btch"] = upld_btch
  1843. data2["solidify_id"] = ids
  1844. client2 := &http.Client{}
  1845. bytesData2, _ := json.Marshal(data2)
  1846. var req *http.Request
  1847. if miConfig.MdtrtareaAdmvs == "320921" {
  1848. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1849. } else {
  1850. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1851. }
  1852. resp2, _ := client2.Do(req)
  1853. defer resp.Body.Close()
  1854. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1855. if ioErr2 != nil {
  1856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1858. }
  1859. var respJSON map[string]interface{}
  1860. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1863. }
  1864. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1865. fmt.Println(respJSON)
  1866. result2, _ := json.Marshal(respJSON)
  1867. fmt.Println(result2)
  1868. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1869. utils.ErrorLog("解析失败:%v", err)
  1870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1871. }
  1872. if empty.Infcode != "0" {
  1873. c.ServeSuccessJSON(map[string]interface{}{
  1874. "failed_code": -10,
  1875. "msg": empty.ErrMsg,
  1876. })
  1877. return
  1878. } else {
  1879. c.ServeSuccessJSON(map[string]interface{}{
  1880. "msg": "",
  1881. })
  1882. return
  1883. }
  1884. }
  1885. func (c *HisApiController) Get3265() {
  1886. admin_user_id, _ := c.GetInt64("admin_user_id")
  1887. startTime := c.GetString("start_time")
  1888. //endTime, _ := c.GetString("end_time")
  1889. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1891. times := strings.Split(startTime, "-")
  1892. setl_mon := times[0] + times[1]
  1893. var upld_btch string
  1894. upld_btch = "0"
  1895. //var empty models.JSResultEmpty
  1896. var result3265 models.JSResult3264
  1897. var result3263 models.JSResult3263
  1898. data2 := make(map[string]interface{})
  1899. data2["org_name"] = miConfig.OrgName
  1900. data2["doctor"] = curRoles.UserName
  1901. data2["doctor_name"] = curRoles.UserName
  1902. data2["fixmedins_code"] = miConfig.Code
  1903. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1904. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1905. data2["secret_key"] = miConfig.SecretKey
  1906. data2["url"] = miConfig.Url
  1907. data2["ak"] = miConfig.AccessKey
  1908. data2["cainfo"] = miConfig.Cainfo
  1909. data2["setl_mon"] = setl_mon
  1910. data2["stmt_loc"] = "2"
  1911. data2["upld_btch"] = upld_btch
  1912. client2 := &http.Client{}
  1913. bytesData2, _ := json.Marshal(data2)
  1914. var req3263 *http.Request
  1915. if miConfig.MdtrtareaAdmvs == "320921" {
  1916. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1917. } else {
  1918. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1919. }
  1920. resp2, _ := client2.Do(req3263)
  1921. defer resp2.Body.Close()
  1922. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1923. if ioErr2 != nil {
  1924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. }
  1927. var respJSON3263 map[string]interface{}
  1928. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1931. }
  1932. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1933. fmt.Println(respJSON3263)
  1934. result2, _ := json.Marshal(respJSON3263)
  1935. fmt.Println(result2)
  1936. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1937. utils.ErrorLog("解析失败:%v", err)
  1938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1939. }
  1940. var ids []string
  1941. for _, item := range result3263.Output {
  1942. ids = append(ids, item.SolidifyID)
  1943. }
  1944. data := make(map[string]interface{})
  1945. data["org_name"] = miConfig.OrgName
  1946. data["doctor"] = curRoles.UserName
  1947. data["doctor_name"] = curRoles.UserName
  1948. data["fixmedins_code"] = miConfig.Code
  1949. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1950. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1951. data["secret_key"] = miConfig.SecretKey
  1952. data["url"] = miConfig.Url
  1953. data["ak"] = miConfig.AccessKey
  1954. data["cainfo"] = miConfig.Cainfo
  1955. data["setl_mon"] = setl_mon
  1956. data["solidify_id"] = ids
  1957. month := time.Unix(1557042972, 0).Format("1")
  1958. year := time.Now().Format("2006")
  1959. month = time.Now().Format("01")
  1960. day := time.Now().Format("02")
  1961. hour := time.Now().Format("15")
  1962. min := time.Now().Format("04")
  1963. sec := time.Now().Format("05")
  1964. fix_fill_date := year + month + day + hour + min + sec
  1965. data["fix_fill_dept"] = miConfig.OrgName
  1966. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1967. data["fix_fill_psn"] = curRoles.UserName
  1968. data["fix_fill_date"] = fix_fill_date
  1969. data["stmt_loc"] = "2"
  1970. data["upld_btch"] = upld_btch
  1971. client := &http.Client{}
  1972. bytesData, _ := json.Marshal(data)
  1973. var req *http.Request
  1974. if miConfig.MdtrtareaAdmvs == "320921" {
  1975. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1976. } else {
  1977. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1978. }
  1979. resp, _ := client.Do(req)
  1980. defer resp.Body.Close()
  1981. body, ioErr := ioutil.ReadAll(resp.Body)
  1982. if ioErr != nil {
  1983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1985. }
  1986. var respJSON map[string]interface{}
  1987. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1990. }
  1991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1992. fmt.Println(respJSON)
  1993. result, _ := json.Marshal(respJSON)
  1994. fmt.Println(result)
  1995. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1996. utils.ErrorLog("解析失败:%v", err)
  1997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1998. }
  1999. if result3265.Infcode != "0" {
  2000. c.ServeSuccessJSON(map[string]interface{}{
  2001. "failed_code": -10,
  2002. "msg": result3265.ErrMsg,
  2003. })
  2004. return
  2005. } else {
  2006. c.ServeSuccessJSON(map[string]interface{}{
  2007. "info": result3265.Output,
  2008. })
  2009. return
  2010. }
  2011. }
  2012. func (c *HisApiController) Get3266() {
  2013. admin_user_id, _ := c.GetInt64("admin_user_id")
  2014. startTime := c.GetString("start_time")
  2015. //endTime, _ := c.GetString("end_time")
  2016. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2017. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2018. times := strings.Split(startTime, "-")
  2019. stmt_mon := times[0] + times[1]
  2020. var upld_btch string
  2021. //var empty models.JSResultEmpty
  2022. var result3265 models.JSResult3264
  2023. data := make(map[string]interface{})
  2024. data["org_name"] = miConfig.OrgName
  2025. data["doctor"] = curRoles.UserName
  2026. data["doctor_name"] = curRoles.UserName
  2027. data["fixmedins_code"] = miConfig.Code
  2028. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2029. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2030. data["secret_key"] = miConfig.SecretKey
  2031. data["url"] = miConfig.Url
  2032. data["ak"] = miConfig.AccessKey
  2033. data["cainfo"] = miConfig.Cainfo
  2034. data["setl_mon"] = stmt_mon
  2035. month := time.Unix(1557042972, 0).Format("1")
  2036. year := time.Now().Format("2006")
  2037. month = time.Now().Format("01")
  2038. day := time.Now().Format("02")
  2039. hour := time.Now().Format("15")
  2040. min := time.Now().Format("04")
  2041. sec := time.Now().Format("05")
  2042. fix_fill_date := year + month + day + hour + min + sec
  2043. data["fix_fill_dept"] = miConfig.OrgName
  2044. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2045. data["fix_fill_psn"] = curRoles.UserName
  2046. data["fix_fill_date"] = fix_fill_date
  2047. data["stmt_loc"] = "2"
  2048. upld_btch = "0"
  2049. data["upld_btch"] = upld_btch
  2050. client := &http.Client{}
  2051. bytesData, _ := json.Marshal(data)
  2052. var req *http.Request
  2053. if miConfig.MdtrtareaAdmvs == "320921" {
  2054. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  2055. } else {
  2056. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  2057. }
  2058. resp, _ := client.Do(req)
  2059. defer resp.Body.Close()
  2060. body, ioErr := ioutil.ReadAll(resp.Body)
  2061. if ioErr != nil {
  2062. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2064. }
  2065. var respJSON map[string]interface{}
  2066. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2069. }
  2070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2071. fmt.Println(respJSON)
  2072. result, _ := json.Marshal(respJSON)
  2073. fmt.Println(result)
  2074. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2075. utils.ErrorLog("解析失败:%v", err)
  2076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2077. }
  2078. if result3265.Infcode != "0" {
  2079. c.ServeSuccessJSON(map[string]interface{}{
  2080. "failed_code": -10,
  2081. "msg": result3265.ErrMsg,
  2082. })
  2083. return
  2084. } else {
  2085. c.ServeSuccessJSON(map[string]interface{}{
  2086. "info": result3265.Output,
  2087. })
  2088. return
  2089. }
  2090. }
  2091. func (c *HisApiController) Get3267() {
  2092. admin_user_id, _ := c.GetInt64("admin_user_id")
  2093. startTime := c.GetString("start_time")
  2094. //endTime, _ := c.GetString("end_time")
  2095. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2096. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2097. times := strings.Split(startTime, "-")
  2098. setl_mon := times[0] + times[1]
  2099. var upld_btch string
  2100. //var empty models.JSResultEmpty
  2101. var result3265 models.JSResult3264
  2102. upld_btch = "0"
  2103. data := make(map[string]interface{})
  2104. data["org_name"] = miConfig.OrgName
  2105. data["doctor"] = curRoles.UserName
  2106. data["doctor_name"] = curRoles.UserName
  2107. data["fixmedins_code"] = miConfig.Code
  2108. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2109. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2110. data["secret_key"] = miConfig.SecretKey
  2111. data["url"] = miConfig.Url
  2112. data["ak"] = miConfig.AccessKey
  2113. data["cainfo"] = miConfig.Cainfo
  2114. data["setl_mon"] = setl_mon
  2115. data["stmt_loc"] = "2"
  2116. data["upld_btch"] = upld_btch
  2117. client := &http.Client{}
  2118. bytesData, _ := json.Marshal(data)
  2119. var req *http.Request
  2120. if miConfig.MdtrtareaAdmvs == "320921" {
  2121. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  2122. } else {
  2123. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  2124. }
  2125. resp, _ := client.Do(req)
  2126. defer resp.Body.Close()
  2127. body, ioErr := ioutil.ReadAll(resp.Body)
  2128. if ioErr != nil {
  2129. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2131. }
  2132. var respJSON map[string]interface{}
  2133. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2136. }
  2137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2138. fmt.Println(respJSON)
  2139. result, _ := json.Marshal(respJSON)
  2140. fmt.Println(result)
  2141. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2142. utils.ErrorLog("解析失败:%v", err)
  2143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2144. }
  2145. if result3265.Infcode != "0" {
  2146. c.ServeSuccessJSON(map[string]interface{}{
  2147. "failed_code": -10,
  2148. "msg": result3265.ErrMsg,
  2149. })
  2150. return
  2151. } else {
  2152. c.ServeSuccessJSON(map[string]interface{}{
  2153. "info": result3265.Output.Data,
  2154. })
  2155. return
  2156. }
  2157. }
  2158. func (c *HisApiController) Get3268() {
  2159. admin_user_id, _ := c.GetInt64("admin_user_id")
  2160. startTime := c.GetString("start_time")
  2161. endTime := c.GetString("end_time")
  2162. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2163. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2164. times := strings.Split(startTime, "-")
  2165. setl_mon := times[0] + times[1]
  2166. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2167. var twos []models.FixMonRecDetailFileInTwo
  2168. var funs []models.FundDetail
  2169. for _, item := range datas {
  2170. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  2171. funs = append(funs, fun...)
  2172. }
  2173. var funInfos []models.Fund
  2174. //for _, item := range funs {
  2175. // var rf []models.FundInfo
  2176. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  2177. // for _, subitem := range rf {
  2178. // var fund models.Fund
  2179. // fund.FundCode = subitem.FundPayType
  2180. // fund.FundName = subitem.FundPayTypeName
  2181. // fund.FundAmt = subitem.FundPayAmt
  2182. // fund.FundKey = item.FundKey
  2183. // fund.InsuAdmdvs = "555555"
  2184. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  2185. // funInfos = append(funInfos, fund)
  2186. // }
  2187. //}
  2188. for _, team := range datas {
  2189. var two models.FixMonRecDetailFileInTwo
  2190. two.SetlDate = time.Now().Format("2006-01-02")
  2191. two.MedType = team.MedType
  2192. two.Insutype = team.Insutype
  2193. two.PsnType = team.PsnType
  2194. two.MedType = team.MedType
  2195. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  2196. two.InsuAdmdvs = team.InsuAdmdvs
  2197. two.PsnTime = team.PsnTime
  2198. two.PsnCnt = team.PsnCnt
  2199. two.FundKey = team.FundKey
  2200. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  2201. fps, _ := strconv.ParseFloat(team.Fund, 64)
  2202. ia, _ := strconv.ParseFloat(team.Amt, 64)
  2203. two.MedfeeSumAmt = ms
  2204. two.InscpAmt = ia
  2205. two.FundPaySumAmt = fps
  2206. twos = append(twos, two)
  2207. }
  2208. var upld_btch string
  2209. upld_btch = "0"
  2210. var empty models.JSResultEmpty
  2211. data := make(map[string]interface{})
  2212. data["org_name"] = miConfig.OrgName
  2213. data["doctor"] = curRoles.UserName
  2214. data["doctor_name"] = curRoles.UserName
  2215. data["fixmedins_code"] = miConfig.Code
  2216. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2217. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2218. data["secret_key"] = miConfig.SecretKey
  2219. data["url"] = miConfig.Url
  2220. data["ak"] = miConfig.AccessKey
  2221. data["cainfo"] = miConfig.Cainfo
  2222. data["datas"] = twos
  2223. data["fund"] = funInfos
  2224. data["setl_mon"] = setl_mon
  2225. month := time.Unix(1557042972, 0).Format("1")
  2226. year := time.Now().Format("2006")
  2227. month = time.Now().Format("01")
  2228. day := time.Now().Format("02")
  2229. hour := time.Now().Format("15")
  2230. min := time.Now().Format("04")
  2231. sec := time.Now().Format("05")
  2232. fix_fill_date := year + month + day + hour + min + sec
  2233. data["fix_fill_dept"] = miConfig.OrgName
  2234. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2235. data["fix_fill_psn"] = curRoles.UserName
  2236. data["fix_fill_date"] = fix_fill_date
  2237. data["stmt_loc"] = "2"
  2238. data["upld_btch"] = upld_btch
  2239. client := &http.Client{}
  2240. bytesData, _ := json.Marshal(data)
  2241. var req *http.Request
  2242. if miConfig.MdtrtareaAdmvs == "320921" {
  2243. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2244. } else {
  2245. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2246. }
  2247. resp, _ := client.Do(req)
  2248. defer resp.Body.Close()
  2249. body, ioErr := ioutil.ReadAll(resp.Body)
  2250. if ioErr != nil {
  2251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2253. }
  2254. var respJSON map[string]interface{}
  2255. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2258. }
  2259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2260. fmt.Println(respJSON)
  2261. result, _ := json.Marshal(respJSON)
  2262. fmt.Println(result)
  2263. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  2264. utils.ErrorLog("解析失败:%v", err)
  2265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2266. }
  2267. if empty.Infcode != "0" {
  2268. c.ServeSuccessJSON(map[string]interface{}{
  2269. "failed_code": -10,
  2270. "msg": empty.ErrMsg,
  2271. })
  2272. return
  2273. } else {
  2274. c.ServeSuccessJSON(map[string]interface{}{
  2275. "msg": "上传成功",
  2276. })
  2277. return
  2278. }
  2279. }
  2280. func (c *HisApiController) Get3269() {
  2281. admin_user_id, _ := c.GetInt64("admin_user_id")
  2282. startTime := c.GetString("start_time")
  2283. //endTime, _ := c.GetString("end_time")
  2284. times := strings.Split(startTime, "-")
  2285. setl_mon := times[0] + times[1]
  2286. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2287. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2288. var result3263 models.JSResult3263
  2289. data := make(map[string]interface{})
  2290. data["org_name"] = miConfig.OrgName
  2291. data["doctor"] = curRoles.UserName
  2292. data["doctor_name"] = curRoles.UserName
  2293. data["fixmedins_code"] = miConfig.Code
  2294. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2295. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2296. data["secret_key"] = miConfig.SecretKey
  2297. data["url"] = miConfig.Url
  2298. data["ak"] = miConfig.AccessKey
  2299. data["cainfo"] = miConfig.Cainfo
  2300. data["setl_mon"] = setl_mon
  2301. data["stmt_loc"] = "2"
  2302. client := &http.Client{}
  2303. bytesData, _ := json.Marshal(data)
  2304. var req *http.Request
  2305. if miConfig.MdtrtareaAdmvs == "320921" {
  2306. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  2307. } else {
  2308. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  2309. }
  2310. resp, _ := client.Do(req)
  2311. defer resp.Body.Close()
  2312. body, ioErr := ioutil.ReadAll(resp.Body)
  2313. if ioErr != nil {
  2314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2316. }
  2317. var respJSON map[string]interface{}
  2318. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2321. }
  2322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2323. fmt.Println(respJSON)
  2324. result, _ := json.Marshal(respJSON)
  2325. fmt.Println(result)
  2326. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2327. utils.ErrorLog("解析失败:%v", err)
  2328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2329. }
  2330. if result3263.Infcode != "0" {
  2331. c.ServeSuccessJSON(map[string]interface{}{
  2332. "failed_code": -10,
  2333. "msg": result3263.ErrMsg,
  2334. })
  2335. return
  2336. } else {
  2337. c.ServeSuccessJSON(map[string]interface{}{
  2338. "msg": "上传成功",
  2339. })
  2340. return
  2341. }
  2342. }
  2343. func (c *HisApiController) Get3270() {
  2344. admin_user_id, _ := c.GetInt64("admin_user_id")
  2345. startTime := c.GetString("start_time")
  2346. //endTime, _ := c.GetString("end_time")
  2347. times := strings.Split(startTime, "-")
  2348. setl_mon := times[0] + times[1]
  2349. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2351. var result3263 models.JSResult3263
  2352. data2 := make(map[string]interface{})
  2353. data2["org_name"] = miConfig.OrgName
  2354. data2["doctor"] = curRoles.UserName
  2355. data2["doctor_name"] = curRoles.UserName
  2356. data2["fixmedins_code"] = miConfig.Code
  2357. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2358. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2359. data2["secret_key"] = miConfig.SecretKey
  2360. data2["url"] = miConfig.Url
  2361. data2["ak"] = miConfig.AccessKey
  2362. data2["cainfo"] = miConfig.Cainfo
  2363. data2["setl_mon"] = setl_mon
  2364. data2["stmt_loc"] = "2"
  2365. client2 := &http.Client{}
  2366. bytesData2, _ := json.Marshal(data2)
  2367. var req3263 *http.Request
  2368. if miConfig.MdtrtareaAdmvs == "320921" {
  2369. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2370. } else {
  2371. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2372. }
  2373. resp2, _ := client2.Do(req3263)
  2374. defer resp2.Body.Close()
  2375. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2376. if ioErr2 != nil {
  2377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2379. }
  2380. var respJSON3263 map[string]interface{}
  2381. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2384. }
  2385. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2386. fmt.Println(respJSON3263)
  2387. result2, _ := json.Marshal(respJSON3263)
  2388. fmt.Println(result2)
  2389. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2390. utils.ErrorLog("解析失败:%v", err)
  2391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2392. }
  2393. var ids []string
  2394. for _, item := range result3263.Output {
  2395. ids = append(ids, item.SolidifyID)
  2396. }
  2397. var result3264 models.JSResult3264
  2398. data := make(map[string]interface{})
  2399. data["org_name"] = miConfig.OrgName
  2400. data["doctor"] = curRoles.UserName
  2401. data["doctor_name"] = curRoles.UserName
  2402. data["fixmedins_code"] = miConfig.Code
  2403. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2404. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2405. data["secret_key"] = miConfig.SecretKey
  2406. data["url"] = miConfig.Url
  2407. data["ak"] = miConfig.AccessKey
  2408. data["cainfo"] = miConfig.Cainfo
  2409. data["setl_mon"] = setl_mon
  2410. data["stmt_loc"] = "2"
  2411. data["solidify_id"] = ids
  2412. client := &http.Client{}
  2413. bytesData, _ := json.Marshal(data)
  2414. var req *http.Request
  2415. if miConfig.MdtrtareaAdmvs == "320921" {
  2416. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2417. } else {
  2418. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2419. }
  2420. resp, _ := client.Do(req)
  2421. defer resp.Body.Close()
  2422. body, ioErr := ioutil.ReadAll(resp.Body)
  2423. if ioErr != nil {
  2424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2426. }
  2427. var respJSON map[string]interface{}
  2428. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2431. }
  2432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2433. fmt.Println(respJSON)
  2434. result, _ := json.Marshal(respJSON)
  2435. fmt.Println(result)
  2436. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2437. utils.ErrorLog("解析失败:%v", err)
  2438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2439. }
  2440. if result3264.Infcode != "0" {
  2441. c.ServeSuccessJSON(map[string]interface{}{
  2442. "failed_code": -10,
  2443. "msg": result3264.ErrMsg,
  2444. })
  2445. return
  2446. } else {
  2447. c.ServeSuccessJSON(map[string]interface{}{
  2448. "info": result3264.Output,
  2449. })
  2450. return
  2451. }
  2452. }
  2453. func (c *HisApiController) Get3271() {
  2454. admin_user_id, _ := c.GetInt64("admin_user_id")
  2455. startTime := c.GetString("start_time")
  2456. //endTime, _ := c.GetString("end_time")
  2457. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2458. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2459. times := strings.Split(startTime, "-")
  2460. setl_mon := times[0] + times[1]
  2461. //var empty models.JSResultEmpty
  2462. var result3265 models.JSResult3264
  2463. var result3263 models.JSResult3263
  2464. data2 := make(map[string]interface{})
  2465. data2["org_name"] = miConfig.OrgName
  2466. data2["doctor"] = curRoles.UserName
  2467. data2["doctor_name"] = curRoles.UserName
  2468. data2["fixmedins_code"] = miConfig.Code
  2469. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2470. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2471. data2["secret_key"] = miConfig.SecretKey
  2472. data2["url"] = miConfig.Url
  2473. data2["ak"] = miConfig.AccessKey
  2474. data2["cainfo"] = miConfig.Cainfo
  2475. data2["setl_mon"] = setl_mon
  2476. data2["stmt_loc"] = "2"
  2477. client2 := &http.Client{}
  2478. bytesData2, _ := json.Marshal(data2)
  2479. var req3263 *http.Request
  2480. if miConfig.MdtrtareaAdmvs == "320921" {
  2481. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2482. } else {
  2483. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2484. }
  2485. resp2, _ := client2.Do(req3263)
  2486. defer resp2.Body.Close()
  2487. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2488. if ioErr2 != nil {
  2489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2491. }
  2492. var respJSON3263 map[string]interface{}
  2493. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2496. }
  2497. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2498. fmt.Println(respJSON3263)
  2499. result2, _ := json.Marshal(respJSON3263)
  2500. fmt.Println(result2)
  2501. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2502. utils.ErrorLog("解析失败:%v", err)
  2503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2504. }
  2505. var ids []string
  2506. for _, item := range result3263.Output {
  2507. ids = append(ids, item.SolidifyID)
  2508. }
  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["solidify_id"] = ids
  2522. month := time.Unix(1557042972, 0).Format("1")
  2523. year := time.Now().Format("2006")
  2524. month = time.Now().Format("01")
  2525. day := time.Now().Format("02")
  2526. hour := time.Now().Format("15")
  2527. min := time.Now().Format("04")
  2528. sec := time.Now().Format("05")
  2529. fix_fill_date := year + month + day + hour + min + sec
  2530. data["fix_fill_dept"] = miConfig.OrgName
  2531. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2532. data["fix_fill_psn"] = curRoles.UserName
  2533. data["fix_fill_date"] = fix_fill_date
  2534. data["stmt_loc"] = "2"
  2535. client := &http.Client{}
  2536. bytesData, _ := json.Marshal(data)
  2537. var req *http.Request
  2538. if miConfig.MdtrtareaAdmvs == "320921" {
  2539. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2540. } else {
  2541. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2542. }
  2543. resp, _ := client.Do(req)
  2544. defer resp.Body.Close()
  2545. body, ioErr := ioutil.ReadAll(resp.Body)
  2546. if ioErr != nil {
  2547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2549. }
  2550. var respJSON map[string]interface{}
  2551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2554. }
  2555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2556. fmt.Println(respJSON)
  2557. result, _ := json.Marshal(respJSON)
  2558. fmt.Println(result)
  2559. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2560. utils.ErrorLog("解析失败:%v", err)
  2561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2562. }
  2563. if result3265.Infcode != "0" {
  2564. c.ServeSuccessJSON(map[string]interface{}{
  2565. "failed_code": -10,
  2566. "msg": result3265.ErrMsg,
  2567. })
  2568. return
  2569. } else {
  2570. c.ServeSuccessJSON(map[string]interface{}{
  2571. "info": result3265.Output.Data,
  2572. })
  2573. return
  2574. }
  2575. }
  2576. func (c *HisApiController) Get3272() {
  2577. admin_user_id, _ := c.GetInt64("admin_user_id")
  2578. startTime := c.GetString("start_time")
  2579. //endTime, _ := c.GetString("end_time")
  2580. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2581. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2582. times := strings.Split(startTime, "-")
  2583. setl_mon := times[0] + times[1]
  2584. var upld_btch string
  2585. //var empty models.JSResultEmpty
  2586. var result3265 models.JSResult3264
  2587. data := make(map[string]interface{})
  2588. data["org_name"] = miConfig.OrgName
  2589. data["doctor"] = curRoles.UserName
  2590. data["doctor_name"] = curRoles.UserName
  2591. data["fixmedins_code"] = miConfig.Code
  2592. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2593. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2594. data["secret_key"] = miConfig.SecretKey
  2595. data["url"] = miConfig.Url
  2596. data["ak"] = miConfig.AccessKey
  2597. data["cainfo"] = miConfig.Cainfo
  2598. data["setl_mon"] = setl_mon
  2599. month := time.Unix(1557042972, 0).Format("1")
  2600. year := time.Now().Format("2006")
  2601. month = time.Now().Format("01")
  2602. day := time.Now().Format("02")
  2603. hour := time.Now().Format("15")
  2604. min := time.Now().Format("04")
  2605. sec := time.Now().Format("05")
  2606. fix_fill_date := year + month + day + hour + min + sec
  2607. data["fix_fill_dept"] = miConfig.OrgName
  2608. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2609. data["fix_fill_psn"] = curRoles.UserName
  2610. data["fix_fill_date"] = fix_fill_date
  2611. data["stmt_loc"] = "2"
  2612. data["upld_btch"] = upld_btch
  2613. client := &http.Client{}
  2614. bytesData, _ := json.Marshal(data)
  2615. var req *http.Request
  2616. if miConfig.MdtrtareaAdmvs == "320921" {
  2617. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2618. } else {
  2619. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2620. }
  2621. resp, _ := client.Do(req)
  2622. defer resp.Body.Close()
  2623. body, ioErr := ioutil.ReadAll(resp.Body)
  2624. if ioErr != nil {
  2625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2627. }
  2628. var respJSON map[string]interface{}
  2629. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2632. }
  2633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2634. fmt.Println(respJSON)
  2635. result, _ := json.Marshal(respJSON)
  2636. fmt.Println(result)
  2637. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2638. utils.ErrorLog("解析失败:%v", err)
  2639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2640. }
  2641. if result3265.Infcode != "0" {
  2642. c.ServeSuccessJSON(map[string]interface{}{
  2643. "failed_code": -10,
  2644. "msg": result3265.ErrMsg,
  2645. })
  2646. return
  2647. } else {
  2648. c.ServeSuccessJSON(map[string]interface{}{
  2649. "info": result3265.Output,
  2650. })
  2651. return
  2652. }
  2653. }
  2654. func (c *HisApiController) Get3273() {
  2655. admin_user_id, _ := c.GetInt64("admin_user_id")
  2656. startTime := c.GetString("start_time")
  2657. //endTime, _ := c.GetString("end_time")
  2658. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2659. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2660. times := strings.Split(startTime, "-")
  2661. setl_mon := times[0] + times[1]
  2662. var result3265 models.JSResult3264
  2663. data := make(map[string]interface{})
  2664. data["org_name"] = miConfig.OrgName
  2665. data["doctor"] = curRoles.UserName
  2666. data["doctor_name"] = curRoles.UserName
  2667. data["fixmedins_code"] = miConfig.Code
  2668. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2669. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2670. data["secret_key"] = miConfig.SecretKey
  2671. data["url"] = miConfig.Url
  2672. data["ak"] = miConfig.AccessKey
  2673. data["cainfo"] = miConfig.Cainfo
  2674. data["setl_mon"] = setl_mon
  2675. data["stmt_loc"] = "2"
  2676. client := &http.Client{}
  2677. bytesData, _ := json.Marshal(data)
  2678. var req *http.Request
  2679. if miConfig.MdtrtareaAdmvs == "320921" {
  2680. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2681. } else {
  2682. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2683. }
  2684. resp, _ := client.Do(req)
  2685. defer resp.Body.Close()
  2686. body, ioErr := ioutil.ReadAll(resp.Body)
  2687. if ioErr != nil {
  2688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2690. }
  2691. var respJSON map[string]interface{}
  2692. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2695. }
  2696. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2697. fmt.Println(respJSON)
  2698. result, _ := json.Marshal(respJSON)
  2699. fmt.Println(result)
  2700. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2701. utils.ErrorLog("解析失败:%v", err)
  2702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2703. }
  2704. if result3265.Infcode != "0" {
  2705. c.ServeSuccessJSON(map[string]interface{}{
  2706. "failed_code": -10,
  2707. "msg": result3265.ErrMsg,
  2708. })
  2709. return
  2710. } else {
  2711. c.ServeSuccessJSON(map[string]interface{}{
  2712. "info": result3265.Output.Data,
  2713. })
  2714. return
  2715. }
  2716. }
  2717. func (c *HisApiController) Get3274() {
  2718. //if miConfig.MdtrtareaAdmvs == "320921" {
  2719. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2720. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2721. // "&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
  2722. //
  2723. //} else {
  2724. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2725. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2726. // "&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
  2727. //
  2728. //}
  2729. }
  2730. func (c *HisApiController) Get3275() {
  2731. //if miConfig.MdtrtareaAdmvs == "320921" {
  2732. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2733. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2734. // "&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
  2735. //
  2736. //} else {
  2737. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2738. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2739. // "&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
  2740. //
  2741. //}
  2742. }
  2743. func (c *HisApiController) Get3276() {
  2744. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2745. //month := c.GetString("month")
  2746. //
  2747. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2748. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2749. //var api string
  2750. //var res Result5301
  2751. //
  2752. //if miConfig.MdtrtareaAdmvs == "320921" {
  2753. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2754. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2755. //} else {
  2756. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2757. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2758. //}
  2759. //
  2760. //resp, requestErr := http.Get(api)
  2761. //if requestErr != nil {
  2762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2763. // return
  2764. //}
  2765. //
  2766. //body, ioErr := ioutil.ReadAll(resp.Body)
  2767. //if ioErr != nil {
  2768. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2770. // return
  2771. //}
  2772. //var respJSON map[string]interface{}
  2773. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2774. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2776. // return
  2777. //}
  2778. //
  2779. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2780. //result, _ := json.Marshal(respJSON)
  2781. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2782. // utils.ErrorLog("解析失败:%v", err)
  2783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2784. // return
  2785. //}
  2786. }
  2787. func (c *HisApiController) Get3277() {
  2788. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2789. //month := c.GetString("month")
  2790. //
  2791. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2792. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2793. //var api string
  2794. //var res Result5301
  2795. //
  2796. //if miConfig.MdtrtareaAdmvs == "320921" {
  2797. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2798. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2799. //} else {
  2800. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2801. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2802. //}
  2803. //
  2804. //resp, requestErr := http.Get(api)
  2805. //if requestErr != nil {
  2806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2807. // return
  2808. //}
  2809. //
  2810. //body, ioErr := ioutil.ReadAll(resp.Body)
  2811. //if ioErr != nil {
  2812. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2814. // return
  2815. //}
  2816. //var respJSON map[string]interface{}
  2817. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2818. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2820. // return
  2821. //}
  2822. //
  2823. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2824. //result, _ := json.Marshal(respJSON)
  2825. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2826. // utils.ErrorLog("解析失败:%v", err)
  2827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2828. // return
  2829. //}
  2830. }
  2831. func (c *HisApiController) GetCFYLJG001() {
  2832. admin_user_id, _ := c.GetInt64("admin_user_id")
  2833. patient_id, _ := c.GetInt64("patient_id")
  2834. his_patient_id, _ := c.GetInt64("his_patient_id")
  2835. record_time := c.GetString("record_time")
  2836. admin_user_id = 3626
  2837. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2838. psn, _ := service.GetPsnByPatientId(patient_id)
  2839. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2840. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2841. var cFYLJG001 models.CFYLJG001
  2842. timeLayout := "2006-01-02"
  2843. loc, _ := time.LoadLocation("Local")
  2844. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2845. if err != nil {
  2846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2847. return
  2848. }
  2849. recordDateTime := theTime.Unix()
  2850. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2851. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2852. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2853. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2854. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2855. for _, item := range prescriptions {
  2856. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2857. if his.IdCardType == 1 {
  2858. bas := strings.Split(psn.CardInfo, "|")
  2859. basNumber := bas[1]
  2860. fmt.Println(basNumber)
  2861. card_sn := bas[3]
  2862. card_no := bas[2]
  2863. cFYLJG001.MdtrtCertType = "03"
  2864. cFYLJG001.CardSn = card_sn
  2865. cFYLJG001.MdtrtCertNo = card_no
  2866. cFYLJG001.EcToken = ""
  2867. cFYLJG001.AuthNo = ""
  2868. } else if his.IdCardType == 2 {
  2869. cFYLJG001.MdtrtCertType = "02"
  2870. cFYLJG001.CardSn = ""
  2871. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2872. cFYLJG001.EcToken = ""
  2873. cFYLJG001.AuthNo = ""
  2874. } else if his.IdCardType == 4 {
  2875. cFYLJG001.MdtrtCertType = "01"
  2876. cFYLJG001.CardSn = ""
  2877. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2878. cFYLJG001.EcToken = psn.VerifyNumber
  2879. cFYLJG001.AuthNo = ""
  2880. }
  2881. cFYLJG001.BizTypeCode = "01"
  2882. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2883. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2884. cFYLJG001.RxTypeCode = "1"
  2885. tempTime := time.Unix(item.PreTime, 0)
  2886. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2887. cFYLJG001.PrscTime = timeFormatOne
  2888. var count float64
  2889. if item.Type == 1 {
  2890. for _, sumItem := range item.HisDoctorAdviceInfo {
  2891. count = count + sumItem.PrescribingNumber
  2892. }
  2893. }
  2894. cFYLJG001.RxDrugCnt = count
  2895. cFYLJG001.ValiDays = "5"
  2896. ts := time.Unix(item.PreTime, 0)
  2897. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2898. tempTime3 := time.Unix(record_time2, 0)
  2899. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2900. cFYLJG001.ValiEndTime = timeFormat3
  2901. cFYLJG001.RxCotnFlag = "0"
  2902. for _, subItem := range item.HisDoctorAdviceInfo {
  2903. var drug models.RxDrug
  2904. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2905. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2906. drug.RxItemTypeCode = "11"
  2907. drug.DrugDosform = "乳膏剂" //TODO
  2908. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2909. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2910. }
  2911. drug.MedcWayDscr = subItem.DeliveryWay
  2912. tempTime2 := time.Unix(subItem.StartTime, 0)
  2913. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2914. drug.MedcBegntime = timeFormatTwo
  2915. if subItem.Day > 0 {
  2916. ts := time.Unix(subItem.StartTime, 0)
  2917. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2918. tempTime4 := time.Unix(record_time, 0)
  2919. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2920. drug.MedcEndtime = timeFormat5
  2921. } else {
  2922. tempTime2 := time.Unix(subItem.StartTime, 0)
  2923. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2924. drug.MedcEndtime = timeFormatTwo
  2925. }
  2926. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2927. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2928. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2929. drug.DrugCnt = subItem.PrescribingNumber
  2930. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2931. drug.DrugGenname = subItem.AdviceName
  2932. drug.MedcWayCodg = subItem.DeliveryWay
  2933. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2934. drug.SinDoscnt = subItem.SingleDose
  2935. drug.SinDosunt = subItem.SingleDoseUnit
  2936. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2937. drug.UsedFrquName = subItem.ExecutionFrequency
  2938. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2939. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2940. drug.HospApprFlag = "1"
  2941. cFYLJG001.List = append(cFYLJG001.List, drug)
  2942. }
  2943. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2944. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2945. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2946. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2947. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2948. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2949. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2950. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2951. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2952. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2953. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2954. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2955. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2956. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2957. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2958. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2959. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2960. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2961. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2962. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2963. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2964. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2965. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2966. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2967. tempTime2 := time.Now().Unix()
  2968. tempTime6 := time.Unix(tempTime2, 0)
  2969. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2970. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2971. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2972. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2973. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2974. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2975. //memo := make(map[string]interface{})
  2976. //inputData := make(map[string]interface{}, 0)
  2977. //type MyData struct {
  2978. // Insutype string `json:"insutype"`
  2979. //}
  2980. //
  2981. // data := MyData{
  2982. // Insutype: his.Insutype,
  2983. //}
  2984. //
  2985. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2986. var config []*models.HisXtDiagnoseConfig
  2987. for _, item := range diagnosis_ids {
  2988. id, _ := strconv.ParseInt(item, 10, 64)
  2989. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2990. config = append(config, &diagnosisConfig)
  2991. }
  2992. for index, subitem := range config {
  2993. if index == 0 {
  2994. var dia models.DiseInfo
  2995. dia.DiagType = "1"
  2996. dia.MaindiagFlag = "1"
  2997. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2998. dia.DiagCode = subitem.CountryCode
  2999. dia.DiagName = subitem.ClassName
  3000. dia.DiagDept = "肾内科"
  3001. dia.DiagDrNo = doctor.DoctorNumber
  3002. dia.DiagDrName = doctor.UserName
  3003. tempTime3 := time.Unix(item.PreTime, 0)
  3004. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  3005. dia.DiagTime = timeFormatTwo
  3006. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  3007. } else {
  3008. var dia models.DiseInfo
  3009. dia.DiagType = "1"
  3010. dia.MaindiagFlag = "0"
  3011. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3012. dia.DiagCode = subitem.CountryCode
  3013. dia.DiagName = subitem.ClassName
  3014. dia.DiagDept = "肾内科"
  3015. dia.DiagDrNo = doctor.DoctorNumber
  3016. dia.DiagDrName = doctor.UserName
  3017. tempTime3 := time.Unix(item.PreTime, 0)
  3018. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  3019. dia.DiagTime = timeFormatTwo
  3020. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  3021. }
  3022. }
  3023. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  3024. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  3025. var res ResultCFYLJG001
  3026. var respJSON2 map[string]interface{}
  3027. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3030. return
  3031. }
  3032. userJSONBytes2, _ := json.Marshal(respJSON2)
  3033. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3034. utils.ErrorLog("解析失败:%v", err)
  3035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3036. return
  3037. }
  3038. if res.Infcode == -1 {
  3039. c.ServeSuccessJSON(map[string]interface{}{
  3040. "failed_code": -10,
  3041. "msg": res.ErrMsg,
  3042. })
  3043. return
  3044. } else {
  3045. var flow models.HisPrescriptionFlow
  3046. flow.Ctime = time.Now().Unix()
  3047. flow.SignDigest = ""
  3048. flow.RxTraceCode = res.Output.RxTraceCode
  3049. flow.HiRxno = res.Output.HiRxno
  3050. flow.MID = his.Number
  3051. flow.Status = 1
  3052. flow.DCode = doctor_info.DoctorNumber
  3053. flow.OriginalRxFile = ""
  3054. flow.OriginalValue = ""
  3055. flow.SignCertDn = ""
  3056. flow.UserOrgId = 10454
  3057. flow.SignCertSn = ""
  3058. flow.Mtime = time.Now().Unix()
  3059. service.Createflow(&flow)
  3060. c.ServeSuccessJSON(map[string]interface{}{
  3061. "msg": "上传成功",
  3062. })
  3063. }
  3064. }
  3065. }
  3066. func (c *HisApiController) GetCFYLJG002() {
  3067. admin_user_id, _ := c.GetInt64("admin_user_id")
  3068. his_patient_id, _ := c.GetInt64("his_patient_id")
  3069. record_time := c.GetString("record_time")
  3070. admin_user_id = 3626
  3071. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3072. //id, _ := c.GetInt64("id")
  3073. admin_user_id = 3626
  3074. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3075. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3076. flow, _ := service.Getflowtwo(his.Number)
  3077. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3078. //record_time := c.GetString("record_time")
  3079. patient_id, _ := c.GetInt64("patient_id")
  3080. //patient_id = 23834
  3081. //record_time = "2023-09-18"
  3082. timeLayout := "2006-01-02"
  3083. loc, _ := time.LoadLocation("Local")
  3084. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3085. if err != nil {
  3086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3087. return
  3088. }
  3089. recordDateTime := theTime.Unix()
  3090. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3091. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3092. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3093. dept, _ := service.GetDepartMentDetail(info.Departments)
  3094. inputData := make(map[string]interface{})
  3095. inputData["rxTraceCode"] = flow.RxTraceCode
  3096. inputData["hiRxno"] = flow.HiRxno
  3097. inputData["mdtrtId"] = flow.MID
  3098. inputData["patnName"] = his.PsnName
  3099. inputData["psnCertType"] = his.PsnCertType
  3100. inputData["certno"] = his.Certno
  3101. inputData["fixmedinsName"] = miConfig.OrgName
  3102. inputData["fixmedinsCode"] = miConfig.Code
  3103. inputData["drCode"] = doctor_info.DoctorNumber
  3104. inputData["prscDrName"] = doctor_info.UserName
  3105. inputData["pharDeptName"] = dept.Name
  3106. inputData["pharDeptCode"] = dept.Number
  3107. inputData["pharProfttlCodg"] = dept.Name
  3108. inputData["pharProfttlName"] = ""
  3109. inputData["pharCode"] = "HY440309002107"
  3110. inputData["pharCertType"] = "01"
  3111. inputData["pharCertno"] = "430482199408260023"
  3112. inputData["pharName"] = "彭斯遥"
  3113. inputData["pharPracCertNo"] = ""
  3114. tempTime2 := time.Unix(info.Ctime, 0)
  3115. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3116. inputData["pharChkTime"] = timeFormatTwo
  3117. bytesData, _ := json.Marshal(inputData)
  3118. fmt.Println(string(bytesData))
  3119. encoded := base64.StdEncoding.EncodeToString(bytesData)
  3120. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  3121. if err != nil {
  3122. fmt.Println("Error reading PDF file:", err)
  3123. return
  3124. }
  3125. // 将 PDF 文件内容进行 Base64 编码
  3126. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  3127. fmt.Println(err)
  3128. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  3129. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  3130. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  3131. var res2 Result002
  3132. var respJSON2 map[string]interface{}
  3133. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3136. return
  3137. }
  3138. userJSONBytes2, _ := json.Marshal(respJSON2)
  3139. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3140. utils.ErrorLog("解析失败:%v", err)
  3141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3142. return
  3143. }
  3144. if res2.Infcode == 0 {
  3145. flow.Ctime = time.Now().Unix()
  3146. flow.SignDigest = res2.Output.SignDigest
  3147. flow.RxFile = res2.Output.RxFile
  3148. flow.MID = his.Number
  3149. flow.Status = 1
  3150. flow.DCode = doctor_info.DoctorNumber
  3151. flow.OriginalRxFile = rx_encoded
  3152. flow.OriginalValue = encoded
  3153. flow.SignCertDn = res2.Output.SignCertDn
  3154. flow.SignCertSn = res2.Output.SignCertSn
  3155. flow.Mtime = time.Now().Unix()
  3156. service.Saveflow(flow)
  3157. c.ServeSuccessJSON(map[string]interface{}{
  3158. "msg": "预签名成功",
  3159. })
  3160. } else {
  3161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3162. return
  3163. }
  3164. }
  3165. func (c *HisApiController) GetCFYLJG003() {
  3166. admin_user_id, _ := c.GetInt64("admin_user_id")
  3167. his_patient_id, _ := c.GetInt64("his_patient_id")
  3168. record_time := c.GetString("record_time")
  3169. admin_user_id = 3626
  3170. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3171. //id, _ := c.GetInt64("id")
  3172. admin_user_id = 3626
  3173. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3174. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3175. flow, _ := service.Getflowtwo(his.Number)
  3176. //id = 3
  3177. patient_id, _ := c.GetInt64("patient_id")
  3178. //patient_id = 23834
  3179. //record_time = "2023-09-18"
  3180. timeLayout := "2006-01-02"
  3181. loc, _ := time.LoadLocation("Local")
  3182. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3183. if err != nil {
  3184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3185. return
  3186. }
  3187. recordDateTime := theTime.Unix()
  3188. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3189. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3190. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3191. dept, _ := service.GetDepartMentDetail(info.Departments)
  3192. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  3193. var cFYLJG003 models.CFYLJG003
  3194. cFYLJG003.RxTraceCode = flow.RxTraceCode
  3195. cFYLJG003.HiRxno = flow.HiRxno
  3196. cFYLJG003.MdtrtID = flow.MID
  3197. cFYLJG003.PatnName = his.Name
  3198. cFYLJG003.Certno = his.Certno
  3199. cFYLJG003.FixmedinsName = miConfig.OrgName
  3200. cFYLJG003.FixmedinsCode = miConfig.Code
  3201. cFYLJG003.DrCode = doctor_info.DoctorNumber
  3202. cFYLJG003.PrscDrName = doctor_info.UserName
  3203. cFYLJG003.PharDeptName = dept.Name
  3204. cFYLJG003.PharDeptCode = dept.Number
  3205. cFYLJG003.PharCode = "HY440309002107"
  3206. cFYLJG003.PharCertType = "01"
  3207. cFYLJG003.PharCertno = "430482199408260023"
  3208. cFYLJG003.PharName = "彭斯遥"
  3209. cFYLJG003.PsnCertType = "01"
  3210. cFYLJG003.RxFile = flow.RxFile
  3211. cFYLJG003.SignDigest = flow.SignDigest
  3212. cFYLJG003.FixmedinsCode = miConfig.Code
  3213. cFYLJG003.PsnCertType = "01"
  3214. cFYLJG003.PharProfttlCodg = dept.Name
  3215. //inputData["pharProfttlCodg"] =dept.Name
  3216. tempTime2 := time.Unix(info.Ctime, 0)
  3217. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3218. cFYLJG003.PharChkTime = timeFormatTwo
  3219. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  3220. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  3221. var res ResultCFYLJG003
  3222. var respJSON2 map[string]interface{}
  3223. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3226. return
  3227. }
  3228. userJSONBytes2, _ := json.Marshal(respJSON2)
  3229. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3230. utils.ErrorLog("解析失败:%v", err)
  3231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3232. return
  3233. }
  3234. if res.Infcode == -1 {
  3235. c.ServeSuccessJSON(map[string]interface{}{
  3236. "failed_code": -10,
  3237. "msg": res.ErrMsg,
  3238. })
  3239. return
  3240. } else {
  3241. c.ServeSuccessJSON(map[string]interface{}{
  3242. "info": res.Output,
  3243. })
  3244. }
  3245. }
  3246. func (c *HisApiController) GetCFYLJG004() {
  3247. admin_user_id, _ := c.GetInt64("admin_user_id")
  3248. his_patient_id, _ := c.GetInt64("his_patient_id")
  3249. record_time := c.GetString("record_time")
  3250. admin_user_id = 3626
  3251. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3252. //id, _ := c.GetInt64("id")
  3253. admin_user_id = 3626
  3254. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3255. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3256. flow, _ := service.Getflowtwo(his.Number)
  3257. //id = 3
  3258. patient_id, _ := c.GetInt64("patient_id")
  3259. //patient_id = 23834
  3260. //record_time = "2023-09-18"
  3261. timeLayout := "2006-01-02"
  3262. loc, _ := time.LoadLocation("Local")
  3263. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3264. if err != nil {
  3265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3266. return
  3267. }
  3268. recordDateTime := theTime.Unix()
  3269. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3270. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3271. var cFYLJG004 models.CFYLJG004
  3272. cFYLJG004.HiRxno = flow.HiRxno
  3273. cFYLJG004.FixmedinsCode = miConfig.Code
  3274. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  3275. cFYLJG004.UndoDrCertType = "01"
  3276. cFYLJG004.UndoRea = "撤销处方"
  3277. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  3278. cFYLJG004.UndoDrName = doctor_info.UserName
  3279. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  3280. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  3281. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  3282. var res ResultCFYLJG004
  3283. var respJSON2 map[string]interface{}
  3284. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3287. return
  3288. }
  3289. userJSONBytes2, _ := json.Marshal(respJSON2)
  3290. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3291. utils.ErrorLog("解析失败:%v", err)
  3292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3293. return
  3294. }
  3295. if res.Infcode == -1 {
  3296. c.ServeSuccessJSON(map[string]interface{}{
  3297. "failed_code": -10,
  3298. "msg": res.ErrMsg,
  3299. })
  3300. return
  3301. } else {
  3302. flow.Status = 0
  3303. service.Saveflow(flow)
  3304. c.ServeSuccessJSON(map[string]interface{}{
  3305. "msg": "撤销成功",
  3306. })
  3307. return
  3308. }
  3309. }
  3310. func (c *HisApiController) GetCFYLJG005() {
  3311. admin_user_id, _ := c.GetInt64("admin_user_id")
  3312. his_patient_id, _ := c.GetInt64("his_patient_id")
  3313. //record_time := c.GetString("record_time")
  3314. admin_user_id = 3626
  3315. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3316. //id, _ := c.GetInt64("id")
  3317. admin_user_id = 3626
  3318. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3319. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3320. flow, _ := service.Getflowtwo(his.Number)
  3321. //id = 3
  3322. var cFYLJG005 models.CFYLJG005
  3323. //patient_id, _ := c.GetInt64("patient_id")
  3324. cFYLJG005.HiRxno = flow.HiRxno
  3325. cFYLJG005.MdtrtID = flow.MID
  3326. cFYLJG005.EcToken = ""
  3327. cFYLJG005.PsnName = his.Name
  3328. cFYLJG005.PsnCertType = "01"
  3329. cFYLJG005.Certno = his.IdCardNo
  3330. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  3331. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  3332. var res ResultCFYLJG005
  3333. var respJSON2 map[string]interface{}
  3334. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3337. return
  3338. }
  3339. userJSONBytes2, _ := json.Marshal(respJSON2)
  3340. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3341. utils.ErrorLog("解析失败:%v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. if res.Infcode == -1 {
  3346. c.ServeSuccessJSON(map[string]interface{}{
  3347. "failed_code": -10,
  3348. "msg": res.ErrMsg,
  3349. })
  3350. return
  3351. } else {
  3352. c.ServeSuccessJSON(map[string]interface{}{
  3353. "info": res.Output,
  3354. })
  3355. return
  3356. }
  3357. }
  3358. func (c *HisApiController) GetCFYLJG006() {
  3359. admin_user_id, _ := c.GetInt64("admin_user_id")
  3360. his_patient_id, _ := c.GetInt64("his_patient_id")
  3361. admin_user_id = 3626
  3362. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3363. //id, _ := c.GetInt64("id")
  3364. admin_user_id = 3626
  3365. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3366. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3367. flow, _ := service.Getflowtwo(his.Number)
  3368. //id = 3
  3369. patient_id, _ := c.GetInt64("patient_id")
  3370. var cFYLJG006 models.CFYLJG006
  3371. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3372. cFYLJG006.HiRxno = flow.HiRxno
  3373. cFYLJG006.MdtrtID = flow.MID
  3374. cFYLJG006.PsnName = patient.Name
  3375. cFYLJG006.PsnCertType = "01"
  3376. cFYLJG006.Certno = patient.IdCardNo
  3377. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  3378. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  3379. var res ResultCFYLJG006
  3380. var respJSON2 map[string]interface{}
  3381. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3384. return
  3385. }
  3386. userJSONBytes2, _ := json.Marshal(respJSON2)
  3387. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3388. utils.ErrorLog("解析失败:%v", err)
  3389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3390. return
  3391. }
  3392. if res.Infcode == -1 {
  3393. c.ServeSuccessJSON(map[string]interface{}{
  3394. "failed_code": -10,
  3395. "msg": res.ErrMsg,
  3396. })
  3397. return
  3398. } else {
  3399. c.ServeSuccessJSON(map[string]interface{}{
  3400. "info": res.Output,
  3401. })
  3402. return
  3403. }
  3404. }
  3405. func (c *HisApiController) GetCFYLJG007() {
  3406. admin_user_id, _ := c.GetInt64("admin_user_id")
  3407. his_patient_id, _ := c.GetInt64("his_patient_id")
  3408. admin_user_id = 3626
  3409. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3410. //id, _ := c.GetInt64("id")
  3411. admin_user_id = 3626
  3412. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3413. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3414. flow, _ := service.Getflowtwo(his.Number)
  3415. //id = 3
  3416. patient_id, _ := c.GetInt64("patient_id")
  3417. var cFYLJG007 models.CFYLJG007
  3418. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3419. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3420. cFYLJG007.HiRxno = flow.HiRxno
  3421. cFYLJG007.MdtrtID = flow.MID
  3422. cFYLJG007.PsnNo = his.PsnNo
  3423. cFYLJG007.PsnCertType = "01"
  3424. cFYLJG007.Certno = patient.IdCardNo
  3425. cFYLJG007.PsnName = patient.Name
  3426. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3427. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3428. var res ResultCFYLJG007
  3429. var respJSON2 map[string]interface{}
  3430. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3433. return
  3434. }
  3435. userJSONBytes2, _ := json.Marshal(respJSON2)
  3436. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3437. utils.ErrorLog("解析失败:%v", err)
  3438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. return
  3440. }
  3441. if res.Infcode == -1 {
  3442. c.ServeSuccessJSON(map[string]interface{}{
  3443. "failed_code": -10,
  3444. "msg": res.ErrMsg,
  3445. })
  3446. return
  3447. } else {
  3448. c.ServeSuccessJSON(map[string]interface{}{
  3449. "info": res,
  3450. })
  3451. return
  3452. }
  3453. }
  3454. func (c *HisApiController) GetCFYLJG008() {
  3455. admin_user_id, _ := c.GetInt64("admin_user_id")
  3456. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3457. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3458. var cFYLJG008 models.CFYLJG008
  3459. //id, _ := c.GetInt64("id")
  3460. patient_id, _ := c.GetInt64("patient_id")
  3461. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3462. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3463. //id = 3
  3464. //flow, _ := service.Getflow(id)
  3465. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3466. //
  3467. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3468. //patient_id, _ := c.GetInt64("patient_id")
  3469. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3470. record_time := c.GetString("record_time")
  3471. admin_user_id = 3626
  3472. patient_id = 19424
  3473. //his_patient_id = 263947
  3474. record_time = "2023-08-29"
  3475. timeLayout := "2006-01-02"
  3476. loc, _ := time.LoadLocation("Local")
  3477. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3478. if err != nil {
  3479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3480. return
  3481. }
  3482. recordDateTime := theTime.Unix()
  3483. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3484. cFYLJG008.FixmedinsName = ""
  3485. cFYLJG008.Lat = ""
  3486. cFYLJG008.Lng = ""
  3487. cFYLJG008.OrderType = "1"
  3488. cFYLJG008.PoolareaNo = ""
  3489. cFYLJG008.Lng = ""
  3490. cFYLJG008.PageNum = 1
  3491. cFYLJG008.PageSize = 10
  3492. var MPI models.MedinsProdInvChgDDTO
  3493. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3494. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3495. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3496. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3497. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3498. var res ResultCFYLJG008
  3499. var respJSON2 map[string]interface{}
  3500. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3503. return
  3504. }
  3505. userJSONBytes2, _ := json.Marshal(respJSON2)
  3506. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3507. utils.ErrorLog("解析失败:%v", err)
  3508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3509. return
  3510. }
  3511. if res.Infcode == -1 {
  3512. c.ServeSuccessJSON(map[string]interface{}{
  3513. "failed_code": -10,
  3514. "msg": res.ErrMsg,
  3515. })
  3516. return
  3517. } else {
  3518. c.ServeSuccessJSON(map[string]interface{}{
  3519. "info": res.Output,
  3520. })
  3521. return
  3522. }
  3523. }
  3524. func (c *HisApiController) GetBL4201A() {
  3525. order_id, _ := c.GetInt64("order_id")
  3526. admin_user_id, _ := c.GetInt64("admin_user_id")
  3527. order, _ := service.GetHisOrderByIDTwo(order_id)
  3528. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3529. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3530. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3531. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3532. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3533. department, _ := service.GetDepartMentDetail(his.Departments)
  3534. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3535. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3536. if order.ID == 0 {
  3537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3538. return
  3539. }
  3540. var struct4201A models.Struct4201A
  3541. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3542. for _, items := range order_info {
  3543. memo := make(map[string]interface{})
  3544. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3545. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3546. fsiOPFLD.MedType = "14"
  3547. fsiOPFLD.BkkpSn = items.FeedetlSn
  3548. fsiOPFLD.FixmedinsCode = miConfig.Code
  3549. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3550. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3551. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3552. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3553. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3554. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3555. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3556. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3557. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3558. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3559. fsiOPFLD.BilgDeptName = department.Name
  3560. fsiOPFLD.BilgDeptCodg = department.Number
  3561. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3562. fsiOPFLD.BilgDrName = doctor.UserName
  3563. fsiOPFLD.MedChrgitmType = "09"
  3564. memo["hosp_appr_flag"] = "1"
  3565. memo["invoice_no"] = order.MdtrtId
  3566. memo["memo"] = "自费"
  3567. bytesData, _ := json.Marshal(memo)
  3568. fsiOPFLD.Memo = string(bytesData)
  3569. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3570. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3571. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3572. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3573. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3574. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3575. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3576. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3577. fsiOPFLD.BilgDeptName = department.Name
  3578. fsiOPFLD.BilgDeptCodg = department.Number
  3579. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3580. fsiOPFLD.BilgDrName = doctor.UserName
  3581. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3582. case 0:
  3583. break
  3584. case 1:
  3585. fsiOPFLD.MedChrgitmType = "14"
  3586. break
  3587. case 2:
  3588. fsiOPFLD.MedChrgitmType = "05"
  3589. break
  3590. case 3:
  3591. fsiOPFLD.MedChrgitmType = "03"
  3592. break
  3593. case 4:
  3594. fsiOPFLD.MedChrgitmType = "03"
  3595. break
  3596. case 5:
  3597. fsiOPFLD.MedChrgitmType = "08"
  3598. break
  3599. case 6:
  3600. fsiOPFLD.MedChrgitmType = "14"
  3601. break
  3602. case 7:
  3603. fsiOPFLD.MedChrgitmType = "14"
  3604. break
  3605. case 8:
  3606. fsiOPFLD.MedChrgitmType = "03"
  3607. break
  3608. case 9:
  3609. fsiOPFLD.MedChrgitmType = "14"
  3610. break
  3611. case 10:
  3612. fsiOPFLD.MedChrgitmType = "14"
  3613. break
  3614. case 11:
  3615. fsiOPFLD.MedChrgitmType = "06"
  3616. break
  3617. case 12:
  3618. fsiOPFLD.MedChrgitmType = "12"
  3619. break
  3620. case 13:
  3621. fsiOPFLD.MedChrgitmType = "01"
  3622. break
  3623. case 14:
  3624. fsiOPFLD.MedChrgitmType = "04"
  3625. break
  3626. case 15:
  3627. fsiOPFLD.MedChrgitmType = "14"
  3628. break
  3629. }
  3630. memo["hosp_appr_flag"] = "1"
  3631. memo["invoice_no"] = order.MdtrtId
  3632. memo["memo"] = "自费"
  3633. bytesData, _ := json.Marshal(memo)
  3634. fsiOPFLD.Memo = string(bytesData)
  3635. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3636. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3637. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3638. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3639. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3640. fsiOPFLD.BilgDeptName = department.Name
  3641. fsiOPFLD.BilgDeptCodg = department.Number
  3642. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3643. fsiOPFLD.BilgDrName = doctor.UserName
  3644. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3645. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3646. fsiOPFLD.MedChrgitmType = "08"
  3647. memo["hosp_appr_flag"] = "1"
  3648. memo["invoice_no"] = order.MdtrtId
  3649. memo["memo"] = "自费"
  3650. bytesData, _ := json.Marshal(memo)
  3651. fsiOPFLD.Memo = string(bytesData)
  3652. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3653. }
  3654. }
  3655. }
  3656. for _, items := range order_info_two {
  3657. memo := make(map[string]interface{})
  3658. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3659. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3660. fsiOPFLD.MedType = "14"
  3661. fsiOPFLD.BkkpSn = items.FeedetlSn
  3662. fsiOPFLD.FixmedinsCode = miConfig.Code
  3663. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3664. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3665. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3666. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3667. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3668. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3669. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3670. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3671. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3672. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3673. fsiOPFLD.BilgDeptName = department.Name
  3674. fsiOPFLD.BilgDeptCodg = department.Number
  3675. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3676. fsiOPFLD.BilgDrName = doctor.UserName
  3677. fsiOPFLD.MedChrgitmType = "09"
  3678. memo["hosp_appr_flag"] = "1"
  3679. memo["invoice_no"] = order.MdtrtId
  3680. memo["memo"] = "自费"
  3681. bytesData, _ := json.Marshal(memo)
  3682. fsiOPFLD.Memo = string(bytesData)
  3683. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3684. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3685. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3686. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3687. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3688. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3689. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3690. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3691. fsiOPFLD.BilgDeptName = department.Name
  3692. fsiOPFLD.BilgDeptCodg = department.Number
  3693. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3694. fsiOPFLD.BilgDrName = doctor.UserName
  3695. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3696. case 0:
  3697. break
  3698. case 1:
  3699. fsiOPFLD.MedChrgitmType = "14"
  3700. break
  3701. case 2:
  3702. fsiOPFLD.MedChrgitmType = "05"
  3703. break
  3704. case 3:
  3705. fsiOPFLD.MedChrgitmType = "03"
  3706. break
  3707. case 4:
  3708. fsiOPFLD.MedChrgitmType = "03"
  3709. break
  3710. case 5:
  3711. fsiOPFLD.MedChrgitmType = "08"
  3712. break
  3713. case 6:
  3714. fsiOPFLD.MedChrgitmType = "14"
  3715. break
  3716. case 7:
  3717. fsiOPFLD.MedChrgitmType = "14"
  3718. break
  3719. case 8:
  3720. fsiOPFLD.MedChrgitmType = "03"
  3721. break
  3722. case 9:
  3723. fsiOPFLD.MedChrgitmType = "14"
  3724. break
  3725. case 10:
  3726. fsiOPFLD.MedChrgitmType = "14"
  3727. break
  3728. case 11:
  3729. fsiOPFLD.MedChrgitmType = "06"
  3730. break
  3731. case 12:
  3732. fsiOPFLD.MedChrgitmType = "12"
  3733. break
  3734. case 13:
  3735. fsiOPFLD.MedChrgitmType = "01"
  3736. break
  3737. case 14:
  3738. fsiOPFLD.MedChrgitmType = "04"
  3739. break
  3740. case 15:
  3741. fsiOPFLD.MedChrgitmType = "14"
  3742. break
  3743. }
  3744. memo["hosp_appr_flag"] = "1"
  3745. memo["invoice_no"] = order.MdtrtId
  3746. memo["memo"] = "自费"
  3747. bytesData, _ := json.Marshal(memo)
  3748. fsiOPFLD.Memo = string(bytesData)
  3749. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3750. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3751. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3752. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3753. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3754. fsiOPFLD.BilgDeptName = department.Name
  3755. fsiOPFLD.BilgDeptCodg = department.Number
  3756. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3757. fsiOPFLD.BilgDrName = doctor.UserName
  3758. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3759. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3760. fsiOPFLD.MedChrgitmType = "08"
  3761. memo["hosp_appr_flag"] = "1"
  3762. memo["invoice_no"] = order.MdtrtId
  3763. memo["memo"] = "自费"
  3764. bytesData, _ := json.Marshal(memo)
  3765. fsiOPFLD.Memo = string(bytesData)
  3766. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3767. }
  3768. }
  3769. }
  3770. fmt.Println(fsiOPFLDs)
  3771. struct4201A.Fopfd = fsiOPFLDs
  3772. fmt.Println(struct4201A.Fopfd)
  3773. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3774. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3775. var res2 ResultSix
  3776. var respJSON2 map[string]interface{}
  3777. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3780. return
  3781. }
  3782. userJSONBytes2, _ := json.Marshal(respJSON2)
  3783. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3784. utils.ErrorLog("解析失败:%v", err)
  3785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3786. return
  3787. }
  3788. if res2.Infcode != 0 {
  3789. c.ServeSuccessJSON(map[string]interface{}{
  3790. "failed_code": -10,
  3791. "msg": res2.ErrMsg,
  3792. })
  3793. return
  3794. } else {
  3795. order.IsUploadOrderInfo = 1
  3796. service.UpdateOrder(order)
  3797. c.ServeSuccessJSON(map[string]interface{}{
  3798. "msg": "上传成功",
  3799. })
  3800. }
  3801. }
  3802. func (c *HisApiController) Get2505() {
  3803. admin_user_id, _ := c.GetInt64("admin_user_id")
  3804. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3805. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3806. 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)
  3807. }
  3808. func (c *HisApiController) Get4201A() {
  3809. order_id, _ := c.GetInt64("order_id")
  3810. admin_user_id, _ := c.GetInt64("admin_user_id")
  3811. order, _ := service.GetHisOrderByIDTwo(order_id)
  3812. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3813. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3814. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3815. //order_info = append(order_info, order_info_two...)
  3816. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3817. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3818. department, _ := service.GetDepartMentDetail(his.Departments)
  3819. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3820. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3821. if order.ID == 0 {
  3822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3823. return
  3824. }
  3825. var struct4201A models.Struct4201A
  3826. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3827. for _, items := range order_info {
  3828. memo := make(map[string]interface{})
  3829. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3830. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3831. fsiOPFLD.MedType = "14"
  3832. fsiOPFLD.BkkpSn = items.FeedetlSn
  3833. fsiOPFLD.FixmedinsCode = miConfig.Code
  3834. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3835. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3836. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3837. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3838. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3839. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3840. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3841. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3842. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3843. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3844. fsiOPFLD.BilgDeptName = department.Name
  3845. fsiOPFLD.BilgDeptCodg = department.Number
  3846. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3847. fsiOPFLD.BilgDrName = doctor.UserName
  3848. fsiOPFLD.MedChrgitmType = "09"
  3849. memo["hosp_appr_flag"] = "1"
  3850. memo["invoice_no"] = order.MdtrtId
  3851. memo["memo"] = "自费"
  3852. bytesData, _ := json.Marshal(memo)
  3853. fsiOPFLD.Memo = string(bytesData)
  3854. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3855. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3856. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3857. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3858. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3859. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3860. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3861. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3862. fsiOPFLD.BilgDeptName = department.Name
  3863. fsiOPFLD.BilgDeptCodg = department.Number
  3864. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3865. fsiOPFLD.BilgDrName = doctor.UserName
  3866. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3867. case 0:
  3868. break
  3869. case 1:
  3870. fsiOPFLD.MedChrgitmType = "14"
  3871. break
  3872. case 2:
  3873. fsiOPFLD.MedChrgitmType = "05"
  3874. break
  3875. case 3:
  3876. fsiOPFLD.MedChrgitmType = "03"
  3877. break
  3878. case 4:
  3879. fsiOPFLD.MedChrgitmType = "03"
  3880. break
  3881. case 5:
  3882. fsiOPFLD.MedChrgitmType = "08"
  3883. break
  3884. case 6:
  3885. fsiOPFLD.MedChrgitmType = "14"
  3886. break
  3887. case 7:
  3888. fsiOPFLD.MedChrgitmType = "14"
  3889. break
  3890. case 8:
  3891. fsiOPFLD.MedChrgitmType = "03"
  3892. break
  3893. case 9:
  3894. fsiOPFLD.MedChrgitmType = "14"
  3895. break
  3896. case 10:
  3897. fsiOPFLD.MedChrgitmType = "14"
  3898. break
  3899. case 11:
  3900. fsiOPFLD.MedChrgitmType = "06"
  3901. break
  3902. case 12:
  3903. fsiOPFLD.MedChrgitmType = "12"
  3904. break
  3905. case 13:
  3906. fsiOPFLD.MedChrgitmType = "01"
  3907. break
  3908. case 14:
  3909. fsiOPFLD.MedChrgitmType = "04"
  3910. break
  3911. case 15:
  3912. fsiOPFLD.MedChrgitmType = "14"
  3913. break
  3914. }
  3915. memo["hosp_appr_flag"] = "1"
  3916. memo["invoice_no"] = order.MdtrtId
  3917. memo["memo"] = "自费"
  3918. bytesData, _ := json.Marshal(memo)
  3919. fsiOPFLD.Memo = string(bytesData)
  3920. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3921. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3922. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3923. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3924. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3925. fsiOPFLD.BilgDeptName = department.Name
  3926. fsiOPFLD.BilgDeptCodg = department.Number
  3927. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3928. fsiOPFLD.BilgDrName = doctor.UserName
  3929. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3930. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3931. fsiOPFLD.MedChrgitmType = "08"
  3932. memo["hosp_appr_flag"] = "1"
  3933. memo["invoice_no"] = order.MdtrtId
  3934. memo["memo"] = "自费"
  3935. bytesData, _ := json.Marshal(memo)
  3936. fsiOPFLD.Memo = string(bytesData)
  3937. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3938. }
  3939. }
  3940. }
  3941. for _, items := range order_info_two {
  3942. memo := make(map[string]interface{})
  3943. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3944. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3945. fsiOPFLD.MedType = "14"
  3946. fsiOPFLD.BkkpSn = items.FeedetlSn
  3947. fsiOPFLD.FixmedinsCode = miConfig.Code
  3948. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3949. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3950. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3951. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3952. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3953. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3954. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3955. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3956. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3957. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3958. fsiOPFLD.BilgDeptName = department.Name
  3959. fsiOPFLD.BilgDeptCodg = department.Number
  3960. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3961. fsiOPFLD.BilgDrName = doctor.UserName
  3962. fsiOPFLD.MedChrgitmType = "09"
  3963. memo["hosp_appr_flag"] = "1"
  3964. memo["invoice_no"] = order.MdtrtId
  3965. memo["memo"] = "自费"
  3966. bytesData, _ := json.Marshal(memo)
  3967. fsiOPFLD.Memo = string(bytesData)
  3968. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3969. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3970. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3971. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3972. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3973. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3974. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3975. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3976. fsiOPFLD.BilgDeptName = department.Name
  3977. fsiOPFLD.BilgDeptCodg = department.Number
  3978. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3979. fsiOPFLD.BilgDrName = doctor.UserName
  3980. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3981. case 0:
  3982. break
  3983. case 1:
  3984. fsiOPFLD.MedChrgitmType = "14"
  3985. break
  3986. case 2:
  3987. fsiOPFLD.MedChrgitmType = "05"
  3988. break
  3989. case 3:
  3990. fsiOPFLD.MedChrgitmType = "03"
  3991. break
  3992. case 4:
  3993. fsiOPFLD.MedChrgitmType = "03"
  3994. break
  3995. case 5:
  3996. fsiOPFLD.MedChrgitmType = "08"
  3997. break
  3998. case 6:
  3999. fsiOPFLD.MedChrgitmType = "14"
  4000. break
  4001. case 7:
  4002. fsiOPFLD.MedChrgitmType = "14"
  4003. break
  4004. case 8:
  4005. fsiOPFLD.MedChrgitmType = "03"
  4006. break
  4007. case 9:
  4008. fsiOPFLD.MedChrgitmType = "14"
  4009. break
  4010. case 10:
  4011. fsiOPFLD.MedChrgitmType = "14"
  4012. break
  4013. case 11:
  4014. fsiOPFLD.MedChrgitmType = "06"
  4015. break
  4016. case 12:
  4017. fsiOPFLD.MedChrgitmType = "12"
  4018. break
  4019. case 13:
  4020. fsiOPFLD.MedChrgitmType = "01"
  4021. break
  4022. case 14:
  4023. fsiOPFLD.MedChrgitmType = "04"
  4024. break
  4025. case 15:
  4026. fsiOPFLD.MedChrgitmType = "14"
  4027. break
  4028. }
  4029. memo["hosp_appr_flag"] = "1"
  4030. memo["invoice_no"] = order.MdtrtId
  4031. memo["memo"] = "自费"
  4032. bytesData, _ := json.Marshal(memo)
  4033. fsiOPFLD.Memo = string(bytesData)
  4034. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4035. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4036. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4037. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4038. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4039. fsiOPFLD.BilgDeptName = department.Name
  4040. fsiOPFLD.BilgDeptCodg = department.Number
  4041. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4042. fsiOPFLD.BilgDrName = doctor.UserName
  4043. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4044. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4045. fsiOPFLD.MedChrgitmType = "08"
  4046. memo["hosp_appr_flag"] = "1"
  4047. memo["invoice_no"] = order.MdtrtId
  4048. memo["memo"] = "自费"
  4049. bytesData, _ := json.Marshal(memo)
  4050. fsiOPFLD.Memo = string(bytesData)
  4051. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4052. }
  4053. }
  4054. }
  4055. fmt.Println(fsiOPFLDs)
  4056. struct4201A.Fopfd = fsiOPFLDs
  4057. fmt.Println(struct4201A.Fopfd)
  4058. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  4059. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  4060. var res2 ResultSix
  4061. var respJSON2 map[string]interface{}
  4062. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4065. return
  4066. }
  4067. userJSONBytes2, _ := json.Marshal(respJSON2)
  4068. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4069. utils.ErrorLog("解析失败:%v", err)
  4070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4071. return
  4072. }
  4073. if res2.Infcode != 0 {
  4074. c.ServeSuccessJSON(map[string]interface{}{
  4075. "failed_code": -10,
  4076. "msg": res2.ErrMsg,
  4077. })
  4078. return
  4079. } else {
  4080. order.IsUploadOrderInfo = 1
  4081. service.UpdateOrder(order)
  4082. c.ServeSuccessJSON(map[string]interface{}{
  4083. "msg": "上传成功",
  4084. })
  4085. }
  4086. }
  4087. func (c *HisApiController) Get4202() {
  4088. order_id, _ := c.GetInt64("order_id")
  4089. admin_user_id, _ := c.GetInt64("admin_user_id")
  4090. order, _ := service.GetHisOrderByIDTwo(order_id)
  4091. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4092. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4093. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4094. if order.ID == 0 {
  4095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4096. return
  4097. }
  4098. var struct4202 models.Struct4202
  4099. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4100. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4101. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4102. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4103. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4104. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4105. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  4106. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  4107. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4108. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4109. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4110. var config []*models.HisXtDiagnoseConfig
  4111. for _, item := range diagnosis_ids {
  4112. id, _ := strconv.ParseInt(item, 10, 64)
  4113. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4114. config = append(config, &diagnosisConfig)
  4115. }
  4116. var tempDiaginfos []models.OwnPayPatnDiagListD
  4117. for index, item := range config {
  4118. if index == 0 {
  4119. var tempDiaginfo models.OwnPayPatnDiagListD
  4120. tempDiaginfo.InoutDiagType = "1"
  4121. tempDiaginfo.DiagCode = item.CountryCode
  4122. tempDiaginfo.DiagName = item.CountryContentName
  4123. tempDiaginfo.DiagType = "1"
  4124. tempDiaginfo.DiagSrtNo = "1"
  4125. tempDiaginfo.MaindiagFlag = "1"
  4126. tempDiaginfo.ValiFlag = "1"
  4127. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4128. } else {
  4129. var tempDiaginfo models.OwnPayPatnDiagListD
  4130. tempDiaginfo.DiagCode = item.CountryCode
  4131. tempDiaginfo.DiagName = item.CountryContentName
  4132. tempDiaginfo.DiagType = "2"
  4133. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4134. tempDiaginfo.MaindiagFlag = "0"
  4135. tempDiaginfo.ValiFlag = "1"
  4136. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4137. }
  4138. }
  4139. struct4202.ODiagListD = tempDiaginfos
  4140. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  4141. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  4142. var res2 ResultSix
  4143. var respJSON2 map[string]interface{}
  4144. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4147. return
  4148. }
  4149. userJSONBytes2, _ := json.Marshal(respJSON2)
  4150. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4151. utils.ErrorLog("解析失败:%v", err)
  4152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4153. return
  4154. }
  4155. if res2.Infcode != 0 {
  4156. c.ServeSuccessJSON(map[string]interface{}{
  4157. "failed_code": -10,
  4158. "msg": res2.ErrMsg,
  4159. })
  4160. return
  4161. } else {
  4162. order.IsUploadDiagnose = 1
  4163. service.UpdateOrder(order)
  4164. c.ServeSuccessJSON(map[string]interface{}{
  4165. "msg": "上传成功",
  4166. })
  4167. }
  4168. }
  4169. func (c *HisApiController) Get4203() {
  4170. admin_user_id, _ := c.GetInt64("admin_user_id")
  4171. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4172. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4173. order_id, _ := c.GetInt64("order_id")
  4174. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4175. number := ""
  4176. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4177. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4178. if his.ID == 0 {
  4179. number = hospital.Number
  4180. } else {
  4181. number = his.Number
  4182. }
  4183. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  4184. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  4185. var res2 ResultSix
  4186. var respJSON2 map[string]interface{}
  4187. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4190. return
  4191. }
  4192. userJSONBytes2, _ := json.Marshal(respJSON2)
  4193. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4194. utils.ErrorLog("解析失败:%v", err)
  4195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4196. return
  4197. }
  4198. if res2.Infcode != 0 {
  4199. c.ServeSuccessJSON(map[string]interface{}{
  4200. "failed_code": -10,
  4201. "msg": res2.ErrMsg,
  4202. })
  4203. return
  4204. } else {
  4205. order.IsUploadSuccess = 1
  4206. service.UpdateOrderTwo(order)
  4207. c.ServeSuccessJSON(map[string]interface{}{
  4208. "msg": "上传成功",
  4209. })
  4210. }
  4211. }
  4212. func (c *HisApiController) Get4205() {
  4213. order_id, _ := c.GetInt64("order_id")
  4214. admin_user_id, _ := c.GetInt64("admin_user_id")
  4215. fapiao_code := c.GetString("fapiao_code")
  4216. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4217. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4218. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4219. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4220. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  4221. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4222. //order_info = append(order_info, order_info_two...)
  4223. department, _ := service.GetDepartMentDetail(his.Departments)
  4224. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4225. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4226. if order.ID == 0 {
  4227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4228. return
  4229. }
  4230. var struct4201A models.Struct4201A
  4231. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4232. for _, items := range order_info {
  4233. memo := make(map[string]interface{})
  4234. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4235. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4236. fsiOPFLD.MedType = pre.MedType
  4237. fsiOPFLD.FixmedinsCode = miConfig.Code
  4238. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4239. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4240. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4241. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4242. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4243. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4244. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4245. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  4246. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4247. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4248. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4249. fsiOPFLD.BilgDeptName = department.Name
  4250. fsiOPFLD.BilgDeptCodg = department.Number
  4251. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4252. fsiOPFLD.BilgDrName = doctor.UserName
  4253. fsiOPFLD.MedChrgitmType = "09"
  4254. memo["hosp_appr_flag"] = "1"
  4255. memo["invoice_no"] = fapiao_code
  4256. memo["memo"] = "自费"
  4257. bytesData, _ := json.Marshal(memo)
  4258. fsiOPFLD.Memo = string(bytesData)
  4259. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4260. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4261. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4262. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4263. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4264. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4265. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4266. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4267. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4268. fsiOPFLD.BilgDeptName = department.Name
  4269. fsiOPFLD.BilgDeptCodg = department.Number
  4270. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4271. fsiOPFLD.BilgDrName = doctor.UserName
  4272. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4273. case 0:
  4274. break
  4275. case 1:
  4276. fsiOPFLD.MedChrgitmType = "14"
  4277. break
  4278. case 2:
  4279. fsiOPFLD.MedChrgitmType = "05"
  4280. break
  4281. case 3:
  4282. fsiOPFLD.MedChrgitmType = "03"
  4283. break
  4284. case 4:
  4285. fsiOPFLD.MedChrgitmType = "03"
  4286. break
  4287. case 5:
  4288. fsiOPFLD.MedChrgitmType = "08"
  4289. break
  4290. case 6:
  4291. fsiOPFLD.MedChrgitmType = "14"
  4292. break
  4293. case 7:
  4294. fsiOPFLD.MedChrgitmType = "14"
  4295. break
  4296. case 8:
  4297. fsiOPFLD.MedChrgitmType = "03"
  4298. break
  4299. case 9:
  4300. fsiOPFLD.MedChrgitmType = "14"
  4301. break
  4302. case 10:
  4303. fsiOPFLD.MedChrgitmType = "14"
  4304. break
  4305. case 11:
  4306. fsiOPFLD.MedChrgitmType = "06"
  4307. break
  4308. case 12:
  4309. fsiOPFLD.MedChrgitmType = "12"
  4310. break
  4311. case 13:
  4312. fsiOPFLD.MedChrgitmType = "01"
  4313. break
  4314. case 14:
  4315. fsiOPFLD.MedChrgitmType = "04"
  4316. break
  4317. case 15:
  4318. fsiOPFLD.MedChrgitmType = "14"
  4319. break
  4320. }
  4321. memo["hosp_appr_flag"] = "1"
  4322. memo["invoice_no"] = fapiao_code
  4323. memo["memo"] = "自费"
  4324. bytesData, _ := json.Marshal(memo)
  4325. fsiOPFLD.Memo = string(bytesData)
  4326. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4327. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4328. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4329. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4330. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4331. fsiOPFLD.BilgDeptName = department.Name
  4332. fsiOPFLD.BilgDeptCodg = department.Number
  4333. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4334. fsiOPFLD.BilgDrName = doctor.UserName
  4335. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4336. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4337. fsiOPFLD.MedChrgitmType = "08"
  4338. memo["hosp_appr_flag"] = "1"
  4339. memo["invoice_no"] = fapiao_code
  4340. memo["memo"] = "自费"
  4341. bytesData, _ := json.Marshal(memo)
  4342. fsiOPFLD.Memo = string(bytesData)
  4343. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4344. }
  4345. }
  4346. }
  4347. for _, items := range order_info_two {
  4348. memo := make(map[string]interface{})
  4349. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4350. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4351. fsiOPFLD.MedType = pre.MedType
  4352. fsiOPFLD.BkkpSn = items.FeedetlSn
  4353. fsiOPFLD.FixmedinsCode = miConfig.Code
  4354. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4355. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4356. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4357. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4358. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4359. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4360. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4361. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4362. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4363. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4364. fsiOPFLD.BilgDeptName = department.Name
  4365. fsiOPFLD.BilgDeptCodg = department.Number
  4366. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4367. fsiOPFLD.BilgDrName = doctor.UserName
  4368. fsiOPFLD.MedChrgitmType = "09"
  4369. memo["hosp_appr_flag"] = "1"
  4370. memo["invoice_no"] = fapiao_code
  4371. memo["memo"] = "自费"
  4372. bytesData, _ := json.Marshal(memo)
  4373. fsiOPFLD.Memo = string(bytesData)
  4374. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4375. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4376. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4377. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4378. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4379. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4380. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4381. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4382. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4383. fsiOPFLD.BilgDeptName = department.Name
  4384. fsiOPFLD.BilgDeptCodg = department.Number
  4385. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4386. fsiOPFLD.BilgDrName = doctor.UserName
  4387. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4388. case 0:
  4389. break
  4390. case 1:
  4391. fsiOPFLD.MedChrgitmType = "14"
  4392. break
  4393. case 2:
  4394. fsiOPFLD.MedChrgitmType = "05"
  4395. break
  4396. case 3:
  4397. fsiOPFLD.MedChrgitmType = "03"
  4398. break
  4399. case 4:
  4400. fsiOPFLD.MedChrgitmType = "03"
  4401. break
  4402. case 5:
  4403. fsiOPFLD.MedChrgitmType = "08"
  4404. break
  4405. case 6:
  4406. fsiOPFLD.MedChrgitmType = "14"
  4407. break
  4408. case 7:
  4409. fsiOPFLD.MedChrgitmType = "14"
  4410. break
  4411. case 8:
  4412. fsiOPFLD.MedChrgitmType = "03"
  4413. break
  4414. case 9:
  4415. fsiOPFLD.MedChrgitmType = "14"
  4416. break
  4417. case 10:
  4418. fsiOPFLD.MedChrgitmType = "14"
  4419. break
  4420. case 11:
  4421. fsiOPFLD.MedChrgitmType = "06"
  4422. break
  4423. case 12:
  4424. fsiOPFLD.MedChrgitmType = "12"
  4425. break
  4426. case 13:
  4427. fsiOPFLD.MedChrgitmType = "01"
  4428. break
  4429. case 14:
  4430. fsiOPFLD.MedChrgitmType = "04"
  4431. break
  4432. case 15:
  4433. fsiOPFLD.MedChrgitmType = "14"
  4434. break
  4435. }
  4436. memo["hosp_appr_flag"] = "1"
  4437. memo["invoice_no"] = fapiao_code
  4438. memo["memo"] = "自费"
  4439. bytesData, _ := json.Marshal(memo)
  4440. fsiOPFLD.Memo = string(bytesData)
  4441. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4442. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4443. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4444. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4445. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4446. fsiOPFLD.BilgDeptName = department.Name
  4447. fsiOPFLD.BilgDeptCodg = department.Number
  4448. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4449. fsiOPFLD.BilgDrName = doctor.UserName
  4450. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4451. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4452. fsiOPFLD.MedChrgitmType = "08"
  4453. memo["hosp_appr_flag"] = "1"
  4454. memo["invoice_no"] = fapiao_code
  4455. memo["memo"] = "自费"
  4456. bytesData, _ := json.Marshal(memo)
  4457. fsiOPFLD.Memo = string(bytesData)
  4458. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4459. }
  4460. }
  4461. }
  4462. fmt.Println(fsiOPFLDs)
  4463. struct4201A.Fopfd = fsiOPFLDs
  4464. fmt.Println(struct4201A.Fopfd)
  4465. var struct4202 models.Struct4202
  4466. timeLayout := "2006-01-02 15:04:05"
  4467. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4468. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4469. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4470. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4471. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4472. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4473. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4474. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4475. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4476. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4477. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4478. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4479. var config []*models.HisXtDiagnoseConfig
  4480. for _, item := range diagnosis_ids {
  4481. id, _ := strconv.ParseInt(item, 10, 64)
  4482. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4483. config = append(config, &diagnosisConfig)
  4484. }
  4485. var tempDiaginfos []models.OwnPayPatnDiagListD
  4486. for index, item := range config {
  4487. if index == 0 {
  4488. var tempDiaginfo models.OwnPayPatnDiagListD
  4489. tempDiaginfo.InoutDiagType = "1"
  4490. tempDiaginfo.DiagCode = item.CountryCode
  4491. tempDiaginfo.DiagName = item.CountryContentName
  4492. tempDiaginfo.DiagType = "1"
  4493. tempDiaginfo.DiagSrtNo = "1"
  4494. tempDiaginfo.MaindiagFlag = "1"
  4495. tempDiaginfo.ValiFlag = "1"
  4496. tempDiaginfo.DiagDrName = doctor.UserName
  4497. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4498. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4499. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4500. } else {
  4501. var tempDiaginfo models.OwnPayPatnDiagListD
  4502. tempDiaginfo.DiagCode = item.CountryCode
  4503. tempDiaginfo.DiagName = item.CountryContentName
  4504. tempDiaginfo.DiagType = "2"
  4505. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4506. tempDiaginfo.MaindiagFlag = "0"
  4507. tempDiaginfo.ValiFlag = "1"
  4508. tempDiaginfo.DiagDrName = doctor.UserName
  4509. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4510. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4511. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4512. }
  4513. }
  4514. struct4202.ODiagListD = tempDiaginfos
  4515. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4516. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4517. var res2 ResultSix
  4518. var respJSON2 map[string]interface{}
  4519. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4522. return
  4523. }
  4524. userJSONBytes2, _ := json.Marshal(respJSON2)
  4525. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4526. utils.ErrorLog("解析失败:%v", err)
  4527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4528. return
  4529. }
  4530. if res2.Infcode != 0 {
  4531. c.ServeSuccessJSON(map[string]interface{}{
  4532. "failed_code": -10,
  4533. "msg": res2.ErrMsg,
  4534. })
  4535. return
  4536. } else {
  4537. order.IsUploadDiagnose = 1
  4538. order.IsUploadOrderInfo = 1
  4539. service.UpdateOrderTwo(order)
  4540. c.ServeSuccessJSON(map[string]interface{}{
  4541. "msg": "上传成功",
  4542. })
  4543. }
  4544. }
  4545. func (c *HisApiController) Get4207() {
  4546. admin_user_id, _ := c.GetInt64("admin_user_id")
  4547. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4548. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4549. order_id, _ := c.GetInt64("order_id")
  4550. order, _ := service.GetHisOrderByIDTwo(order_id)
  4551. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4552. var struct4207 models.Struct4207
  4553. struct4207.PageNum = "1"
  4554. struct4207.PageSize = "1000"
  4555. struct4207.FixmedinsCode = miConfig.Code
  4556. struct4207.FixmedinsMdtrtID = order.Number
  4557. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4558. saveLog(result, requestLog, "4207", "查询")
  4559. var res2 ResultSix
  4560. var respJSON2 map[string]interface{}
  4561. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4564. return
  4565. }
  4566. userJSONBytes2, _ := json.Marshal(respJSON2)
  4567. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4568. utils.ErrorLog("解析失败:%v", err)
  4569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4570. return
  4571. }
  4572. if res2.Infcode != 0 {
  4573. c.ServeSuccessJSON(map[string]interface{}{
  4574. "failed_code": -10,
  4575. "msg": res2.ErrMsg,
  4576. })
  4577. return
  4578. } else {
  4579. c.ServeSuccessJSON(map[string]interface{}{
  4580. "msg": "查询成功",
  4581. })
  4582. }
  4583. }
  4584. func (c *HisApiController) Get4208() {
  4585. admin_user_id, _ := c.GetInt64("admin_user_id")
  4586. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4587. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4588. order_id, _ := c.GetInt64("order_id")
  4589. order, _ := service.GetHisOrderByIDTwo(order_id)
  4590. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4591. var struct4208 models.Struct4208
  4592. struct4208.PageNum = "1"
  4593. struct4208.PageSize = "1000"
  4594. struct4208.PsnCertType = "01"
  4595. struct4208.Certno = his.Certno
  4596. struct4208.MedType = order.MedType
  4597. struct4208.PsnName = his.Name
  4598. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4599. saveLog(result, requestLog, "4208", "查询")
  4600. var res2 ResultSix
  4601. var respJSON2 map[string]interface{}
  4602. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4605. return
  4606. }
  4607. userJSONBytes2, _ := json.Marshal(respJSON2)
  4608. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4609. utils.ErrorLog("解析失败:%v", err)
  4610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4611. return
  4612. }
  4613. if res2.Infcode != 0 {
  4614. c.ServeSuccessJSON(map[string]interface{}{
  4615. "failed_code": -10,
  4616. "msg": res2.ErrMsg,
  4617. })
  4618. return
  4619. } else {
  4620. c.ServeSuccessJSON(map[string]interface{}{
  4621. "msg": "查询成功",
  4622. })
  4623. }
  4624. }
  4625. func (c *HisApiController) Get4209() {
  4626. admin_user_id, _ := c.GetInt64("admin_user_id")
  4627. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4628. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4629. order_id, _ := c.GetInt64("order_id")
  4630. order, _ := service.GetHisOrderByIDTwo(order_id)
  4631. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4632. var struct4209 models.Struct4209
  4633. struct4209.FixmedinsMdtrtID = order.Number
  4634. struct4209.FixmedinsCode = miConfig.Code
  4635. struct4209.PageSize = "1000"
  4636. struct4209.PageNum = "1"
  4637. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4638. saveLog(result, requestLog, "4209", "查询")
  4639. var res2 ResultSix
  4640. var respJSON2 map[string]interface{}
  4641. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. userJSONBytes2, _ := json.Marshal(respJSON2)
  4647. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4648. utils.ErrorLog("解析失败:%v", err)
  4649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4650. return
  4651. }
  4652. if res2.Infcode != 0 {
  4653. c.ServeSuccessJSON(map[string]interface{}{
  4654. "failed_code": -10,
  4655. "msg": res2.ErrMsg,
  4656. })
  4657. return
  4658. } else {
  4659. c.ServeSuccessJSON(map[string]interface{}{
  4660. "msg": "查询成功",
  4661. })
  4662. }
  4663. }
  4664. type Result3101 struct {
  4665. Infcode string `json:"infcode"`
  4666. InfRefmsgid string `json:"inf_refmsgid"`
  4667. RefmsgTime string `json:"refmsg_time"`
  4668. RespondTime string `json:"respond_time"`
  4669. Enctype string `json:"enctype"`
  4670. Signtype string `json:"signtype"`
  4671. ErrMsg string `json:"err_msg"`
  4672. Output struct {
  4673. Result []struct {
  4674. JudgeResultDetailDtos []struct {
  4675. VolaItemType string `json:"vola_item_type"`
  4676. MdtrtID string `json:"mdtrt_id"`
  4677. JrdID string `json:"jrd_id"`
  4678. PatnID string `json:"patn_id"`
  4679. RxID string `json:"rx_id"`
  4680. VolaAmt interface{} `json:"vola_amt"`
  4681. } `json:"judge_result_detail_dtos"`
  4682. RuleID string `json:"rule_id"`
  4683. VolaEvid string `json:"vola_evid"`
  4684. MdtrtID string `json:"mdtrt_id"`
  4685. RuleName string `json:"rule_name"`
  4686. VolaAmtStas string `json:"vola_amt_stas"`
  4687. JrID string `json:"jr_id"`
  4688. PatnID string `json:"patn_id"`
  4689. SevDeg string `json:"sev_deg"`
  4690. VolaAmt float64 `json:"vola_amt"`
  4691. VolaBhvrType string `json:"vola_bhvr_type"`
  4692. VolaCont string `json:"vola_cont"`
  4693. } `json:"result"`
  4694. } `json:"output"`
  4695. }
  4696. type Resultgd3101 struct {
  4697. Infcode int64 `json:"infcode"`
  4698. InfRefmsgid string `json:"inf_refmsgid"`
  4699. RefmsgTime string `json:"refmsg_time"`
  4700. RespondTime string `json:"respond_time"`
  4701. Enctype string `json:"enctype"`
  4702. Signtype string `json:"signtype"`
  4703. ErrMsg string `json:"err_msg"`
  4704. Output struct {
  4705. Result []struct {
  4706. JudgeResultDetailDtos []struct {
  4707. VolaItemType string `json:"vola_item_type"`
  4708. MdtrtID string `json:"mdtrt_id"`
  4709. JrdID string `json:"jrd_id"`
  4710. PatnID string `json:"patn_id"`
  4711. RxID string `json:"rx_id"`
  4712. VolaAmt interface{} `json:"vola_amt"`
  4713. } `json:"judge_result_detail_dtos"`
  4714. RuleID string `json:"rule_id"`
  4715. VolaEvid string `json:"vola_evid"`
  4716. MdtrtID string `json:"mdtrt_id"`
  4717. RuleName string `json:"rule_name"`
  4718. VolaAmtStas string `json:"vola_amt_stas"`
  4719. JrID string `json:"jr_id"`
  4720. PatnID string `json:"patn_id"`
  4721. SevDeg string `json:"sev_deg"`
  4722. VolaAmt float64 `json:"vola_amt"`
  4723. VolaBhvrType string `json:"vola_bhvr_type"`
  4724. VolaCont string `json:"vola_cont"`
  4725. } `json:"result"`
  4726. } `json:"output"`
  4727. }
  4728. func (c *HisApiController) ReadEleToken() {
  4729. admin_user_id, _ := c.GetInt64("admin_user_id")
  4730. his_patient_id, _ := c.GetInt64("his_patient_id")
  4731. adminUser := c.GetAdminUserInfo()
  4732. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4733. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4734. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4735. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4736. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4737. if len(tokens) > 0 {
  4738. c.ServeSuccessJSON(map[string]interface{}{
  4739. "msg": "读取成功",
  4740. })
  4741. } else {
  4742. c.ServeSuccessJSON(map[string]interface{}{
  4743. "failed_code": -10,
  4744. "msg": "读取失败",
  4745. })
  4746. }
  4747. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4748. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4749. if len(tokens) > 0 {
  4750. c.ServeSuccessJSON(map[string]interface{}{
  4751. "msg": "读取成功",
  4752. })
  4753. } else {
  4754. c.ServeSuccessJSON(map[string]interface{}{
  4755. "failed_code": -10,
  4756. "msg": "读取失败",
  4757. })
  4758. }
  4759. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4760. var api string
  4761. 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 +
  4762. "&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"
  4763. resp, requestErr := http.Get(api)
  4764. if requestErr != nil {
  4765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4766. }
  4767. body, ioErr := ioutil.ReadAll(resp.Body)
  4768. if ioErr != nil {
  4769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4771. }
  4772. var respJSON map[string]interface{}
  4773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4776. return
  4777. }
  4778. var status string
  4779. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4780. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4781. var token string
  4782. var res ResultTwo //1101结果
  4783. var res10265 ResultTwo10265 //1101结果
  4784. if status == "0" { //读卡成功
  4785. var card_info string //卡信息
  4786. var busi_card_info string
  4787. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4788. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4789. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4790. fmt.Println(card_info)
  4791. fmt.Println(busi_card_info)
  4792. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4793. result, _ := json.Marshal(respJSON)
  4794. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4795. utils.ErrorLog("解析失败:%v", err)
  4796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4797. return
  4798. }
  4799. res.ErrMsg = res10265.ErrMsg
  4800. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4801. res.Infcode = infocode
  4802. res.Output = res10265.Output
  4803. res.InfRefmsgid = res10265.InfRefmsgid
  4804. if res.Infcode == 0 {
  4805. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4806. if err == gorm.ErrRecordNotFound {
  4807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4808. return
  4809. } else if err != nil {
  4810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4811. return
  4812. } else {
  4813. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4814. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4815. infoStr := string(Iinfos)
  4816. idetinfoStr := string(Idetinfos)
  4817. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4818. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4819. psn := &models.HisPsn{
  4820. PsnNo: res.Output.Baseinfo.PsnNo,
  4821. PatientId: patient.ID,
  4822. Certno: res.Output.Baseinfo.Certno,
  4823. Gend: res.Output.Baseinfo.Gend,
  4824. Naty: res.Output.Baseinfo.Naty,
  4825. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4826. PsnName: res.Output.Baseinfo.PsnName,
  4827. Age: float64(age),
  4828. Brdy: b,
  4829. Idetinfo: idetinfoStr,
  4830. Insuinfo: infoStr,
  4831. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4832. CardInfo: card_info,
  4833. VerifyNumber: token,
  4834. IdCardType: 4,
  4835. }
  4836. var rf []*ResultFive
  4837. json.Unmarshal([]byte(infoStr), &rf)
  4838. var insutypes []*ResultFive
  4839. var insutype string
  4840. var is390 int = 0
  4841. var is310 int = 0
  4842. for _, item := range rf {
  4843. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4844. insutypes = append(insutypes, item)
  4845. }
  4846. }
  4847. if len(insutypes) == 1 {
  4848. insutype = insutypes[0].Insutype
  4849. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4850. } else {
  4851. for _, i := range insutypes {
  4852. if i.Insutype == "390" {
  4853. is390 = 1
  4854. }
  4855. if i.Insutype == "310" {
  4856. is310 = 1
  4857. }
  4858. }
  4859. }
  4860. if is390 == 1 {
  4861. insutype = "390"
  4862. }
  4863. if is310 == 1 {
  4864. insutype = "310"
  4865. }
  4866. if len(insutypes) == 0 {
  4867. insutype = "310"
  4868. }
  4869. service.CreateHisPsn(psn)
  4870. c.ServeSuccessJSON(map[string]interface{}{
  4871. "patient": patient,
  4872. "number": token,
  4873. "insutype": insutype,
  4874. })
  4875. }
  4876. } else {
  4877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4878. return
  4879. }
  4880. } else { //读卡失败
  4881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4882. return
  4883. }
  4884. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4885. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4886. if len(errMsg) == 0 {
  4887. type ELeData struct {
  4888. Data struct {
  4889. IdNo string `json:"idNo"`
  4890. IdType string `json:"idType"`
  4891. UserName string `json:"userName"`
  4892. EcToken string `json:"ecToken"`
  4893. InsuOrg string `json:"insuOrg"`
  4894. Gender string `json:"gender"`
  4895. Birthday string `json:"birthday"`
  4896. Nationality string `json:"nationality"`
  4897. Email string `json:"email"`
  4898. Extra string `json:"extra"`
  4899. } `json:"data"`
  4900. Code int `json:"code"`
  4901. Message string `json:"message"`
  4902. }
  4903. var ele ELeData
  4904. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4905. if err != nil {
  4906. utils.ErrorLog("解析失败:%v", err)
  4907. }
  4908. token := ele.Data.EcToken
  4909. if len(token) > 0 {
  4910. psn := &models.HisPsn{
  4911. PsnNo: his.PsnNo,
  4912. Age: 0,
  4913. PatientId: his.PatientId,
  4914. Certno: his.Certno,
  4915. Brdy: his.Brdy,
  4916. Gend: his.Gend,
  4917. Naty: his.Naty,
  4918. PsnCertType: his.PsnCertType,
  4919. PsnName: his.PsnName,
  4920. Idetinfo: his.Idetinfo,
  4921. Insuinfo: his.Iinfo,
  4922. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4923. CardInfo: outPutInfo,
  4924. VerifyNumber: token,
  4925. }
  4926. service.CreateHisPsn(psn)
  4927. }
  4928. if len(token) > 0 {
  4929. c.ServeSuccessJSON(map[string]interface{}{
  4930. "msg": "读取成功",
  4931. })
  4932. } else {
  4933. c.ServeSuccessJSON(map[string]interface{}{
  4934. "failed_code": -10,
  4935. "msg": "读取失败",
  4936. })
  4937. }
  4938. }
  4939. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4940. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4941. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4942. type ELeData struct {
  4943. Data struct {
  4944. IdNo string `json:"idNo"`
  4945. IdType string `json:"idType"`
  4946. UserName string `json:"userName"`
  4947. EcToken string `json:"ecToken"`
  4948. InsuOrg string `json:"insuOrg"`
  4949. Gender string `json:"gender"`
  4950. Birthday string `json:"birthday"`
  4951. Nationality string `json:"nationality"`
  4952. Email string `json:"email"`
  4953. Extra string `json:"extra"`
  4954. } `json:"data"`
  4955. Code int `json:"code"`
  4956. Message string `json:"message"`
  4957. }
  4958. var ele ELeData
  4959. err := json.Unmarshal([]byte(result), &ele)
  4960. if err != nil {
  4961. utils.ErrorLog("解析失败:%v", err)
  4962. }
  4963. token := ele.Data.EcToken
  4964. token = Remove0000(token)
  4965. fmt.Println(ele.Data.UserName)
  4966. 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)
  4967. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4968. var res ResultTwo
  4969. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4970. utils.ErrorLog("解析失败:%v", err)
  4971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4972. return
  4973. }
  4974. if res.Infcode == 0 {
  4975. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4976. if err == gorm.ErrRecordNotFound {
  4977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4978. return
  4979. } else if err != nil {
  4980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4981. return
  4982. } else {
  4983. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4984. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4985. infoStr := string(Iinfos)
  4986. idetinfoStr := string(Idetinfos)
  4987. psn := &models.HisPsn{
  4988. PsnNo: res.Output.Baseinfo.PsnNo,
  4989. PatientId: patient.ID,
  4990. Certno: res.Output.Baseinfo.Certno,
  4991. Gend: res.Output.Baseinfo.Gend,
  4992. Naty: res.Output.Baseinfo.Naty,
  4993. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4994. PsnName: res.Output.Baseinfo.PsnName,
  4995. Idetinfo: idetinfoStr,
  4996. Insuinfo: infoStr,
  4997. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4998. CardInfo: "",
  4999. VerifyNumber: token,
  5000. }
  5001. service.CreateHisPsn(psn)
  5002. c.ServeSuccessJSON(map[string]interface{}{
  5003. "patient": patient,
  5004. "number": token,
  5005. })
  5006. }
  5007. } else {
  5008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5009. return
  5010. }
  5011. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5012. idNo := c.GetString("idNo")
  5013. userName := c.GetString("userName")
  5014. ecToken := c.GetString("ecToken")
  5015. insuOrg := c.GetString("insuOrg")
  5016. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  5017. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5018. var res ResultTwo
  5019. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5020. utils.ErrorLog("解析失败:%v", err)
  5021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5022. return
  5023. }
  5024. if res.Infcode == 0 {
  5025. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5026. if err == gorm.ErrRecordNotFound {
  5027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5028. return
  5029. } else if err != nil {
  5030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5031. return
  5032. } else {
  5033. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5034. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5035. infoStr := string(Iinfos)
  5036. idetinfoStr := string(Idetinfos)
  5037. psn := &models.HisPsn{
  5038. PsnNo: res.Output.Baseinfo.PsnNo,
  5039. PatientId: patient.ID,
  5040. Certno: res.Output.Baseinfo.Certno,
  5041. Gend: res.Output.Baseinfo.Gend,
  5042. Naty: res.Output.Baseinfo.Naty,
  5043. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5044. PsnName: res.Output.Baseinfo.PsnName,
  5045. Idetinfo: idetinfoStr,
  5046. Insuinfo: infoStr,
  5047. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5048. CardInfo: "",
  5049. VerifyNumber: ecToken,
  5050. InsuplcAdmdvs: insuOrg,
  5051. }
  5052. service.CreateHisPsn(psn)
  5053. c.ServeSuccessJSON(map[string]interface{}{
  5054. "patient": patient,
  5055. "number": ecToken,
  5056. })
  5057. }
  5058. } else {
  5059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5060. return
  5061. }
  5062. } else if miConfig.MdtrtareaAdmvs == "450721" {
  5063. res := c.GetoleInfo()
  5064. if res.Infcode == 0 {
  5065. var result string
  5066. if res.Output.MdtrtCertType == "01" {
  5067. 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)
  5068. } else if res.Output.MdtrtCertType == "02" {
  5069. 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)
  5070. } else if res.Output.MdtrtCertType == "03" {
  5071. 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)
  5072. }
  5073. var dat map[string]interface{}
  5074. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5075. fmt.Println(dat)
  5076. } else {
  5077. fmt.Println(err)
  5078. }
  5079. userJSONBytes, _ := json.Marshal(dat)
  5080. var res2 ResultTwo
  5081. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5082. utils.ErrorLog("解析失败:%v", err)
  5083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5084. return
  5085. }
  5086. if res2.Infcode == 0 {
  5087. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  5088. if err == gorm.ErrRecordNotFound {
  5089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5090. return
  5091. } else if err != nil {
  5092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5093. return
  5094. } else {
  5095. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  5096. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  5097. infoStr := string(Iinfos)
  5098. idetinfoStr := string(Idetinfos)
  5099. var rf []*ResultFive
  5100. json.Unmarshal([]byte(infoStr), &rf)
  5101. var insutypes []*ResultFive
  5102. var insutype string
  5103. var is390 int = 0
  5104. var is310 int = 0
  5105. //var insuplc_admdvs string
  5106. for _, item := range rf {
  5107. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5108. insutypes = append(insutypes, item)
  5109. }
  5110. }
  5111. if len(insutypes) == 1 {
  5112. insutype = insutypes[0].Insutype
  5113. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5114. } else {
  5115. for _, i := range insutypes {
  5116. if i.Insutype == "390" {
  5117. is390 = 1
  5118. }
  5119. if i.Insutype == "310" {
  5120. is310 = 1
  5121. }
  5122. }
  5123. }
  5124. if is390 == 1 {
  5125. insutype = "390"
  5126. }
  5127. if is310 == 1 {
  5128. insutype = "310"
  5129. }
  5130. if len(insutypes) == 0 {
  5131. insutype = "310"
  5132. }
  5133. psn := &models.HisPsn{
  5134. PsnNo: res2.Output.Baseinfo.PsnNo,
  5135. PatientId: patient.ID,
  5136. Certno: res2.Output.Baseinfo.Certno,
  5137. Gend: res2.Output.Baseinfo.Gend,
  5138. Naty: res2.Output.Baseinfo.Naty,
  5139. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  5140. PsnName: res2.Output.Baseinfo.PsnName,
  5141. Idetinfo: idetinfoStr,
  5142. Insuinfo: infoStr,
  5143. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5144. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  5145. VerifyNumber: res.Output.EcToken,
  5146. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  5147. }
  5148. service.CreateHisPsn(psn)
  5149. c.ServeSuccessJSON(map[string]interface{}{
  5150. "patient": patient,
  5151. "number": res.Output.CardNo,
  5152. "insutype": insutype,
  5153. })
  5154. }
  5155. } else {
  5156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5157. return
  5158. }
  5159. } else {
  5160. c.ServeSuccessJSON(map[string]interface{}{
  5161. "failed_code": -10,
  5162. "msg": res.ErrMsg,
  5163. })
  5164. }
  5165. } else {
  5166. //if initFlag == 0 {
  5167. // c.TestGetBasBaseInit()
  5168. //}
  5169. //token := c.GetEleBaseInfo()
  5170. //token = Remove0000(token)
  5171. type ELeData struct {
  5172. Code string `json:"code"`
  5173. Data struct {
  5174. Aac002 string `json:"aac002"`
  5175. Aaz500 string `json:"aaz500"`
  5176. ActCardNo string `json:"actCardNo"`
  5177. Bab520 string `json:"bab520"`
  5178. Bkz543 string `json:"bkz543"`
  5179. BusinessType string `json:"businessType"`
  5180. CertfCodg string `json:"certfCodg"`
  5181. EcIndexNo string `json:"ecIndexNo"`
  5182. EcToken string `json:"ecToken"`
  5183. ID0000 string `json:"id0000"`
  5184. IDNo string `json:"idNo"`
  5185. IDType string `json:"idType"`
  5186. Idcode string `json:"idcode"`
  5187. IdentityToken string `json:"identity_token"`
  5188. InsuOrg string `json:"insuOrg"`
  5189. OfficeID string `json:"officeId"`
  5190. OfficeName string `json:"officeName"`
  5191. OperatorID string `json:"operatorId"`
  5192. OperatorName string `json:"operatorName"`
  5193. OrgID string `json:"orgId"`
  5194. UserName string `json:"userName"`
  5195. } `json:"data"`
  5196. Infno interface{} `json:"infno"`
  5197. Message string `json:"message"`
  5198. OrgID string `json:"orgId"`
  5199. TransType string `json:"transType"`
  5200. }
  5201. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  5202. fmt.Println(result)
  5203. outPutInfo := Remove0000(result)
  5204. fmt.Println(outPutInfo)
  5205. var ele ELeData
  5206. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5207. if err != nil {
  5208. utils.ErrorLog("解析失败:%v", err)
  5209. }
  5210. token := ele.Data.EcToken
  5211. var result2 string
  5212. var requestLog2 string
  5213. if len(token) > 0 {
  5214. if strings.Contains(ele.Data.IDNo, "HKG") {
  5215. 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)
  5216. } else {
  5217. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5218. }
  5219. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5220. var res ResultTwo
  5221. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5222. utils.ErrorLog("解析失败:%v", err)
  5223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5224. return
  5225. }
  5226. if res.Infcode == 0 {
  5227. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5228. if err == gorm.ErrRecordNotFound {
  5229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5230. return
  5231. } else if err != nil {
  5232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5233. return
  5234. } else {
  5235. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5236. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5237. infoStr := string(Iinfos)
  5238. idetinfoStr := string(Idetinfos)
  5239. psn := &models.HisPsn{
  5240. PsnNo: res.Output.Baseinfo.PsnNo,
  5241. PatientId: patient.ID,
  5242. Certno: res.Output.Baseinfo.Certno,
  5243. Gend: res.Output.Baseinfo.Gend,
  5244. Naty: res.Output.Baseinfo.Naty,
  5245. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5246. PsnName: res.Output.Baseinfo.PsnName,
  5247. Idetinfo: idetinfoStr,
  5248. Insuinfo: infoStr,
  5249. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5250. CardInfo: "",
  5251. VerifyNumber: token,
  5252. }
  5253. service.CreateHisPsn(psn)
  5254. c.ServeSuccessJSON(map[string]interface{}{
  5255. "msg": "读取成功",
  5256. })
  5257. }
  5258. } else {
  5259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5260. return
  5261. }
  5262. } else {
  5263. c.ServeSuccessJSON(map[string]interface{}{
  5264. "failed_code": -10,
  5265. "msg": "读取失败",
  5266. })
  5267. }
  5268. }
  5269. }
  5270. func (c *HisApiController) ReadEleFace() {
  5271. admin_user_id, _ := c.GetInt64("admin_user_id")
  5272. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5273. adminUser := c.GetAdminUserInfo()
  5274. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5275. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5276. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5277. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5278. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  5279. if len(tokens) > 0 {
  5280. c.ServeSuccessJSON(map[string]interface{}{
  5281. "msg": "读取成功",
  5282. })
  5283. } else {
  5284. c.ServeSuccessJSON(map[string]interface{}{
  5285. "failed_code": -10,
  5286. "msg": "读取失败",
  5287. })
  5288. }
  5289. }
  5290. }
  5291. func (c *HisApiController) Get9001() {
  5292. adminUser := c.GetAdminUserInfo()
  5293. admin_user_id, _ := c.GetInt64("admin_user_id")
  5294. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5295. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5296. if miConfig.MdtrtareaAdmvs == "350500" {
  5297. service.GetFjAuthorizationInfo(miConfig.Code)
  5298. } else if miConfig.MdtrtareaAdmvs == "131023" {
  5299. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  5300. var dat map[string]interface{}
  5301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5302. fmt.Println(dat)
  5303. } else {
  5304. fmt.Println(err)
  5305. }
  5306. userJSONBytes, _ := json.Marshal(dat)
  5307. var res models.Result9001
  5308. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5309. utils.ErrorLog("解析失败:%v", err)
  5310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5311. return
  5312. }
  5313. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5314. fmt.Println(miConfig.SecretKey)
  5315. var res models.Result9001Two
  5316. 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 +
  5317. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  5318. resp, requestErr := http.Get(api)
  5319. if requestErr != nil {
  5320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5321. return
  5322. }
  5323. body, ioErr := ioutil.ReadAll(resp.Body)
  5324. if ioErr != nil {
  5325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5327. return
  5328. }
  5329. var respJSON map[string]interface{}
  5330. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5333. return
  5334. }
  5335. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5336. if status == "0" {
  5337. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5338. c.ServeSuccessJSON(map[string]interface{}{
  5339. "failed_code": -10,
  5340. "msg": err_msg,
  5341. })
  5342. return
  5343. }
  5344. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5345. result, _ := json.Marshal(respJSON)
  5346. fmt.Println("log")
  5347. fmt.Println(string(result))
  5348. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5349. utils.ErrorLog("解析失败:%v", err)
  5350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5351. return
  5352. }
  5353. if res.Infcode == 0 {
  5354. sign := models.HisSignIn{
  5355. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5356. SignNo: res.Output.Signinoutb.SignNo,
  5357. SignTime: "",
  5358. Ctime: time.Now().Unix(),
  5359. Mtime: time.Now().Unix(),
  5360. Status: 1,
  5361. InputLog: "",
  5362. OutputLog: "",
  5363. FixmedinsCode: miConfig.Code,
  5364. }
  5365. err := service.CreateSignIn(&sign)
  5366. if err == nil {
  5367. c.ServeSuccessJSON(map[string]interface{}{
  5368. "msg": "签到成功",
  5369. })
  5370. }
  5371. } else {
  5372. c.ServeSuccessJSON(map[string]interface{}{
  5373. "failed_code": -10,
  5374. "msg": res.ErrMsg,
  5375. })
  5376. return
  5377. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5378. //return
  5379. }
  5380. } else {
  5381. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5382. var dat map[string]interface{}
  5383. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5384. fmt.Println(dat)
  5385. } else {
  5386. fmt.Println(err)
  5387. }
  5388. userJSONBytes, _ := json.Marshal(dat)
  5389. var res models.Result9001
  5390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5391. utils.ErrorLog("解析失败:%v", err)
  5392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5393. return
  5394. }
  5395. if res.Infcode == 0 {
  5396. sign := models.HisSignIn{
  5397. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5398. SignNo: res.Output.Signinoutb.SignNo,
  5399. SignTime: res.Output.Signinoutb.SignTime,
  5400. Ctime: time.Now().Unix(),
  5401. Mtime: time.Now().Unix(),
  5402. Status: 1,
  5403. InputLog: "",
  5404. OutputLog: "",
  5405. FixmedinsCode: miConfig.Code,
  5406. }
  5407. err := service.CreateSignIn(&sign)
  5408. if err == nil {
  5409. c.ServeSuccessJSON(map[string]interface{}{
  5410. "msg": "签到成功",
  5411. })
  5412. }
  5413. }
  5414. }
  5415. }
  5416. 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) {
  5417. var res Result3101
  5418. adminUser := c.GetAdminUserInfo()
  5419. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5420. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5421. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5422. //record_time := c.GetString("record_time")
  5423. //trig_scen := c.GetString("trig_scen")
  5424. timeLayout := "2006-01-02"
  5425. loc, _ := time.LoadLocation("Local")
  5426. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5427. if err != nil {
  5428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5429. return res
  5430. }
  5431. recordDateTime := theTime.Unix()
  5432. var patientPrescription models.HisPrescriptionInfo
  5433. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5434. //if patientPrescription.ID == 0 {
  5435. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5436. //}
  5437. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5438. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5439. //
  5440. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5441. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5442. var pp models.PublicParams
  5443. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5444. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5445. pp.FixmedinsName = miConfig.OrgName
  5446. pp.FixmedinsCode = miConfig.Code
  5447. pp.RequestUrl = miConfig.Url
  5448. pp.Cainfo = miConfig.Cainfo
  5449. pp.SecretKey = miConfig.SecretKey
  5450. pp.AccessKey = miConfig.AccessKey
  5451. pp.OpterName = roles.UserName
  5452. var config []*models.HisXtDiagnoseConfig
  5453. for _, item := range diagnosis_ids {
  5454. id, _ := strconv.ParseInt(item, 10, 64)
  5455. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5456. config = append(config, &diagnosisConfig)
  5457. }
  5458. var pd models.PatientDtos
  5459. pd.PatnID = his.PsnNo
  5460. pd.PatnName = his.Name
  5461. pd.Gend = his.Gend
  5462. pd.Brdy = his.Brdy
  5463. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5464. pd.CurrMdtrtID = his.Number
  5465. var fed models.FsiEncounterDtos
  5466. fed.MdtrtID = his.Number
  5467. fed.MedinsID = miConfig.Code
  5468. fed.MedinsName = miConfig.OrgName
  5469. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5470. fed.MedMdtrtType = "1"
  5471. fed.MedinsType = "1"
  5472. fed.MedinsLv = "11"
  5473. tm := time.Unix(his.RecordDate, 0)
  5474. s_tm := tm.Format("2006-01-02 15:04:05")
  5475. fed.AdmDate = s_tm
  5476. fed.DscgDate = s_tm
  5477. fed.DscgMainDiseCodg = config[0].CountryCode
  5478. fed.DscgMainDiseName = config[0].CountryContentName
  5479. //诊断信息
  5480. var fdds []*models.FsiDiagnoseDtos
  5481. for index, item := range config {
  5482. if index == 0 {
  5483. var fdd models.FsiDiagnoseDtos
  5484. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5485. fdd.InoutDiseType = "1"
  5486. fdd.MaindiseFlag = "1"
  5487. fdd.DiseDate = s_tm
  5488. fdd.DiasSrtNo = "1"
  5489. fdd.DiseName = item.CountryContentName
  5490. fdd.DiseCodg = item.CountryCode
  5491. fdds = append(fdds, &fdd)
  5492. } else {
  5493. var fdd models.FsiDiagnoseDtos
  5494. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5495. fdd.InoutDiseType = "1"
  5496. fdd.MaindiseFlag = "1"
  5497. fdd.DiseDate = s_tm
  5498. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5499. fdd.DiseName = item.CountryContentName
  5500. fdd.DiseCodg = item.CountryCode
  5501. fdds = append(fdds, &fdd)
  5502. }
  5503. }
  5504. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5505. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5506. fed.AdmDeptName = department.Name
  5507. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5508. fed.DscgDeptName = department.Name
  5509. fed.MedMdtrtType = "1"
  5510. fed.MedType = "11"
  5511. //if his.Insutype == "390" {
  5512. // fed.MedType = "1402"
  5513. //} else {
  5514. // fed.MedType = "9933"
  5515. //}
  5516. var orders []*models.FsiOrderDtos
  5517. if trig_scen == "2" {
  5518. //处方医嘱信息
  5519. for _, item := range prescriptions {
  5520. for _, subItem := range item.HisDoctorAdviceInfo {
  5521. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5522. var order models.FsiOrderDtos
  5523. order.RxID = strconv.FormatInt(item.ID, 10)
  5524. order.Rxno = strconv.FormatInt(item.ID, 10)
  5525. order.LongDrordFlag = "0"
  5526. order.HilistType = "1"
  5527. order.ChrgType = "1"
  5528. order.DrordBhvr = "-"
  5529. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5530. order.HosplistName = subItem.BaseDrugLib.DrugName
  5531. order.HilistLv = "1"
  5532. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5533. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5534. order.HosplistName = subItem.BaseDrugLib.DrugName
  5535. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5536. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5537. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5538. order.OwnpayAmt = ""
  5539. order.SelfpayAmt = ""
  5540. order.Spec = ""
  5541. order.SpecUnt = ""
  5542. order.DrordBegnDate = s_tm
  5543. order.DrordStopDate = ""
  5544. order.DrordDrCodg = doctor_info.DoctorNumber
  5545. order.DrordDeptName = department.Name
  5546. order.DrordDeptCodg = department.Number
  5547. order.DrordDrName = doctor_info.UserName
  5548. order.DrordDrProfttl = "234"
  5549. order.CurrDrordFlag = "1"
  5550. orders = append(orders, &order)
  5551. }
  5552. }
  5553. for _, subItem := range item.HisPrescriptionProject {
  5554. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5555. var order models.FsiOrderDtos
  5556. order.RxID = strconv.FormatInt(item.ID, 10)
  5557. order.Rxno = strconv.FormatInt(item.ID, 10)
  5558. order.LongDrordFlag = "0"
  5559. order.HilistType = "1"
  5560. order.ChrgType = "1"
  5561. order.DrordBhvr = "-"
  5562. order.HilistCode = subItem.HisProject.MedicalCode
  5563. order.HosplistName = subItem.HisProject.ProjectName
  5564. order.HilistLv = "1"
  5565. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5566. order.HosplistCode = subItem.HisProject.MedicalCode
  5567. order.HosplistName = subItem.HisProject.ProjectName
  5568. order.Cnt = subItem.Count
  5569. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5570. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5571. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5572. order.OwnpayAmt = ""
  5573. order.SelfpayAmt = ""
  5574. order.Spec = ""
  5575. order.SpecUnt = ""
  5576. order.DrordBegnDate = s_tm
  5577. order.DrordStopDate = ""
  5578. order.DrordDrCodg = doctor_info.DoctorNumber
  5579. order.DrordDeptName = department.Name
  5580. order.DrordDeptCodg = department.Number
  5581. order.DrordDrName = doctor_info.UserName
  5582. order.DrordDrProfttl = "234"
  5583. order.CurrDrordFlag = "1"
  5584. orders = append(orders, &order)
  5585. }
  5586. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5587. var order models.FsiOrderDtos
  5588. order.RxID = strconv.FormatInt(item.ID, 10)
  5589. order.Rxno = strconv.FormatInt(item.ID, 10)
  5590. order.LongDrordFlag = "0"
  5591. order.HilistType = "1"
  5592. order.ChrgType = "1"
  5593. order.DrordBhvr = "-"
  5594. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5595. order.HosplistName = subItem.GoodInfo.GoodName
  5596. order.HilistLv = "1"
  5597. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5598. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5599. order.HosplistName = subItem.GoodInfo.GoodName
  5600. order.Cnt = subItem.Count
  5601. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5602. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5603. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5604. order.OwnpayAmt = ""
  5605. order.SelfpayAmt = ""
  5606. order.Spec = ""
  5607. order.SpecUnt = ""
  5608. order.DrordBegnDate = s_tm
  5609. order.DrordStopDate = ""
  5610. order.DrordDrCodg = doctor_info.DoctorNumber
  5611. order.DrordDeptName = department.Name
  5612. order.DrordDeptCodg = department.Number
  5613. order.DrordDrName = doctor_info.UserName
  5614. order.DrordDrProfttl = "234"
  5615. order.CurrDrordFlag = "1"
  5616. orders = append(orders, &order)
  5617. }
  5618. }
  5619. }
  5620. //处方医嘱信息
  5621. }
  5622. fed.MatnStas = "0"
  5623. fed.MedfeeSumamt = "0"
  5624. fed.OwnpayAmt = "0"
  5625. fed.SelfpayAmt = "0"
  5626. fed.AcctPayamt = "0"
  5627. fed.MaAmt = "0"
  5628. fed.HifpPayamt = "0"
  5629. fed.SetlTotlnum = "1"
  5630. fed.Insutype = his.Insutype
  5631. fed.ReimFlag = "0"
  5632. fed.OutSetlFlag = "0"
  5633. var fopd []*models.FsiOperationDtosData
  5634. data := make(map[string]interface{})
  5635. data["fed"] = fed
  5636. data["fdd"] = fdds
  5637. data["fod"] = orders
  5638. data["pd"] = pd
  5639. data["pp"] = pp
  5640. data["fopd"] = fopd
  5641. data["trig_scen"] = trig_scen
  5642. fmt.Println(data)
  5643. fmt.Println(fed)
  5644. fmt.Println(fdds)
  5645. fmt.Println(orders)
  5646. fmt.Println(pd)
  5647. fmt.Println(pp)
  5648. fmt.Println(fopd)
  5649. client := &http.Client{}
  5650. bytesData, _ := json.Marshal(data)
  5651. var req *http.Request
  5652. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5653. if miConfig.MdtrtareaAdmvs == "320921" {
  5654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5655. } else {
  5656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5657. }
  5658. resp, _ := client.Do(req)
  5659. defer resp.Body.Close()
  5660. body, ioErr := ioutil.ReadAll(resp.Body)
  5661. if ioErr != nil {
  5662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5664. return res
  5665. }
  5666. var respJSON map[string]interface{}
  5667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5670. return res
  5671. }
  5672. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5673. fmt.Println(respJSON)
  5674. result, _ := json.Marshal(respJSON)
  5675. fmt.Println(result)
  5676. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5677. utils.ErrorLog("解析失败:%v", err)
  5678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5679. return res
  5680. }
  5681. return res
  5682. } else {
  5683. //if miConfig.MdtrtareaAdmvs == "441202" {
  5684. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5685. saveLog(output, input, "3101", "事前")
  5686. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5687. utils.ErrorLog("解析失败:%v", err)
  5688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5689. return
  5690. }
  5691. return res
  5692. //}
  5693. }
  5694. }
  5695. 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) {
  5696. adminUser := c.GetAdminUserInfo()
  5697. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5698. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5699. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5700. //record_time := c.GetString("record_time")
  5701. //trig_scen := c.GetString("trig_scen")
  5702. timeLayout := "2006-01-02"
  5703. loc, _ := time.LoadLocation("Local")
  5704. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5705. if err != nil {
  5706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5707. return res
  5708. }
  5709. recordDateTime := theTime.Unix()
  5710. var patientPrescription models.HisPrescriptionInfo
  5711. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5712. if patientPrescription.ID == 0 {
  5713. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5714. }
  5715. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5716. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5717. //
  5718. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5719. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5720. var pp models.PublicParams
  5721. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5722. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5723. pp.FixmedinsName = miConfig.OrgName
  5724. pp.FixmedinsCode = miConfig.Code
  5725. pp.RequestUrl = miConfig.Url
  5726. pp.Cainfo = miConfig.Cainfo
  5727. pp.SecretKey = miConfig.SecretKey
  5728. pp.AccessKey = miConfig.AccessKey
  5729. pp.OpterName = roles.UserName
  5730. var config []*models.HisXtDiagnoseConfig
  5731. for _, item := range diagnosis_ids {
  5732. id, _ := strconv.ParseInt(item, 10, 64)
  5733. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5734. config = append(config, &diagnosisConfig)
  5735. }
  5736. var pd models.PatientDtos
  5737. pd.PatnID = his.PsnNo
  5738. pd.PatnName = his.Name
  5739. pd.Gend = his.Gend
  5740. pd.Brdy = his.Brdy
  5741. pd.Poolarea = his.InsuplcAdmdvs
  5742. pd.CurrMdtrtID = his.Number
  5743. var fed models.FsiEncounterDtos
  5744. fed.MdtrtID = his.Number
  5745. fed.MedinsID = miConfig.Code
  5746. fed.MedinsName = miConfig.OrgName
  5747. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5748. fed.MedMdtrtType = "1"
  5749. fed.MedinsType = "1"
  5750. fed.MedinsLv = "11"
  5751. tm := time.Unix(his.RecordDate, 0)
  5752. s_tm := tm.Format("2006-01-02 15:04:05")
  5753. fed.AdmDate = s_tm
  5754. fed.DscgDate = s_tm
  5755. fed.DscgMainDiseCodg = config[0].CountryCode
  5756. fed.DscgMainDiseName = config[0].CountryContentName
  5757. //诊断信息
  5758. var fdds []*models.FsiDiagnoseDtos
  5759. for index, item := range config {
  5760. if index == 0 {
  5761. var fdd models.FsiDiagnoseDtos
  5762. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5763. fdd.InoutDiseType = "1"
  5764. fdd.MaindiseFlag = "1"
  5765. fdd.DiseDate = s_tm
  5766. fdd.DiasSrtNo = "1"
  5767. fdd.DiseName = item.CountryContentName
  5768. fdd.DiseCodg = item.CountryCode
  5769. fdds = append(fdds, &fdd)
  5770. } else {
  5771. var fdd models.FsiDiagnoseDtos
  5772. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5773. fdd.InoutDiseType = "1"
  5774. fdd.MaindiseFlag = "1"
  5775. fdd.DiseDate = s_tm
  5776. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5777. fdd.DiseName = item.CountryContentName
  5778. fdd.DiseCodg = item.CountryCode
  5779. fdds = append(fdds, &fdd)
  5780. }
  5781. }
  5782. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5783. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5784. fed.AdmDeptName = department.Name
  5785. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5786. fed.DscgDeptName = department.Name
  5787. fed.MedMdtrtType = "1"
  5788. fed.MedType = "11"
  5789. //if his.Insutype == "390" {
  5790. // fed.MedType = "1402"
  5791. //} else {
  5792. // fed.MedType = "9933"
  5793. //}
  5794. var orders []*models.FsiOrderDtos
  5795. if trig_scen == "2" {
  5796. //处方医嘱信息
  5797. for _, item := range prescriptions {
  5798. for _, subItem := range item.HisDoctorAdviceInfo {
  5799. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5800. var order models.FsiOrderDtos
  5801. order.RxID = strconv.FormatInt(item.ID, 10)
  5802. order.Rxno = strconv.FormatInt(item.ID, 10)
  5803. order.LongDrordFlag = "0"
  5804. order.HilistType = "1"
  5805. order.ChrgType = "1"
  5806. order.DrordBhvr = "-"
  5807. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5808. order.HosplistName = subItem.BaseDrugLib.DrugName
  5809. order.HilistLv = "1"
  5810. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5811. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5812. order.HosplistName = subItem.BaseDrugLib.DrugName
  5813. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5814. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5815. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5816. order.OwnpayAmt = ""
  5817. order.SelfpayAmt = ""
  5818. order.Spec = ""
  5819. order.SpecUnt = ""
  5820. order.DrordBegnDate = s_tm
  5821. order.DrordStopDate = ""
  5822. order.DrordDrCodg = doctor_info.DoctorNumber
  5823. order.DrordDeptName = department.Name
  5824. order.DrordDeptCodg = department.Number
  5825. order.DrordDrName = doctor_info.UserName
  5826. order.DrordDrProfttl = "234"
  5827. order.CurrDrordFlag = "1"
  5828. orders = append(orders, &order)
  5829. }
  5830. }
  5831. for _, subItem := range item.HisPrescriptionProject {
  5832. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5833. var order models.FsiOrderDtos
  5834. order.RxID = strconv.FormatInt(item.ID, 10)
  5835. order.Rxno = strconv.FormatInt(item.ID, 10)
  5836. order.LongDrordFlag = "0"
  5837. order.HilistType = "1"
  5838. order.ChrgType = "1"
  5839. order.DrordBhvr = "-"
  5840. order.HilistCode = subItem.HisProject.MedicalCode
  5841. order.HosplistName = subItem.HisProject.ProjectName
  5842. order.HilistLv = "1"
  5843. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5844. order.HosplistCode = subItem.HisProject.MedicalCode
  5845. order.HosplistName = subItem.HisProject.ProjectName
  5846. order.Cnt = subItem.Count
  5847. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5848. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5849. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5850. order.OwnpayAmt = ""
  5851. order.SelfpayAmt = ""
  5852. order.Spec = ""
  5853. order.SpecUnt = ""
  5854. order.DrordBegnDate = s_tm
  5855. order.DrordStopDate = ""
  5856. order.DrordDrCodg = doctor_info.DoctorNumber
  5857. order.DrordDeptName = department.Name
  5858. order.DrordDeptCodg = department.Number
  5859. order.DrordDrName = doctor_info.UserName
  5860. order.DrordDrProfttl = "234"
  5861. order.CurrDrordFlag = "1"
  5862. orders = append(orders, &order)
  5863. }
  5864. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5865. var order models.FsiOrderDtos
  5866. order.RxID = strconv.FormatInt(item.ID, 10)
  5867. order.Rxno = strconv.FormatInt(item.ID, 10)
  5868. order.LongDrordFlag = "0"
  5869. order.HilistType = "1"
  5870. order.ChrgType = "1"
  5871. order.DrordBhvr = "-"
  5872. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5873. order.HosplistName = subItem.GoodInfo.GoodName
  5874. order.HilistLv = "1"
  5875. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5876. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5877. order.HosplistName = subItem.GoodInfo.GoodName
  5878. order.Cnt = subItem.Count
  5879. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5880. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5881. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5882. order.OwnpayAmt = ""
  5883. order.SelfpayAmt = ""
  5884. order.Spec = ""
  5885. order.SpecUnt = ""
  5886. order.DrordBegnDate = s_tm
  5887. order.DrordStopDate = ""
  5888. order.DrordDrCodg = doctor_info.DoctorNumber
  5889. order.DrordDeptName = department.Name
  5890. order.DrordDeptCodg = department.Number
  5891. order.DrordDrName = doctor_info.UserName
  5892. order.DrordDrProfttl = "234"
  5893. order.CurrDrordFlag = "1"
  5894. orders = append(orders, &order)
  5895. }
  5896. }
  5897. }
  5898. //处方医嘱信息
  5899. }
  5900. fed.MatnStas = "0"
  5901. fed.MedfeeSumamt = "0"
  5902. fed.OwnpayAmt = "0"
  5903. fed.SelfpayAmt = "0"
  5904. fed.AcctPayamt = "0"
  5905. fed.MaAmt = "0"
  5906. fed.HifpPayamt = "0"
  5907. fed.SetlTotlnum = "1"
  5908. fed.Insutype = his.Insutype
  5909. fed.ReimFlag = "0"
  5910. fed.OutSetlFlag = "0"
  5911. var fopd []*models.FsiOperationDtosData
  5912. data := make(map[string]interface{})
  5913. data["fed"] = fed
  5914. data["fdd"] = fdds
  5915. data["fod"] = orders
  5916. data["pd"] = pd
  5917. data["pp"] = pp
  5918. data["fopd"] = fopd
  5919. data["trig_scen"] = trig_scen
  5920. fmt.Println(data)
  5921. fmt.Println(fed)
  5922. fmt.Println(fdds)
  5923. fmt.Println(orders)
  5924. fmt.Println(pd)
  5925. fmt.Println(pp)
  5926. fmt.Println(fopd)
  5927. client := &http.Client{}
  5928. bytesData, _ := json.Marshal(data)
  5929. var req *http.Request
  5930. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5931. if miConfig.MdtrtareaAdmvs == "320921" {
  5932. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5933. } else {
  5934. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5935. }
  5936. resp, _ := client.Do(req)
  5937. defer resp.Body.Close()
  5938. body, ioErr := ioutil.ReadAll(resp.Body)
  5939. if ioErr != nil {
  5940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5942. return res
  5943. }
  5944. var respJSON map[string]interface{}
  5945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5948. return res
  5949. }
  5950. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5951. fmt.Println(respJSON)
  5952. result, _ := json.Marshal(respJSON)
  5953. fmt.Println(result)
  5954. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5955. utils.ErrorLog("解析失败:%v", err)
  5956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5957. return res
  5958. }
  5959. return res
  5960. } else {
  5961. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5962. saveLog(output, input, "3101", "事前")
  5963. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5964. utils.ErrorLog("解析失败:%v", err)
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5966. return
  5967. }
  5968. return res
  5969. }
  5970. return res
  5971. }
  5972. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5973. ////patient_id, _ := c.GetInt64("patient_id")
  5974. //order_id, _ := c.GetInt64("order_id")
  5975. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5976. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5977. //trig_scen := c.GetString("trig_scen")
  5978. adminUser := c.GetAdminUserInfo()
  5979. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5980. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5981. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5982. record_time := c.GetString("record_time")
  5983. order, _ := service.GetHisOrderByID(order_id)
  5984. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5985. timeLayout := "2006-01-02"
  5986. loc, _ := time.LoadLocation("Local")
  5987. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5988. if err != nil {
  5989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5990. return
  5991. }
  5992. recordDateTime := theTime.Unix()
  5993. var patientPrescription models.HisPrescriptionInfo
  5994. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5995. if patientPrescription.ID == 0 {
  5996. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5997. }
  5998. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5999. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6000. //
  6001. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6002. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6003. var pp models.PublicParams
  6004. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6005. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6006. pp.FixmedinsName = miConfig.OrgName
  6007. pp.FixmedinsCode = miConfig.Code
  6008. pp.RequestUrl = miConfig.Url
  6009. pp.Cainfo = miConfig.Cainfo
  6010. pp.SecretKey = miConfig.SecretKey
  6011. pp.AccessKey = miConfig.AccessKey
  6012. pp.OpterName = roles.UserName
  6013. var config []*models.HisXtDiagnoseConfig
  6014. for _, item := range diagnosis_ids {
  6015. id, _ := strconv.ParseInt(item, 10, 64)
  6016. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6017. config = append(config, &diagnosisConfig)
  6018. }
  6019. var pd models.PatientDtos
  6020. pd.PatnID = his.PsnNo
  6021. pd.PatnName = his.Name
  6022. pd.Gend = his.Gend
  6023. pd.Brdy = psn_info.Brdy
  6024. pd.Poolarea = his.InsuplcAdmdvs
  6025. pd.CurrMdtrtID = his.Number
  6026. var fed models.FsiEncounterDtos
  6027. fed.MdtrtID = his.Number
  6028. fed.MedinsID = miConfig.Code
  6029. fed.MedinsName = miConfig.OrgName
  6030. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6031. fed.MedMdtrtType = "1"
  6032. fed.MedinsType = "1"
  6033. fed.MedinsLv = "11"
  6034. tm := time.Unix(his.RecordDate, 0)
  6035. s_tm := tm.Format("2006-01-02 15:04:05")
  6036. fed.AdmDate = s_tm
  6037. fed.DscgDate = s_tm
  6038. fed.DscgMainDiseCodg = config[0].CountryCode
  6039. fed.DscgMainDiseName = config[0].CountryContentName
  6040. //诊断信息
  6041. var fdds []*models.FsiDiagnoseDtos
  6042. for index, item := range config {
  6043. if index == 0 {
  6044. var fdd models.FsiDiagnoseDtos
  6045. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6046. fdd.InoutDiseType = "1"
  6047. fdd.MaindiseFlag = "1"
  6048. fdd.DiseDate = s_tm
  6049. fdd.DiasSrtNo = "1"
  6050. fdd.DiseName = item.CountryContentName
  6051. fdd.DiseCodg = item.CountryCode
  6052. fdds = append(fdds, &fdd)
  6053. } else {
  6054. var fdd models.FsiDiagnoseDtos
  6055. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6056. fdd.InoutDiseType = "1"
  6057. fdd.MaindiseFlag = "1"
  6058. fdd.DiseDate = s_tm
  6059. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6060. fdd.DiseName = item.CountryContentName
  6061. fdd.DiseCodg = item.CountryCode
  6062. fdds = append(fdds, &fdd)
  6063. }
  6064. }
  6065. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6066. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6067. fed.AdmDeptName = department.Name
  6068. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6069. fed.DscgDeptName = department.Name
  6070. fed.MedType = order.MedType
  6071. //处方医嘱信息
  6072. var orders []*models.FsiOrderDtos
  6073. //for _, item := range prescriptions {
  6074. // for _, subItem := range item.HisDoctorAdviceInfo {
  6075. // var order models.FsiOrderDtos
  6076. // order.RxID = strconv.FormatInt(item.ID, 10)
  6077. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6078. // order.LongDrordFlag = "0"
  6079. // order.HilistType = "1"
  6080. // order.ChrgType = "1"
  6081. // order.DrordBhvr = "-"
  6082. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6083. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6084. // order.HilistLv = "1"
  6085. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6086. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6087. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6088. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6089. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6090. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6091. // order.OwnpayAmt = ""
  6092. // order.SelfpayAmt = ""
  6093. // order.Spec = ""
  6094. // order.SpecUnt = ""
  6095. // order.DrordBegnDate = s_tm
  6096. // order.DrordStopDate = ""
  6097. // order.DrordDrCodg = "1"
  6098. // order.DrordDeptName = department.Name
  6099. // order.DrordDrCodg = "1"
  6100. // order.DrordDrName = doctor_info.UserName
  6101. // order.DrordDrProfttl = ""
  6102. // order.CurrDrordFlag = "1"
  6103. // orders = append(orders, &order)
  6104. // }
  6105. // for _, subItem := range item.HisPrescriptionProject {
  6106. // if subItem.Type == 2 {
  6107. // var order models.FsiOrderDtos
  6108. // order.RxID = strconv.FormatInt(item.ID, 10)
  6109. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6110. // order.LongDrordFlag = "0"
  6111. // order.HilistType = "1"
  6112. // order.ChrgType = "1"
  6113. // order.DrordBhvr = "-"
  6114. // order.HilistCode = subItem.HisProject.MedicalCode
  6115. // order.HosplistName = subItem.HisProject.ProjectName
  6116. // order.HilistLv = "1"
  6117. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6118. // order.HosplistCode = subItem.HisProject.MedicalCode
  6119. // order.HosplistName = subItem.HisProject.ProjectName
  6120. // order.Cnt = subItem.Count
  6121. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6122. //
  6123. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6124. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6125. // order.OwnpayAmt = ""
  6126. // order.SelfpayAmt = ""
  6127. // order.Spec = ""
  6128. // order.SpecUnt = ""
  6129. // order.DrordBegnDate = s_tm
  6130. // order.DrordStopDate = ""
  6131. // order.DrordDrCodg = "1"
  6132. // order.DrordDeptName = department.Name
  6133. // order.DrordDrCodg = "1"
  6134. // order.DrordDrName = doctor_info.UserName
  6135. // order.DrordDrProfttl = ""
  6136. // order.CurrDrordFlag = "1"
  6137. // orders = append(orders, &order)
  6138. //
  6139. // }
  6140. // if subItem.Type == 3 {
  6141. //
  6142. // var order models.FsiOrderDtos
  6143. // order.RxID = strconv.FormatInt(item.ID, 10)
  6144. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6145. // order.LongDrordFlag = "0"
  6146. // order.HilistType = "1"
  6147. // order.ChrgType = "1"
  6148. // order.DrordBhvr = "-"
  6149. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6150. // order.HosplistName = subItem.GoodInfo.GoodName
  6151. // order.HilistLv = "1"
  6152. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6153. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6154. // order.HosplistName = subItem.GoodInfo.GoodName
  6155. // order.Cnt = subItem.Count
  6156. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6157. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6158. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6159. // order.OwnpayAmt = ""
  6160. // order.SelfpayAmt = ""
  6161. // order.Spec = ""
  6162. // order.SpecUnt = ""
  6163. // order.DrordBegnDate = s_tm
  6164. // order.DrordStopDate = ""
  6165. // order.DrordDrCodg = "1"
  6166. // order.DrordDeptName = department.Name
  6167. // order.DrordDrCodg = "1"
  6168. // order.DrordDrName = doctor_info.UserName
  6169. // order.DrordDrProfttl = ""
  6170. // order.CurrDrordFlag = "1"
  6171. // orders = append(orders, &order)
  6172. //
  6173. // }
  6174. // }
  6175. //}
  6176. for _, item := range prescriptions {
  6177. for _, subItem := range item.HisDoctorAdviceInfo {
  6178. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6179. var order models.FsiOrderDtos
  6180. order.RxID = strconv.FormatInt(item.ID, 10)
  6181. order.Rxno = strconv.FormatInt(item.ID, 10)
  6182. order.LongDrordFlag = "0"
  6183. order.HilistType = "1"
  6184. order.ChrgType = "1"
  6185. order.DrordBhvr = "-"
  6186. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6187. order.HosplistName = subItem.BaseDrugLib.DrugName
  6188. order.HilistLv = "1"
  6189. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6190. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6191. order.HosplistName = subItem.BaseDrugLib.DrugName
  6192. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6193. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6194. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6195. order.OwnpayAmt = ""
  6196. order.SelfpayAmt = ""
  6197. order.Spec = ""
  6198. order.SpecUnt = ""
  6199. order.DrordBegnDate = s_tm
  6200. order.DrordStopDate = ""
  6201. order.DrordDrCodg = doctor_info.DoctorNumber
  6202. order.DrordDeptName = department.Name
  6203. order.DrordDeptCodg = department.Number
  6204. order.DrordDrName = doctor_info.UserName
  6205. order.DrordDrProfttl = "234"
  6206. order.CurrDrordFlag = "1"
  6207. orders = append(orders, &order)
  6208. }
  6209. }
  6210. for _, subItem := range item.HisPrescriptionProject {
  6211. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6212. var order models.FsiOrderDtos
  6213. order.RxID = strconv.FormatInt(item.ID, 10)
  6214. order.Rxno = strconv.FormatInt(item.ID, 10)
  6215. order.LongDrordFlag = "0"
  6216. order.HilistType = "1"
  6217. order.ChrgType = "1"
  6218. order.DrordBhvr = "-"
  6219. order.HilistCode = subItem.HisProject.MedicalCode
  6220. order.HosplistName = subItem.HisProject.ProjectName
  6221. order.HilistLv = "1"
  6222. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6223. order.HosplistCode = subItem.HisProject.MedicalCode
  6224. order.HosplistName = subItem.HisProject.ProjectName
  6225. order.Cnt = subItem.Count
  6226. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6227. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6228. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6229. order.OwnpayAmt = ""
  6230. order.SelfpayAmt = ""
  6231. order.Spec = ""
  6232. order.SpecUnt = ""
  6233. order.DrordBegnDate = s_tm
  6234. order.DrordStopDate = ""
  6235. order.DrordDrCodg = doctor_info.DoctorNumber
  6236. order.DrordDeptName = department.Name
  6237. order.DrordDeptCodg = department.Number
  6238. order.DrordDrName = doctor_info.UserName
  6239. order.DrordDrProfttl = "234"
  6240. order.CurrDrordFlag = "1"
  6241. orders = append(orders, &order)
  6242. }
  6243. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6244. var order models.FsiOrderDtos
  6245. order.RxID = strconv.FormatInt(item.ID, 10)
  6246. order.Rxno = strconv.FormatInt(item.ID, 10)
  6247. order.LongDrordFlag = "0"
  6248. order.HilistType = "1"
  6249. order.ChrgType = "1"
  6250. order.DrordBhvr = "0"
  6251. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6252. order.HosplistName = subItem.GoodInfo.GoodName
  6253. order.HilistLv = "1"
  6254. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6255. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6256. order.HosplistName = subItem.GoodInfo.GoodName
  6257. order.Cnt = subItem.Count
  6258. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6259. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6260. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6261. order.OwnpayAmt = ""
  6262. order.SelfpayAmt = ""
  6263. order.Spec = ""
  6264. order.SpecUnt = ""
  6265. order.DrordBegnDate = s_tm
  6266. order.DrordStopDate = ""
  6267. order.DrordDrCodg = doctor_info.DoctorNumber
  6268. order.DrordDeptName = department.Name
  6269. order.DrordDeptCodg = department.Number
  6270. order.DrordDrName = doctor_info.UserName
  6271. order.DrordDrProfttl = "234"
  6272. order.CurrDrordFlag = "1"
  6273. orders = append(orders, &order)
  6274. }
  6275. }
  6276. }
  6277. //处方医嘱信息
  6278. fed.MatnStas = "0"
  6279. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6280. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6281. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6282. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6283. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6284. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6285. fed.SetlTotlnum = "1"
  6286. fed.Insutype = his.Insutype
  6287. fed.ReimFlag = "0"
  6288. fed.OutSetlFlag = "0"
  6289. var fopd []*models.FsiOperationDtosData
  6290. data := make(map[string]interface{})
  6291. data["fed"] = fed
  6292. data["fdd"] = fdds
  6293. data["fod"] = orders
  6294. data["pd"] = pd
  6295. data["pp"] = pp
  6296. data["fopd"] = fopd
  6297. data["trig_scen"] = trig_scen
  6298. client := &http.Client{}
  6299. bytesData, _ := json.Marshal(data)
  6300. var req *http.Request
  6301. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6302. if miConfig.MdtrtareaAdmvs == "320921" {
  6303. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6304. } else {
  6305. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6306. }
  6307. resp, _ := client.Do(req)
  6308. defer resp.Body.Close()
  6309. body, ioErr := ioutil.ReadAll(resp.Body)
  6310. if ioErr != nil {
  6311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6313. return res
  6314. }
  6315. var respJSON map[string]interface{}
  6316. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6319. return res
  6320. }
  6321. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6322. result, _ := json.Marshal(respJSON)
  6323. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6324. utils.ErrorLog("解析失败:%v", err)
  6325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6326. return res
  6327. }
  6328. return res
  6329. } else {
  6330. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6331. saveLog(output, input, "3102", "事中")
  6332. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6333. utils.ErrorLog("解析失败:%v", err)
  6334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6335. return
  6336. }
  6337. return res
  6338. }
  6339. return res
  6340. }
  6341. 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) {
  6342. var res Resultgd3101
  6343. adminUser := c.GetAdminUserInfo()
  6344. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6345. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6346. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6347. //record_time := c.GetString("record_time")
  6348. //trig_scen := c.GetString("trig_scen")
  6349. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6350. timeLayout := "2006-01-02"
  6351. loc, _ := time.LoadLocation("Local")
  6352. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6353. if err != nil {
  6354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6355. return res
  6356. }
  6357. recordDateTime := theTime.Unix()
  6358. var patientPrescription models.HisPrescriptionInfo
  6359. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6360. //if patientPrescription.ID == 0 {
  6361. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6362. //}
  6363. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6364. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6365. //
  6366. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6367. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6368. var pp models.PublicParams
  6369. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6370. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6371. pp.FixmedinsName = miConfig.OrgName
  6372. pp.FixmedinsCode = miConfig.Code
  6373. pp.RequestUrl = miConfig.Url
  6374. pp.Cainfo = miConfig.Cainfo
  6375. pp.SecretKey = miConfig.SecretKey
  6376. pp.AccessKey = miConfig.AccessKey
  6377. pp.OpterName = roles.UserName
  6378. var config []*models.HisXtDiagnoseConfig
  6379. for _, item := range diagnosis_ids {
  6380. id, _ := strconv.ParseInt(item, 10, 64)
  6381. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6382. config = append(config, &diagnosisConfig)
  6383. }
  6384. var pd models.PatientDtos
  6385. pd.PatnID = his.PsnNo
  6386. pd.PatnName = his.Name
  6387. pd.Gend = his.Gend
  6388. pd.Brdy = psn_info.Brdy
  6389. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6390. pd.CurrMdtrtID = his.Number
  6391. var fed models.FsiEncounterDtos
  6392. fed.MdtrtID = his.Number
  6393. fed.MedinsID = miConfig.Code
  6394. fed.MedinsName = miConfig.OrgName
  6395. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6396. fed.MedMdtrtType = "1"
  6397. fed.MedinsType = "1"
  6398. fed.MedinsLv = "11"
  6399. tm := time.Unix(his.RecordDate, 0)
  6400. s_tm := tm.Format("2006-01-02 15:04:05")
  6401. fed.AdmDate = s_tm
  6402. fed.DscgDate = s_tm
  6403. fed.DscgMainDiseCodg = config[0].CountryCode
  6404. fed.DscgMainDiseName = config[0].CountryContentName
  6405. //诊断信息
  6406. var fdds []*models.FsiDiagnoseDtos
  6407. for index, item := range config {
  6408. if index == 0 {
  6409. var fdd models.FsiDiagnoseDtos
  6410. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6411. fdd.InoutDiseType = "1"
  6412. fdd.MaindiseFlag = "1"
  6413. fdd.DiseDate = s_tm
  6414. fdd.DiasSrtNo = "1"
  6415. fdd.DiseName = item.CountryContentName
  6416. fdd.DiseCodg = item.CountryCode
  6417. fdds = append(fdds, &fdd)
  6418. } else {
  6419. var fdd models.FsiDiagnoseDtos
  6420. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6421. fdd.InoutDiseType = "1"
  6422. fdd.MaindiseFlag = "1"
  6423. fdd.DiseDate = s_tm
  6424. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6425. fdd.DiseName = item.CountryContentName
  6426. fdd.DiseCodg = item.CountryCode
  6427. fdds = append(fdds, &fdd)
  6428. }
  6429. }
  6430. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6431. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6432. fed.AdmDeptName = department.Name
  6433. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6434. fed.DscgDeptName = department.Name
  6435. fed.MedMdtrtType = "1"
  6436. fed.MedType = "11"
  6437. //if his.Insutype == "390" {
  6438. // fed.MedType = "1402"
  6439. //} else {
  6440. // fed.MedType = "9933"
  6441. //}
  6442. var orders []*models.FsiOrderDtos
  6443. if trig_scen == "2" {
  6444. //处方医嘱信息
  6445. for _, item := range prescriptions {
  6446. for _, subItem := range item.HisDoctorAdviceInfo {
  6447. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6448. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6449. var order models.FsiOrderDtos
  6450. order.RxID = strconv.FormatInt(item.ID, 10)
  6451. order.Rxno = strconv.FormatInt(item.ID, 10)
  6452. order.LongDrordFlag = "0"
  6453. order.HilistType = "1"
  6454. order.ChrgType = "1"
  6455. order.DrordBhvr = "0"
  6456. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6457. order.HosplistName = subItem.BaseDrugLib.DrugName
  6458. order.HilistLv = "1"
  6459. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6460. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6461. order.HosplistName = subItem.BaseDrugLib.DrugName
  6462. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6463. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6464. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6465. order.OwnpayAmt = ""
  6466. order.SelfpayAmt = ""
  6467. order.Spec = spec
  6468. order.SpecUnt = subItem.PrescribingNumberUnit
  6469. order.DrordBegnDate = s_tm
  6470. order.DrordStopDate = ""
  6471. order.DrordDrCodg = doctor_info.DoctorNumber
  6472. order.DrordDeptName = department.Name
  6473. order.DrordDeptCodg = department.Number
  6474. order.DrordDrName = doctor_info.UserName
  6475. order.DrordDrProfttl = "234"
  6476. order.CurrDrordFlag = "1"
  6477. orders = append(orders, &order)
  6478. }
  6479. }
  6480. for _, subItem := range item.HisPrescriptionProject {
  6481. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6482. var order models.FsiOrderDtos
  6483. order.RxID = strconv.FormatInt(item.ID, 10)
  6484. order.Rxno = strconv.FormatInt(item.ID, 10)
  6485. order.LongDrordFlag = "0"
  6486. order.HilistType = "1"
  6487. order.ChrgType = "1"
  6488. order.DrordBhvr = "0"
  6489. order.HilistCode = subItem.HisProject.MedicalCode
  6490. order.HosplistName = subItem.HisProject.ProjectName
  6491. order.HilistLv = "1"
  6492. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6493. order.HosplistCode = subItem.HisProject.MedicalCode
  6494. order.HosplistName = subItem.HisProject.ProjectName
  6495. order.Cnt = subItem.Count
  6496. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6497. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6498. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6499. order.OwnpayAmt = ""
  6500. order.SelfpayAmt = ""
  6501. order.Spec = subItem.Unit
  6502. order.SpecUnt = subItem.Unit
  6503. order.DrordBegnDate = s_tm
  6504. order.DrordStopDate = ""
  6505. order.DrordDrCodg = doctor_info.DoctorNumber
  6506. order.DrordDeptName = department.Name
  6507. order.DrordDeptCodg = department.Number
  6508. order.DrordDrName = doctor_info.UserName
  6509. order.DrordDrProfttl = "234"
  6510. order.CurrDrordFlag = "1"
  6511. orders = append(orders, &order)
  6512. }
  6513. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6514. var order models.FsiOrderDtos
  6515. order.RxID = strconv.FormatInt(item.ID, 10)
  6516. order.Rxno = strconv.FormatInt(item.ID, 10)
  6517. order.LongDrordFlag = "0"
  6518. order.HilistType = "1"
  6519. order.ChrgType = "1"
  6520. order.DrordBhvr = "0"
  6521. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6522. order.HosplistName = subItem.GoodInfo.GoodName
  6523. order.HilistLv = "1"
  6524. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6525. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6526. order.HosplistName = subItem.GoodInfo.GoodName
  6527. order.Cnt = subItem.Count
  6528. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6529. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6530. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6531. order.OwnpayAmt = ""
  6532. order.SelfpayAmt = ""
  6533. order.Spec = subItem.GoodInfo.SpecificationName
  6534. order.SpecUnt = subItem.Unit
  6535. order.DrordBegnDate = s_tm
  6536. order.DrordStopDate = ""
  6537. order.DrordDrCodg = doctor_info.DoctorNumber
  6538. order.DrordDeptName = department.Name
  6539. order.DrordDeptCodg = department.Number
  6540. order.DrordDrName = doctor_info.UserName
  6541. order.DrordDrProfttl = "234"
  6542. order.CurrDrordFlag = "1"
  6543. orders = append(orders, &order)
  6544. }
  6545. }
  6546. }
  6547. //处方医嘱信息
  6548. }
  6549. fed.MatnStas = "0"
  6550. fed.MedfeeSumamt = "0"
  6551. fed.OwnpayAmt = "0"
  6552. fed.SelfpayAmt = "0"
  6553. fed.AcctPayamt = "0"
  6554. fed.MaAmt = "0"
  6555. fed.HifpPayamt = "0"
  6556. fed.SetlTotlnum = "1"
  6557. fed.Insutype = his.Insutype
  6558. fed.ReimFlag = "0"
  6559. fed.OutSetlFlag = "0"
  6560. var fopd []*models.FsiOperationDtosData
  6561. data := make(map[string]interface{})
  6562. data["fed"] = fed
  6563. data["fdd"] = fdds
  6564. data["fod"] = orders
  6565. data["pd"] = pd
  6566. data["pp"] = pp
  6567. data["fopd"] = fopd
  6568. data["trig_scen"] = trig_scen
  6569. fmt.Println(data)
  6570. fmt.Println(fed)
  6571. fmt.Println(fdds)
  6572. fmt.Println(orders)
  6573. fmt.Println(pd)
  6574. fmt.Println(pp)
  6575. fmt.Println(fopd)
  6576. client := &http.Client{}
  6577. bytesData, _ := json.Marshal(data)
  6578. var req *http.Request
  6579. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6580. if miConfig.MdtrtareaAdmvs == "320921" {
  6581. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6582. } else {
  6583. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6584. }
  6585. resp, _ := client.Do(req)
  6586. defer resp.Body.Close()
  6587. body, ioErr := ioutil.ReadAll(resp.Body)
  6588. if ioErr != nil {
  6589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6591. return res
  6592. }
  6593. var respJSON map[string]interface{}
  6594. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6597. return res
  6598. }
  6599. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6600. fmt.Println(respJSON)
  6601. result, _ := json.Marshal(respJSON)
  6602. fmt.Println(result)
  6603. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6604. utils.ErrorLog("解析失败:%v", err)
  6605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6606. return res
  6607. }
  6608. return res
  6609. } else {
  6610. //if miConfig.MdtrtareaAdmvs == "441202" {
  6611. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6612. saveLog(output, input, "3101", "事前")
  6613. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6614. utils.ErrorLog("解析失败:%v", err)
  6615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6616. return
  6617. }
  6618. return res
  6619. //}
  6620. }
  6621. }
  6622. 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) {
  6623. adminUser := c.GetAdminUserInfo()
  6624. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6625. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6626. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6627. //record_time := c.GetString("record_time")
  6628. //trig_scen := c.GetString("trig_scen")
  6629. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6630. timeLayout := "2006-01-02"
  6631. loc, _ := time.LoadLocation("Local")
  6632. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6633. if err != nil {
  6634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6635. return res
  6636. }
  6637. recordDateTime := theTime.Unix()
  6638. var patientPrescription models.HisPrescriptionInfo
  6639. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6640. if patientPrescription.ID == 0 {
  6641. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6642. }
  6643. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6644. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6645. //
  6646. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6647. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6648. var pp models.PublicParams
  6649. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6650. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6651. pp.FixmedinsName = miConfig.OrgName
  6652. pp.FixmedinsCode = miConfig.Code
  6653. pp.RequestUrl = miConfig.Url
  6654. pp.Cainfo = miConfig.Cainfo
  6655. pp.SecretKey = miConfig.SecretKey
  6656. pp.AccessKey = miConfig.AccessKey
  6657. pp.OpterName = roles.UserName
  6658. var config []*models.HisXtDiagnoseConfig
  6659. for _, item := range diagnosis_ids {
  6660. id, _ := strconv.ParseInt(item, 10, 64)
  6661. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6662. config = append(config, &diagnosisConfig)
  6663. }
  6664. var pd models.PatientDtos
  6665. pd.PatnID = his.PsnNo
  6666. pd.PatnName = his.Name
  6667. pd.Gend = his.Gend
  6668. pd.Brdy = psn_info.Brdy
  6669. pd.Poolarea = his.InsuplcAdmdvs
  6670. pd.CurrMdtrtID = his.Number
  6671. var fed models.FsiEncounterDtos
  6672. fed.MdtrtID = his.Number
  6673. fed.MedinsID = miConfig.Code
  6674. fed.MedinsName = miConfig.OrgName
  6675. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6676. fed.MedMdtrtType = "1"
  6677. fed.MedinsType = "1"
  6678. fed.MedinsLv = "11"
  6679. tm := time.Unix(his.RecordDate, 0)
  6680. s_tm := tm.Format("2006-01-02 15:04:05")
  6681. fed.AdmDate = s_tm
  6682. fed.DscgDate = s_tm
  6683. fed.DscgMainDiseCodg = config[0].CountryCode
  6684. fed.DscgMainDiseName = config[0].CountryContentName
  6685. //诊断信息
  6686. var fdds []*models.FsiDiagnoseDtos
  6687. for index, item := range config {
  6688. if index == 0 {
  6689. var fdd models.FsiDiagnoseDtos
  6690. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6691. fdd.InoutDiseType = "1"
  6692. fdd.MaindiseFlag = "1"
  6693. fdd.DiseDate = s_tm
  6694. fdd.DiasSrtNo = "1"
  6695. fdd.DiseName = item.CountryContentName
  6696. fdd.DiseCodg = item.CountryCode
  6697. fdds = append(fdds, &fdd)
  6698. } else {
  6699. var fdd models.FsiDiagnoseDtos
  6700. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6701. fdd.InoutDiseType = "1"
  6702. fdd.MaindiseFlag = "1"
  6703. fdd.DiseDate = s_tm
  6704. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6705. fdd.DiseName = item.CountryContentName
  6706. fdd.DiseCodg = item.CountryCode
  6707. fdds = append(fdds, &fdd)
  6708. }
  6709. }
  6710. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6711. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6712. fed.AdmDeptName = department.Name
  6713. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6714. fed.DscgDeptName = department.Name
  6715. fed.MedMdtrtType = "1"
  6716. fed.MedType = "11"
  6717. //if his.Insutype == "390" {
  6718. // fed.MedType = "1402"
  6719. //} else {
  6720. // fed.MedType = "9933"
  6721. //}
  6722. var orders []*models.FsiOrderDtos
  6723. if trig_scen == "2" {
  6724. //处方医嘱信息
  6725. for _, item := range prescriptions {
  6726. for _, subItem := range item.HisDoctorAdviceInfo {
  6727. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6728. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6729. var order models.FsiOrderDtos
  6730. order.RxID = strconv.FormatInt(item.ID, 10)
  6731. order.Rxno = strconv.FormatInt(item.ID, 10)
  6732. order.LongDrordFlag = "0"
  6733. order.HilistType = "1"
  6734. order.ChrgType = "1"
  6735. order.DrordBhvr = "0"
  6736. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6737. order.HosplistName = subItem.BaseDrugLib.DrugName
  6738. order.HilistLv = "1"
  6739. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6740. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6741. order.HosplistName = subItem.BaseDrugLib.DrugName
  6742. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6743. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6744. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6745. order.OwnpayAmt = ""
  6746. order.SelfpayAmt = ""
  6747. order.Spec = spec
  6748. order.SpecUnt = subItem.PrescribingNumberUnit
  6749. order.DrordBegnDate = s_tm
  6750. order.DrordStopDate = ""
  6751. order.DrordDrCodg = doctor_info.DoctorNumber
  6752. order.DrordDeptName = department.Name
  6753. order.DrordDeptCodg = department.Number
  6754. order.DrordDrName = doctor_info.UserName
  6755. order.DrordDrProfttl = "234"
  6756. order.CurrDrordFlag = "1"
  6757. orders = append(orders, &order)
  6758. }
  6759. }
  6760. for _, subItem := range item.HisPrescriptionProject {
  6761. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6762. var order models.FsiOrderDtos
  6763. order.RxID = strconv.FormatInt(item.ID, 10)
  6764. order.Rxno = strconv.FormatInt(item.ID, 10)
  6765. order.LongDrordFlag = "0"
  6766. order.HilistType = "1"
  6767. order.ChrgType = "1"
  6768. order.DrordBhvr = "0"
  6769. order.HilistCode = subItem.HisProject.MedicalCode
  6770. order.HosplistName = subItem.HisProject.ProjectName
  6771. order.HilistLv = "1"
  6772. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6773. order.HosplistCode = subItem.HisProject.MedicalCode
  6774. order.HosplistName = subItem.HisProject.ProjectName
  6775. order.Cnt = subItem.Count
  6776. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6777. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6778. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6779. order.OwnpayAmt = ""
  6780. order.SelfpayAmt = ""
  6781. order.Spec = subItem.Unit
  6782. order.SpecUnt = subItem.Unit
  6783. order.DrordBegnDate = s_tm
  6784. order.DrordStopDate = ""
  6785. order.DrordDrCodg = doctor_info.DoctorNumber
  6786. order.DrordDeptName = department.Name
  6787. order.DrordDeptCodg = department.Number
  6788. order.DrordDrName = doctor_info.UserName
  6789. order.DrordDrProfttl = "234"
  6790. order.CurrDrordFlag = "1"
  6791. orders = append(orders, &order)
  6792. }
  6793. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6794. var order models.FsiOrderDtos
  6795. order.RxID = strconv.FormatInt(item.ID, 10)
  6796. order.Rxno = strconv.FormatInt(item.ID, 10)
  6797. order.LongDrordFlag = "0"
  6798. order.HilistType = "1"
  6799. order.ChrgType = "1"
  6800. order.DrordBhvr = "0"
  6801. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6802. order.HosplistName = subItem.GoodInfo.GoodName
  6803. order.HilistLv = "1"
  6804. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6805. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6806. order.HosplistName = subItem.GoodInfo.GoodName
  6807. order.Cnt = subItem.Count
  6808. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6809. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6810. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6811. order.OwnpayAmt = ""
  6812. order.SelfpayAmt = ""
  6813. order.Spec = subItem.GoodInfo.SpecificationName
  6814. order.SpecUnt = subItem.Unit
  6815. order.DrordBegnDate = s_tm
  6816. order.DrordStopDate = ""
  6817. order.DrordDrCodg = doctor_info.DoctorNumber
  6818. order.DrordDeptName = department.Name
  6819. order.DrordDeptCodg = department.Number
  6820. order.DrordDrName = doctor_info.UserName
  6821. order.DrordDrProfttl = "234"
  6822. order.CurrDrordFlag = "1"
  6823. orders = append(orders, &order)
  6824. }
  6825. }
  6826. }
  6827. //处方医嘱信息
  6828. }
  6829. fed.MatnStas = "0"
  6830. fed.MedfeeSumamt = "0"
  6831. fed.OwnpayAmt = "0"
  6832. fed.SelfpayAmt = "0"
  6833. fed.AcctPayamt = "0"
  6834. fed.MaAmt = "0"
  6835. fed.HifpPayamt = "0"
  6836. fed.SetlTotlnum = "1"
  6837. fed.Insutype = his.Insutype
  6838. fed.ReimFlag = "0"
  6839. fed.OutSetlFlag = "0"
  6840. var fopd []*models.FsiOperationDtosData
  6841. data := make(map[string]interface{})
  6842. data["fed"] = fed
  6843. data["fdd"] = fdds
  6844. data["fod"] = orders
  6845. data["pd"] = pd
  6846. data["pp"] = pp
  6847. data["fopd"] = fopd
  6848. data["trig_scen"] = trig_scen
  6849. fmt.Println(data)
  6850. fmt.Println(fed)
  6851. fmt.Println(fdds)
  6852. fmt.Println(orders)
  6853. fmt.Println(pd)
  6854. fmt.Println(pp)
  6855. fmt.Println(fopd)
  6856. client := &http.Client{}
  6857. bytesData, _ := json.Marshal(data)
  6858. var req *http.Request
  6859. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6860. if miConfig.MdtrtareaAdmvs == "320921" {
  6861. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6862. } else {
  6863. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6864. }
  6865. resp, _ := client.Do(req)
  6866. defer resp.Body.Close()
  6867. body, ioErr := ioutil.ReadAll(resp.Body)
  6868. if ioErr != nil {
  6869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6871. return res
  6872. }
  6873. var respJSON map[string]interface{}
  6874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6877. return res
  6878. }
  6879. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6880. fmt.Println(respJSON)
  6881. result, _ := json.Marshal(respJSON)
  6882. fmt.Println(result)
  6883. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6884. utils.ErrorLog("解析失败:%v", err)
  6885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6886. return res
  6887. }
  6888. return res
  6889. } else {
  6890. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6891. saveLog(output, input, "3101", "事前")
  6892. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6893. utils.ErrorLog("解析失败:%v", err)
  6894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. return
  6896. }
  6897. return res
  6898. }
  6899. return res
  6900. }
  6901. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6902. ////patient_id, _ := c.GetInt64("patient_id")
  6903. //order_id, _ := c.GetInt64("order_id")
  6904. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6905. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6906. //trig_scen := c.GetString("trig_scen")
  6907. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6908. utils.ErrorLog("解析失败:%v", psn_info)
  6909. adminUser := c.GetAdminUserInfo()
  6910. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6911. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6912. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6913. record_time := c.GetString("record_time")
  6914. order, _ := service.GetHisOrderByID(order_id)
  6915. timeLayout := "2006-01-02"
  6916. loc, _ := time.LoadLocation("Local")
  6917. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6918. if err != nil {
  6919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6920. return
  6921. }
  6922. recordDateTime := theTime.Unix()
  6923. var patientPrescription models.HisPrescriptionInfo
  6924. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6925. if patientPrescription.ID == 0 {
  6926. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6927. }
  6928. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6929. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6930. //
  6931. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6932. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6933. var pp models.PublicParams
  6934. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6935. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6936. pp.FixmedinsName = miConfig.OrgName
  6937. pp.FixmedinsCode = miConfig.Code
  6938. pp.RequestUrl = miConfig.Url
  6939. pp.Cainfo = miConfig.Cainfo
  6940. pp.SecretKey = miConfig.SecretKey
  6941. pp.AccessKey = miConfig.AccessKey
  6942. pp.OpterName = roles.UserName
  6943. var config []*models.HisXtDiagnoseConfig
  6944. for _, item := range diagnosis_ids {
  6945. id, _ := strconv.ParseInt(item, 10, 64)
  6946. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6947. config = append(config, &diagnosisConfig)
  6948. }
  6949. var pd models.PatientDtos
  6950. pd.PatnID = his.PsnNo
  6951. pd.PatnName = his.Name
  6952. pd.Gend = his.Gend
  6953. pd.Brdy = psn_info.Brdy
  6954. pd.Poolarea = his.InsuplcAdmdvs
  6955. pd.CurrMdtrtID = his.Number
  6956. var fed models.FsiEncounterDtos
  6957. fed.MdtrtID = his.Number
  6958. fed.MedinsID = miConfig.Code
  6959. fed.MedinsName = miConfig.OrgName
  6960. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6961. fed.MedMdtrtType = "1"
  6962. fed.MedinsType = "1"
  6963. fed.MedinsLv = "11"
  6964. tm := time.Unix(his.RecordDate, 0)
  6965. s_tm := tm.Format("2006-01-02 15:04:05")
  6966. fed.AdmDate = s_tm
  6967. fed.DscgDate = s_tm
  6968. fed.DscgMainDiseCodg = config[0].CountryCode
  6969. fed.DscgMainDiseName = config[0].CountryContentName
  6970. //诊断信息
  6971. var fdds []*models.FsiDiagnoseDtos
  6972. for index, item := range config {
  6973. if index == 0 {
  6974. var fdd models.FsiDiagnoseDtos
  6975. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6976. fdd.InoutDiseType = "1"
  6977. fdd.MaindiseFlag = "1"
  6978. fdd.DiseDate = s_tm
  6979. fdd.DiasSrtNo = "1"
  6980. fdd.DiseName = item.CountryContentName
  6981. fdd.DiseCodg = item.CountryCode
  6982. fdds = append(fdds, &fdd)
  6983. } else {
  6984. var fdd models.FsiDiagnoseDtos
  6985. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6986. fdd.InoutDiseType = "1"
  6987. fdd.MaindiseFlag = "1"
  6988. fdd.DiseDate = s_tm
  6989. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6990. fdd.DiseName = item.CountryContentName
  6991. fdd.DiseCodg = item.CountryCode
  6992. fdds = append(fdds, &fdd)
  6993. }
  6994. }
  6995. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6996. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6997. fed.AdmDeptName = department.Name
  6998. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6999. fed.DscgDeptName = department.Name
  7000. fed.MedType = order.MedType
  7001. //处方医嘱信息
  7002. var orders []*models.FsiOrderDtos
  7003. //for _, item := range prescriptions {
  7004. // for _, subItem := range item.HisDoctorAdviceInfo {
  7005. // var order models.FsiOrderDtos
  7006. // order.RxID = strconv.FormatInt(item.ID, 10)
  7007. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7008. // order.LongDrordFlag = "0"
  7009. // order.HilistType = "1"
  7010. // order.ChrgType = "1"
  7011. // order.DrordBhvr = "-"
  7012. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7013. // order.HosplistName = subItem.BaseDrugLib.DrugName
  7014. // order.HilistLv = "1"
  7015. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7016. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7017. // order.HosplistName = subItem.BaseDrugLib.DrugName
  7018. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  7019. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7020. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  7021. // order.OwnpayAmt = ""
  7022. // order.SelfpayAmt = ""
  7023. // order.Spec = ""
  7024. // order.SpecUnt = ""
  7025. // order.DrordBegnDate = s_tm
  7026. // order.DrordStopDate = ""
  7027. // order.DrordDrCodg = "1"
  7028. // order.DrordDeptName = department.Name
  7029. // order.DrordDrCodg = "1"
  7030. // order.DrordDrName = doctor_info.UserName
  7031. // order.DrordDrProfttl = ""
  7032. // order.CurrDrordFlag = "1"
  7033. // orders = append(orders, &order)
  7034. // }
  7035. // for _, subItem := range item.HisPrescriptionProject {
  7036. // if subItem.Type == 2 {
  7037. // var order models.FsiOrderDtos
  7038. // order.RxID = strconv.FormatInt(item.ID, 10)
  7039. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7040. // order.LongDrordFlag = "0"
  7041. // order.HilistType = "1"
  7042. // order.ChrgType = "1"
  7043. // order.DrordBhvr = "-"
  7044. // order.HilistCode = subItem.HisProject.MedicalCode
  7045. // order.HosplistName = subItem.HisProject.ProjectName
  7046. // order.HilistLv = "1"
  7047. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7048. // order.HosplistCode = subItem.HisProject.MedicalCode
  7049. // order.HosplistName = subItem.HisProject.ProjectName
  7050. // order.Cnt = subItem.Count
  7051. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7052. //
  7053. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7054. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  7055. // order.OwnpayAmt = ""
  7056. // order.SelfpayAmt = ""
  7057. // order.Spec = ""
  7058. // order.SpecUnt = ""
  7059. // order.DrordBegnDate = s_tm
  7060. // order.DrordStopDate = ""
  7061. // order.DrordDrCodg = "1"
  7062. // order.DrordDeptName = department.Name
  7063. // order.DrordDrCodg = "1"
  7064. // order.DrordDrName = doctor_info.UserName
  7065. // order.DrordDrProfttl = ""
  7066. // order.CurrDrordFlag = "1"
  7067. // orders = append(orders, &order)
  7068. //
  7069. // }
  7070. // if subItem.Type == 3 {
  7071. //
  7072. // var order models.FsiOrderDtos
  7073. // order.RxID = strconv.FormatInt(item.ID, 10)
  7074. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7075. // order.LongDrordFlag = "0"
  7076. // order.HilistType = "1"
  7077. // order.ChrgType = "1"
  7078. // order.DrordBhvr = "-"
  7079. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7080. // order.HosplistName = subItem.GoodInfo.GoodName
  7081. // order.HilistLv = "1"
  7082. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7083. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7084. // order.HosplistName = subItem.GoodInfo.GoodName
  7085. // order.Cnt = subItem.Count
  7086. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7087. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7088. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  7089. // order.OwnpayAmt = ""
  7090. // order.SelfpayAmt = ""
  7091. // order.Spec = ""
  7092. // order.SpecUnt = ""
  7093. // order.DrordBegnDate = s_tm
  7094. // order.DrordStopDate = ""
  7095. // order.DrordDrCodg = "1"
  7096. // order.DrordDeptName = department.Name
  7097. // order.DrordDrCodg = "1"
  7098. // order.DrordDrName = doctor_info.UserName
  7099. // order.DrordDrProfttl = ""
  7100. // order.CurrDrordFlag = "1"
  7101. // orders = append(orders, &order)
  7102. //
  7103. // }
  7104. // }
  7105. //}
  7106. for _, item := range prescriptions {
  7107. for _, subItem := range item.HisDoctorAdviceInfo {
  7108. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7109. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7110. var order models.FsiOrderDtos
  7111. order.RxID = strconv.FormatInt(item.ID, 10)
  7112. order.Rxno = strconv.FormatInt(item.ID, 10)
  7113. order.LongDrordFlag = "0"
  7114. order.HilistType = "1"
  7115. order.ChrgType = "1"
  7116. order.DrordBhvr = "0"
  7117. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7118. order.HosplistName = subItem.BaseDrugLib.DrugName
  7119. order.HilistLv = "1"
  7120. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7121. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7122. order.HosplistName = subItem.BaseDrugLib.DrugName
  7123. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7124. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7125. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  7126. order.OwnpayAmt = ""
  7127. order.SelfpayAmt = ""
  7128. order.Spec = spec
  7129. order.SpecUnt = subItem.PrescribingNumberUnit
  7130. order.DrordBegnDate = s_tm
  7131. order.DrordStopDate = ""
  7132. order.DrordDrCodg = doctor_info.DoctorNumber
  7133. order.DrordDeptName = department.Name
  7134. order.DrordDeptCodg = department.Number
  7135. order.DrordDrName = doctor_info.UserName
  7136. order.DrordDrProfttl = "234"
  7137. order.CurrDrordFlag = "1"
  7138. orders = append(orders, &order)
  7139. }
  7140. }
  7141. for _, subItem := range item.HisPrescriptionProject {
  7142. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  7143. var order models.FsiOrderDtos
  7144. order.RxID = strconv.FormatInt(item.ID, 10)
  7145. order.Rxno = strconv.FormatInt(item.ID, 10)
  7146. order.LongDrordFlag = "0"
  7147. order.HilistType = "1"
  7148. order.ChrgType = "1"
  7149. order.DrordBhvr = "0"
  7150. order.HilistCode = subItem.HisProject.MedicalCode
  7151. order.HosplistName = subItem.HisProject.ProjectName
  7152. order.HilistLv = "1"
  7153. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7154. order.HosplistCode = subItem.HisProject.MedicalCode
  7155. order.HosplistName = subItem.HisProject.ProjectName
  7156. order.Cnt = subItem.Count
  7157. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7158. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7159. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7160. order.OwnpayAmt = ""
  7161. order.SelfpayAmt = ""
  7162. order.Spec = subItem.Unit
  7163. order.SpecUnt = subItem.Unit
  7164. order.DrordBegnDate = s_tm
  7165. order.DrordStopDate = ""
  7166. order.DrordDrCodg = doctor_info.DoctorNumber
  7167. order.DrordDeptName = department.Name
  7168. order.DrordDeptCodg = department.Number
  7169. order.DrordDrName = doctor_info.UserName
  7170. order.DrordDrProfttl = "234"
  7171. order.CurrDrordFlag = "1"
  7172. orders = append(orders, &order)
  7173. }
  7174. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7175. var order models.FsiOrderDtos
  7176. order.RxID = strconv.FormatInt(item.ID, 10)
  7177. order.Rxno = strconv.FormatInt(item.ID, 10)
  7178. order.LongDrordFlag = "0"
  7179. order.HilistType = "1"
  7180. order.ChrgType = "1"
  7181. order.DrordBhvr = "0"
  7182. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7183. order.HosplistName = subItem.GoodInfo.GoodName
  7184. order.HilistLv = "1"
  7185. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7186. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7187. order.HosplistName = subItem.GoodInfo.GoodName
  7188. order.Cnt = subItem.Count
  7189. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7190. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7191. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7192. order.OwnpayAmt = ""
  7193. order.SelfpayAmt = ""
  7194. order.Spec = subItem.GoodInfo.SpecificationName
  7195. order.SpecUnt = subItem.Unit
  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. }
  7208. //处方医嘱信息
  7209. fed.MatnStas = "0"
  7210. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7211. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  7212. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  7213. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  7214. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  7215. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  7216. fed.SetlTotlnum = "1"
  7217. fed.Insutype = his.Insutype
  7218. fed.ReimFlag = "0"
  7219. fed.OutSetlFlag = "0"
  7220. var fopd []*models.FsiOperationDtosData
  7221. data := make(map[string]interface{})
  7222. data["fed"] = fed
  7223. data["fdd"] = fdds
  7224. data["fod"] = orders
  7225. data["pd"] = pd
  7226. data["pp"] = pp
  7227. data["fopd"] = fopd
  7228. data["trig_scen"] = trig_scen
  7229. client := &http.Client{}
  7230. bytesData, _ := json.Marshal(data)
  7231. var req *http.Request
  7232. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7233. if miConfig.MdtrtareaAdmvs == "320921" {
  7234. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7235. } else {
  7236. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7237. }
  7238. resp, _ := client.Do(req)
  7239. defer resp.Body.Close()
  7240. body, ioErr := ioutil.ReadAll(resp.Body)
  7241. if ioErr != nil {
  7242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7244. return res
  7245. }
  7246. var respJSON map[string]interface{}
  7247. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7250. return res
  7251. }
  7252. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7253. result, _ := json.Marshal(respJSON)
  7254. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7255. utils.ErrorLog("解析失败:%v", err)
  7256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7257. return res
  7258. }
  7259. return res
  7260. } else {
  7261. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7262. saveLog(output, input, "3102", "事中")
  7263. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7264. utils.ErrorLog("解析失败:%v", err)
  7265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7266. return
  7267. }
  7268. return res
  7269. }
  7270. return res
  7271. }
  7272. func (c *HisApiController) Check() {
  7273. psn_no := c.GetString("psn_no")
  7274. in := c.GetString("in")
  7275. mt := c.GetString("mt")
  7276. baseParams := models.BaseParams{
  7277. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  7278. FixmedinsCode: "H15049901371",
  7279. InsuplcAdmdvs: "150499",
  7280. MdtrtareaAdmvs: "150499",
  7281. OrgName: "赤峰费森血液透析中心",
  7282. Doctor: "1111",
  7283. }
  7284. service.Gdyb2001(baseParams, psn_no, in, mt)
  7285. }
  7286. func (c *HisApiController) GetPsnNcdsInfo() {
  7287. admin_user_id, _ := c.GetInt64("admin_user_id")
  7288. patient_id, _ := c.GetInt64("patient_id")
  7289. //id, _ := c.GetInt64("id")
  7290. adminUser := c.GetAdminUserInfo()
  7291. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7292. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7293. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7294. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7295. //psn_record, _ := service.GetP(id)
  7296. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7297. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  7298. //
  7299. //if psn_record.ID == 0 {
  7300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7301. // return
  7302. //}
  7303. var res Result5301
  7304. var res10265 Result5301For10265
  7305. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7306. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7307. var api string
  7308. if miConfig.MdtrtareaAdmvs == "320921" {
  7309. 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 +
  7310. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7311. } else {
  7312. 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 +
  7313. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7314. }
  7315. resp, requestErr := http.Get(api)
  7316. if requestErr != nil {
  7317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7318. return
  7319. }
  7320. body, ioErr := ioutil.ReadAll(resp.Body)
  7321. if ioErr != nil {
  7322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7324. return
  7325. }
  7326. var respJSON map[string]interface{}
  7327. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7330. return
  7331. }
  7332. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7333. result, _ := json.Marshal(respJSON)
  7334. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7335. utils.ErrorLog("解析失败:%v", err)
  7336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7337. return
  7338. }
  7339. res.ErrMsg = res10265.ErrMsg
  7340. res.Output = res10265.Output
  7341. res.InfRefmsgid = res10265.InfRefmsgid
  7342. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7343. res.Infcode = infocode
  7344. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7345. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7346. var api string
  7347. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7348. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7349. resp, requestErr := http.Get(api)
  7350. if requestErr != nil {
  7351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7352. return
  7353. }
  7354. body, ioErr := ioutil.ReadAll(resp.Body)
  7355. if ioErr != nil {
  7356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7358. return
  7359. }
  7360. var respJSON map[string]interface{}
  7361. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7362. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7364. return
  7365. }
  7366. status := respJSON["data"].(map[string]interface{})["status"].(string)
  7367. if status == "0" {
  7368. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  7369. c.ServeSuccessJSON(map[string]interface{}{
  7370. "failed_code": -10,
  7371. "msg": err_msg,
  7372. })
  7373. return
  7374. }
  7375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7376. result, _ := json.Marshal(respJSON)
  7377. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7378. utils.ErrorLog("解析失败:%v", err)
  7379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7380. return
  7381. }
  7382. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7383. p, _ := service.GetHisPatientById(patient_id)
  7384. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7385. var dat map[string]interface{}
  7386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7387. fmt.Println(dat)
  7388. } else {
  7389. fmt.Println(err)
  7390. }
  7391. userJSONBytes, _ := json.Marshal(dat)
  7392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7393. utils.ErrorLog("解析失败:%v", err)
  7394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7395. return
  7396. }
  7397. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7398. p, _ := service.GetHisPatientById(patient_id)
  7399. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7400. var dat map[string]interface{}
  7401. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7402. fmt.Println(dat)
  7403. } else {
  7404. fmt.Println(err)
  7405. }
  7406. userJSONBytes, _ := json.Marshal(dat)
  7407. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7408. utils.ErrorLog("解析失败:%v", err)
  7409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7410. return
  7411. }
  7412. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7413. p, _ := service.GetHisPatientById(patient_id)
  7414. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7415. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7416. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7417. resp, requestErr := http.Get(api)
  7418. if requestErr != nil {
  7419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7420. return
  7421. }
  7422. body, ioErr := ioutil.ReadAll(resp.Body)
  7423. if ioErr != nil {
  7424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7426. return
  7427. }
  7428. var respJSON map[string]interface{}
  7429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7432. return
  7433. }
  7434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7435. result, _ := json.Marshal(respJSON)
  7436. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7437. utils.ErrorLog("解析失败:%v", err)
  7438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7439. return
  7440. }
  7441. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7442. p, _ := service.GetHisPatientById(patient_id)
  7443. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  7444. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7445. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7446. resp, requestErr := http.Get(api)
  7447. if requestErr != nil {
  7448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7449. return
  7450. }
  7451. body, ioErr := ioutil.ReadAll(resp.Body)
  7452. if ioErr != nil {
  7453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7455. return
  7456. }
  7457. var respJSON map[string]interface{}
  7458. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7461. return
  7462. }
  7463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7464. result, _ := json.Marshal(respJSON)
  7465. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7466. utils.ErrorLog("解析失败:%v", err)
  7467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. return
  7469. }
  7470. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7471. p, _ := service.GetHisPatientById(patient_id)
  7472. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7473. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7474. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7475. resp, requestErr := http.Get(api)
  7476. if requestErr != nil {
  7477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7478. return
  7479. }
  7480. body, ioErr := ioutil.ReadAll(resp.Body)
  7481. if ioErr != nil {
  7482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7484. return
  7485. }
  7486. var respJSON map[string]interface{}
  7487. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7490. return
  7491. }
  7492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7493. result, _ := json.Marshal(respJSON)
  7494. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7495. utils.ErrorLog("解析失败:%v", err)
  7496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7497. return
  7498. }
  7499. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7500. p, _ := service.GetHisPatientById(patient_id)
  7501. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7502. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7503. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7504. resp, requestErr := http.Get(api)
  7505. if requestErr != nil {
  7506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7507. return
  7508. }
  7509. body, ioErr := ioutil.ReadAll(resp.Body)
  7510. if ioErr != nil {
  7511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7513. return
  7514. }
  7515. var respJSON map[string]interface{}
  7516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7519. return
  7520. }
  7521. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7522. result, _ := json.Marshal(respJSON)
  7523. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7524. utils.ErrorLog("解析失败:%v", err)
  7525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7526. return
  7527. }
  7528. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7529. p, _ := service.GetHisPatientById(patient_id)
  7530. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7531. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7532. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7533. resp, requestErr := http.Get(api)
  7534. if requestErr != nil {
  7535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7536. return
  7537. }
  7538. body, ioErr := ioutil.ReadAll(resp.Body)
  7539. if ioErr != nil {
  7540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7542. return
  7543. }
  7544. var respJSON map[string]interface{}
  7545. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7548. return
  7549. }
  7550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7551. result, _ := json.Marshal(respJSON)
  7552. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7553. utils.ErrorLog("解析失败:%v", err)
  7554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7555. return
  7556. }
  7557. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7558. p, _ := service.GetHisPatientById(patient_id)
  7559. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7560. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7561. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7562. resp, requestErr := http.Get(api)
  7563. if requestErr != nil {
  7564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7565. return
  7566. }
  7567. body, ioErr := ioutil.ReadAll(resp.Body)
  7568. if ioErr != nil {
  7569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7571. return
  7572. }
  7573. var respJSON map[string]interface{}
  7574. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7577. return
  7578. }
  7579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7580. result, _ := json.Marshal(respJSON)
  7581. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7582. utils.ErrorLog("解析失败:%v", err)
  7583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7584. return
  7585. }
  7586. } else {
  7587. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7588. var dat map[string]interface{}
  7589. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7590. fmt.Println(dat)
  7591. } else {
  7592. fmt.Println(err)
  7593. }
  7594. userJSONBytes, _ := json.Marshal(dat)
  7595. if miConfig.Code == "H15049901371" {
  7596. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7597. utils.ErrorLog("解析失败:%v", err)
  7598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7599. return
  7600. }
  7601. res.InfRefmsgid = res10265.InfRefmsgid
  7602. res.Output = res10265.Output
  7603. res.ErrMsg = res10265.ErrMsg
  7604. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7605. res.Infcode = infocode
  7606. } else {
  7607. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7608. utils.ErrorLog("解析失败:%v", err)
  7609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7610. return
  7611. }
  7612. }
  7613. }
  7614. if res.Infcode == 0 {
  7615. c.ServeSuccessJSON(map[string]interface{}{
  7616. "result": res.Output.Result,
  7617. })
  7618. }
  7619. }
  7620. func (c *HisApiController) CheckInsutype() {
  7621. his_patient_id, _ := c.GetInt64("his_patient_id")
  7622. admin_user_id, _ := c.GetInt64("admin_user_id")
  7623. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7624. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7625. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7626. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7627. var dat map[string]interface{}
  7628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7629. fmt.Println(dat)
  7630. } else {
  7631. fmt.Println(err)
  7632. }
  7633. userJSONBytes, _ := json.Marshal(dat)
  7634. var res Result90100
  7635. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7636. utils.ErrorLog("解析失败:%v", err)
  7637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7638. return
  7639. }
  7640. if res.Infcode != 0 {
  7641. c.ServeSuccessJSON(map[string]interface{}{
  7642. "failed_code": -10,
  7643. "msg": res.ErrMsg,
  7644. })
  7645. return
  7646. } else {
  7647. fmt.Println(res)
  7648. }
  7649. }
  7650. func (c *HisApiController) CheckCardPWD() {
  7651. card_pwd := c.GetString("card_pwd")
  7652. his_patient_id, _ := c.GetInt64("his_patient_id")
  7653. admin_user_id, _ := c.GetInt64("admin_user_id")
  7654. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7655. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7656. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7657. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7658. bas := strings.Split(psn.CardInfo, "|")
  7659. basNumber := bas[2]
  7660. if psn.InsuplcAdmdvs[:4] == "4403" {
  7661. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7662. var dat map[string]interface{}
  7663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7664. fmt.Println(dat)
  7665. } else {
  7666. fmt.Println(err)
  7667. }
  7668. userJSONBytes, _ := json.Marshal(dat)
  7669. var res Result90991
  7670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7671. utils.ErrorLog("解析失败:%v", err)
  7672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7673. return
  7674. }
  7675. if res.Infcode != 0 {
  7676. c.ServeSuccessJSON(map[string]interface{}{
  7677. "failed_code": -10,
  7678. "msg": res.ErrMsg,
  7679. })
  7680. return
  7681. } else {
  7682. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7683. var msg string
  7684. switch res.Output.Result.CardStat {
  7685. case "00":
  7686. msg = "未激活"
  7687. break
  7688. case "10":
  7689. msg = "激活"
  7690. break
  7691. case "20":
  7692. msg = "窗口挂失"
  7693. break
  7694. case "21":
  7695. msg = "电话挂失"
  7696. break
  7697. case "22":
  7698. msg = "单位网上申报挂失"
  7699. break
  7700. case "23":
  7701. msg = "保健办挂失"
  7702. break
  7703. case "24":
  7704. msg = "个人网上挂失"
  7705. break
  7706. case "25":
  7707. msg = "网上服务大厅挂失"
  7708. break
  7709. case "30":
  7710. msg = "注销"
  7711. break
  7712. case "40":
  7713. msg = "回收"
  7714. break
  7715. case "99":
  7716. msg = "制卡中(无效卡)"
  7717. break
  7718. }
  7719. c.ServeSuccessJSON(map[string]interface{}{
  7720. "failed_code": -10,
  7721. "msg": msg,
  7722. })
  7723. return
  7724. } else {
  7725. c.ServeSuccessJSON(map[string]interface{}{
  7726. "msg": "校验成功",
  7727. })
  7728. return
  7729. }
  7730. }
  7731. } else {
  7732. c.ServeSuccessJSON(map[string]interface{}{
  7733. "msg": "校验成功",
  7734. })
  7735. return
  7736. }
  7737. }
  7738. func (c *HisApiController) CheckCardPWDTwo() {
  7739. //card_pwd := c.GetString("card_pwd")
  7740. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7741. admin_user_id, _ := c.GetInt64("admin_user_id")
  7742. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7743. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7744. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7745. var dat map[string]interface{}
  7746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7747. fmt.Println(dat)
  7748. } else {
  7749. fmt.Println(err)
  7750. }
  7751. userJSONBytes, _ := json.Marshal(dat)
  7752. var res Result90991
  7753. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7754. utils.ErrorLog("解析失败:%v", err)
  7755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7756. return
  7757. }
  7758. if res.Infcode != 0 {
  7759. c.ServeSuccessJSON(map[string]interface{}{
  7760. "failed_code": -10,
  7761. "msg": res.ErrMsg,
  7762. })
  7763. return
  7764. } else {
  7765. if res.Output.Result.SscnoCheckStat == "0" {
  7766. var msg string
  7767. switch res.Output.Result.CardStat {
  7768. case "00":
  7769. msg = "未激活"
  7770. break
  7771. case "10":
  7772. msg = "激活"
  7773. break
  7774. case "20":
  7775. msg = "窗口挂失"
  7776. break
  7777. case "21":
  7778. msg = "电话挂失"
  7779. break
  7780. case "22":
  7781. msg = "单位网上申报挂失"
  7782. break
  7783. case "23":
  7784. msg = "保健办挂失"
  7785. break
  7786. case "24":
  7787. msg = "个人网上挂失"
  7788. break
  7789. case "25":
  7790. msg = "网上服务大厅挂失"
  7791. break
  7792. case "30":
  7793. msg = "注销"
  7794. break
  7795. case "40":
  7796. msg = "回收"
  7797. break
  7798. case "99":
  7799. msg = "制卡中(无效卡)"
  7800. break
  7801. }
  7802. c.ServeSuccessJSON(map[string]interface{}{
  7803. "failed_code": -10,
  7804. "msg": msg,
  7805. })
  7806. return
  7807. } else {
  7808. c.ServeSuccessJSON(map[string]interface{}{
  7809. "msg": "校验成功",
  7810. })
  7811. return
  7812. }
  7813. }
  7814. }
  7815. type ELeCertData struct {
  7816. Data struct {
  7817. Extra string `json:"extra"`
  7818. IDNo string `json:"idNo"`
  7819. IDType string `json:"idType"`
  7820. EcToken string `json:"ecToken"`
  7821. InsuOrg string `json:"insuOrg"`
  7822. UserName string `json:"userName"`
  7823. EcIndexNo string `json:"ecIndexNo"`
  7824. Gender string `json:"gender"`
  7825. Birthday string `json:"birthday"`
  7826. Nationality string `json:"nationality"`
  7827. Email string `json:"email"`
  7828. } `json:"OutData"`
  7829. }
  7830. func (c *HisApiController) ReadCard() {
  7831. id_card_type, _ := c.GetInt64("id_card_type")
  7832. admin_user_id, _ := c.GetInt64("admin_user_id")
  7833. certificates, _ := c.GetInt64("certificates")
  7834. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7835. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7836. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7837. switch id_card_type {
  7838. case 1:
  7839. if miConfig.MdtrtareaAdmvs == "421300" {
  7840. var res ResultTwo
  7841. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7842. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7843. "&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)
  7844. resp, requestErr := http.Get(api)
  7845. if requestErr != nil {
  7846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7847. return
  7848. }
  7849. body, ioErr := ioutil.ReadAll(resp.Body)
  7850. if ioErr != nil {
  7851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7853. return
  7854. }
  7855. var respJSON map[string]interface{}
  7856. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7859. return
  7860. }
  7861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7862. result, _ := json.Marshal(respJSON)
  7863. fmt.Println("log")
  7864. fmt.Println(string(result))
  7865. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7866. utils.ErrorLog("解析失败:%v", err)
  7867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7868. return
  7869. }
  7870. if res.Infcode == 0 {
  7871. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7872. if err == gorm.ErrRecordNotFound {
  7873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7874. return
  7875. } else if err != nil {
  7876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7877. return
  7878. } else {
  7879. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7880. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7881. infoStr := string(Iinfos)
  7882. idetinfoStr := string(Idetinfos)
  7883. var rf []*ResultFive
  7884. json.Unmarshal([]byte(infoStr), &rf)
  7885. var insutypes []*ResultFive
  7886. var insutype string
  7887. var is390 int = 0
  7888. var is310 int = 0
  7889. for _, item := range rf {
  7890. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7891. insutypes = append(insutypes, item)
  7892. }
  7893. }
  7894. if len(insutypes) == 1 {
  7895. insutype = insutypes[0].Insutype
  7896. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7897. } else {
  7898. for _, i := range insutypes {
  7899. if i.Insutype == "390" {
  7900. is390 = 1
  7901. }
  7902. if i.Insutype == "310" {
  7903. is310 = 1
  7904. }
  7905. }
  7906. }
  7907. if is390 == 1 {
  7908. insutype = "390"
  7909. }
  7910. if is310 == 1 {
  7911. insutype = "310"
  7912. }
  7913. if len(insutypes) == 0 {
  7914. insutype = "390"
  7915. }
  7916. var insuplc_admdvs string
  7917. for _, item := range rf {
  7918. if item.Insutype == insutype {
  7919. insuplc_admdvs = item.InsuplcAdmdvs
  7920. }
  7921. }
  7922. if strings.Contains(insuplc_admdvs, "4213") {
  7923. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7924. }
  7925. psn := &models.HisPsn{
  7926. PsnNo: res.Output.Baseinfo.PsnNo,
  7927. PatientId: patient.ID,
  7928. Certno: res.Output.Baseinfo.Certno,
  7929. Gend: res.Output.Baseinfo.Gend,
  7930. Naty: res.Output.Baseinfo.Naty,
  7931. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7932. PsnName: res.Output.Baseinfo.PsnName,
  7933. Idetinfo: idetinfoStr,
  7934. Insuinfo: infoStr,
  7935. InsuplcAdmdvs: insuplc_admdvs,
  7936. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7937. }
  7938. service.CreateHisPsn(psn)
  7939. c.ServeSuccessJSON(map[string]interface{}{
  7940. "patient": patient,
  7941. "number": res.Output.Baseinfo.Certno,
  7942. })
  7943. }
  7944. } else {
  7945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7946. return
  7947. }
  7948. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7949. var res ResultTwo
  7950. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7951. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7952. "&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)
  7953. resp, requestErr := http.Get(api)
  7954. if requestErr != nil {
  7955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7956. return
  7957. }
  7958. body, ioErr := ioutil.ReadAll(resp.Body)
  7959. if ioErr != nil {
  7960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7962. return
  7963. }
  7964. var respJSON map[string]interface{}
  7965. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7968. return
  7969. }
  7970. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7971. result, _ := json.Marshal(respJSON)
  7972. fmt.Println("log")
  7973. fmt.Println(string(result))
  7974. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7975. utils.ErrorLog("解析失败:%v", err)
  7976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7977. return
  7978. }
  7979. if res.Infcode == 0 {
  7980. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7981. if err == gorm.ErrRecordNotFound {
  7982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7983. return
  7984. } else if err != nil {
  7985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7986. return
  7987. } else {
  7988. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7989. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7990. infoStr := string(Iinfos)
  7991. idetinfoStr := string(Idetinfos)
  7992. psn := &models.HisPsn{
  7993. PsnNo: res.Output.Baseinfo.PsnNo,
  7994. PatientId: patient.ID,
  7995. Certno: res.Output.Baseinfo.Certno,
  7996. Gend: res.Output.Baseinfo.Gend,
  7997. Naty: res.Output.Baseinfo.Naty,
  7998. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7999. PsnName: res.Output.Baseinfo.PsnName,
  8000. Idetinfo: idetinfoStr,
  8001. Insuinfo: infoStr,
  8002. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8003. }
  8004. service.CreateHisPsn(psn)
  8005. var rf []*ResultFive
  8006. json.Unmarshal([]byte(infoStr), &rf)
  8007. var insutypes []*ResultFive
  8008. var insutype string
  8009. var is390 int = 0
  8010. var is310 int = 0
  8011. for _, item := range rf {
  8012. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8013. insutypes = append(insutypes, item)
  8014. }
  8015. }
  8016. if len(insutypes) == 1 {
  8017. insutype = insutypes[0].Insutype
  8018. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8019. } else {
  8020. for _, i := range insutypes {
  8021. if i.Insutype == "390" {
  8022. is390 = 1
  8023. }
  8024. if i.Insutype == "310" {
  8025. is310 = 1
  8026. }
  8027. }
  8028. }
  8029. if is390 == 1 {
  8030. insutype = "390"
  8031. }
  8032. if is310 == 1 {
  8033. insutype = "310"
  8034. }
  8035. if len(insutypes) == 0 {
  8036. insutype = "310"
  8037. }
  8038. c.ServeSuccessJSON(map[string]interface{}{
  8039. "patient": patient,
  8040. "number": res.Output.Baseinfo.Certno,
  8041. "insutype": insutype,
  8042. })
  8043. }
  8044. } else {
  8045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8046. return
  8047. }
  8048. } else if miConfig.MdtrtareaAdmvs == "420902" {
  8049. var res ResultTwo
  8050. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  8051. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8052. "&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)
  8053. resp, requestErr := http.Get(api)
  8054. if requestErr != nil {
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. return
  8057. }
  8058. body, ioErr := ioutil.ReadAll(resp.Body)
  8059. if ioErr != nil {
  8060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8062. return
  8063. }
  8064. var respJSON map[string]interface{}
  8065. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8068. return
  8069. }
  8070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8071. result, _ := json.Marshal(respJSON)
  8072. fmt.Println("log")
  8073. fmt.Println(string(result))
  8074. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8075. utils.ErrorLog("解析失败:%v", err)
  8076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8077. return
  8078. }
  8079. if res.Infcode == 0 {
  8080. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8081. if err == gorm.ErrRecordNotFound {
  8082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8083. return
  8084. } else if err != nil {
  8085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8086. return
  8087. } else {
  8088. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8089. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8090. infoStr := string(Iinfos)
  8091. idetinfoStr := string(Idetinfos)
  8092. var rf []*ResultFive
  8093. json.Unmarshal([]byte(infoStr), &rf)
  8094. var insutypes []*ResultFive
  8095. var insutype string
  8096. var is390 int = 0
  8097. var is310 int = 0
  8098. for _, item := range rf {
  8099. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8100. insutypes = append(insutypes, item)
  8101. }
  8102. }
  8103. if len(insutypes) == 1 {
  8104. insutype = insutypes[0].Insutype
  8105. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8106. } else {
  8107. for _, i := range insutypes {
  8108. if i.Insutype == "390" {
  8109. is390 = 1
  8110. }
  8111. if i.Insutype == "310" {
  8112. is310 = 1
  8113. }
  8114. }
  8115. }
  8116. if is390 == 1 {
  8117. insutype = "390"
  8118. }
  8119. if is310 == 1 {
  8120. insutype = "310"
  8121. }
  8122. if len(insutypes) == 0 {
  8123. insutype = "390"
  8124. }
  8125. var insuplc_admdvs string
  8126. for _, item := range rf {
  8127. if item.Insutype == insutype {
  8128. insuplc_admdvs = item.InsuplcAdmdvs
  8129. }
  8130. }
  8131. psn := &models.HisPsn{
  8132. PsnNo: res.Output.Baseinfo.PsnNo,
  8133. PatientId: patient.ID,
  8134. Certno: res.Output.Baseinfo.Certno,
  8135. Gend: res.Output.Baseinfo.Gend,
  8136. Naty: res.Output.Baseinfo.Naty,
  8137. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8138. PsnName: res.Output.Baseinfo.PsnName,
  8139. Idetinfo: idetinfoStr,
  8140. Insuinfo: infoStr,
  8141. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8142. InsuplcAdmdvs: insuplc_admdvs,
  8143. }
  8144. service.CreateHisPsn(psn)
  8145. for _, item := range rf {
  8146. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8147. insutypes = append(insutypes, item)
  8148. }
  8149. }
  8150. if len(insutypes) == 1 {
  8151. insutype = insutypes[0].Insutype
  8152. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8153. } else {
  8154. for _, i := range insutypes {
  8155. if i.Insutype == "390" {
  8156. is390 = 1
  8157. }
  8158. if i.Insutype == "310" {
  8159. is310 = 1
  8160. }
  8161. }
  8162. }
  8163. if is390 == 1 {
  8164. insutype = "390"
  8165. }
  8166. if is310 == 1 {
  8167. insutype = "310"
  8168. }
  8169. if len(insutypes) == 0 {
  8170. insutype = "310"
  8171. }
  8172. c.ServeSuccessJSON(map[string]interface{}{
  8173. "patient": patient,
  8174. "number": res.Output.Baseinfo.Certno,
  8175. "insutype": insutype,
  8176. })
  8177. }
  8178. } else {
  8179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8180. return
  8181. }
  8182. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8183. var res ResultTwo
  8184. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  8185. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8186. "&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)
  8187. resp, requestErr := http.Get(api)
  8188. if requestErr != nil {
  8189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8190. return
  8191. }
  8192. body, ioErr := ioutil.ReadAll(resp.Body)
  8193. if ioErr != nil {
  8194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8196. return
  8197. }
  8198. var respJSON map[string]interface{}
  8199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8202. return
  8203. }
  8204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8205. result, _ := json.Marshal(respJSON)
  8206. fmt.Println("log")
  8207. fmt.Println(string(result))
  8208. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8209. utils.ErrorLog("解析失败:%v", err)
  8210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8211. return
  8212. }
  8213. if res.Infcode == 0 {
  8214. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8215. if err == gorm.ErrRecordNotFound {
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8217. return
  8218. } else if err != nil {
  8219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8220. return
  8221. } else {
  8222. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8223. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8224. infoStr := string(Iinfos)
  8225. idetinfoStr := string(Idetinfos)
  8226. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8227. psn := &models.HisPsn{
  8228. PsnNo: res.Output.Baseinfo.PsnNo,
  8229. PatientId: patient.ID,
  8230. Certno: res.Output.Baseinfo.Certno,
  8231. Brdy: b,
  8232. Age: float64(age),
  8233. Gend: res.Output.Baseinfo.Gend,
  8234. Naty: res.Output.Baseinfo.Naty,
  8235. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8236. PsnName: res.Output.Baseinfo.PsnName,
  8237. Idetinfo: idetinfoStr,
  8238. Insuinfo: infoStr,
  8239. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8240. }
  8241. service.CreateHisPsn(psn)
  8242. var rf []*ResultFive
  8243. json.Unmarshal([]byte(infoStr), &rf)
  8244. var insutypes []*ResultFive
  8245. var insutype string
  8246. var is390 int = 0
  8247. var is310 int = 0
  8248. for _, item := range rf {
  8249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8250. insutypes = append(insutypes, item)
  8251. }
  8252. }
  8253. if len(insutypes) == 1 {
  8254. insutype = insutypes[0].Insutype
  8255. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8256. } else {
  8257. for _, i := range insutypes {
  8258. if i.Insutype == "390" {
  8259. is390 = 1
  8260. }
  8261. if i.Insutype == "310" {
  8262. is310 = 1
  8263. }
  8264. }
  8265. }
  8266. if is390 == 1 {
  8267. insutype = "390"
  8268. }
  8269. if is310 == 1 {
  8270. insutype = "310"
  8271. }
  8272. if len(insutypes) == 0 {
  8273. insutype = "310"
  8274. }
  8275. c.ServeSuccessJSON(map[string]interface{}{
  8276. "patient": patient,
  8277. "number": res.Output.Baseinfo.Certno,
  8278. "insutype": insutype,
  8279. })
  8280. }
  8281. } else {
  8282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8283. return
  8284. }
  8285. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8286. var api string
  8287. if miConfig.MdtrtareaAdmvs == "320921" {
  8288. 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 +
  8289. "&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
  8290. fmt.Println(api)
  8291. } else {
  8292. 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 +
  8293. "&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)
  8294. }
  8295. resp, requestErr := http.Get(api)
  8296. if requestErr != nil {
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8298. return
  8299. }
  8300. body, ioErr := ioutil.ReadAll(resp.Body)
  8301. if ioErr != nil {
  8302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8304. return
  8305. }
  8306. var respJSON map[string]interface{}
  8307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8310. return
  8311. }
  8312. var status string
  8313. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8314. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8315. //console.log()
  8316. fmt.Println("type===")
  8317. fmt.Println(card_type)
  8318. var token string
  8319. var res ResultTwo //1101结果
  8320. var res10265 ResultTwo10265 //1101结果
  8321. var card_info string //卡信息
  8322. var busi_card_info string
  8323. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8324. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8325. if status == "0" { //读卡成功
  8326. if card_type == "1" {
  8327. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8328. result, _ := json.Marshal(respJSON)
  8329. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8330. utils.ErrorLog("解析失败:%v", err)
  8331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8332. return
  8333. }
  8334. res.ErrMsg = res10265.ErrMsg
  8335. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8336. res.Infcode = infocode
  8337. res.Output = res10265.Output
  8338. res.InfRefmsgid = res10265.InfRefmsgid
  8339. } else {
  8340. //var card_info string //卡信息
  8341. //var busi_card_info string
  8342. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8343. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8344. //fmt.Println(card_info)
  8345. //fmt.Println(busi_card_info)
  8346. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8347. result, _ := json.Marshal(respJSON)
  8348. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8349. utils.ErrorLog("解析失败:%v", err)
  8350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8351. return
  8352. }
  8353. res.ErrMsg = res10265.ErrMsg
  8354. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8355. res.Infcode = infocode
  8356. res.Output = res10265.Output
  8357. res.InfRefmsgid = res10265.InfRefmsgid
  8358. }
  8359. if res.Infcode == 0 {
  8360. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8361. if err == gorm.ErrRecordNotFound {
  8362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8363. return
  8364. } else if err != nil {
  8365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8366. return
  8367. } else {
  8368. if card_type == "1" {
  8369. bas := strings.Split(card_info, "|")
  8370. basNumber := bas[2]
  8371. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8372. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8373. infoStr := string(Iinfos)
  8374. idetinfoStr := string(Idetinfos)
  8375. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8376. psn := &models.HisPsn{
  8377. PsnNo: res.Output.Baseinfo.PsnNo,
  8378. PatientId: patient.ID,
  8379. Certno: res.Output.Baseinfo.Certno,
  8380. Brdy: b,
  8381. Age: float64(age),
  8382. Gend: res.Output.Baseinfo.Gend,
  8383. Naty: res.Output.Baseinfo.Naty,
  8384. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8385. PsnName: res.Output.Baseinfo.PsnName,
  8386. Idetinfo: idetinfoStr,
  8387. Insuinfo: infoStr,
  8388. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8389. CardInfo: card_info,
  8390. VerifyNumber: busi_card_info,
  8391. }
  8392. service.CreateHisPsn(psn)
  8393. var rf []*ResultFive
  8394. json.Unmarshal([]byte(infoStr), &rf)
  8395. var insutypes []*ResultFive
  8396. var insutype string
  8397. var is390 int = 0
  8398. var is310 int = 0
  8399. for _, item := range rf {
  8400. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8401. insutypes = append(insutypes, item)
  8402. }
  8403. }
  8404. if len(insutypes) == 1 {
  8405. insutype = insutypes[0].Insutype
  8406. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8407. } else {
  8408. for _, i := range insutypes {
  8409. if i.Insutype == "390" {
  8410. is390 = 1
  8411. }
  8412. if i.Insutype == "310" {
  8413. is310 = 1
  8414. }
  8415. }
  8416. }
  8417. if is390 == 1 {
  8418. insutype = "390"
  8419. }
  8420. if is310 == 1 {
  8421. insutype = "310"
  8422. }
  8423. if len(insutypes) == 0 {
  8424. insutype = "310"
  8425. }
  8426. c.ServeSuccessJSON(map[string]interface{}{
  8427. "patient": patient,
  8428. "number": basNumber,
  8429. "insutype": insutype,
  8430. })
  8431. } else {
  8432. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8433. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8434. infoStr := string(Iinfos)
  8435. idetinfoStr := string(Idetinfos)
  8436. psn := &models.HisPsn{
  8437. PsnNo: res.Output.Baseinfo.PsnNo,
  8438. PatientId: patient.ID,
  8439. Certno: res.Output.Baseinfo.Certno,
  8440. Gend: res.Output.Baseinfo.Gend,
  8441. Naty: res.Output.Baseinfo.Naty,
  8442. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8443. PsnName: res.Output.Baseinfo.PsnName,
  8444. Idetinfo: idetinfoStr,
  8445. Insuinfo: infoStr,
  8446. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8447. CardInfo: card_info,
  8448. VerifyNumber: token,
  8449. }
  8450. service.CreateHisPsn(psn)
  8451. c.ServeSuccessJSON(map[string]interface{}{
  8452. "patient": patient,
  8453. "number": token,
  8454. })
  8455. }
  8456. }
  8457. } else {
  8458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8459. return
  8460. }
  8461. } else { //读卡失败
  8462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8463. return
  8464. }
  8465. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8466. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  8467. cardnum = DeleteExtraSpaceTwo(cardnum)
  8468. cardCode = DeleteExtraSpaceTwo(cardCode)
  8469. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  8470. name = DeleteExtraSpaceTwo(name)
  8471. errmsg = DeleteExtraSpaceTwo(errmsg)
  8472. cardnum = Remove0000(cardnum)
  8473. cardCode = Remove0000(cardCode)
  8474. id_card_no = Remove0000(id_card_no)
  8475. name = Remove0000(name)
  8476. errmsg = Remove0000(errmsg)
  8477. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  8478. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  8479. //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)
  8480. //fmt.Println(result2)
  8481. //fmt.Println(requestLog2)
  8482. //fmt.Println(errMsgLog2)
  8483. 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)
  8484. saveLog(result, requestLog, "1101", "获取人员信息")
  8485. fmt.Println(errMsgLog)
  8486. if len(errMsgLog) > 0 {
  8487. } else {
  8488. var dat map[string]interface{}
  8489. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8490. fmt.Println(dat)
  8491. } else {
  8492. fmt.Println(err)
  8493. }
  8494. userJSONBytes, _ := json.Marshal(dat)
  8495. var res ResultTwo
  8496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8497. utils.ErrorLog("解析失败:%v", err)
  8498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8499. return
  8500. }
  8501. res.ErrMsg = errMsgLog
  8502. if res.Infcode == 0 {
  8503. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8504. if err == gorm.ErrRecordNotFound {
  8505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8506. return
  8507. } else if err != nil {
  8508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8509. return
  8510. } else {
  8511. fmt.Println(res)
  8512. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8513. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8514. infoStr := string(Iinfos)
  8515. idetinfoStr := string(Idetinfos)
  8516. var rf []*ResultFive
  8517. json.Unmarshal([]byte(infoStr), &rf)
  8518. var insutypes []*ResultFive
  8519. var insutype string
  8520. var is390 int = 0
  8521. var is310 int = 0
  8522. for _, item := range rf {
  8523. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8524. insutypes = append(insutypes, item)
  8525. }
  8526. }
  8527. if len(insutypes) == 1 {
  8528. insutype = insutypes[0].Insutype
  8529. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8530. } else {
  8531. for _, i := range insutypes {
  8532. if i.Insutype == "390" {
  8533. is390 = 1
  8534. }
  8535. if i.Insutype == "310" {
  8536. is310 = 1
  8537. }
  8538. }
  8539. }
  8540. if is390 == 1 {
  8541. insutype = "390"
  8542. }
  8543. if is310 == 1 {
  8544. insutype = "310"
  8545. }
  8546. if len(insutypes) == 0 {
  8547. insutype = "390"
  8548. }
  8549. var insuplc_admdvs string
  8550. for _, item := range rf {
  8551. if item.Insutype == insutype {
  8552. insuplc_admdvs = item.InsuplcAdmdvs
  8553. }
  8554. }
  8555. psn := &models.HisPsn{
  8556. PsnNo: res.Output.Baseinfo.PsnNo,
  8557. PatientId: patient.ID,
  8558. Certno: res.Output.Baseinfo.Certno,
  8559. Gend: res.Output.Baseinfo.Gend,
  8560. Naty: res.Output.Baseinfo.Naty,
  8561. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8562. PsnName: res.Output.Baseinfo.PsnName,
  8563. Idetinfo: idetinfoStr,
  8564. Insuinfo: infoStr,
  8565. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8566. CardInfo: basStr,
  8567. VerifyNumber: "",
  8568. InsuplcAdmdvs: insuplc_admdvs,
  8569. }
  8570. service.CreateHisPsn(psn)
  8571. c.ServeSuccessJSON(map[string]interface{}{
  8572. "patient": patient,
  8573. "number": cardnum,
  8574. "insutype": insutype,
  8575. })
  8576. }
  8577. } else {
  8578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8579. return
  8580. }
  8581. }
  8582. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8583. fmt.Println(initFlag)
  8584. fmt.Println("initFlag")
  8585. if initFlag == 0 {
  8586. c.TestGetJiangXiBasBaseInit()
  8587. }
  8588. basStr := c.GetBasBaseInfo()
  8589. if len(basStr) == 0 {
  8590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8591. return
  8592. }
  8593. fmt.Println(basStr)
  8594. bas := strings.Split(basStr, "|")
  8595. basNumber := bas[1]
  8596. fmt.Println(basNumber)
  8597. card_sn := bas[3]
  8598. fmt.Println(card_sn)
  8599. 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, "")
  8600. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8601. var dat map[string]interface{}
  8602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8603. fmt.Println(dat)
  8604. } else {
  8605. fmt.Println(err)
  8606. }
  8607. userJSONBytes, _ := json.Marshal(dat)
  8608. var res ResultTwo
  8609. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8610. utils.ErrorLog("解析失败:%v", err)
  8611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8612. return
  8613. }
  8614. if res.Infcode == 0 {
  8615. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8616. if err == gorm.ErrRecordNotFound {
  8617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8618. return
  8619. } else if err != nil {
  8620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8621. return
  8622. } else {
  8623. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8624. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8625. infoStr := string(Iinfos)
  8626. idetinfoStr := string(Idetinfos)
  8627. var rf []*ResultFive
  8628. json.Unmarshal([]byte(infoStr), &rf)
  8629. var insutypes []*ResultFive
  8630. var insutype string
  8631. var is390 int = 0
  8632. var is310 int = 0
  8633. var insuplc_admdvs string
  8634. for _, item := range rf {
  8635. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8636. insutypes = append(insutypes, item)
  8637. }
  8638. }
  8639. if len(insutypes) == 1 {
  8640. insutype = insutypes[0].Insutype
  8641. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8642. } else {
  8643. for _, i := range insutypes {
  8644. if i.Insutype == "390" {
  8645. is390 = 1
  8646. }
  8647. if i.Insutype == "310" {
  8648. is310 = 1
  8649. }
  8650. }
  8651. }
  8652. if is390 == 1 {
  8653. insutype = "390"
  8654. }
  8655. if is310 == 1 {
  8656. insutype = "310"
  8657. }
  8658. if len(insutypes) == 0 {
  8659. insutype = "310"
  8660. }
  8661. for _, item := range rf {
  8662. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8663. insuplc_admdvs = item.InsuplcAdmdvs
  8664. }
  8665. }
  8666. psn := &models.HisPsn{
  8667. PsnNo: res.Output.Baseinfo.PsnNo,
  8668. PatientId: patient.ID,
  8669. Certno: res.Output.Baseinfo.Certno,
  8670. Gend: res.Output.Baseinfo.Gend,
  8671. Naty: res.Output.Baseinfo.Naty,
  8672. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8673. PsnName: res.Output.Baseinfo.PsnName,
  8674. Idetinfo: idetinfoStr,
  8675. Insuinfo: infoStr,
  8676. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8677. CardInfo: basStr,
  8678. InsuplcAdmdvs: insuplc_admdvs,
  8679. VerifyNumber: "",
  8680. }
  8681. service.CreateHisPsn(psn)
  8682. c.ServeSuccessJSON(map[string]interface{}{
  8683. "patient": patient,
  8684. "number": basNumber,
  8685. "insutype": insutype,
  8686. })
  8687. }
  8688. } else {
  8689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8690. return
  8691. }
  8692. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8693. fmt.Println(initFlag)
  8694. fmt.Println("initFlag")
  8695. if initFlag == 0 {
  8696. c.TestGetHnBasBaseInit()
  8697. }
  8698. basStr := c.GetBasBaseInfo()
  8699. if len(basStr) == 0 {
  8700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8701. return
  8702. }
  8703. fmt.Println(basStr)
  8704. bas := strings.Split(basStr, "|")
  8705. basNumber := bas[1]
  8706. fmt.Println(basNumber)
  8707. card_sn := bas[3]
  8708. card_no := bas[2]
  8709. fmt.Println(card_sn)
  8710. name := bas[4]
  8711. name = ConvertToString(name, "gbk", "utf-8")
  8712. 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)
  8713. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8714. var dat map[string]interface{}
  8715. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8716. fmt.Println(dat)
  8717. } else {
  8718. fmt.Println(err)
  8719. }
  8720. userJSONBytes, _ := json.Marshal(dat)
  8721. var res ResultTwo
  8722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8723. utils.ErrorLog("解析失败:%v", err)
  8724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8725. return
  8726. }
  8727. if res.Infcode == 0 {
  8728. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8729. if err == gorm.ErrRecordNotFound {
  8730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8731. return
  8732. } else if err != nil {
  8733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8734. return
  8735. } else {
  8736. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8737. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8738. infoStr := string(Iinfos)
  8739. idetinfoStr := string(Idetinfos)
  8740. psn := &models.HisPsn{
  8741. PsnNo: res.Output.Baseinfo.PsnNo,
  8742. PatientId: patient.ID,
  8743. Certno: res.Output.Baseinfo.Certno,
  8744. Gend: res.Output.Baseinfo.Gend,
  8745. Naty: res.Output.Baseinfo.Naty,
  8746. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8747. PsnName: res.Output.Baseinfo.PsnName,
  8748. Idetinfo: idetinfoStr,
  8749. Insuinfo: infoStr,
  8750. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8751. CardInfo: basStr,
  8752. VerifyNumber: "",
  8753. }
  8754. service.CreateHisPsn(psn)
  8755. var rf []*ResultFive
  8756. json.Unmarshal([]byte(infoStr), &rf)
  8757. var insutypes []*ResultFive
  8758. var insutype string
  8759. var is390 int = 0
  8760. var is310 int = 0
  8761. for _, item := range rf {
  8762. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8763. insutypes = append(insutypes, item)
  8764. }
  8765. }
  8766. if len(insutypes) == 1 {
  8767. insutype = insutypes[0].Insutype
  8768. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8769. } else {
  8770. for _, i := range insutypes {
  8771. if i.Insutype == "390" {
  8772. is390 = 1
  8773. }
  8774. if i.Insutype == "310" {
  8775. is310 = 1
  8776. }
  8777. }
  8778. }
  8779. if is390 == 1 {
  8780. insutype = "390"
  8781. }
  8782. if is310 == 1 {
  8783. insutype = "310"
  8784. }
  8785. if len(insutypes) == 0 {
  8786. insutype = "310"
  8787. }
  8788. c.ServeSuccessJSON(map[string]interface{}{
  8789. "patient": patient,
  8790. "number": basNumber,
  8791. "insutype": insutype,
  8792. })
  8793. }
  8794. } else {
  8795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8796. return
  8797. }
  8798. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8799. var api string
  8800. 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 +
  8801. "&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
  8802. fmt.Println(api)
  8803. resp, requestErr := http.Get(api)
  8804. if requestErr != nil {
  8805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8806. return
  8807. }
  8808. body, ioErr := ioutil.ReadAll(resp.Body)
  8809. if ioErr != nil {
  8810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8812. return
  8813. }
  8814. var respJSON map[string]interface{}
  8815. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8818. return
  8819. }
  8820. var res ResultTwo //1101结果
  8821. var res10265 ResultTwo10265 //1101结果
  8822. var card_info string //卡信息
  8823. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8824. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8825. result, _ := json.Marshal(respJSON)
  8826. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8827. utils.ErrorLog("解析失败:%v", err)
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8829. return
  8830. }
  8831. res.ErrMsg = res10265.ErrMsg
  8832. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8833. res.Infcode = infocode
  8834. res.Output = res10265.Output
  8835. res.InfRefmsgid = res10265.InfRefmsgid
  8836. if res.Infcode == 0 {
  8837. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8838. if err == gorm.ErrRecordNotFound {
  8839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8840. return
  8841. } else if err != nil {
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8843. return
  8844. } else {
  8845. bas := strings.Split(card_info, "|")
  8846. basNumber := bas[2]
  8847. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8848. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8849. infoStr := string(Iinfos)
  8850. idetinfoStr := string(Idetinfos)
  8851. psn := &models.HisPsn{
  8852. PsnNo: res.Output.Baseinfo.PsnNo,
  8853. PatientId: patient.ID,
  8854. Certno: res.Output.Baseinfo.Certno,
  8855. Gend: res.Output.Baseinfo.Gend,
  8856. Naty: res.Output.Baseinfo.Naty,
  8857. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8858. PsnName: res.Output.Baseinfo.PsnName,
  8859. Idetinfo: idetinfoStr,
  8860. Insuinfo: infoStr,
  8861. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8862. CardInfo: card_info,
  8863. VerifyNumber: token,
  8864. }
  8865. service.CreateHisPsn(psn)
  8866. var rf []*ResultFive
  8867. json.Unmarshal([]byte(infoStr), &rf)
  8868. var insutypes []*ResultFive
  8869. var insutype string
  8870. var is390 int = 0
  8871. var is310 int = 0
  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": basNumber,
  8902. "insutype": insutype,
  8903. })
  8904. }
  8905. } else {
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8907. return
  8908. }
  8909. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8910. res := c.GetoleInfo()
  8911. if res.Infcode == 0 {
  8912. var result string
  8913. if res.Output.MdtrtCertType == "01" {
  8914. 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)
  8915. } else if res.Output.MdtrtCertType == "02" {
  8916. 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)
  8917. } else if res.Output.MdtrtCertType == "03" {
  8918. 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)
  8919. }
  8920. var dat map[string]interface{}
  8921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8922. fmt.Println(dat)
  8923. } else {
  8924. fmt.Println(err)
  8925. }
  8926. userJSONBytes, _ := json.Marshal(dat)
  8927. var res2 ResultTwo
  8928. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8929. utils.ErrorLog("解析失败:%v", err)
  8930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8931. return
  8932. }
  8933. if res2.Infcode == 0 {
  8934. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8935. if err == gorm.ErrRecordNotFound {
  8936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8937. return
  8938. } else if err != nil {
  8939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8940. return
  8941. } else {
  8942. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8943. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8944. infoStr := string(Iinfos)
  8945. idetinfoStr := string(Idetinfos)
  8946. var rf []*ResultFive
  8947. json.Unmarshal([]byte(infoStr), &rf)
  8948. var insutypes []*ResultFive
  8949. var insutype string
  8950. var is390 int = 0
  8951. var is310 int = 0
  8952. //var insuplc_admdvs string
  8953. for _, item := range rf {
  8954. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8955. insutypes = append(insutypes, item)
  8956. }
  8957. }
  8958. if len(insutypes) == 1 {
  8959. insutype = insutypes[0].Insutype
  8960. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8961. } else {
  8962. for _, i := range insutypes {
  8963. if i.Insutype == "390" {
  8964. is390 = 1
  8965. }
  8966. if i.Insutype == "310" {
  8967. is310 = 1
  8968. }
  8969. }
  8970. }
  8971. if is390 == 1 {
  8972. insutype = "390"
  8973. }
  8974. if is310 == 1 {
  8975. insutype = "310"
  8976. }
  8977. if len(insutypes) == 0 {
  8978. insutype = "310"
  8979. }
  8980. psn := &models.HisPsn{
  8981. PsnNo: res2.Output.Baseinfo.PsnNo,
  8982. PatientId: patient.ID,
  8983. Certno: res2.Output.Baseinfo.Certno,
  8984. Gend: res2.Output.Baseinfo.Gend,
  8985. Naty: res2.Output.Baseinfo.Naty,
  8986. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8987. PsnName: res2.Output.Baseinfo.PsnName,
  8988. Idetinfo: idetinfoStr,
  8989. Insuinfo: infoStr,
  8990. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8991. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8992. VerifyNumber: res.Output.EcToken,
  8993. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8994. }
  8995. if res.Output.MdtrtCertType == "01" {
  8996. psn.VerifyNumber = res.Output.EcToken
  8997. //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)
  8998. } else if res.Output.MdtrtCertType == "02" {
  8999. psn.VerifyNumber = res.Output.MdtrtCertNo
  9000. //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)
  9001. } else if res.Output.MdtrtCertType == "03" {
  9002. psn.VerifyNumber = res.Output.MdtrtCertNo
  9003. //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)
  9004. }
  9005. var balc float64
  9006. for _, item := range rf {
  9007. if item.Insutype == insutype {
  9008. balc = item.Balc
  9009. }
  9010. }
  9011. service.CreateHisPsn(psn)
  9012. c.ServeSuccessJSON(map[string]interface{}{
  9013. "patient": patient,
  9014. "number": res.Output.CardNo,
  9015. "insutype": insutype,
  9016. "blac": balc,
  9017. "desc": idetinfoStr,
  9018. })
  9019. }
  9020. } else {
  9021. c.ServeSuccessJSON(map[string]interface{}{
  9022. "failed_code": -10,
  9023. "msg": res2.ErrMsg,
  9024. })
  9025. }
  9026. } else {
  9027. c.ServeSuccessJSON(map[string]interface{}{
  9028. "failed_code": -10,
  9029. "msg": res.ErrMsg,
  9030. })
  9031. }
  9032. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9033. var api string
  9034. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9035. "&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
  9036. fmt.Println(api)
  9037. resp, requestErr := http.Get(api)
  9038. if requestErr != nil {
  9039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9040. return
  9041. }
  9042. body, ioErr := ioutil.ReadAll(resp.Body)
  9043. if ioErr != nil {
  9044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9046. return
  9047. }
  9048. var respJSON map[string]interface{}
  9049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9052. return
  9053. }
  9054. var status string
  9055. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9056. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9057. //console.log()
  9058. fmt.Println("type===")
  9059. fmt.Println(card_type)
  9060. var token string
  9061. var res ResultTwo //1101结果
  9062. //var res10265 ResultTwoesultTwo10265 //1101结果
  9063. var card_info string //卡信息
  9064. var busi_card_info string
  9065. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9066. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9067. if status == "0" { //读卡成功
  9068. if card_type == "1" {
  9069. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9070. result, _ := json.Marshal(respJSON)
  9071. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9072. utils.ErrorLog("解析失败:%v", err)
  9073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9074. return
  9075. }
  9076. } else {
  9077. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9078. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9079. result, _ := json.Marshal(respJSON)
  9080. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9081. utils.ErrorLog("解析失败:%v", err)
  9082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9083. return
  9084. }
  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. psn := &models.HisPsn{
  9103. PsnNo: res.Output.Baseinfo.PsnNo,
  9104. PatientId: patient.ID,
  9105. Certno: res.Output.Baseinfo.Certno,
  9106. Gend: res.Output.Baseinfo.Gend,
  9107. Naty: res.Output.Baseinfo.Naty,
  9108. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9109. PsnName: res.Output.Baseinfo.PsnName,
  9110. Idetinfo: idetinfoStr,
  9111. Insuinfo: infoStr,
  9112. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9113. CardInfo: card_info,
  9114. VerifyNumber: busi_card_info,
  9115. }
  9116. service.CreateHisPsn(psn)
  9117. var rf []*ResultFive
  9118. json.Unmarshal([]byte(infoStr), &rf)
  9119. var insutypes []*ResultFive
  9120. var insutype string
  9121. var is390 int = 0
  9122. var is310 int = 0
  9123. for _, item := range rf {
  9124. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9125. insutypes = append(insutypes, item)
  9126. }
  9127. }
  9128. if len(insutypes) == 1 {
  9129. insutype = insutypes[0].Insutype
  9130. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9131. } else {
  9132. for _, i := range insutypes {
  9133. if i.Insutype == "390" {
  9134. is390 = 1
  9135. }
  9136. if i.Insutype == "310" {
  9137. is310 = 1
  9138. }
  9139. }
  9140. }
  9141. if is390 == 1 {
  9142. insutype = "390"
  9143. }
  9144. if is310 == 1 {
  9145. insutype = "310"
  9146. }
  9147. if len(insutypes) == 0 {
  9148. insutype = "310"
  9149. }
  9150. c.ServeSuccessJSON(map[string]interface{}{
  9151. "patient": patient,
  9152. "number": basNumber,
  9153. "insutype": insutype,
  9154. })
  9155. } else {
  9156. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9157. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9158. infoStr := string(Iinfos)
  9159. idetinfoStr := string(Idetinfos)
  9160. psn := &models.HisPsn{
  9161. PsnNo: res.Output.Baseinfo.PsnNo,
  9162. PatientId: patient.ID,
  9163. Certno: res.Output.Baseinfo.Certno,
  9164. Gend: res.Output.Baseinfo.Gend,
  9165. Naty: res.Output.Baseinfo.Naty,
  9166. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9167. PsnName: res.Output.Baseinfo.PsnName,
  9168. Idetinfo: idetinfoStr,
  9169. Insuinfo: infoStr,
  9170. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9171. CardInfo: card_info,
  9172. VerifyNumber: token,
  9173. }
  9174. service.CreateHisPsn(psn)
  9175. c.ServeSuccessJSON(map[string]interface{}{
  9176. "patient": patient,
  9177. "number": token,
  9178. })
  9179. }
  9180. }
  9181. } else {
  9182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9183. return
  9184. }
  9185. } else { //读卡失败
  9186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9187. return
  9188. }
  9189. } else {
  9190. if initFlag == 0 {
  9191. c.TestGetBasBaseInit()
  9192. }
  9193. basStr := c.GetBasBaseInfo()
  9194. if len(basStr) == 0 {
  9195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9196. return
  9197. }
  9198. fmt.Println(basStr)
  9199. bas := strings.Split(basStr, "|")
  9200. basNumber := bas[1]
  9201. fmt.Println(basNumber)
  9202. card_sn := bas[3]
  9203. fmt.Println(card_sn)
  9204. cardNumber := bas[2]
  9205. fmt.Println(cardNumber)
  9206. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  9207. var result string
  9208. if bas[0][:2] == "44" {
  9209. 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)
  9210. } else {
  9211. 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)
  9212. }
  9213. var dat map[string]interface{}
  9214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9215. fmt.Println(dat)
  9216. } else {
  9217. fmt.Println(err)
  9218. }
  9219. userJSONBytes, _ := json.Marshal(dat)
  9220. var res ResultTwo
  9221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9222. utils.ErrorLog("解析失败:%v", err)
  9223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9224. return
  9225. }
  9226. if res.Infcode == 0 {
  9227. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9228. if err == gorm.ErrRecordNotFound {
  9229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9230. return
  9231. } else if err != nil {
  9232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9233. return
  9234. } else {
  9235. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9236. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9237. infoStr := string(Iinfos)
  9238. idetinfoStr := string(Idetinfos)
  9239. var rf []*ResultFive
  9240. json.Unmarshal([]byte(infoStr), &rf)
  9241. var insutypes []*ResultFive
  9242. var insutype string
  9243. var is390 int = 0
  9244. var is310 int = 0
  9245. var insuplc_admdvs string
  9246. for _, item := range rf {
  9247. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9248. insutypes = append(insutypes, item)
  9249. }
  9250. }
  9251. if len(insutypes) == 1 {
  9252. insutype = insutypes[0].Insutype
  9253. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9254. } else {
  9255. for _, i := range insutypes {
  9256. if i.Insutype == "390" {
  9257. is390 = 1
  9258. }
  9259. if i.Insutype == "310" {
  9260. is310 = 1
  9261. }
  9262. }
  9263. }
  9264. if is390 == 1 {
  9265. insutype = "390"
  9266. }
  9267. if is310 == 1 {
  9268. insutype = "310"
  9269. }
  9270. if len(insutypes) == 0 {
  9271. insutype = "310"
  9272. }
  9273. for _, item := range rf {
  9274. if item.Insutype == insutype {
  9275. insuplc_admdvs = item.InsuplcAdmdvs
  9276. }
  9277. }
  9278. psn := &models.HisPsn{
  9279. PsnNo: res.Output.Baseinfo.PsnNo,
  9280. PatientId: patient.ID,
  9281. Certno: res.Output.Baseinfo.Certno,
  9282. Gend: res.Output.Baseinfo.Gend,
  9283. Naty: res.Output.Baseinfo.Naty,
  9284. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9285. PsnName: res.Output.Baseinfo.PsnName,
  9286. Idetinfo: idetinfoStr,
  9287. Insuinfo: infoStr,
  9288. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9289. CardInfo: basStr,
  9290. VerifyNumber: "",
  9291. InsuplcAdmdvs: insuplc_admdvs,
  9292. }
  9293. service.CreateHisPsn(psn)
  9294. c.ServeSuccessJSON(map[string]interface{}{
  9295. "patient": patient,
  9296. "number": basNumber,
  9297. })
  9298. }
  9299. } else {
  9300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9301. return
  9302. }
  9303. break
  9304. }
  9305. case 2:
  9306. if miConfig.MdtrtareaAdmvs == "430800" {
  9307. if initFlag == 0 {
  9308. c.TestGetHnBasBaseInit()
  9309. }
  9310. SFZStr := c.GetSFZBaseInfo()
  9311. if len(SFZStr) == 0 {
  9312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9313. return
  9314. }
  9315. fmt.Println(SFZStr)
  9316. id_card_str := strings.Split(SFZStr, "^")
  9317. card_no := id_card_str[0]
  9318. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9319. //name := id_card_str[1]
  9320. //name = ConvertToString(name, "gbk", "utf-8")
  9321. 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)
  9322. var dat map[string]interface{}
  9323. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9324. fmt.Println(dat)
  9325. } else {
  9326. fmt.Println(err)
  9327. }
  9328. userJSONBytes, _ := json.Marshal(dat)
  9329. var res ResultTwo
  9330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9331. utils.ErrorLog("解析失败:%v", err)
  9332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9333. return
  9334. }
  9335. if res.Infcode == 0 {
  9336. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9337. if err == gorm.ErrRecordNotFound {
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9339. return
  9340. } else if err != nil {
  9341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9342. return
  9343. } else {
  9344. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9345. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9346. infoStr := string(Iinfos)
  9347. idetinfoStr := string(Idetinfos)
  9348. var rf []*ResultFive
  9349. json.Unmarshal([]byte(infoStr), &rf)
  9350. var insutypes []*ResultFive
  9351. var insutype string
  9352. var is390 int = 0
  9353. var is310 int = 0
  9354. for _, item := range rf {
  9355. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9356. insutypes = append(insutypes, item)
  9357. }
  9358. }
  9359. if len(insutypes) == 1 {
  9360. insutype = insutypes[0].Insutype
  9361. } else {
  9362. for _, i := range insutypes {
  9363. if i.Insutype == "390" {
  9364. is390 = 1
  9365. }
  9366. if i.Insutype == "310" {
  9367. is310 = 1
  9368. }
  9369. }
  9370. }
  9371. if is390 == 1 {
  9372. insutype = "390"
  9373. }
  9374. if is310 == 1 {
  9375. insutype = "310"
  9376. }
  9377. if len(insutypes) == 0 {
  9378. insutype = "310"
  9379. }
  9380. var InsuplcAdmdvs string
  9381. for _, item := range rf {
  9382. if item.Insutype == insutype {
  9383. InsuplcAdmdvs = item.InsuplcAdmdvs
  9384. }
  9385. }
  9386. psn := &models.HisPsn{
  9387. PsnNo: res.Output.Baseinfo.PsnNo,
  9388. PatientId: patient.ID,
  9389. Certno: res.Output.Baseinfo.Certno,
  9390. Gend: res.Output.Baseinfo.Gend,
  9391. Naty: res.Output.Baseinfo.Naty,
  9392. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9393. PsnName: res.Output.Baseinfo.PsnName,
  9394. Idetinfo: idetinfoStr,
  9395. Insuinfo: infoStr,
  9396. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9397. CardInfo: SFZStr,
  9398. VerifyNumber: "",
  9399. InsuplcAdmdvs: InsuplcAdmdvs,
  9400. }
  9401. service.CreateHisPsn(psn)
  9402. c.ServeSuccessJSON(map[string]interface{}{
  9403. "patient": patient,
  9404. "number": card_no,
  9405. "insutype": insutype,
  9406. })
  9407. }
  9408. } else {
  9409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9410. return
  9411. }
  9412. } else if miConfig.MdtrtareaAdmvs == "420200" {
  9413. var res ResultTwo
  9414. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  9415. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9416. "&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)
  9417. resp, requestErr := http.Get(api)
  9418. if requestErr != nil {
  9419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9420. return
  9421. }
  9422. body, ioErr := ioutil.ReadAll(resp.Body)
  9423. if ioErr != nil {
  9424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9426. return
  9427. }
  9428. var respJSON map[string]interface{}
  9429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9432. return
  9433. }
  9434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9435. result, _ := json.Marshal(respJSON)
  9436. fmt.Println("log")
  9437. fmt.Println(string(result))
  9438. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9439. utils.ErrorLog("解析失败:%v", err)
  9440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9441. return
  9442. }
  9443. if res.Infcode == 0 {
  9444. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9445. if err == gorm.ErrRecordNotFound {
  9446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9447. return
  9448. } else if err != nil {
  9449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9450. return
  9451. } else {
  9452. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9453. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9454. infoStr := string(Iinfos)
  9455. idetinfoStr := string(Idetinfos)
  9456. psn := &models.HisPsn{
  9457. PsnNo: res.Output.Baseinfo.PsnNo,
  9458. PatientId: patient.ID,
  9459. Certno: res.Output.Baseinfo.Certno,
  9460. Gend: res.Output.Baseinfo.Gend,
  9461. Naty: res.Output.Baseinfo.Naty,
  9462. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9463. PsnName: res.Output.Baseinfo.PsnName,
  9464. Idetinfo: idetinfoStr,
  9465. Insuinfo: infoStr,
  9466. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9467. }
  9468. service.CreateHisPsn(psn)
  9469. c.ServeSuccessJSON(map[string]interface{}{
  9470. "patient": patient,
  9471. "number": res.Output.Baseinfo.Certno,
  9472. })
  9473. }
  9474. } else {
  9475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9476. return
  9477. }
  9478. } else if miConfig.MdtrtareaAdmvs == "421182" {
  9479. var res ResultTwo
  9480. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9481. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9482. "&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)
  9483. resp, requestErr := http.Get(api)
  9484. if requestErr != nil {
  9485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9486. return
  9487. }
  9488. body, ioErr := ioutil.ReadAll(resp.Body)
  9489. if ioErr != nil {
  9490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9492. return
  9493. }
  9494. var respJSON map[string]interface{}
  9495. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9498. return
  9499. }
  9500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9501. result, _ := json.Marshal(respJSON)
  9502. fmt.Println("log")
  9503. fmt.Println(string(result))
  9504. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9505. utils.ErrorLog("解析失败:%v", err)
  9506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9507. return
  9508. }
  9509. if res.Infcode == 0 {
  9510. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9511. if err == gorm.ErrRecordNotFound {
  9512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9513. return
  9514. } else if err != nil {
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9516. return
  9517. } else {
  9518. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9519. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9520. infoStr := string(Iinfos)
  9521. idetinfoStr := string(Idetinfos)
  9522. psn := &models.HisPsn{
  9523. PsnNo: res.Output.Baseinfo.PsnNo,
  9524. PatientId: patient.ID,
  9525. Certno: res.Output.Baseinfo.Certno,
  9526. Gend: res.Output.Baseinfo.Gend,
  9527. Naty: res.Output.Baseinfo.Naty,
  9528. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9529. PsnName: res.Output.Baseinfo.PsnName,
  9530. Idetinfo: idetinfoStr,
  9531. Insuinfo: infoStr,
  9532. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9533. }
  9534. service.CreateHisPsn(psn)
  9535. c.ServeSuccessJSON(map[string]interface{}{
  9536. "patient": patient,
  9537. "number": res.Output.Baseinfo.Certno,
  9538. })
  9539. }
  9540. } else {
  9541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9542. return
  9543. }
  9544. } else if miConfig.MdtrtareaAdmvs == "420902" {
  9545. var res ResultTwo
  9546. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9547. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9548. "&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)
  9549. resp, requestErr := http.Get(api)
  9550. if requestErr != nil {
  9551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9552. return
  9553. }
  9554. body, ioErr := ioutil.ReadAll(resp.Body)
  9555. if ioErr != nil {
  9556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9558. return
  9559. }
  9560. var respJSON map[string]interface{}
  9561. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9564. return
  9565. }
  9566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9567. result, _ := json.Marshal(respJSON)
  9568. fmt.Println("log")
  9569. fmt.Println(string(result))
  9570. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9571. utils.ErrorLog("解析失败:%v", err)
  9572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9573. return
  9574. }
  9575. if res.Infcode == 0 {
  9576. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9577. if err == gorm.ErrRecordNotFound {
  9578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9579. return
  9580. } else if err != nil {
  9581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9582. return
  9583. } else {
  9584. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9585. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9586. infoStr := string(Iinfos)
  9587. idetinfoStr := string(Idetinfos)
  9588. var rf []*ResultFive
  9589. json.Unmarshal([]byte(infoStr), &rf)
  9590. var insutypes []*ResultFive
  9591. var insutype string
  9592. var is390 int = 0
  9593. var is310 int = 0
  9594. for _, item := range rf {
  9595. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9596. insutypes = append(insutypes, item)
  9597. }
  9598. }
  9599. if len(insutypes) == 1 {
  9600. insutype = insutypes[0].Insutype
  9601. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9602. } else {
  9603. for _, i := range insutypes {
  9604. if i.Insutype == "390" {
  9605. is390 = 1
  9606. }
  9607. if i.Insutype == "310" {
  9608. is310 = 1
  9609. }
  9610. }
  9611. }
  9612. if is390 == 1 {
  9613. insutype = "390"
  9614. }
  9615. if is310 == 1 {
  9616. insutype = "310"
  9617. }
  9618. if len(insutypes) == 0 {
  9619. insutype = "390"
  9620. }
  9621. var insuplc_admdvs string
  9622. for _, item := range rf {
  9623. if item.Insutype == insutype {
  9624. insuplc_admdvs = item.InsuplcAdmdvs
  9625. }
  9626. }
  9627. psn := &models.HisPsn{
  9628. PsnNo: res.Output.Baseinfo.PsnNo,
  9629. PatientId: patient.ID,
  9630. Certno: res.Output.Baseinfo.Certno,
  9631. Gend: res.Output.Baseinfo.Gend,
  9632. Naty: res.Output.Baseinfo.Naty,
  9633. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9634. PsnName: res.Output.Baseinfo.PsnName,
  9635. Idetinfo: idetinfoStr,
  9636. Insuinfo: infoStr,
  9637. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9638. InsuplcAdmdvs: insuplc_admdvs,
  9639. }
  9640. service.CreateHisPsn(psn)
  9641. c.ServeSuccessJSON(map[string]interface{}{
  9642. "patient": patient,
  9643. "number": res.Output.Baseinfo.Certno,
  9644. })
  9645. }
  9646. } else {
  9647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9648. return
  9649. }
  9650. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9651. res := c.GetoleInfo()
  9652. if res.Infcode == 0 {
  9653. var result string
  9654. if res.Output.MdtrtCertType == "01" {
  9655. 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)
  9656. } else if res.Output.MdtrtCertType == "02" {
  9657. 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)
  9658. } else if res.Output.MdtrtCertType == "03" {
  9659. 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)
  9660. }
  9661. var dat map[string]interface{}
  9662. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9663. fmt.Println(dat)
  9664. } else {
  9665. fmt.Println(err)
  9666. }
  9667. userJSONBytes, _ := json.Marshal(dat)
  9668. var res2 ResultTwo
  9669. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9670. utils.ErrorLog("解析失败:%v", err)
  9671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9672. return
  9673. }
  9674. if res2.Infcode == 0 {
  9675. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9676. if err == gorm.ErrRecordNotFound {
  9677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9678. return
  9679. } else if err != nil {
  9680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9681. return
  9682. } else {
  9683. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9684. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9685. infoStr := string(Iinfos)
  9686. idetinfoStr := string(Idetinfos)
  9687. var rf []*ResultFive
  9688. json.Unmarshal([]byte(infoStr), &rf)
  9689. var insutypes []*ResultFive
  9690. var insutype string
  9691. var is390 int = 0
  9692. var is310 int = 0
  9693. //var insuplc_admdvs string
  9694. for _, item := range rf {
  9695. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9696. insutypes = append(insutypes, item)
  9697. }
  9698. }
  9699. if len(insutypes) == 1 {
  9700. insutype = insutypes[0].Insutype
  9701. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9702. } else {
  9703. for _, i := range insutypes {
  9704. if i.Insutype == "390" {
  9705. is390 = 1
  9706. }
  9707. if i.Insutype == "310" {
  9708. is310 = 1
  9709. }
  9710. }
  9711. }
  9712. if is390 == 1 {
  9713. insutype = "390"
  9714. }
  9715. if is310 == 1 {
  9716. insutype = "310"
  9717. }
  9718. if len(insutypes) == 0 {
  9719. insutype = "310"
  9720. }
  9721. psn := &models.HisPsn{
  9722. PsnNo: res2.Output.Baseinfo.PsnNo,
  9723. PatientId: patient.ID,
  9724. //Brdy: res2.Output.Baseinfo.Brdy,
  9725. Certno: res2.Output.Baseinfo.Certno,
  9726. Gend: res2.Output.Baseinfo.Gend,
  9727. Naty: res2.Output.Baseinfo.Naty,
  9728. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9729. PsnName: res2.Output.Baseinfo.PsnName,
  9730. Idetinfo: idetinfoStr,
  9731. Insuinfo: infoStr,
  9732. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9733. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9734. VerifyNumber: res.Output.EcToken,
  9735. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9736. }
  9737. service.CreateHisPsn(psn)
  9738. var balc float64
  9739. for _, item := range rf {
  9740. if item.Insutype == insutype {
  9741. balc = item.Balc
  9742. }
  9743. }
  9744. c.ServeSuccessJSON(map[string]interface{}{
  9745. "patient": patient,
  9746. "number": res.Output.CardNo,
  9747. "insutype": insutype,
  9748. "blac": balc,
  9749. "desc": idetinfoStr,
  9750. })
  9751. }
  9752. } else {
  9753. c.ServeSuccessJSON(map[string]interface{}{
  9754. "failed_code": -10,
  9755. "msg": res2.ErrMsg,
  9756. })
  9757. }
  9758. } else {
  9759. c.ServeSuccessJSON(map[string]interface{}{
  9760. "failed_code": -10,
  9761. "msg": res.ErrMsg,
  9762. })
  9763. }
  9764. } else {
  9765. SFZStr := c.GetSFZBaseInfo()
  9766. id_card_str := strings.Split(SFZStr, "^")
  9767. id_card_number := id_card_str[0]
  9768. card_sn := ""
  9769. 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)
  9770. var dat map[string]interface{}
  9771. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9772. fmt.Println(dat)
  9773. } else {
  9774. fmt.Println(err)
  9775. }
  9776. userJSONBytes, _ := json.Marshal(dat)
  9777. var res ResultTwo
  9778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9779. utils.ErrorLog("解析失败:%v", err)
  9780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9781. return
  9782. }
  9783. if res.Infcode == 0 {
  9784. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9785. if err == gorm.ErrRecordNotFound {
  9786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9787. return
  9788. } else if err != nil {
  9789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9790. return
  9791. } else {
  9792. c.ServeSuccessJSON(map[string]interface{}{
  9793. "patient": patient,
  9794. "number": id_card_number,
  9795. })
  9796. }
  9797. } else {
  9798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9799. return
  9800. }
  9801. }
  9802. break
  9803. case 3:
  9804. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9805. var api string
  9806. if miConfig.MdtrtareaAdmvs == "320921" {
  9807. 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 +
  9808. "&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
  9809. fmt.Println(api)
  9810. } else {
  9811. 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 +
  9812. "&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)
  9813. }
  9814. resp, requestErr := http.Get(api)
  9815. if requestErr != nil {
  9816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9817. return
  9818. }
  9819. body, ioErr := ioutil.ReadAll(resp.Body)
  9820. if ioErr != nil {
  9821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9823. return
  9824. }
  9825. var respJSON map[string]interface{}
  9826. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9829. return
  9830. }
  9831. var status string
  9832. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9833. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9834. var token string
  9835. var res ResultTwo //1101结果
  9836. var res10265 ResultTwo10265 //1101结果
  9837. var card_info string //卡信息
  9838. var busi_card_info string
  9839. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9840. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9841. if status == "0" { //读卡成功
  9842. if card_type == "1" {
  9843. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9844. result, _ := json.Marshal(respJSON)
  9845. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9846. utils.ErrorLog("解析失败:%v", err)
  9847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9848. return
  9849. }
  9850. res.ErrMsg = res10265.ErrMsg
  9851. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9852. res.Infcode = infocode
  9853. res.Output = res10265.Output
  9854. res.InfRefmsgid = res10265.InfRefmsgid
  9855. } else {
  9856. //var card_info string //卡信息
  9857. //var busi_card_info string
  9858. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9859. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9860. //fmt.Println(card_info)
  9861. //fmt.Println(busi_card_info)
  9862. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9863. result, _ := json.Marshal(respJSON)
  9864. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9865. utils.ErrorLog("解析失败:%v", err)
  9866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9867. return
  9868. }
  9869. res.ErrMsg = res10265.ErrMsg
  9870. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9871. res.Infcode = infocode
  9872. res.Output = res10265.Output
  9873. res.InfRefmsgid = res10265.InfRefmsgid
  9874. }
  9875. if res.Infcode == 0 {
  9876. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9877. if err == gorm.ErrRecordNotFound {
  9878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9879. return
  9880. } else if err != nil {
  9881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9882. return
  9883. } else {
  9884. if card_type == "1" {
  9885. bas := strings.Split(card_info, "|")
  9886. basNumber := bas[2]
  9887. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9888. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9889. infoStr := string(Iinfos)
  9890. idetinfoStr := string(Idetinfos)
  9891. psn := &models.HisPsn{
  9892. PsnNo: res.Output.Baseinfo.PsnNo,
  9893. PatientId: patient.ID,
  9894. Certno: res.Output.Baseinfo.Certno,
  9895. //Brdy: res.Output.Baseinfo.Brdy,
  9896. Gend: res.Output.Baseinfo.Gend,
  9897. Naty: res.Output.Baseinfo.Naty,
  9898. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9899. PsnName: res.Output.Baseinfo.PsnName,
  9900. Idetinfo: idetinfoStr,
  9901. Insuinfo: infoStr,
  9902. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9903. CardInfo: card_info,
  9904. VerifyNumber: busi_card_info,
  9905. }
  9906. service.CreateHisPsn(psn)
  9907. c.ServeSuccessJSON(map[string]interface{}{
  9908. "patient": patient,
  9909. "number": basNumber,
  9910. })
  9911. } else {
  9912. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9913. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9914. infoStr := string(Iinfos)
  9915. idetinfoStr := string(Idetinfos)
  9916. psn := &models.HisPsn{
  9917. PsnNo: res.Output.Baseinfo.PsnNo,
  9918. PatientId: patient.ID,
  9919. Certno: res.Output.Baseinfo.Certno,
  9920. Gend: res.Output.Baseinfo.Gend,
  9921. Naty: res.Output.Baseinfo.Naty,
  9922. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9923. PsnName: res.Output.Baseinfo.PsnName,
  9924. Idetinfo: idetinfoStr,
  9925. Insuinfo: infoStr,
  9926. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9927. CardInfo: card_info,
  9928. VerifyNumber: token,
  9929. }
  9930. service.CreateHisPsn(psn)
  9931. var rf []*ResultFive
  9932. json.Unmarshal([]byte(infoStr), &rf)
  9933. var insutypes []*ResultFive
  9934. var insutype string
  9935. var is390 int = 0
  9936. var is310 int = 0
  9937. for _, item := range rf {
  9938. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9939. insutypes = append(insutypes, item)
  9940. }
  9941. }
  9942. if len(insutypes) == 1 {
  9943. insutype = insutypes[0].Insutype
  9944. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9945. } else {
  9946. for _, i := range insutypes {
  9947. if i.Insutype == "390" {
  9948. is390 = 1
  9949. }
  9950. if i.Insutype == "310" {
  9951. is310 = 1
  9952. }
  9953. }
  9954. }
  9955. if is390 == 1 {
  9956. insutype = "390"
  9957. }
  9958. if is310 == 1 {
  9959. insutype = "310"
  9960. }
  9961. if len(insutypes) == 0 {
  9962. insutype = "310"
  9963. }
  9964. c.ServeSuccessJSON(map[string]interface{}{
  9965. "patient": patient,
  9966. "number": token,
  9967. "insutype": insutype,
  9968. })
  9969. }
  9970. }
  9971. } else {
  9972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9973. return
  9974. }
  9975. } else { //读卡失败
  9976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9977. return
  9978. }
  9979. }
  9980. break
  9981. case 4:
  9982. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9983. var api string
  9984. if miConfig.MdtrtareaAdmvs == "320921" {
  9985. 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 +
  9986. "&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
  9987. fmt.Println(api)
  9988. } else {
  9989. 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 +
  9990. "&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)
  9991. }
  9992. resp, requestErr := http.Get(api)
  9993. if requestErr != nil {
  9994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9995. return
  9996. }
  9997. body, ioErr := ioutil.ReadAll(resp.Body)
  9998. if ioErr != nil {
  9999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10001. return
  10002. }
  10003. var respJSON map[string]interface{}
  10004. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10007. return
  10008. }
  10009. var status string
  10010. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10011. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10012. var token string
  10013. var res ResultTwo //1101结果
  10014. var res10265 ResultTwo10265 //1101结果
  10015. if status == "0" { //读卡成功
  10016. var card_info string //卡信息
  10017. var busi_card_info string
  10018. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10019. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10020. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10021. fmt.Println(card_info)
  10022. fmt.Println(busi_card_info)
  10023. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10024. result, _ := json.Marshal(respJSON)
  10025. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10026. utils.ErrorLog("解析失败:%v", err)
  10027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10028. return
  10029. }
  10030. res.ErrMsg = res10265.ErrMsg
  10031. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10032. res.Infcode = infocode
  10033. res.Output = res10265.Output
  10034. res.InfRefmsgid = res10265.InfRefmsgid
  10035. if res.Infcode == 0 {
  10036. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10037. if err == gorm.ErrRecordNotFound {
  10038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10039. return
  10040. } else if err != nil {
  10041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10042. return
  10043. } else {
  10044. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10045. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10046. infoStr := string(Iinfos)
  10047. idetinfoStr := string(Idetinfos)
  10048. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10049. psn := &models.HisPsn{
  10050. PsnNo: res.Output.Baseinfo.PsnNo,
  10051. PatientId: patient.ID,
  10052. Certno: res.Output.Baseinfo.Certno,
  10053. Brdy: b,
  10054. Age: float64(age),
  10055. //Brdy: res.Output.Baseinfo.Brdy,
  10056. Gend: res.Output.Baseinfo.Gend,
  10057. Naty: res.Output.Baseinfo.Naty,
  10058. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10059. PsnName: res.Output.Baseinfo.PsnName,
  10060. Idetinfo: idetinfoStr,
  10061. Insuinfo: infoStr,
  10062. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10063. CardInfo: card_info,
  10064. VerifyNumber: token,
  10065. }
  10066. var rf []*ResultFive
  10067. json.Unmarshal([]byte(infoStr), &rf)
  10068. var insutypes []*ResultFive
  10069. var insutype string
  10070. var is390 int = 0
  10071. var is310 int = 0
  10072. for _, item := range rf {
  10073. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10074. insutypes = append(insutypes, item)
  10075. }
  10076. }
  10077. if len(insutypes) == 1 {
  10078. insutype = insutypes[0].Insutype
  10079. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10080. } else {
  10081. for _, i := range insutypes {
  10082. if i.Insutype == "390" {
  10083. is390 = 1
  10084. }
  10085. if i.Insutype == "310" {
  10086. is310 = 1
  10087. }
  10088. }
  10089. }
  10090. if is390 == 1 {
  10091. insutype = "390"
  10092. }
  10093. if is310 == 1 {
  10094. insutype = "310"
  10095. }
  10096. if len(insutypes) == 0 {
  10097. insutype = "310"
  10098. }
  10099. service.CreateHisPsn(psn)
  10100. c.ServeSuccessJSON(map[string]interface{}{
  10101. "patient": patient,
  10102. "number": token,
  10103. "insutype": insutype,
  10104. })
  10105. }
  10106. } else {
  10107. c.ServeSuccessJSON(map[string]interface{}{
  10108. "failed_code": -10,
  10109. "msg": res.ErrMsg,
  10110. })
  10111. }
  10112. } else { //读卡失败
  10113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10114. return
  10115. }
  10116. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10117. var api string
  10118. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10119. "&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
  10120. resp, requestErr := http.Get(api)
  10121. if requestErr != nil {
  10122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10123. return
  10124. }
  10125. body, ioErr := ioutil.ReadAll(resp.Body)
  10126. if ioErr != nil {
  10127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10129. return
  10130. }
  10131. var respJSON map[string]interface{}
  10132. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10135. return
  10136. }
  10137. var status string
  10138. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10139. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10140. var token string
  10141. var res ResultTwo //1101结果
  10142. if status == "1" { //读卡成功
  10143. var card_info string //卡信息
  10144. var busi_card_info string
  10145. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10146. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10147. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10148. fmt.Println(card_info)
  10149. fmt.Println(busi_card_info)
  10150. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10151. result, _ := json.Marshal(respJSON)
  10152. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10153. utils.ErrorLog("解析失败:%v", err)
  10154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10155. return
  10156. }
  10157. if res.Infcode == 0 {
  10158. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10159. if err == gorm.ErrRecordNotFound {
  10160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10161. return
  10162. } else if err != nil {
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10164. return
  10165. } else {
  10166. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10167. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10168. infoStr := string(Iinfos)
  10169. idetinfoStr := string(Idetinfos)
  10170. psn := &models.HisPsn{
  10171. PsnNo: res.Output.Baseinfo.PsnNo,
  10172. PatientId: patient.ID,
  10173. Certno: res.Output.Baseinfo.Certno,
  10174. Gend: res.Output.Baseinfo.Gend,
  10175. Naty: res.Output.Baseinfo.Naty,
  10176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10177. PsnName: res.Output.Baseinfo.PsnName,
  10178. Idetinfo: idetinfoStr,
  10179. Insuinfo: infoStr,
  10180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10181. CardInfo: card_info,
  10182. VerifyNumber: token,
  10183. }
  10184. var rf []*ResultFive
  10185. json.Unmarshal([]byte(infoStr), &rf)
  10186. var insutypes []*ResultFive
  10187. var insutype string
  10188. var is390 int = 0
  10189. var is310 int = 0
  10190. for _, item := range rf {
  10191. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10192. insutypes = append(insutypes, item)
  10193. }
  10194. }
  10195. if len(insutypes) == 1 {
  10196. insutype = insutypes[0].Insutype
  10197. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10198. } else {
  10199. for _, i := range insutypes {
  10200. if i.Insutype == "390" {
  10201. is390 = 1
  10202. }
  10203. if i.Insutype == "310" {
  10204. is310 = 1
  10205. }
  10206. }
  10207. }
  10208. if is390 == 1 {
  10209. insutype = "390"
  10210. }
  10211. if is310 == 1 {
  10212. insutype = "310"
  10213. }
  10214. if len(insutypes) == 0 {
  10215. insutype = "310"
  10216. }
  10217. service.CreateHisPsn(psn)
  10218. c.ServeSuccessJSON(map[string]interface{}{
  10219. "patient": patient,
  10220. "number": token,
  10221. "insutype": insutype,
  10222. })
  10223. }
  10224. } else {
  10225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10226. return
  10227. }
  10228. } else { //读卡失败
  10229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10230. return
  10231. }
  10232. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10233. idNo := c.GetString("idNo")
  10234. userName := c.GetString("userName")
  10235. ecToken := c.GetString("ecToken")
  10236. insuOrg := c.GetString("insuOrg")
  10237. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10238. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10239. var res ResultTwo
  10240. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10241. utils.ErrorLog("解析失败:%v", err)
  10242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10243. return
  10244. }
  10245. if res.Infcode == 0 {
  10246. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10247. if err == gorm.ErrRecordNotFound {
  10248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10249. return
  10250. } else if err != nil {
  10251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10252. return
  10253. } else {
  10254. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10255. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10256. infoStr := string(Iinfos)
  10257. idetinfoStr := string(Idetinfos)
  10258. psn := &models.HisPsn{
  10259. PsnNo: res.Output.Baseinfo.PsnNo,
  10260. PatientId: patient.ID,
  10261. Certno: res.Output.Baseinfo.Certno,
  10262. Gend: res.Output.Baseinfo.Gend,
  10263. Naty: res.Output.Baseinfo.Naty,
  10264. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10265. PsnName: res.Output.Baseinfo.PsnName,
  10266. Idetinfo: idetinfoStr,
  10267. Insuinfo: infoStr,
  10268. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10269. CardInfo: "",
  10270. Stage: "1",
  10271. VerifyNumber: ecToken,
  10272. InsuplcAdmdvs: insuOrg,
  10273. }
  10274. service.CreateHisPsn(psn)
  10275. var rf []*ResultFive
  10276. json.Unmarshal([]byte(infoStr), &rf)
  10277. var insutypes []*ResultFive
  10278. var insutype string
  10279. var is390 int = 0
  10280. var is310 int = 0
  10281. for _, item := range rf {
  10282. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10283. insutypes = append(insutypes, item)
  10284. }
  10285. }
  10286. if len(insutypes) == 1 {
  10287. insutype = insutypes[0].Insutype
  10288. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10289. } else {
  10290. for _, i := range insutypes {
  10291. if i.Insutype == "390" {
  10292. is390 = 1
  10293. }
  10294. if i.Insutype == "310" {
  10295. is310 = 1
  10296. }
  10297. }
  10298. }
  10299. if is390 == 1 {
  10300. insutype = "390"
  10301. }
  10302. if is310 == 1 {
  10303. insutype = "310"
  10304. }
  10305. if len(insutypes) == 0 {
  10306. insutype = "310"
  10307. }
  10308. c.ServeSuccessJSON(map[string]interface{}{
  10309. "patient": patient,
  10310. "number": ecToken,
  10311. "insutype": insutype,
  10312. })
  10313. }
  10314. } else {
  10315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10316. return
  10317. }
  10318. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10319. //if initFlag == 0 {
  10320. //c.TestGetJiangXiBasBaseInit()
  10321. //}
  10322. //if initEleFlag == 0 {
  10323. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10324. //}
  10325. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  10326. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  10327. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10328. type ELeData struct {
  10329. Data struct {
  10330. IdNo string `json:"idNo"`
  10331. IdType string `json:"idType"`
  10332. UserName string `json:"userName"`
  10333. EcToken string `json:"ecToken"`
  10334. InsuOrg string `json:"insuOrg"`
  10335. Gender string `json:"gender"`
  10336. Birthday string `json:"birthday"`
  10337. Nationality string `json:"nationality"`
  10338. Email string `json:"email"`
  10339. Extra string `json:"extra"`
  10340. } `json:"data"`
  10341. Code int `json:"code"`
  10342. Message string `json:"message"`
  10343. }
  10344. var ele ELeData
  10345. err := json.Unmarshal([]byte(result), &ele)
  10346. if err != nil {
  10347. utils.ErrorLog("解析失败:%v", err)
  10348. }
  10349. token := ele.Data.EcToken
  10350. token = Remove0000(token)
  10351. 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)
  10352. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10353. var res ResultTwo
  10354. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10355. utils.ErrorLog("解析失败:%v", err)
  10356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10357. return
  10358. }
  10359. if res.Infcode == 0 {
  10360. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10361. if err == gorm.ErrRecordNotFound {
  10362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10363. return
  10364. } else if err != nil {
  10365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10366. return
  10367. } else {
  10368. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10369. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10370. infoStr := string(Iinfos)
  10371. idetinfoStr := string(Idetinfos)
  10372. psn := &models.HisPsn{
  10373. PsnNo: res.Output.Baseinfo.PsnNo,
  10374. PatientId: patient.ID,
  10375. Certno: res.Output.Baseinfo.Certno,
  10376. Gend: res.Output.Baseinfo.Gend,
  10377. Naty: res.Output.Baseinfo.Naty,
  10378. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10379. PsnName: res.Output.Baseinfo.PsnName,
  10380. Idetinfo: idetinfoStr,
  10381. Insuinfo: infoStr,
  10382. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10383. CardInfo: "",
  10384. VerifyNumber: token,
  10385. }
  10386. service.CreateHisPsn(psn)
  10387. var rf []*ResultFive
  10388. json.Unmarshal([]byte(infoStr), &rf)
  10389. var insutypes []*ResultFive
  10390. var insutype string
  10391. var is390 int = 0
  10392. var is310 int = 0
  10393. for _, item := range rf {
  10394. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10395. insutypes = append(insutypes, item)
  10396. }
  10397. }
  10398. if len(insutypes) == 1 {
  10399. insutype = insutypes[0].Insutype
  10400. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10401. } else {
  10402. for _, i := range insutypes {
  10403. if i.Insutype == "390" {
  10404. is390 = 1
  10405. }
  10406. if i.Insutype == "310" {
  10407. is310 = 1
  10408. }
  10409. }
  10410. }
  10411. if is390 == 1 {
  10412. insutype = "390"
  10413. }
  10414. if is310 == 1 {
  10415. insutype = "310"
  10416. }
  10417. if len(insutypes) == 0 {
  10418. insutype = "310"
  10419. }
  10420. c.ServeSuccessJSON(map[string]interface{}{
  10421. "patient": patient,
  10422. "number": token,
  10423. "insutype": insutype,
  10424. })
  10425. }
  10426. } else {
  10427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10428. return
  10429. }
  10430. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10431. //if initFlag == 0 {
  10432. c.TestGetJiangXiBasBaseInit()
  10433. //}
  10434. //if initEleFlag == 0 {
  10435. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10436. //}
  10437. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10438. type ELeData struct {
  10439. Data struct {
  10440. IdNo string `json:"idNo"`
  10441. IdType string `json:"idType"`
  10442. UserName string `json:"userName"`
  10443. EcToken string `json:"ecToken"`
  10444. InsuOrg string `json:"insuOrg"`
  10445. Gender string `json:"gender"`
  10446. Birthday string `json:"birthday"`
  10447. Nationality string `json:"nationality"`
  10448. Email string `json:"email"`
  10449. Extra string `json:"extra"`
  10450. } `json:"data"`
  10451. Code int `json:"code"`
  10452. Message string `json:"message"`
  10453. }
  10454. var ele ELeData
  10455. err := json.Unmarshal([]byte(json_result), &ele)
  10456. if err != nil {
  10457. utils.ErrorLog("解析失败:%v", err)
  10458. }
  10459. token := ele.Data.EcToken
  10460. token = Remove0000(token)
  10461. 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)
  10462. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10463. var res ResultTwo
  10464. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10465. utils.ErrorLog("解析失败:%v", err)
  10466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10467. return
  10468. }
  10469. if res.Infcode == 0 {
  10470. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10471. if err == gorm.ErrRecordNotFound {
  10472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10473. return
  10474. } else if err != nil {
  10475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10476. return
  10477. } else {
  10478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10480. infoStr := string(Iinfos)
  10481. idetinfoStr := string(Idetinfos)
  10482. psn := &models.HisPsn{
  10483. PsnNo: res.Output.Baseinfo.PsnNo,
  10484. PatientId: patient.ID,
  10485. Certno: res.Output.Baseinfo.Certno,
  10486. Gend: res.Output.Baseinfo.Gend,
  10487. Naty: res.Output.Baseinfo.Naty,
  10488. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10489. PsnName: res.Output.Baseinfo.PsnName,
  10490. Idetinfo: idetinfoStr,
  10491. Insuinfo: infoStr,
  10492. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10493. CardInfo: "",
  10494. VerifyNumber: token,
  10495. }
  10496. service.CreateHisPsn(psn)
  10497. var rf []*ResultFive
  10498. json.Unmarshal([]byte(infoStr), &rf)
  10499. var insutypes []*ResultFive
  10500. var insutype string
  10501. var is390 int = 0
  10502. var is310 int = 0
  10503. for _, item := range rf {
  10504. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10505. insutypes = append(insutypes, item)
  10506. }
  10507. }
  10508. if len(insutypes) == 1 {
  10509. insutype = insutypes[0].Insutype
  10510. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10511. } else {
  10512. for _, i := range insutypes {
  10513. if i.Insutype == "390" {
  10514. is390 = 1
  10515. }
  10516. if i.Insutype == "310" {
  10517. is310 = 1
  10518. }
  10519. }
  10520. }
  10521. if is390 == 1 {
  10522. insutype = "390"
  10523. }
  10524. if is310 == 1 {
  10525. insutype = "310"
  10526. }
  10527. if len(insutypes) == 0 {
  10528. insutype = "310"
  10529. }
  10530. c.ServeSuccessJSON(map[string]interface{}{
  10531. "patient": patient,
  10532. "number": token,
  10533. "insutype": insutype,
  10534. })
  10535. }
  10536. } else {
  10537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10538. return
  10539. }
  10540. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10541. type ELeData struct {
  10542. Code string `json:"code"`
  10543. Data struct {
  10544. Aac002 string `json:"aac002"`
  10545. Aaz500 string `json:"aaz500"`
  10546. ActCardNo string `json:"actCardNo"`
  10547. Bab520 string `json:"bab520"`
  10548. Bkz543 string `json:"bkz543"`
  10549. BusinessType string `json:"businessType"`
  10550. CertfCodg string `json:"certfCodg"`
  10551. EcIndexNo string `json:"ecIndexNo"`
  10552. EcToken string `json:"ecToken"`
  10553. ID0000 string `json:"id0000"`
  10554. IDNo string `json:"idNo"`
  10555. IDType string `json:"idType"`
  10556. Idcode string `json:"idcode"`
  10557. IdentityToken string `json:"identity_token"`
  10558. InsuOrg string `json:"insuOrg"`
  10559. OfficeID string `json:"officeId"`
  10560. OfficeName string `json:"officeName"`
  10561. OperatorID string `json:"operatorId"`
  10562. OperatorName string `json:"operatorName"`
  10563. OrgID string `json:"orgId"`
  10564. UserName string `json:"userName"`
  10565. } `json:"data"`
  10566. Infno interface{} `json:"infno"`
  10567. Message string `json:"message"`
  10568. OrgID string `json:"orgId"`
  10569. TransType string `json:"transType"`
  10570. }
  10571. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  10572. outPutInfo = Remove0000(outPutInfo)
  10573. if len(outPutInfo) > 0 {
  10574. var ele ELeData
  10575. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10576. if err != nil {
  10577. utils.ErrorLog("解析失败:%v", err)
  10578. }
  10579. token := ele.Data.EcToken
  10580. fmt.Println(inputInfo)
  10581. fmt.Println(outPutInfo)
  10582. 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)
  10583. saveLog(result, requestLog, "1101", "获取人员信息")
  10584. var dat map[string]interface{}
  10585. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10586. fmt.Println(dat)
  10587. } else {
  10588. fmt.Println(err)
  10589. }
  10590. userJSONBytes, _ := json.Marshal(dat)
  10591. var res ResultTwo
  10592. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10593. utils.ErrorLog("解析失败:%v", err)
  10594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10595. return
  10596. }
  10597. res.ErrMsg = errMsgLog
  10598. if res.Infcode == 0 {
  10599. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10600. if err == gorm.ErrRecordNotFound {
  10601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10602. return
  10603. } else if err != nil {
  10604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10605. return
  10606. } else {
  10607. fmt.Println(res)
  10608. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10609. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10610. infoStr := string(Iinfos)
  10611. idetinfoStr := string(Idetinfos)
  10612. psn := &models.HisPsn{
  10613. PsnNo: res.Output.Baseinfo.PsnNo,
  10614. PatientId: patient.ID,
  10615. Certno: res.Output.Baseinfo.Certno,
  10616. Gend: res.Output.Baseinfo.Gend,
  10617. Naty: res.Output.Baseinfo.Naty,
  10618. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10619. PsnName: res.Output.Baseinfo.PsnName,
  10620. Idetinfo: idetinfoStr,
  10621. Insuinfo: infoStr,
  10622. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10623. CardInfo: outPutInfo,
  10624. VerifyNumber: token,
  10625. InsuplcAdmdvs: ele.Data.InsuOrg,
  10626. }
  10627. service.CreateHisPsn(psn)
  10628. var rf []*ResultFive
  10629. json.Unmarshal([]byte(infoStr), &rf)
  10630. var insutypes []*ResultFive
  10631. var insutype string
  10632. var is390 int = 0
  10633. var is310 int = 0
  10634. for _, item := range rf {
  10635. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10636. insutypes = append(insutypes, item)
  10637. }
  10638. }
  10639. if len(insutypes) == 1 {
  10640. insutype = insutypes[0].Insutype
  10641. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10642. } else {
  10643. for _, i := range insutypes {
  10644. if i.Insutype == "390" {
  10645. is390 = 1
  10646. }
  10647. if i.Insutype == "310" {
  10648. is310 = 1
  10649. }
  10650. }
  10651. }
  10652. if is390 == 1 {
  10653. insutype = "390"
  10654. }
  10655. if is310 == 1 {
  10656. insutype = "310"
  10657. }
  10658. if len(insutypes) == 0 {
  10659. insutype = "310"
  10660. }
  10661. c.ServeSuccessJSON(map[string]interface{}{
  10662. "patient": patient,
  10663. "number": token,
  10664. "insutype": insutype,
  10665. })
  10666. }
  10667. } else {
  10668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10669. return
  10670. }
  10671. }
  10672. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10673. var api string
  10674. 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 +
  10675. "&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
  10676. resp, requestErr := http.Get(api)
  10677. if requestErr != nil {
  10678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10679. return
  10680. }
  10681. body, ioErr := ioutil.ReadAll(resp.Body)
  10682. if ioErr != nil {
  10683. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10685. return
  10686. }
  10687. var respJSON map[string]interface{}
  10688. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10691. return
  10692. }
  10693. var status string
  10694. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10695. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10696. var token string
  10697. var res ResultTwo //1101结果
  10698. var res10265 ResultTwo10265 //1101结果
  10699. if status == "0" { //读卡成功
  10700. var card_info string //卡信息
  10701. var busi_card_info string
  10702. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10703. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10704. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10705. fmt.Println(card_info)
  10706. fmt.Println(busi_card_info)
  10707. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10708. result, _ := json.Marshal(respJSON)
  10709. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10710. utils.ErrorLog("解析失败:%v", err)
  10711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10712. return
  10713. }
  10714. res.ErrMsg = res10265.ErrMsg
  10715. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10716. res.Infcode = infocode
  10717. res.Output = res10265.Output
  10718. res.InfRefmsgid = res10265.InfRefmsgid
  10719. if res.Infcode == 0 {
  10720. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10721. if err == gorm.ErrRecordNotFound {
  10722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10723. return
  10724. } else if err != nil {
  10725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10726. return
  10727. } else {
  10728. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10729. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10730. infoStr := string(Iinfos)
  10731. idetinfoStr := string(Idetinfos)
  10732. psn := &models.HisPsn{
  10733. PsnNo: res.Output.Baseinfo.PsnNo,
  10734. PatientId: patient.ID,
  10735. Certno: res.Output.Baseinfo.Certno,
  10736. Gend: res.Output.Baseinfo.Gend,
  10737. Naty: res.Output.Baseinfo.Naty,
  10738. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10739. PsnName: res.Output.Baseinfo.PsnName,
  10740. Idetinfo: idetinfoStr,
  10741. Insuinfo: infoStr,
  10742. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10743. CardInfo: card_info,
  10744. VerifyNumber: token,
  10745. }
  10746. var rf []*ResultFive
  10747. json.Unmarshal([]byte(infoStr), &rf)
  10748. var insutypes []*ResultFive
  10749. var insutype string
  10750. var is390 int = 0
  10751. var is310 int = 0
  10752. for _, item := range rf {
  10753. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10754. insutypes = append(insutypes, item)
  10755. }
  10756. }
  10757. if len(insutypes) == 1 {
  10758. insutype = insutypes[0].Insutype
  10759. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10760. } else {
  10761. for _, i := range insutypes {
  10762. if i.Insutype == "390" {
  10763. is390 = 1
  10764. }
  10765. if i.Insutype == "310" {
  10766. is310 = 1
  10767. }
  10768. }
  10769. }
  10770. if is390 == 1 {
  10771. insutype = "390"
  10772. }
  10773. if is310 == 1 {
  10774. insutype = "310"
  10775. }
  10776. if len(insutypes) == 0 {
  10777. insutype = "310"
  10778. }
  10779. service.CreateHisPsn(psn)
  10780. c.ServeSuccessJSON(map[string]interface{}{
  10781. "patient": patient,
  10782. "number": token,
  10783. "insutype": insutype,
  10784. })
  10785. }
  10786. } else {
  10787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10788. return
  10789. }
  10790. } else { //读卡失败
  10791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10792. return
  10793. }
  10794. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10795. res := c.GetoleInfo()
  10796. if res.Infcode == 0 {
  10797. var result string
  10798. if res.Output.MdtrtCertType == "01" {
  10799. 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)
  10800. } else if res.Output.MdtrtCertType == "02" {
  10801. 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)
  10802. } else if res.Output.MdtrtCertType == "03" {
  10803. 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)
  10804. }
  10805. var dat map[string]interface{}
  10806. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10807. fmt.Println(dat)
  10808. } else {
  10809. fmt.Println(err)
  10810. }
  10811. userJSONBytes, _ := json.Marshal(dat)
  10812. var res2 ResultTwo
  10813. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10814. utils.ErrorLog("解析失败:%v", err)
  10815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10816. return
  10817. }
  10818. if res2.Infcode == 0 {
  10819. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10820. if err == gorm.ErrRecordNotFound {
  10821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10822. return
  10823. } else if err != nil {
  10824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10825. return
  10826. } else {
  10827. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10828. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10829. infoStr := string(Iinfos)
  10830. idetinfoStr := string(Idetinfos)
  10831. var rf []*ResultFive
  10832. json.Unmarshal([]byte(infoStr), &rf)
  10833. var insutypes []*ResultFive
  10834. var insutype string
  10835. var is390 int = 0
  10836. var is310 int = 0
  10837. //var insuplc_admdvs string
  10838. for _, item := range rf {
  10839. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10840. insutypes = append(insutypes, item)
  10841. }
  10842. }
  10843. if len(insutypes) == 1 {
  10844. insutype = insutypes[0].Insutype
  10845. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10846. } else {
  10847. for _, i := range insutypes {
  10848. if i.Insutype == "390" {
  10849. is390 = 1
  10850. }
  10851. if i.Insutype == "310" {
  10852. is310 = 1
  10853. }
  10854. }
  10855. }
  10856. if is390 == 1 {
  10857. insutype = "390"
  10858. }
  10859. if is310 == 1 {
  10860. insutype = "310"
  10861. }
  10862. if len(insutypes) == 0 {
  10863. insutype = "310"
  10864. }
  10865. psn := &models.HisPsn{
  10866. PsnNo: res2.Output.Baseinfo.PsnNo,
  10867. PatientId: patient.ID,
  10868. Certno: res2.Output.Baseinfo.Certno,
  10869. Gend: res2.Output.Baseinfo.Gend,
  10870. Naty: res2.Output.Baseinfo.Naty,
  10871. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10872. PsnName: res2.Output.Baseinfo.PsnName,
  10873. Idetinfo: idetinfoStr,
  10874. Insuinfo: infoStr,
  10875. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10876. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10877. VerifyNumber: res.Output.EcToken,
  10878. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10879. }
  10880. if res.Output.MdtrtCertType == "01" {
  10881. psn.VerifyNumber = res.Output.EcToken
  10882. //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)
  10883. } else if res.Output.MdtrtCertType == "02" {
  10884. psn.VerifyNumber = res.Output.CardNo
  10885. //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)
  10886. } else if res.Output.MdtrtCertType == "03" {
  10887. psn.VerifyNumber = res.Output.MdtrtCertNo
  10888. //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)
  10889. }
  10890. service.CreateHisPsn(psn)
  10891. var balc float64
  10892. for _, item := range rf {
  10893. if item.Insutype == insutype {
  10894. balc = item.Balc
  10895. }
  10896. }
  10897. c.ServeSuccessJSON(map[string]interface{}{
  10898. "patient": patient,
  10899. "number": res.Output.CardNo,
  10900. "insutype": insutype,
  10901. "blac": balc,
  10902. "desc": idetinfoStr,
  10903. })
  10904. }
  10905. } else {
  10906. c.ServeSuccessJSON(map[string]interface{}{
  10907. "failed_code": -10,
  10908. "msg": res2.ErrMsg,
  10909. })
  10910. }
  10911. } else {
  10912. c.ServeSuccessJSON(map[string]interface{}{
  10913. "failed_code": -10,
  10914. "msg": res.ErrMsg,
  10915. })
  10916. }
  10917. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10918. var res ResultTwo
  10919. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10920. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10921. "&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)
  10922. resp, requestErr := http.Get(api)
  10923. if requestErr != nil {
  10924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10925. return
  10926. }
  10927. body, ioErr := ioutil.ReadAll(resp.Body)
  10928. if ioErr != nil {
  10929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10931. return
  10932. }
  10933. var respJSON map[string]interface{}
  10934. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10937. return
  10938. }
  10939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10940. result, _ := json.Marshal(respJSON)
  10941. fmt.Println("log")
  10942. fmt.Println(string(result))
  10943. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10944. utils.ErrorLog("解析失败:%v", err)
  10945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10946. return
  10947. }
  10948. if res.Infcode == 0 {
  10949. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10950. if err == gorm.ErrRecordNotFound {
  10951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10952. return
  10953. } else if err != nil {
  10954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10955. return
  10956. } else {
  10957. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10958. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10959. infoStr := string(Iinfos)
  10960. idetinfoStr := string(Idetinfos)
  10961. var rf []*ResultFive
  10962. json.Unmarshal([]byte(infoStr), &rf)
  10963. var insutypes []*ResultFive
  10964. var insutype string
  10965. var is390 int = 0
  10966. var is310 int = 0
  10967. for _, item := range rf {
  10968. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10969. insutypes = append(insutypes, item)
  10970. }
  10971. }
  10972. if len(insutypes) == 1 {
  10973. insutype = insutypes[0].Insutype
  10974. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10975. } else {
  10976. for _, i := range insutypes {
  10977. if i.Insutype == "390" {
  10978. is390 = 1
  10979. }
  10980. if i.Insutype == "310" {
  10981. is310 = 1
  10982. }
  10983. }
  10984. }
  10985. if is390 == 1 {
  10986. insutype = "390"
  10987. }
  10988. if is310 == 1 {
  10989. insutype = "310"
  10990. }
  10991. if len(insutypes) == 0 {
  10992. insutype = "390"
  10993. }
  10994. var insuplc_admdvs string
  10995. for _, item := range rf {
  10996. if item.Insutype == insutype {
  10997. insuplc_admdvs = item.InsuplcAdmdvs
  10998. }
  10999. }
  11000. psn := &models.HisPsn{
  11001. PsnNo: res.Output.Baseinfo.PsnNo,
  11002. PatientId: patient.ID,
  11003. Certno: res.Output.Baseinfo.Certno,
  11004. Gend: res.Output.Baseinfo.Gend,
  11005. Naty: res.Output.Baseinfo.Naty,
  11006. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11007. PsnName: res.Output.Baseinfo.PsnName,
  11008. Idetinfo: idetinfoStr,
  11009. Insuinfo: infoStr,
  11010. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11011. InsuplcAdmdvs: insuplc_admdvs,
  11012. }
  11013. service.CreateHisPsn(psn)
  11014. c.ServeSuccessJSON(map[string]interface{}{
  11015. "patient": patient,
  11016. "number": res.Output.Baseinfo.Certno,
  11017. })
  11018. }
  11019. } else {
  11020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11021. return
  11022. }
  11023. } else {
  11024. type ELeData struct {
  11025. Code string `json:"code"`
  11026. Data struct {
  11027. Aac002 string `json:"aac002"`
  11028. Aaz500 string `json:"aaz500"`
  11029. ActCardNo string `json:"actCardNo"`
  11030. Bab520 string `json:"bab520"`
  11031. Bkz543 string `json:"bkz543"`
  11032. BusinessType string `json:"businessType"`
  11033. CertfCodg string `json:"certfCodg"`
  11034. EcIndexNo string `json:"ecIndexNo"`
  11035. EcToken string `json:"ecToken"`
  11036. ID0000 string `json:"id0000"`
  11037. IDNo string `json:"idNo"`
  11038. IDType string `json:"idType"`
  11039. Idcode string `json:"idcode"`
  11040. IdentityToken string `json:"identity_token"`
  11041. InsuOrg string `json:"insuOrg"`
  11042. OfficeID string `json:"officeId"`
  11043. OfficeName string `json:"officeName"`
  11044. OperatorID string `json:"operatorId"`
  11045. OperatorName string `json:"operatorName"`
  11046. OrgID string `json:"orgId"`
  11047. UserName string `json:"userName"`
  11048. } `json:"data"`
  11049. Infno interface{} `json:"infno"`
  11050. Message string `json:"message"`
  11051. OrgID string `json:"orgId"`
  11052. TransType string `json:"transType"`
  11053. }
  11054. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  11055. fmt.Println(result)
  11056. outPutInfo := Remove0000(result)
  11057. fmt.Println(outPutInfo)
  11058. if len(outPutInfo) > 0 {
  11059. var ele ELeData
  11060. err := json.Unmarshal([]byte(outPutInfo), &ele)
  11061. if err != nil {
  11062. utils.ErrorLog("解析失败:%v", err)
  11063. }
  11064. token := ele.Data.EcToken
  11065. fmt.Println(outPutInfo)
  11066. 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)
  11067. saveLog(result, requestLog, "1101", "获取人员信息")
  11068. var dat map[string]interface{}
  11069. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11070. fmt.Println(dat)
  11071. } else {
  11072. fmt.Println(err)
  11073. }
  11074. userJSONBytes, _ := json.Marshal(dat)
  11075. var res ResultTwo
  11076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11077. utils.ErrorLog("解析失败:%v", err)
  11078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11079. return
  11080. }
  11081. if res.Infcode == 0 {
  11082. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  11083. if err == gorm.ErrRecordNotFound {
  11084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11085. return
  11086. } else if err != nil {
  11087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11088. return
  11089. } else {
  11090. fmt.Println(res)
  11091. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11092. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11093. infoStr := string(Iinfos)
  11094. idetinfoStr := string(Idetinfos)
  11095. psn := &models.HisPsn{
  11096. PsnNo: res.Output.Baseinfo.PsnNo,
  11097. PatientId: patient.ID,
  11098. Certno: res.Output.Baseinfo.Certno,
  11099. Gend: res.Output.Baseinfo.Gend,
  11100. Naty: res.Output.Baseinfo.Naty,
  11101. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11102. PsnName: res.Output.Baseinfo.PsnName,
  11103. Idetinfo: idetinfoStr,
  11104. Insuinfo: infoStr,
  11105. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11106. CardInfo: outPutInfo,
  11107. VerifyNumber: token,
  11108. InsuplcAdmdvs: ele.Data.InsuOrg,
  11109. }
  11110. service.CreateHisPsn(psn)
  11111. var rf []*ResultFive
  11112. json.Unmarshal([]byte(infoStr), &rf)
  11113. var insutypes []*ResultFive
  11114. var insutype string
  11115. var is390 int = 0
  11116. var is310 int = 0
  11117. for _, item := range rf {
  11118. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11119. insutypes = append(insutypes, item)
  11120. }
  11121. }
  11122. if len(insutypes) == 1 {
  11123. insutype = insutypes[0].Insutype
  11124. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11125. } else {
  11126. for _, i := range insutypes {
  11127. if i.Insutype == "390" {
  11128. is390 = 1
  11129. }
  11130. if i.Insutype == "310" {
  11131. is310 = 1
  11132. }
  11133. }
  11134. }
  11135. if is390 == 1 {
  11136. insutype = "390"
  11137. }
  11138. if is310 == 1 {
  11139. insutype = "310"
  11140. }
  11141. if len(insutypes) == 0 {
  11142. insutype = "310"
  11143. }
  11144. c.ServeSuccessJSON(map[string]interface{}{
  11145. "patient": patient,
  11146. "number": token,
  11147. "insutype": insutype,
  11148. })
  11149. }
  11150. } else {
  11151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11152. return
  11153. }
  11154. }
  11155. //fmt.Println(result)
  11156. //
  11157. //if initFlag == 0 {
  11158. // c.TestGetBasBaseInit()
  11159. //}
  11160. //token := c.GetEleBaseInfo()
  11161. //
  11162. //token = Remove0000(token)
  11163. //
  11164. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  11165. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  11166. ////
  11167. //var res ResultTwo
  11168. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11169. // utils.ErrorLog("解析失败:%v", err)
  11170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11171. // return
  11172. //}
  11173. //
  11174. //if res.Infcode == 0 {
  11175. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11176. // if err == gorm.ErrRecordNotFound {
  11177. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11178. // return
  11179. // } else if err != nil {
  11180. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11181. // return
  11182. //
  11183. // } else {
  11184. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11185. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11186. // infoStr := string(Iinfos)
  11187. // idetinfoStr := string(Idetinfos)
  11188. //
  11189. //
  11190. //
  11191. //
  11192. // var rf []*ResultFive
  11193. // json.Unmarshal([]byte(infoStr), &rf)
  11194. //
  11195. // var insutypes []*ResultFive
  11196. // var insutype string
  11197. // var is390 int = 0
  11198. // var is310 int = 0
  11199. // var insuplc_admdvs string
  11200. //
  11201. // for _, item := range rf {
  11202. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11203. // insutypes = append(insutypes, item)
  11204. // }
  11205. // }
  11206. //
  11207. // if len(insutypes) == 1 {
  11208. // insutype = insutypes[0].Insutype
  11209. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11210. // } else {
  11211. // for _, i := range insutypes {
  11212. // if i.Insutype == "390" {
  11213. // is390 = 1
  11214. // }
  11215. //
  11216. // if i.Insutype == "310" {
  11217. // is310 = 1
  11218. // }
  11219. // }
  11220. // }
  11221. // if is390 == 1 {
  11222. // insutype = "390"
  11223. // }
  11224. //
  11225. // if is310 == 1 {
  11226. // insutype = "310"
  11227. // }
  11228. // if len(insutypes) == 0 {
  11229. // insutype = "310"
  11230. // }
  11231. // for _, item := range rf {
  11232. // if item.Insutype == insutype {
  11233. // insuplc_admdvs = item.InsuplcAdmdvs
  11234. // }
  11235. // }
  11236. // psn := &models.HisPsn{
  11237. // PsnNo: res.Output.Baseinfo.PsnNo,
  11238. // Age: res.Output.Baseinfo.Age,
  11239. // PatientId: patient.ID,
  11240. // Certno: res.Output.Baseinfo.Certno,
  11241. // Brdy: res.Output.Baseinfo.Brdy,
  11242. // Gend: res.Output.Baseinfo.Gend,
  11243. // Naty: res.Output.Baseinfo.Naty,
  11244. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  11245. // PsnName: res.Output.Baseinfo.PsnName,
  11246. // Idetinfo: idetinfoStr,
  11247. // Insuinfo: infoStr,
  11248. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11249. // CardInfo: "",
  11250. // VerifyNumber: token,
  11251. // InsuplcAdmdvs: insuplc_admdvs,
  11252. // }
  11253. // service.CreateHisPsn(psn)
  11254. //
  11255. // c.ServeSuccessJSON(map[string]interface{}{
  11256. // "patient": patient,
  11257. // "number": token,
  11258. // })
  11259. // }
  11260. //} else {
  11261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11262. // return
  11263. //}
  11264. }
  11265. break
  11266. case 5:
  11267. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11268. var api string
  11269. if miConfig.MdtrtareaAdmvs == "320921" {
  11270. 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 +
  11271. "&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
  11272. fmt.Println(api)
  11273. } else {
  11274. 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 +
  11275. "&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)
  11276. }
  11277. resp, requestErr := http.Get(api)
  11278. if requestErr != nil {
  11279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11280. return
  11281. }
  11282. body, ioErr := ioutil.ReadAll(resp.Body)
  11283. if ioErr != nil {
  11284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11286. return
  11287. }
  11288. var respJSON map[string]interface{}
  11289. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11292. return
  11293. }
  11294. var status string
  11295. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11296. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11297. var token string
  11298. var res ResultTwo //1101结果
  11299. var res10265 ResultTwo10265 //1101结果
  11300. if status == "0" { //读卡成功
  11301. var card_info string //卡信息
  11302. //var busi_card_info string
  11303. var auth_info string
  11304. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11305. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11306. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11307. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  11308. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11309. result, _ := json.Marshal(respJSON)
  11310. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11311. utils.ErrorLog("解析失败:%v", err)
  11312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11313. return
  11314. }
  11315. res.ErrMsg = res10265.ErrMsg
  11316. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11317. res.Infcode = infocode
  11318. res.Output = res10265.Output
  11319. res.InfRefmsgid = res10265.InfRefmsgid
  11320. if res.Infcode == 0 {
  11321. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11322. if err == gorm.ErrRecordNotFound {
  11323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11324. return
  11325. } else if err != nil {
  11326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11327. return
  11328. } else {
  11329. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11330. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11331. infoStr := string(Iinfos)
  11332. idetinfoStr := string(Idetinfos)
  11333. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  11334. psn := &models.HisPsn{
  11335. PsnNo: res.Output.Baseinfo.PsnNo,
  11336. PatientId: patient.ID,
  11337. Certno: res.Output.Baseinfo.Certno,
  11338. Gend: res.Output.Baseinfo.Gend,
  11339. Brdy: b,
  11340. Age: float64(age),
  11341. Naty: res.Output.Baseinfo.Naty,
  11342. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11343. PsnName: res.Output.Baseinfo.PsnName,
  11344. Idetinfo: idetinfoStr,
  11345. Insuinfo: infoStr,
  11346. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11347. CardInfo: card_info,
  11348. VerifyNumber: token,
  11349. AuthInfo: auth_info,
  11350. }
  11351. var rf []*ResultFive
  11352. json.Unmarshal([]byte(infoStr), &rf)
  11353. var insutypes []*ResultFive
  11354. var insutype string
  11355. var is390 int = 0
  11356. var is310 int = 0
  11357. for _, item := range rf {
  11358. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11359. insutypes = append(insutypes, item)
  11360. }
  11361. }
  11362. if len(insutypes) == 1 {
  11363. insutype = insutypes[0].Insutype
  11364. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11365. } else {
  11366. for _, i := range insutypes {
  11367. if i.Insutype == "390" {
  11368. is390 = 1
  11369. }
  11370. if i.Insutype == "310" {
  11371. is310 = 1
  11372. }
  11373. }
  11374. }
  11375. if is390 == 1 {
  11376. insutype = "390"
  11377. }
  11378. if is310 == 1 {
  11379. insutype = "310"
  11380. }
  11381. if len(insutypes) == 0 {
  11382. insutype = "310"
  11383. }
  11384. service.CreateHisPsn(psn)
  11385. c.ServeSuccessJSON(map[string]interface{}{
  11386. "patient": patient,
  11387. "number": token,
  11388. "insutype": insutype,
  11389. })
  11390. }
  11391. } else {
  11392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11393. return
  11394. }
  11395. } else { //读卡失败
  11396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11397. return
  11398. }
  11399. }
  11400. break
  11401. }
  11402. }
  11403. var initFlag int64 = 0
  11404. var initEleFlag int64 = 0
  11405. func (c *HisApiController) TestGetBasBaseInit() {
  11406. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11407. Iinit := DllDef.MustFindProc("Init")
  11408. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11409. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  11410. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  11411. if ret != 0 {
  11412. fmt.Println("SSCard的报错原因:", err)
  11413. fmt.Println("SSCard的运算结果为:", ret)
  11414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11415. return
  11416. }
  11417. result := int(ret)
  11418. fmt.Println("SSCard的运算结果为1:", result)
  11419. initFlag = 1
  11420. return
  11421. }
  11422. func (c *HisApiController) HandleJiangXiReadCard() {
  11423. fmt.Println("~~~~~~")
  11424. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11425. admin_user_id, _ := c.GetInt64("admin_user_id")
  11426. id_card_type, _ := c.GetInt64("id_card_type")
  11427. //certificates, _ := c.GetInt64("certificates")
  11428. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11429. if initFlag == 0 {
  11430. c.TestGetJiangXiBasBaseInit()
  11431. }
  11432. basStr := c.GetBasBaseInfo()
  11433. if len(basStr) == 0 {
  11434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11435. return
  11436. }
  11437. fmt.Println(basStr)
  11438. bas := strings.Split(basStr, "|")
  11439. basNumber := bas[1]
  11440. fmt.Println(basNumber)
  11441. card_sn := bas[3]
  11442. fmt.Println(card_sn)
  11443. 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, "")
  11444. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11445. var dat map[string]interface{}
  11446. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11447. fmt.Println(dat)
  11448. } else {
  11449. fmt.Println(err)
  11450. }
  11451. userJSONBytes, _ := json.Marshal(dat)
  11452. var res ResultTwo
  11453. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11454. utils.ErrorLog("解析失败:%v", err)
  11455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11456. return
  11457. }
  11458. if res.Infcode == 0 {
  11459. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11460. if err == gorm.ErrRecordNotFound {
  11461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11462. return
  11463. } else if err != nil {
  11464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11465. return
  11466. } else {
  11467. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11468. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11469. infoStr := string(Iinfos)
  11470. idetinfoStr := string(Idetinfos)
  11471. psn := &models.HisPsn{
  11472. PsnNo: res.Output.Baseinfo.PsnNo,
  11473. PatientId: patient.ID,
  11474. Certno: res.Output.Baseinfo.Certno,
  11475. Gend: res.Output.Baseinfo.Gend,
  11476. Naty: res.Output.Baseinfo.Naty,
  11477. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11478. PsnName: res.Output.Baseinfo.PsnName,
  11479. Idetinfo: idetinfoStr,
  11480. Insuinfo: infoStr,
  11481. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11482. CardInfo: basStr,
  11483. VerifyNumber: "",
  11484. }
  11485. service.CreateHisPsn(psn)
  11486. c.ServeSuccessJSON(map[string]interface{}{
  11487. "patient": patient,
  11488. "number": basNumber,
  11489. })
  11490. }
  11491. } else {
  11492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11493. return
  11494. }
  11495. }
  11496. func (c *HisApiController) TestGetHnBasBaseInit() {
  11497. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11498. Iinit := DllDef.MustFindProc("Init")
  11499. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11500. //http://10.77.211.236/CSB/hsa-fsi-1303
  11501. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  11502. if ret != 0 {
  11503. fmt.Println("SSCard的报错原因:", err)
  11504. fmt.Println("SSCard的运算结果为:", ret)
  11505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11506. return
  11507. }
  11508. result := int(ret)
  11509. fmt.Println("SSCard的运算结果为1:", result)
  11510. initFlag = 1
  11511. return
  11512. }
  11513. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  11514. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11515. Iinit := DllDef.MustFindProc("Init")
  11516. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11517. //http://10.77.211.236/CSB/hsa-fsi-1303
  11518. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  11519. if ret != 0 {
  11520. fmt.Println("SSCard的报错原因:", err)
  11521. fmt.Println("SSCard的运算结果为:", ret)
  11522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11523. return
  11524. }
  11525. result := int(ret)
  11526. fmt.Println("SSCard的运算结果为1:", result)
  11527. initFlag = 1
  11528. return
  11529. }
  11530. func (c *HisApiController) GetSFZBaseInfo() string {
  11531. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11532. readCard := DllDef.MustFindProc("ReadSFZ")
  11533. if readCard == nil {
  11534. fmt.Println("readcard is nil")
  11535. readCard = DllDef.MustFindProc("ReadSFZ")
  11536. }
  11537. str := make([]byte, 8096)
  11538. str1 := make([]byte, 8096)
  11539. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  11540. fmt.Println(r)
  11541. return Remove0000(string(str))
  11542. }
  11543. func (c *HisApiController) GetEleBaseInfo() string {
  11544. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11545. readCard := DllDef.MustFindProc("GetQRBase")
  11546. fmt.Println(readCard)
  11547. if readCard == nil {
  11548. fmt.Println("readcard is nil")
  11549. readCard = DllDef.MustFindProc("GetQRBase")
  11550. }
  11551. str := make([]byte, 1024)
  11552. str1 := make([]byte, 1024)
  11553. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11554. fmt.Println(ret2)
  11555. fmt.Println(string(str1))
  11556. fmt.Println(string(str))
  11557. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11558. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11559. if ret2 != 0 {
  11560. return ""
  11561. }
  11562. return string(str)
  11563. }
  11564. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11565. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11566. readCard := DllDef.MustFindProc("NationEcTrans")
  11567. fmt.Println(readCard)
  11568. fmt.Println("!!!!!")
  11569. pBusiCardInfo := make([]byte, 2048)
  11570. input := make(map[string]interface{})
  11571. inputData := make(map[string]interface{})
  11572. inputData["orgId"] = code
  11573. inputData["businessType"] = "01101"
  11574. inputData["operatorId"] = "1"
  11575. inputData["operatorName"] = "admin"
  11576. inputData["officeId"] = "001"
  11577. inputData["officeName"] = "血透室"
  11578. inputData["deviceType"] = ""
  11579. input["data"] = inputData
  11580. input["orgId"] = code
  11581. input["transType"] = "ec.query"
  11582. bytesData, _ := json.Marshal(input)
  11583. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11584. fmt.Println(ret2)
  11585. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11586. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11587. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  11588. }
  11589. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11590. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11591. readCard := DllDef.MustFindProc("NationEcTrans")
  11592. fmt.Println(readCard)
  11593. fmt.Println("!!!!!")
  11594. pBusiCardInfo := make([]byte, 2048)
  11595. input := make(map[string]interface{})
  11596. inputData := make(map[string]interface{})
  11597. inputData["orgId"] = code
  11598. inputData["businessType"] = "01101"
  11599. inputData["operatorId"] = "9"
  11600. inputData["operatorName"] = "admin"
  11601. inputData["officeId"] = "001"
  11602. inputData["officeName"] = "血透室"
  11603. inputData["deviceType"] = ""
  11604. input["data"] = inputData
  11605. input["orgId"] = code
  11606. input["transType"] = "ec.query"
  11607. bytesData, _ := json.Marshal(input)
  11608. 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])))
  11609. fmt.Println(ret2)
  11610. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11611. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11612. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11613. }
  11614. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  11615. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11616. readCard := DllDef.MustFindProc("NationEcTrans")
  11617. fmt.Println(readCard)
  11618. fmt.Println("!!!!!")
  11619. pBusiCardInfo := make([]byte, 2048)
  11620. input := make(map[string]interface{})
  11621. inputData := make(map[string]interface{})
  11622. inputData["orgId"] = code
  11623. inputData["businessType"] = "01301"
  11624. inputData["operatorId"] = "9"
  11625. inputData["operatorName"] = "admin"
  11626. inputData["officeId"] = "001"
  11627. inputData["officeName"] = "血透室"
  11628. inputData["deviceType"] = ""
  11629. input["data"] = inputData
  11630. input["orgId"] = code
  11631. input["transType"] = "ec.query"
  11632. bytesData, _ := json.Marshal(input)
  11633. 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])))
  11634. fmt.Println(ret2)
  11635. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11636. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11637. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11638. }
  11639. func GetJxEleBaseInfo(org_id int64) string {
  11640. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11641. readCard := DllDef.MustFindProc("NationEcTrans")
  11642. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11643. if readCard == nil {
  11644. fmt.Println("readcard is nil")
  11645. readCard = DllDef.MustFindProc("NationEcTrans")
  11646. }
  11647. str1 := make([]byte, 1024)
  11648. data := make(map[string]interface{})
  11649. inputData := make(map[string]interface{})
  11650. inputData["orgId"] = miConfig.Code
  11651. inputData["businessType"] = "01101"
  11652. inputData["operatorId"] = "test001"
  11653. inputData["operatorName"] = "cn"
  11654. inputData["officeId"] = "32760"
  11655. inputData["officeName"] = "waike"
  11656. inputData["deviceType"] = ""
  11657. data["data"] = inputData
  11658. data["transType"] = "ec.query"
  11659. data["extra "] = ""
  11660. data["orgId"] = miConfig.Code
  11661. bytesData, _ := json.Marshal(data)
  11662. //bytesData, _ := json.Marshal(data)
  11663. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11664. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11665. fmt.Println(ret2)
  11666. fmt.Println(string(str1))
  11667. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11668. if ret2 != 0 {
  11669. return ""
  11670. }
  11671. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11672. }
  11673. func GetJxEleBaseInitInfo(org_id int64) string {
  11674. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11675. readCard := DllDef.MustFindProc("NationEcTrans")
  11676. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11677. if readCard == nil {
  11678. fmt.Println("readcard is nil")
  11679. readCard = DllDef.MustFindProc("NationEcTrans")
  11680. }
  11681. str1 := make([]byte, 2048)
  11682. data := make(map[string]interface{})
  11683. inputData := make(map[string]interface{})
  11684. inputData["orgId"] = miConfig.Code
  11685. inputData["businessType"] = "01101"
  11686. inputData["operatorId"] = "1"
  11687. inputData["operatorName"] = "huangchuang"
  11688. inputData["officeId"] = "101"
  11689. inputData["officeName"] = "xuetou"
  11690. inputData["deviceType"] = ""
  11691. data["data"] = inputData
  11692. data["transType"] = "ec.query"
  11693. data["orgId"] = miConfig.Code
  11694. bytesData, _ := json.Marshal(data)
  11695. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11696. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11697. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  11698. fmt.Println(ret2)
  11699. fmt.Println(string(str1))
  11700. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11701. if ret2 != 0 {
  11702. return ""
  11703. }
  11704. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  11705. initEleFlag = 1
  11706. }
  11707. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11708. }
  11709. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  11710. // // 构建命令
  11711. // cmd := exec.Command("python", "b.py")
  11712. //
  11713. // // 执行命令并等待完成
  11714. // output, err := cmd.CombinedOutput()
  11715. // if err != nil {
  11716. // fmt.Println("Error executing Python script:", err)
  11717. // return
  11718. // }
  11719. //
  11720. // // 打印Python脚本的输出
  11721. // fmt.Println(string(output))
  11722. //}
  11723. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  11724. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  11725. readCard := DllDef.MustFindProc("gxyb_call")
  11726. if readCard == nil {
  11727. fmt.Println("readcard is nil")
  11728. readCard = DllDef.MustFindProc("gxyb_call")
  11729. }
  11730. str := make([]byte, 1024)
  11731. str1 := make([]byte, 1024)
  11732. //data := make(map[string]interface{})
  11733. currentTime := time.Now()
  11734. // 格式化时间为 "YYYYMMDDHH24MISS"
  11735. formattedTime := currentTime.Format("20060102150405")
  11736. inputData := make(map[string]interface{})
  11737. inputData2 := make(map[string]interface{})
  11738. inputData["transNo"] = "1401"
  11739. inputData["transType"] = "passwordCheck"
  11740. inputData["timestamp"] = formattedTime
  11741. inputData2["fixmedinsCode"] = code
  11742. inputData2["psnNo"] = ""
  11743. inputData["data"] = inputData2
  11744. jsonBytes, err := json.Marshal(inputData)
  11745. if err != nil {
  11746. fmt.Println("Error encoding map to JSON:", err)
  11747. }
  11748. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11749. fmt.Println(string(str1))
  11750. fmt.Println(string(str))
  11751. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11752. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11753. if ret2 != 0 {
  11754. return ""
  11755. }
  11756. return string(str)
  11757. }
  11758. func (c *HisApiController) GetoleInfo() Response {
  11759. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11760. defer ole.CoUninitialize()
  11761. // Replace with the ProgID or CLSID of your COM object
  11762. progID := "YinHai.XJ.Actual.Interface.New"
  11763. // Create COM object
  11764. unknown, err := oleutil.CreateObject(progID)
  11765. if err != nil {
  11766. fmt.Println("Unable to create COM object:", err)
  11767. }
  11768. defer unknown.Release()
  11769. // Query for the IDispatch interface
  11770. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11771. if err != nil {
  11772. fmt.Println("Unable to get IDispatch interface:", err)
  11773. }
  11774. defer dispatch.Release()
  11775. // Prepare parameters
  11776. transNo := "1401"
  11777. transType := "passwordCheck"
  11778. timestamp := time.Now().Unix()
  11779. fixmedinsCode := "H45072101171"
  11780. psnNo := ""
  11781. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11782. result2 := ""
  11783. // Call COM object's method using the IDispatch interface
  11784. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11785. fmt.Println(resulr)
  11786. fmt.Println(result2)
  11787. if err != nil {
  11788. fmt.Println("调用COM对象方法失败:", err)
  11789. }
  11790. var response Response
  11791. err2 := json.Unmarshal([]byte(result2), &response)
  11792. if err2 != nil {
  11793. fmt.Println("解析JSON失败:", err)
  11794. }
  11795. return response
  11796. }
  11797. func (c *HisApiController) GetBasBaseInfo() string {
  11798. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11799. readCard := DllDef.MustFindProc("ReadCardBas")
  11800. if readCard == nil {
  11801. fmt.Println("readcard is nil")
  11802. readCard = DllDef.MustFindProc("ReadCardBas")
  11803. }
  11804. str := make([]byte, 1024)
  11805. str1 := make([]byte, 1024)
  11806. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11807. fmt.Println(string(str1))
  11808. fmt.Println(string(str))
  11809. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11810. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11811. if ret2 != 0 {
  11812. return ""
  11813. }
  11814. return string(str)
  11815. }
  11816. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11817. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11818. readCard := DllDef.MustFindProc("read_cardinfo")
  11819. if readCard == nil {
  11820. fmt.Println("readcard is nil")
  11821. readCard = DllDef.MustFindProc("read_cardinfo")
  11822. }
  11823. str := make([]byte, 1024) //卡号
  11824. str1 := make([]byte, 1024) //卡识别码
  11825. str2 := make([]byte, 1024) //身份证号
  11826. str3 := make([]byte, 1024) //姓名
  11827. str4 := make([]byte, 1024) //错误信息
  11828. 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])))
  11829. fmt.Println(string(str1))
  11830. fmt.Println(string(str))
  11831. fmt.Println(string(str2))
  11832. fmt.Println(string(str3))
  11833. fmt.Println(string(str4))
  11834. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11835. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11836. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11837. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11838. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11839. if ret2 != 0 {
  11840. return "", "", "", "", ""
  11841. }
  11842. return string(str), string(str1), string(str2), string(str3), string(str4)
  11843. }
  11844. type CustomFundPay struct {
  11845. FundPayType string `json:"fund_pay_type"`
  11846. FundPayamt float64 `json:"fund_payamt"`
  11847. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11848. }
  11849. //func (c *HisApiController) GetBatchSettleList() {
  11850. // start_time_str := c.GetString("start_time")
  11851. // //end_time_str := c.GetString("end_time")
  11852. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11853. //
  11854. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11855. //
  11856. // for _, item := range orders {
  11857. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11858. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11859. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11860. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11861. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11862. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11863. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11864. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11865. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11866. //
  11867. // if order.ID == 0 {
  11868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11869. // return
  11870. // }
  11871. //
  11872. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11873. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11874. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11875. // //fmt.Println(count)
  11876. // //var zero string
  11877. // //number := count + 1
  11878. // //if number >= 1000 {
  11879. // // zero = "0000" + strconv.FormatInt(number, 10)
  11880. // //} else if number >= 10000 {
  11881. // // zero = "000" + strconv.FormatInt(number, 10)
  11882. // //} else if number >= 100000 {
  11883. // // zero = "00" + strconv.FormatInt(number, 10)
  11884. // //} else if number >= 1000000 {
  11885. // // zero = "0" + strconv.FormatInt(number, 10)
  11886. // //} else {
  11887. // // zero = strconv.FormatInt(number, 10)
  11888. // //}
  11889. // //fmt.Println(zero)
  11890. //
  11891. // struct4101 := service.Struct4101{
  11892. // PsnNo: order.PsnNo,
  11893. // MdtrtId: order.MdtrtId,
  11894. // SetlId: order.SetlId,
  11895. // PsnName: order.PsnName,
  11896. // Gend: order.Gend,
  11897. // Brdy: his.Brdy,
  11898. // Age: his.Age,
  11899. // Naty: order.Naty,
  11900. // PatnCertType: "01",
  11901. // Certno: order.Certno,
  11902. // Prfs: "90",
  11903. // ConerName: roles[0].UserName,
  11904. // PatnRlts: "99",
  11905. // ConerAddr: miConfig.OrgName,
  11906. // ConerTel: admin.Mobile,
  11907. // HiType: order.Insutype,
  11908. // Insuplc: miConfig.InsuplcAdmdvs,
  11909. // MaindiagFlag: "1",
  11910. // BillCode: order.SetlId,
  11911. // BillNo: order.SetlId,
  11912. // BizSn: order.Number,
  11913. // PsnSelfPay: order.PsnPartAmt,
  11914. // PsnOwnPay: order.PsnPartAmt,
  11915. // AcctPay: order.AcctPay,
  11916. // PsnCashpay: order.PsnCashPay,
  11917. // HiPaymtd: "1",
  11918. // Hsorg: miConfig.InsuplcAdmdvs,
  11919. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11920. // MedinsFillPsn: curRoles.UserName,
  11921. // MedinsFillDept: miConfig.OrgName,
  11922. // IptMedType: "2",
  11923. // }
  11924. // struct4101.SetlBegnDate = order.SetlTime
  11925. // struct4101.SetlEndDate = order.SetlTime
  11926. // time_arr := strings.Split(order.SetlTime, " ")
  11927. // struct4101.AdmTime = time_arr[0]
  11928. // struct4101.AdmEndTime = time_arr[0]
  11929. //
  11930. // var rf []CustomFundPay
  11931. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11932. //
  11933. // var tempFunPays []service.CustomStruct
  11934. // for _, item := range rf {
  11935. // var tempFunPay service.CustomStruct
  11936. // tempFunPay.FundPayamt = item.FundPayamt
  11937. // tempFunPay.FundPayType = item.FundPayType
  11938. // tempFunPays = append(tempFunPays, tempFunPay)
  11939. // }
  11940. // struct4101.CustomStruct = tempFunPays
  11941. //
  11942. // var tempDiaginfos []service.DiaginfoStructTwo
  11943. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11944. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11945. //
  11946. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11947. // var config []*models.HisXtDiagnoseConfig
  11948. // for _, item := range diagnosis_ids {
  11949. // id, _ := strconv.ParseInt(item, 10, 64)
  11950. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11951. // config = append(config, &diagnosisConfig)
  11952. // }
  11953. //
  11954. // for index, item := range config {
  11955. // if index == 0 {
  11956. // var tempDiaginfo service.DiaginfoStructTwo
  11957. // tempDiaginfo.DiagCode = item.CountryCode
  11958. // tempDiaginfo.DiagName = item.CountryContentName
  11959. // tempDiaginfo.DiagType = "1"
  11960. // tempDiaginfo.MaindiagFlag = "1"
  11961. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11962. // } else {
  11963. // var tempDiaginfo service.DiaginfoStructTwo
  11964. // tempDiaginfo.DiagCode = item.CountryCode
  11965. // tempDiaginfo.DiagName = item.CountryContentName
  11966. // tempDiaginfo.DiagType = "1"
  11967. // tempDiaginfo.MaindiagFlag = "0"
  11968. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11969. // }
  11970. // }
  11971. // struct4101.Diseinfo = tempDiaginfos
  11972. //
  11973. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11974. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11975. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11976. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11977. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11978. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11979. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11980. //
  11981. // var iteminfo service.IteminfoStruct
  11982. //
  11983. // var bedCostTotal float64 = 0 //床位总费
  11984. // var bedCostSelfTotal float64 = 0 //床位自费
  11985. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11986. //
  11987. // var operationCostTotal float64 = 0 //手术费
  11988. // var operationCostSelfTotal float64 = 0 //手术费
  11989. // var operationCostPartSelfTotal float64 = 0 //手术费
  11990. //
  11991. // var otherCostTotal float64 = 0 //其他费用
  11992. // var otherCostSelfTotal float64 = 0 //其他费用
  11993. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11994. //
  11995. // var materialCostTotal float64 = 0 //材料费
  11996. // var materialCostSelfTotal float64 = 0 //材料费
  11997. // var materialCostPartSelfTotal float64 = 0 //材料费
  11998. //
  11999. // var westernMedicineCostTotal float64 = 0 //西药费
  12000. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  12001. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12002. //
  12003. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12004. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12005. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12006. //
  12007. // var checkCostTotal float64 = 0 //检查费
  12008. // var checkCostSelfTotal float64 = 0 //检查费
  12009. // var checkCostPartSelfTotal float64 = 0 //检查费
  12010. //
  12011. // var laboratoryCostTotal float64 = 0 //化验费
  12012. // var laboratoryCostSelfTotal float64 = 0 //化验费
  12013. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12014. //
  12015. // var treatCostTotal float64 = 0 //治疗费用
  12016. // var treatCostSelfTotal float64 = 0 //治疗费用
  12017. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  12018. //
  12019. // decimal.DivisionPrecision = 2
  12020. //
  12021. // var bed_fulamt_ownpay_amt float64 = 0
  12022. // var operation_fulamt_ownpay_amt float64 = 0
  12023. // var other_fulamt_ownpay_amt float64 = 0
  12024. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  12025. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12026. // var check_fulamt_ownpay_amt float64 = 0
  12027. // var material_fulamt_ownpay_amt float64 = 0
  12028. // var laboratory_fulamt_ownpay_amt float64 = 0
  12029. // var treat_fulamt_ownpay_amt float64 = 0
  12030. //
  12031. // var bed_claa_sunmfee float64 = 0
  12032. // var bed_clab_amt float64 = 0
  12033. // var bed_other_amt float64 = 0
  12034. //
  12035. // var operation_claa_sunmfee float64 = 0
  12036. // var operation_clab_amt float64 = 0
  12037. // var operation_other_amt float64 = 0
  12038. //
  12039. // var other_claa_sunmfee float64 = 0
  12040. // var other_clab_amt float64 = 0
  12041. // var other_other_amt float64 = 0
  12042. //
  12043. // var westernMedicine_claa_sunmfee float64 = 0
  12044. // var westernMedicine_clab_amt float64 = 0
  12045. // var westernMedicine_other_amt float64 = 0
  12046. //
  12047. // var chineseTraditional_claa_sunmfee float64 = 0
  12048. // var chineseTraditional_clab_amt float64 = 0
  12049. // var chineseTraditional_other_amt float64 = 0
  12050. //
  12051. // var check_claa_sunmfee float64 = 0
  12052. // var check_clab_amt float64 = 0
  12053. // var check_other_amt float64 = 0
  12054. //
  12055. // var material_claa_sunmfee float64 = 0
  12056. // var material_clab_amt float64 = 0
  12057. // var material_other_amt float64 = 0
  12058. //
  12059. // var laboratory_claa_sunmfee float64 = 0
  12060. // var laboratory_clab_amt float64 = 0
  12061. // var laboratory_other_amt float64 = 0
  12062. //
  12063. // var treat_claa_sunmfee float64 = 0
  12064. // var treat_clab_amt float64 = 0
  12065. // var treat_other_amt float64 = 0
  12066. //
  12067. // for _, item := range order.HisOrderInfo {
  12068. // if item.MedChrgitmType == "01" { //床位费
  12069. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12070. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12071. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12072. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12073. // if item.ChrgitmLv == "1" {
  12074. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12075. // }
  12076. // if item.ChrgitmLv == "2" {
  12077. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12078. //
  12079. // }
  12080. // if item.ChrgitmLv == "3" {
  12081. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12082. // }
  12083. //
  12084. // }
  12085. //
  12086. // if item.MedChrgitmType == "03" { //检查费
  12087. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12088. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12089. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12090. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12091. // if item.ChrgitmLv == "1" {
  12092. //
  12093. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12094. //
  12095. // }
  12096. // if item.ChrgitmLv == "2" {
  12097. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12098. //
  12099. // }
  12100. // if item.ChrgitmLv == "3" {
  12101. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12102. // }
  12103. // }
  12104. //
  12105. // if item.MedChrgitmType == "04" { //化验费
  12106. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12107. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12108. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12109. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12110. // if item.ChrgitmLv == "1" {
  12111. //
  12112. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12113. //
  12114. // }
  12115. // if item.ChrgitmLv == "2" {
  12116. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12117. //
  12118. // }
  12119. // if item.ChrgitmLv == "3" {
  12120. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12121. // }
  12122. // }
  12123. //
  12124. // if item.MedChrgitmType == "05" { //治疗费
  12125. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12126. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12127. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12128. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12129. // if item.ChrgitmLv == "1" {
  12130. //
  12131. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12132. //
  12133. // }
  12134. // if item.ChrgitmLv == "2" {
  12135. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12136. //
  12137. // }
  12138. // if item.ChrgitmLv == "3" {
  12139. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12140. // }
  12141. // }
  12142. //
  12143. // if item.MedChrgitmType == "06" { //手术费
  12144. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12145. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12146. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12147. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12148. //
  12149. // if item.ChrgitmLv == "1" {
  12150. //
  12151. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12152. //
  12153. // }
  12154. // if item.ChrgitmLv == "2" {
  12155. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12156. //
  12157. // }
  12158. // if item.ChrgitmLv == "3" {
  12159. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12160. // }
  12161. // }
  12162. //
  12163. // if item.MedChrgitmType == "08" { //材料费
  12164. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12165. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12166. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12167. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12168. // if item.ChrgitmLv == "1" {
  12169. //
  12170. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12171. //
  12172. // }
  12173. // if item.ChrgitmLv == "2" {
  12174. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12175. //
  12176. // }
  12177. // if item.ChrgitmLv == "3" {
  12178. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12179. // }
  12180. // }
  12181. //
  12182. // if item.MedChrgitmType == "09" { //西药费
  12183. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12184. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12185. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12186. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12187. // if item.ChrgitmLv == "1" {
  12188. //
  12189. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12190. //
  12191. // }
  12192. // if item.ChrgitmLv == "2" {
  12193. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12194. //
  12195. // }
  12196. // if item.ChrgitmLv == "3" {
  12197. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12198. // }
  12199. // }
  12200. //
  12201. // if item.MedChrgitmType == "11" { //中成费
  12202. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12203. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12204. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12205. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12206. // if item.ChrgitmLv == "1" {
  12207. //
  12208. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12209. //
  12210. // }
  12211. // if item.ChrgitmLv == "2" {
  12212. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12213. //
  12214. // }
  12215. // if item.ChrgitmLv == "3" {
  12216. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12217. // }
  12218. // }
  12219. //
  12220. // if item.MedChrgitmType == "14" { //其他费
  12221. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12222. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12223. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12224. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12225. // if item.ChrgitmLv == "1" {
  12226. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12227. //
  12228. // }
  12229. // if item.ChrgitmLv == "2" {
  12230. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12231. //
  12232. // }
  12233. // if item.ChrgitmLv == "3" {
  12234. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12235. // }
  12236. // }
  12237. //
  12238. // }
  12239. //
  12240. // var iteminfoStructs []service.IteminfoStruct
  12241. //
  12242. // if bedCostTotal != 0 {
  12243. // iteminfo.MedChrgitm = "01"
  12244. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12245. // iteminfo.Amt = bedCostTotal
  12246. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  12247. // iteminfo.ClabAmt = bed_clab_amt
  12248. // iteminfo.OthAmt = bed_other_amt
  12249. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12250. // }
  12251. //
  12252. // if checkCostTotal != 0 {
  12253. // iteminfo.MedChrgitm = "03"
  12254. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12255. // iteminfo.Amt = checkCostTotal
  12256. // iteminfo.ClaaSumfee = check_claa_sunmfee
  12257. // iteminfo.ClabAmt = check_clab_amt
  12258. // iteminfo.OthAmt = check_other_amt
  12259. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12260. //
  12261. // }
  12262. //
  12263. // if laboratoryCostTotal != 0 {
  12264. // iteminfo.MedChrgitm = "04"
  12265. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12266. // iteminfo.Amt = laboratoryCostTotal
  12267. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12268. // iteminfo.ClabAmt = laboratory_clab_amt
  12269. // iteminfo.OthAmt = laboratory_other_amt
  12270. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12271. //
  12272. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12273. //
  12274. // }
  12275. //
  12276. // if treatCostTotal != 0 {
  12277. // iteminfo.MedChrgitm = "05"
  12278. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12279. // iteminfo.Amt = treatCostTotal
  12280. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  12281. // iteminfo.ClabAmt = treat_clab_amt
  12282. // iteminfo.OthAmt = treat_other_amt
  12283. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12284. // //(struct4101.IteminfoStruct, iteminfo)
  12285. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12286. // }
  12287. //
  12288. // if operationCostTotal != 0 {
  12289. // iteminfo.MedChrgitm = "06"
  12290. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12291. // iteminfo.Amt = operationCostTotal
  12292. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  12293. // iteminfo.ClabAmt = operation_clab_amt
  12294. // iteminfo.OthAmt = operation_other_amt
  12295. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12296. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12297. // }
  12298. //
  12299. // if materialCostTotal != 0 {
  12300. // iteminfo.MedChrgitm = "08"
  12301. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12302. // iteminfo.Amt = materialCostTotal
  12303. // iteminfo.ClaaSumfee = material_claa_sunmfee
  12304. // iteminfo.ClabAmt = material_clab_amt
  12305. // iteminfo.OthAmt = material_other_amt
  12306. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12307. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12308. // }
  12309. //
  12310. // if westernMedicineCostTotal != 0 {
  12311. // iteminfo.MedChrgitm = "09"
  12312. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12313. // iteminfo.Amt = westernMedicineCostTotal
  12314. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12315. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12316. // iteminfo.OthAmt = westernMedicine_other_amt
  12317. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12318. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12319. //
  12320. // }
  12321. // if chineseTraditionalMedicineCostTotal != 0 {
  12322. // iteminfo.MedChrgitm = "11"
  12323. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12324. // iteminfo.Amt = westernMedicineCostTotal
  12325. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12326. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12327. // iteminfo.OthAmt = westernMedicine_other_amt
  12328. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12329. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12330. //
  12331. // }
  12332. // if otherCostTotal != 0 {
  12333. // iteminfo.MedChrgitm = "14"
  12334. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12335. // iteminfo.Amt = otherCostTotal
  12336. // iteminfo.ClaaSumfee = other_claa_sunmfee
  12337. // iteminfo.ClabAmt = other_clab_amt
  12338. // iteminfo.OthAmt = other_other_amt
  12339. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12340. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12341. //
  12342. // }
  12343. // struct4101.IteminfoStruct = iteminfoStructs
  12344. // struct4101.Ntly = "中国"
  12345. // struct4101.AdmCaty = "A03.06"
  12346. //
  12347. // struct4101.DoctorName = doctor.UserName
  12348. // struct4101.DoctorCode = doctor.DoctorNumber
  12349. //
  12350. // var res ResultSeventeen
  12351. //
  12352. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12353. // struct4101.BillCode = order.Number
  12354. // struct4101.BillNo = order.SetlId
  12355. // var resOther ResultSeventeenOther
  12356. // var pp models.PublicParams
  12357. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12358. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12359. // pp.FixmedinsName = miConfig.OrgName
  12360. // pp.FixmedinsCode = miConfig.Code
  12361. // pp.RequestUrl = miConfig.Url
  12362. // pp.Cainfo = miConfig.Cainfo
  12363. // pp.SecretKey = miConfig.SecretKey
  12364. // pp.AccessKey = miConfig.AccessKey
  12365. // pp.OpterName = curRoles.UserName
  12366. //
  12367. // client := &http.Client{}
  12368. // var req *http.Request
  12369. // data := make(map[string]interface{})
  12370. // data["struct4101"] = struct4101
  12371. // data["pp"] = pp
  12372. // bytesData, _ := json.Marshal(data)
  12373. // if miConfig.MdtrtareaAdmvs == "320921" {
  12374. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12375. // } else {
  12376. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12377. // }
  12378. // resp, _ := client.Do(req)
  12379. // defer resp.Body.Close()
  12380. // body, ioErr := ioutil.ReadAll(resp.Body)
  12381. // if ioErr != nil {
  12382. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12384. // return
  12385. // }
  12386. // var respJSON map[string]interface{}
  12387. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12388. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12390. // return
  12391. // }
  12392. //
  12393. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12394. // userJSONBytes, _ := json.Marshal(respJSON)
  12395. // fmt.Println("log")
  12396. // fmt.Println(string(userJSONBytes))
  12397. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12398. // utils.ErrorLog("解析失败:%v", err)
  12399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12400. // return
  12401. // }
  12402. // res.InfRefmsgid = resOther.InfRefmsgid
  12403. // res.Output = resOther.Output
  12404. // res.ErrMsg = resOther.ErrMsg
  12405. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12406. // res.Infcode = infocode
  12407. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  12408. //
  12409. // var pp models.PublicParams
  12410. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12411. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12412. // pp.FixmedinsName = miConfig.OrgName
  12413. // pp.FixmedinsCode = miConfig.Code
  12414. // pp.RequestUrl = miConfig.Url
  12415. // pp.Cainfo = miConfig.Cainfo
  12416. // pp.SecretKey = miConfig.SecretKey
  12417. // pp.AccessKey = miConfig.AccessKey
  12418. // pp.OpterName = curRoles.UserName
  12419. // result, _ := service.Jxyb4101(struct4101, pp)
  12420. // var dat map[string]interface{}
  12421. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12422. // fmt.Println(dat)
  12423. // } else {
  12424. // fmt.Println(err)
  12425. // }
  12426. // userJSONBytes, _ := json.Marshal(dat)
  12427. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12428. // utils.ErrorLog("解析失败:%v", err)
  12429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12430. // return
  12431. // }
  12432. //
  12433. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  12434. // var pp models.PublicParams
  12435. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12436. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12437. // pp.FixmedinsName = miConfig.OrgName
  12438. // pp.FixmedinsCode = miConfig.Code
  12439. // pp.RequestUrl = miConfig.Url
  12440. // pp.Cainfo = miConfig.Cainfo
  12441. // pp.SecretKey = miConfig.SecretKey
  12442. // pp.AccessKey = miConfig.AccessKey
  12443. // pp.OpterName = curRoles.UserName
  12444. // result, _ := service.Hnyb4101(struct4101, pp)
  12445. // var dat map[string]interface{}
  12446. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12447. // fmt.Println(dat)
  12448. // } else {
  12449. // fmt.Println(err)
  12450. // }
  12451. // userJSONBytes, _ := json.Marshal(dat)
  12452. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12453. // utils.ErrorLog("解析失败:%v", err)
  12454. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12455. // return
  12456. // }
  12457. //
  12458. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  12459. // var resOther ResultSeventeenOther
  12460. //
  12461. // var pp models.PublicParams
  12462. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12463. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12464. // pp.FixmedinsName = miConfig.OrgName
  12465. // pp.FixmedinsCode = miConfig.Code
  12466. // pp.RequestUrl = miConfig.Url
  12467. // pp.Cainfo = miConfig.Cainfo
  12468. // pp.SecretKey = miConfig.SecretKey
  12469. // pp.AccessKey = miConfig.AccessKey
  12470. // pp.OpterName = curRoles.UserName
  12471. // client := &http.Client{}
  12472. // var req *http.Request
  12473. // data := make(map[string]interface{})
  12474. // data["struct4101"] = struct4101
  12475. // data["pp"] = pp
  12476. // bytesData, _ := json.Marshal(data)
  12477. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12478. // resp, _ := client.Do(req)
  12479. // defer resp.Body.Close()
  12480. // body, ioErr := ioutil.ReadAll(resp.Body)
  12481. // if ioErr != nil {
  12482. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12484. // return
  12485. // }
  12486. // var respJSON map[string]interface{}
  12487. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12488. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12489. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12490. // return
  12491. // }
  12492. //
  12493. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12494. // userJSONBytes, _ := json.Marshal(respJSON)
  12495. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12496. // utils.ErrorLog("解析失败:%v", err)
  12497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12498. // return
  12499. // }
  12500. // res.InfRefmsgid = resOther.InfRefmsgid
  12501. // res.Output = resOther.Output
  12502. // res.ErrMsg = resOther.ErrMsg
  12503. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12504. // res.Infcode = infocode
  12505. //
  12506. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  12507. // var pp models.PublicParams
  12508. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12509. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12510. // pp.FixmedinsName = miConfig.OrgName
  12511. // pp.FixmedinsCode = miConfig.Code
  12512. // pp.RequestUrl = miConfig.Url
  12513. // pp.Cainfo = miConfig.Cainfo
  12514. // pp.SecretKey = miConfig.SecretKey
  12515. // pp.AccessKey = miConfig.AccessKey
  12516. // pp.OpterName = curRoles.UserName
  12517. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12518. // fmt.Println(requestLog)
  12519. // fmt.Println(errMsgLog)
  12520. //
  12521. // saveLog(result, requestLog, "4101a", "上传清单")
  12522. //
  12523. // var dat map[string]interface{}
  12524. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12525. // fmt.Println(dat)
  12526. // } else {
  12527. // fmt.Println(err)
  12528. // }
  12529. // userJSONBytes, _ := json.Marshal(dat)
  12530. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12531. // utils.ErrorLog("解析失败:%v", err)
  12532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12533. // return
  12534. // }
  12535. //
  12536. // } else {
  12537. //
  12538. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  12539. // var dat map[string]interface{}
  12540. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12541. // fmt.Println(dat)
  12542. // } else {
  12543. // fmt.Println(err)
  12544. // }
  12545. // userJSONBytes, _ := json.Marshal(dat)
  12546. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12547. // utils.ErrorLog("解析失败:%v", err)
  12548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12549. // return
  12550. // }
  12551. // }
  12552. //
  12553. // if res.Infcode != 0 {
  12554. // adminUser := c.GetAdminUserInfo()
  12555. // errlog := &models.HisOrderError{
  12556. // UserOrgId: adminUser.CurrentOrgId,
  12557. // Ctime: time.Now().Unix(),
  12558. // Mtime: time.Now().Unix(),
  12559. // ErrMsg: res.ErrMsg,
  12560. // Status: 1,
  12561. // PatientId: order.ID,
  12562. // Stage: 10265,
  12563. // }
  12564. // service.CreateErrMsgLog(errlog)
  12565. // continue
  12566. // } else {
  12567. // //order.FaPiaoNumber = zero
  12568. // //order.FaPiaoCode = last_order.FaPiaoCode
  12569. // //service.UpdateOrder(order)
  12570. // hisFundSettleListResult := &models.HisFundSettleListResult{
  12571. // Number: res.Output.SetlListId,
  12572. // Status: 1,
  12573. // Ctime: time.Now().Unix(),
  12574. // Mtime: time.Now().Unix(),
  12575. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12576. // IsUpload: 1,
  12577. // OrderId: order.ID,
  12578. // }
  12579. // service.CreateUploadRecord(hisFundSettleListResult)
  12580. // c.ServeSuccessJSON(map[string]interface{}{
  12581. // "msg": "上传成功",
  12582. // "result": hisFundSettleListResult,
  12583. // })
  12584. // continue
  12585. // }
  12586. // }
  12587. //}
  12588. func (c *HisApiController) GetbatchSettleList() {
  12589. //order_id, _ := c.GetInt64("order_id")
  12590. admin_user_id, _ := c.GetInt64("admin_user_id")
  12591. orders, _ := service.GetAllHisOrderTwo10485()
  12592. for _, item := range orders {
  12593. order, _ := service.GetHisOrderByIDTwo(item.ID)
  12594. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12595. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12596. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12597. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12598. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12599. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12600. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12601. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12602. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12603. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12604. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12605. //fmt.Println(count)
  12606. //var zero string
  12607. //number := count + 1
  12608. //if number >= 1000 {
  12609. // zero = "0000" + strconv.FormatInt(number, 10)
  12610. //} else if number >= 10000 {
  12611. // zero = "000" + strconv.FormatInt(number, 10)
  12612. //} else if number >= 100000 {
  12613. // zero = "00" + strconv.FormatInt(number, 10)
  12614. //} else if number >= 1000000 {
  12615. // zero = "0" + strconv.FormatInt(number, 10)
  12616. //} else {
  12617. // zero = strconv.FormatInt(number, 10)
  12618. //}
  12619. //fmt.Println(zero)
  12620. struct4101 := service.Struct4101{
  12621. PsnNo: order.PsnNo,
  12622. MdtrtId: order.MdtrtId,
  12623. SetlId: order.SetlId,
  12624. PsnName: order.PsnName,
  12625. Gend: order.Gend,
  12626. Brdy: his.Brdy,
  12627. Age: his.Age,
  12628. Naty: order.Naty,
  12629. PatnCertType: "01",
  12630. Certno: order.Certno,
  12631. Prfs: "90",
  12632. ConerName: roles[0].UserName,
  12633. PatnRlts: "99",
  12634. ConerAddr: miConfig.OrgName,
  12635. ConerTel: admin.Mobile,
  12636. HiType: order.Insutype,
  12637. Insuplc: miConfig.InsuplcAdmdvs,
  12638. MaindiagFlag: "1",
  12639. BillCode: order.SetlId,
  12640. BillNo: order.SetlId,
  12641. BizSn: order.Number,
  12642. PsnSelfPay: order.PsnPartAmt,
  12643. PsnOwnPay: order.PsnPartAmt,
  12644. AcctPay: order.AcctPay,
  12645. PsnCashpay: order.PsnCashPay,
  12646. HiPaymtd: "1",
  12647. Hsorg: miConfig.InsuplcAdmdvs,
  12648. HsorgOpter: miConfig.InsuplcAdmdvs,
  12649. MedinsFillPsn: curRoles.UserName,
  12650. MedinsFillDept: miConfig.OrgName,
  12651. IptMedType: "2",
  12652. }
  12653. struct4101.SetlBegnDate = order.SetlTime
  12654. struct4101.SetlEndDate = order.SetlTime
  12655. time_arr := strings.Split(order.SetlTime, " ")
  12656. struct4101.AdmTime = time_arr[0]
  12657. struct4101.AdmEndTime = time_arr[0]
  12658. //var rf []CustomFundPay
  12659. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12660. //
  12661. //var tempFunPays []service.CustomStruct
  12662. //for _, item := range rf {
  12663. // var tempFunPay service.CustomStruct
  12664. // tempFunPay.FundPayamt = item.FundPayamt
  12665. // tempFunPay.FundPayType = item.FundPayType
  12666. // tempFunPays = append(tempFunPays, tempFunPay)
  12667. //}
  12668. //struct4101.CustomStruct = tempFunPays
  12669. var tempDiaginfos []service.DiaginfoStructTwo
  12670. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12671. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12672. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12673. var config []*models.HisXtDiagnoseConfig
  12674. for _, item := range diagnosis_ids {
  12675. id, _ := strconv.ParseInt(item, 10, 64)
  12676. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12677. config = append(config, &diagnosisConfig)
  12678. }
  12679. for index, item := range config {
  12680. if index == 0 {
  12681. var tempDiaginfo service.DiaginfoStructTwo
  12682. tempDiaginfo.DiagCode = item.CountryCode
  12683. tempDiaginfo.DiagName = item.CountryContentName
  12684. tempDiaginfo.DiagType = "1"
  12685. tempDiaginfo.MaindiagFlag = "1"
  12686. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12687. } else {
  12688. var tempDiaginfo service.DiaginfoStructTwo
  12689. tempDiaginfo.DiagCode = item.CountryCode
  12690. tempDiaginfo.DiagName = item.CountryContentName
  12691. tempDiaginfo.DiagType = "1"
  12692. tempDiaginfo.MaindiagFlag = "0"
  12693. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12694. }
  12695. }
  12696. struct4101.Diseinfo = tempDiaginfos
  12697. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12698. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12699. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12700. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12701. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12702. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12703. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12704. var iteminfo service.IteminfoStruct
  12705. var bedCostTotal float64 = 0 //床位总费
  12706. var bedCostSelfTotal float64 = 0 //床位自费
  12707. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12708. var operationCostTotal float64 = 0 //手术费
  12709. var operationCostSelfTotal float64 = 0 //手术费
  12710. var operationCostPartSelfTotal float64 = 0 //手术费
  12711. var otherCostTotal float64 = 0 //其他费用
  12712. var otherCostSelfTotal float64 = 0 //其他费用
  12713. var otherCostPartSelfTotal float64 = 0 //其他费用
  12714. var materialCostTotal float64 = 0 //材料费
  12715. var materialCostSelfTotal float64 = 0 //材料费
  12716. var materialCostPartSelfTotal float64 = 0 //材料费
  12717. var westernMedicineCostTotal float64 = 0 //西药费
  12718. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12719. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12720. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12721. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12722. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12723. var checkCostTotal float64 = 0 //检查费
  12724. var checkCostSelfTotal float64 = 0 //检查费
  12725. var checkCostPartSelfTotal float64 = 0 //检查费
  12726. var laboratoryCostTotal float64 = 0 //化验费
  12727. var laboratoryCostSelfTotal float64 = 0 //化验费
  12728. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12729. var treatCostTotal float64 = 0 //治疗费用
  12730. var treatCostSelfTotal float64 = 0 //治疗费用
  12731. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12732. decimal.DivisionPrecision = 2
  12733. var bed_fulamt_ownpay_amt float64 = 0
  12734. var operation_fulamt_ownpay_amt float64 = 0
  12735. var other_fulamt_ownpay_amt float64 = 0
  12736. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12737. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12738. var check_fulamt_ownpay_amt float64 = 0
  12739. var material_fulamt_ownpay_amt float64 = 0
  12740. var laboratory_fulamt_ownpay_amt float64 = 0
  12741. var treat_fulamt_ownpay_amt float64 = 0
  12742. var bed_claa_sunmfee float64 = 0
  12743. var bed_clab_amt float64 = 0
  12744. var bed_other_amt float64 = 0
  12745. var operation_claa_sunmfee float64 = 0
  12746. var operation_clab_amt float64 = 0
  12747. var operation_other_amt float64 = 0
  12748. var other_claa_sunmfee float64 = 0
  12749. var other_clab_amt float64 = 0
  12750. var other_other_amt float64 = 0
  12751. var westernMedicine_claa_sunmfee float64 = 0
  12752. var westernMedicine_clab_amt float64 = 0
  12753. var westernMedicine_other_amt float64 = 0
  12754. var chineseTraditional_claa_sunmfee float64 = 0
  12755. var chineseTraditional_clab_amt float64 = 0
  12756. var chineseTraditional_other_amt float64 = 0
  12757. var check_claa_sunmfee float64 = 0
  12758. var check_clab_amt float64 = 0
  12759. var check_other_amt float64 = 0
  12760. var material_claa_sunmfee float64 = 0
  12761. var material_clab_amt float64 = 0
  12762. var material_other_amt float64 = 0
  12763. var laboratory_claa_sunmfee float64 = 0
  12764. var laboratory_clab_amt float64 = 0
  12765. var laboratory_other_amt float64 = 0
  12766. var treat_claa_sunmfee float64 = 0
  12767. var treat_clab_amt float64 = 0
  12768. var treat_other_amt float64 = 0
  12769. for _, item := range order.HisOrderInfo {
  12770. if item.MedChrgitmType == "01" { //床位费
  12771. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12772. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12773. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12774. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12775. if item.ChrgitmLv == "1" {
  12776. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12777. }
  12778. if item.ChrgitmLv == "2" {
  12779. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12780. }
  12781. if item.ChrgitmLv == "3" {
  12782. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12783. }
  12784. }
  12785. if item.MedChrgitmType == "03" { //检查费
  12786. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12787. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12788. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12789. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12790. if item.ChrgitmLv == "1" {
  12791. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12792. }
  12793. if item.ChrgitmLv == "2" {
  12794. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12795. }
  12796. if item.ChrgitmLv == "3" {
  12797. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12798. }
  12799. }
  12800. if item.MedChrgitmType == "04" { //化验费
  12801. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12802. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12803. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12804. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12805. if item.ChrgitmLv == "1" {
  12806. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12807. }
  12808. if item.ChrgitmLv == "2" {
  12809. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12810. }
  12811. if item.ChrgitmLv == "3" {
  12812. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12813. }
  12814. }
  12815. if item.MedChrgitmType == "05" { //治疗费
  12816. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12817. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12818. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12819. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12820. if item.ChrgitmLv == "1" {
  12821. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12822. }
  12823. if item.ChrgitmLv == "2" {
  12824. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12825. }
  12826. if item.ChrgitmLv == "3" {
  12827. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12828. }
  12829. }
  12830. if item.MedChrgitmType == "06" { //手术费
  12831. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12832. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12833. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12834. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12835. if item.ChrgitmLv == "1" {
  12836. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12837. }
  12838. if item.ChrgitmLv == "2" {
  12839. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12840. }
  12841. if item.ChrgitmLv == "3" {
  12842. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12843. }
  12844. }
  12845. if item.MedChrgitmType == "08" { //材料费
  12846. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12847. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12848. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12849. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12850. if item.ChrgitmLv == "1" {
  12851. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12852. }
  12853. if item.ChrgitmLv == "2" {
  12854. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12855. }
  12856. if item.ChrgitmLv == "3" {
  12857. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12858. }
  12859. }
  12860. if item.MedChrgitmType == "09" { //西药费
  12861. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12862. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12863. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12864. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12865. if item.ChrgitmLv == "1" {
  12866. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12867. }
  12868. if item.ChrgitmLv == "2" {
  12869. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12870. }
  12871. if item.ChrgitmLv == "3" {
  12872. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12873. }
  12874. }
  12875. if item.MedChrgitmType == "11" { //中成费
  12876. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12877. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12878. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12879. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12880. if item.ChrgitmLv == "1" {
  12881. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12882. }
  12883. if item.ChrgitmLv == "2" {
  12884. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12885. }
  12886. if item.ChrgitmLv == "3" {
  12887. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12888. }
  12889. }
  12890. if item.MedChrgitmType == "14" { //其他费
  12891. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12892. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12893. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12894. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12895. if item.ChrgitmLv == "1" {
  12896. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12897. }
  12898. if item.ChrgitmLv == "2" {
  12899. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12900. }
  12901. if item.ChrgitmLv == "3" {
  12902. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12903. }
  12904. }
  12905. }
  12906. var iteminfoStructs []service.IteminfoStruct
  12907. if bedCostTotal != 0 {
  12908. iteminfo.MedChrgitm = "01"
  12909. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12910. iteminfo.Amt = bedCostTotal
  12911. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12912. iteminfo.ClabAmt = bed_clab_amt
  12913. iteminfo.OthAmt = bed_other_amt
  12914. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12915. }
  12916. if checkCostTotal != 0 {
  12917. iteminfo.MedChrgitm = "03"
  12918. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12919. iteminfo.Amt = checkCostTotal
  12920. iteminfo.ClaaSumfee = check_claa_sunmfee
  12921. iteminfo.ClabAmt = check_clab_amt
  12922. iteminfo.OthAmt = check_other_amt
  12923. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12924. }
  12925. if laboratoryCostTotal != 0 {
  12926. iteminfo.MedChrgitm = "04"
  12927. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12928. iteminfo.Amt = laboratoryCostTotal
  12929. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12930. iteminfo.ClabAmt = laboratory_clab_amt
  12931. iteminfo.OthAmt = laboratory_other_amt
  12932. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12933. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12934. }
  12935. if treatCostTotal != 0 {
  12936. iteminfo.MedChrgitm = "05"
  12937. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12938. iteminfo.Amt = treatCostTotal
  12939. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12940. iteminfo.ClabAmt = treat_clab_amt
  12941. iteminfo.OthAmt = treat_other_amt
  12942. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12943. //(struct4101.IteminfoStruct, iteminfo)
  12944. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12945. }
  12946. if operationCostTotal != 0 {
  12947. iteminfo.MedChrgitm = "06"
  12948. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12949. iteminfo.Amt = operationCostTotal
  12950. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12951. iteminfo.ClabAmt = operation_clab_amt
  12952. iteminfo.OthAmt = operation_other_amt
  12953. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12954. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12955. }
  12956. if materialCostTotal != 0 {
  12957. iteminfo.MedChrgitm = "08"
  12958. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12959. iteminfo.Amt = materialCostTotal
  12960. iteminfo.ClaaSumfee = material_claa_sunmfee
  12961. iteminfo.ClabAmt = material_clab_amt
  12962. iteminfo.OthAmt = material_other_amt
  12963. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12964. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12965. }
  12966. if westernMedicineCostTotal != 0 {
  12967. iteminfo.MedChrgitm = "09"
  12968. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12969. iteminfo.Amt = westernMedicineCostTotal
  12970. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12971. iteminfo.ClabAmt = westernMedicine_clab_amt
  12972. iteminfo.OthAmt = westernMedicine_other_amt
  12973. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12974. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12975. }
  12976. if chineseTraditionalMedicineCostTotal != 0 {
  12977. iteminfo.MedChrgitm = "11"
  12978. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12979. iteminfo.Amt = westernMedicineCostTotal
  12980. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12981. iteminfo.ClabAmt = westernMedicine_clab_amt
  12982. iteminfo.OthAmt = westernMedicine_other_amt
  12983. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12984. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12985. }
  12986. if otherCostTotal != 0 {
  12987. iteminfo.MedChrgitm = "14"
  12988. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12989. iteminfo.Amt = otherCostTotal
  12990. iteminfo.ClaaSumfee = other_claa_sunmfee
  12991. iteminfo.ClabAmt = other_clab_amt
  12992. iteminfo.OthAmt = other_other_amt
  12993. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12994. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12995. }
  12996. struct4101.IteminfoStruct = iteminfoStructs
  12997. struct4101.Ntly = "中国"
  12998. struct4101.AdmCaty = "A03.06"
  12999. struct4101.DoctorName = doctor.UserName
  13000. struct4101.DoctorCode = doctor.DoctorNumber
  13001. var res ResultSeventeen
  13002. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13003. struct4101.BillCode = order.Number
  13004. struct4101.BillNo = order.SetlId
  13005. var resOther ResultSeventeenOther
  13006. var pp models.PublicParams
  13007. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13008. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13009. pp.FixmedinsName = miConfig.OrgName
  13010. pp.FixmedinsCode = miConfig.Code
  13011. pp.RequestUrl = miConfig.Url
  13012. pp.Cainfo = miConfig.Cainfo
  13013. pp.SecretKey = miConfig.SecretKey
  13014. pp.AccessKey = miConfig.AccessKey
  13015. pp.OpterName = curRoles.UserName
  13016. client := &http.Client{}
  13017. var req *http.Request
  13018. data := make(map[string]interface{})
  13019. data["struct4101"] = struct4101
  13020. data["pp"] = pp
  13021. bytesData, _ := json.Marshal(data)
  13022. if miConfig.MdtrtareaAdmvs == "320921" {
  13023. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13024. } else {
  13025. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13026. }
  13027. resp, _ := client.Do(req)
  13028. defer resp.Body.Close()
  13029. body, ioErr := ioutil.ReadAll(resp.Body)
  13030. if ioErr != nil {
  13031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13033. return
  13034. }
  13035. var respJSON map[string]interface{}
  13036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13039. return
  13040. }
  13041. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13042. userJSONBytes, _ := json.Marshal(respJSON)
  13043. fmt.Println("log")
  13044. fmt.Println(string(userJSONBytes))
  13045. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13046. utils.ErrorLog("解析失败:%v", err)
  13047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13048. return
  13049. }
  13050. res.InfRefmsgid = resOther.InfRefmsgid
  13051. res.Output = resOther.Output
  13052. res.ErrMsg = resOther.ErrMsg
  13053. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13054. res.Infcode = infocode
  13055. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13056. var pp models.PublicParams
  13057. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13058. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13059. pp.FixmedinsName = miConfig.OrgName
  13060. pp.FixmedinsCode = miConfig.Code
  13061. pp.RequestUrl = miConfig.Url
  13062. pp.Cainfo = miConfig.Cainfo
  13063. pp.SecretKey = miConfig.SecretKey
  13064. pp.AccessKey = miConfig.AccessKey
  13065. pp.OpterName = curRoles.UserName
  13066. result, _ := service.Jxyb4101(struct4101, pp)
  13067. var dat map[string]interface{}
  13068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13069. fmt.Println(dat)
  13070. } else {
  13071. fmt.Println(err)
  13072. }
  13073. userJSONBytes, _ := json.Marshal(dat)
  13074. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13075. utils.ErrorLog("解析失败:%v", err)
  13076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13077. return
  13078. }
  13079. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13080. var pp models.PublicParams
  13081. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13082. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13083. pp.FixmedinsName = miConfig.OrgName
  13084. pp.FixmedinsCode = miConfig.Code
  13085. pp.RequestUrl = miConfig.Url
  13086. pp.Cainfo = miConfig.Cainfo
  13087. pp.SecretKey = miConfig.SecretKey
  13088. pp.AccessKey = miConfig.AccessKey
  13089. pp.OpterName = curRoles.UserName
  13090. result, _ := service.Hnyb4101(struct4101, pp)
  13091. var dat map[string]interface{}
  13092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13093. fmt.Println(dat)
  13094. } else {
  13095. fmt.Println(err)
  13096. }
  13097. userJSONBytes, _ := json.Marshal(dat)
  13098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13099. utils.ErrorLog("解析失败:%v", err)
  13100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13101. return
  13102. }
  13103. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13104. var resOther ResultSeventeenOther
  13105. var pp models.PublicParams
  13106. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13107. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13108. pp.FixmedinsName = miConfig.OrgName
  13109. pp.FixmedinsCode = miConfig.Code
  13110. pp.RequestUrl = miConfig.Url
  13111. pp.Cainfo = miConfig.Cainfo
  13112. pp.SecretKey = miConfig.SecretKey
  13113. pp.AccessKey = miConfig.AccessKey
  13114. pp.OpterName = curRoles.UserName
  13115. client := &http.Client{}
  13116. var req *http.Request
  13117. data := make(map[string]interface{})
  13118. data["struct4101"] = struct4101
  13119. data["pp"] = pp
  13120. bytesData, _ := json.Marshal(data)
  13121. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13122. resp, _ := client.Do(req)
  13123. defer resp.Body.Close()
  13124. body, ioErr := ioutil.ReadAll(resp.Body)
  13125. if ioErr != nil {
  13126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13128. return
  13129. }
  13130. var respJSON map[string]interface{}
  13131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13134. return
  13135. }
  13136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13137. userJSONBytes, _ := json.Marshal(respJSON)
  13138. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13139. utils.ErrorLog("解析失败:%v", err)
  13140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13141. return
  13142. }
  13143. res.InfRefmsgid = resOther.InfRefmsgid
  13144. res.Output = resOther.Output
  13145. res.ErrMsg = resOther.ErrMsg
  13146. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13147. res.Infcode = infocode
  13148. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13149. var pp models.PublicParams
  13150. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13151. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13152. pp.FixmedinsName = miConfig.OrgName
  13153. pp.FixmedinsCode = miConfig.Code
  13154. pp.RequestUrl = miConfig.Url
  13155. pp.Cainfo = miConfig.Cainfo
  13156. pp.SecretKey = miConfig.SecretKey
  13157. pp.AccessKey = miConfig.AccessKey
  13158. pp.OpterName = curRoles.UserName
  13159. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13160. fmt.Println(requestLog)
  13161. fmt.Println(errMsgLog)
  13162. saveLog(result, requestLog, "4101a", "上传清单")
  13163. var dat map[string]interface{}
  13164. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13165. fmt.Println(dat)
  13166. } else {
  13167. fmt.Println(err)
  13168. }
  13169. userJSONBytes, _ := json.Marshal(dat)
  13170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13171. utils.ErrorLog("解析失败:%v", err)
  13172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13173. return
  13174. }
  13175. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13176. var pp models.PublicParams
  13177. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13178. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13179. pp.FixmedinsName = miConfig.OrgName
  13180. pp.FixmedinsCode = miConfig.Code
  13181. pp.RequestUrl = miConfig.Url
  13182. pp.Cainfo = miConfig.Cainfo
  13183. pp.SecretKey = miConfig.SecretKey
  13184. pp.AccessKey = miConfig.AccessKey
  13185. pp.OpterName = curRoles.UserName
  13186. client := &http.Client{}
  13187. var req *http.Request
  13188. data := make(map[string]interface{})
  13189. data["struct4101"] = struct4101
  13190. data["pp"] = pp
  13191. bytesData, _ := json.Marshal(data)
  13192. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13193. resp, _ := client.Do(req)
  13194. defer resp.Body.Close()
  13195. body, ioErr := ioutil.ReadAll(resp.Body)
  13196. if ioErr != nil {
  13197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13199. return
  13200. }
  13201. var respJSON map[string]interface{}
  13202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13205. return
  13206. }
  13207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13208. userJSONBytes, _ := json.Marshal(respJSON)
  13209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13210. utils.ErrorLog("解析失败:%v", err)
  13211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13212. return
  13213. }
  13214. } else {
  13215. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13216. var dat map[string]interface{}
  13217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13218. fmt.Println(dat)
  13219. } else {
  13220. fmt.Println(err)
  13221. }
  13222. userJSONBytes, _ := json.Marshal(dat)
  13223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13224. utils.ErrorLog("解析失败:%v", err)
  13225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13226. return
  13227. }
  13228. }
  13229. if res.Infcode != 0 {
  13230. errlog := &models.HisOrderError{
  13231. UserOrgId: order.UserOrgId,
  13232. Ctime: time.Now().Unix(),
  13233. Mtime: time.Now().Unix(),
  13234. ErrMsg: res.ErrMsg + "解析失败",
  13235. Status: 1,
  13236. PatientId: order.ID,
  13237. Stage: 10485,
  13238. }
  13239. service.CreateErrMsgLog(errlog)
  13240. continue
  13241. //c.ServeSuccessJSON(map[string]interface{}{
  13242. // "failed_code": -10,
  13243. // "msg": res.ErrMsg,
  13244. //})
  13245. } else {
  13246. //order.FaPiaoNumber = zero
  13247. //order.FaPiaoCode = last_order.FaPiaoCode
  13248. //service.UpdateOrder(order)
  13249. hisFundSettleListResult := &models.HisFundSettleListResult{
  13250. Number: res.Output.SetlListId,
  13251. Status: 1,
  13252. Ctime: time.Now().Unix(),
  13253. Mtime: time.Now().Unix(),
  13254. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13255. IsUpload: 1,
  13256. OrderId: order.ID,
  13257. }
  13258. service.CreateUploadRecord(hisFundSettleListResult)
  13259. continue
  13260. }
  13261. }
  13262. }
  13263. func (c *HisApiController) GetSettleList() {
  13264. order_id, _ := c.GetInt64("order_id")
  13265. admin_user_id, _ := c.GetInt64("admin_user_id")
  13266. order, _ := service.GetHisOrderByIDTwo(order_id)
  13267. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13268. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13269. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13270. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13271. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13272. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13273. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13274. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13275. if order.ID == 0 {
  13276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13277. return
  13278. }
  13279. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13280. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13281. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13282. //fmt.Println(count)
  13283. //var zero string
  13284. //number := count + 1
  13285. //if number >= 1000 {
  13286. // zero = "0000" + strconv.FormatInt(number, 10)
  13287. //} else if number >= 10000 {
  13288. // zero = "000" + strconv.FormatInt(number, 10)
  13289. //} else if number >= 100000 {
  13290. // zero = "00" + strconv.FormatInt(number, 10)
  13291. //} else if number >= 1000000 {
  13292. // zero = "0" + strconv.FormatInt(number, 10)
  13293. //} else {
  13294. // zero = strconv.FormatInt(number, 10)
  13295. //}
  13296. //fmt.Println(zero)
  13297. struct4101 := service.Struct4101{
  13298. PsnNo: order.PsnNo,
  13299. MdtrtId: order.MdtrtId,
  13300. SetlId: order.SetlId,
  13301. PsnName: order.PsnName,
  13302. Gend: order.Gend,
  13303. Brdy: his.Brdy,
  13304. Age: his.Age,
  13305. Naty: order.Naty,
  13306. PatnCertType: "01",
  13307. Certno: order.Certno,
  13308. Prfs: "90",
  13309. ConerName: roles[0].UserName,
  13310. PatnRlts: "99",
  13311. ConerAddr: miConfig.OrgName,
  13312. ConerTel: admin.Mobile,
  13313. HiType: order.Insutype,
  13314. Insuplc: miConfig.InsuplcAdmdvs,
  13315. MaindiagFlag: "1",
  13316. BillCode: order.SetlId,
  13317. BillNo: order.SetlId,
  13318. BizSn: order.Number,
  13319. PsnSelfPay: order.PsnPartAmt,
  13320. PsnOwnPay: order.PsnPartAmt,
  13321. AcctPay: order.AcctPay,
  13322. PsnCashpay: order.PsnCashPay,
  13323. HiPaymtd: "1",
  13324. Hsorg: miConfig.InsuplcAdmdvs,
  13325. HsorgOpter: miConfig.InsuplcAdmdvs,
  13326. MedinsFillPsn: curRoles.UserName,
  13327. MedinsFillDept: miConfig.OrgName,
  13328. IptMedType: "2",
  13329. }
  13330. struct4101.SetlBegnDate = order.SetlTime
  13331. struct4101.SetlEndDate = order.SetlTime
  13332. time_arr := strings.Split(order.SetlTime, " ")
  13333. struct4101.AdmTime = time_arr[0]
  13334. struct4101.AdmEndTime = time_arr[0]
  13335. //
  13336. //var rf []CustomFundPay
  13337. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13338. //
  13339. //var tempFunPays []service.CustomStruct
  13340. //for _, item := range rf {
  13341. // var tempFunPay service.CustomStruct
  13342. // tempFunPay.FundPayamt = item.FundPayamt
  13343. // tempFunPay.FundPayType = item.FundPayType
  13344. // tempFunPays = append(tempFunPays, tempFunPay)
  13345. //}
  13346. //struct4101.CustomStruct = tempFunPays
  13347. var tempDiaginfos []service.DiaginfoStructTwo
  13348. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13349. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13350. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  13351. var config []*models.HisXtDiagnoseConfig
  13352. for _, item := range diagnosis_ids {
  13353. id, _ := strconv.ParseInt(item, 10, 64)
  13354. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13355. config = append(config, &diagnosisConfig)
  13356. }
  13357. if miConfig.Code == "H15049901371" {
  13358. //for _, item := range config {
  13359. // if item.ID == 138 {
  13360. diagnosisConfig, _ := service.FindDiagnoseById(138)
  13361. var tempDiaginfo service.DiaginfoStructTwo
  13362. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  13363. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  13364. tempDiaginfo.DiagType = "1"
  13365. tempDiaginfo.MaindiagFlag = "1"
  13366. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13367. //}
  13368. //}
  13369. for _, item := range config {
  13370. if item.ID != 138 {
  13371. var tempDiaginfo service.DiaginfoStructTwo
  13372. tempDiaginfo.DiagCode = item.CountryCode
  13373. tempDiaginfo.DiagName = item.CountryContentName
  13374. tempDiaginfo.DiagType = "1"
  13375. tempDiaginfo.MaindiagFlag = "0"
  13376. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13377. }
  13378. }
  13379. } else {
  13380. for index, item := range config {
  13381. if index == 0 {
  13382. var tempDiaginfo service.DiaginfoStructTwo
  13383. tempDiaginfo.DiagCode = item.CountryCode
  13384. tempDiaginfo.DiagName = item.CountryContentName
  13385. tempDiaginfo.DiagType = "1"
  13386. tempDiaginfo.MaindiagFlag = "1"
  13387. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13388. } else {
  13389. var tempDiaginfo service.DiaginfoStructTwo
  13390. tempDiaginfo.DiagCode = item.CountryCode
  13391. tempDiaginfo.DiagName = item.CountryContentName
  13392. tempDiaginfo.DiagType = "1"
  13393. tempDiaginfo.MaindiagFlag = "0"
  13394. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13395. }
  13396. }
  13397. }
  13398. struct4101.Diseinfo = tempDiaginfos
  13399. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13400. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13401. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13402. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13403. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13404. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13405. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13406. var iteminfo service.IteminfoStruct
  13407. var bedCostTotal float64 = 0 //床位总费
  13408. var bedCostSelfTotal float64 = 0 //床位自费
  13409. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13410. var operationCostTotal float64 = 0 //手术费
  13411. var operationCostSelfTotal float64 = 0 //手术费
  13412. var operationCostPartSelfTotal float64 = 0 //手术费
  13413. var otherCostTotal float64 = 0 //其他费用
  13414. var otherCostSelfTotal float64 = 0 //其他费用
  13415. var otherCostPartSelfTotal float64 = 0 //其他费用
  13416. var materialCostTotal float64 = 0 //材料费
  13417. var materialCostSelfTotal float64 = 0 //材料费
  13418. var materialCostPartSelfTotal float64 = 0 //材料费
  13419. var westernMedicineCostTotal float64 = 0 //西药费
  13420. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13421. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13422. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13423. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13424. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13425. var checkCostTotal float64 = 0 //检查费
  13426. var checkCostSelfTotal float64 = 0 //检查费
  13427. var checkCostPartSelfTotal float64 = 0 //检查费
  13428. var laboratoryCostTotal float64 = 0 //化验费
  13429. var laboratoryCostSelfTotal float64 = 0 //化验费
  13430. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13431. var treatCostTotal float64 = 0 //治疗费用
  13432. var treatCostSelfTotal float64 = 0 //治疗费用
  13433. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13434. decimal.DivisionPrecision = 2
  13435. var bed_fulamt_ownpay_amt float64 = 0
  13436. var operation_fulamt_ownpay_amt float64 = 0
  13437. var other_fulamt_ownpay_amt float64 = 0
  13438. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13439. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13440. var check_fulamt_ownpay_amt float64 = 0
  13441. var material_fulamt_ownpay_amt float64 = 0
  13442. var laboratory_fulamt_ownpay_amt float64 = 0
  13443. var treat_fulamt_ownpay_amt float64 = 0
  13444. var bed_claa_sunmfee float64 = 0
  13445. var bed_clab_amt float64 = 0
  13446. var bed_other_amt float64 = 0
  13447. var operation_claa_sunmfee float64 = 0
  13448. var operation_clab_amt float64 = 0
  13449. var operation_other_amt float64 = 0
  13450. var other_claa_sunmfee float64 = 0
  13451. var other_clab_amt float64 = 0
  13452. var other_other_amt float64 = 0
  13453. var westernMedicine_claa_sunmfee float64 = 0
  13454. var westernMedicine_clab_amt float64 = 0
  13455. var westernMedicine_other_amt float64 = 0
  13456. var chineseTraditional_claa_sunmfee float64 = 0
  13457. var chineseTraditional_clab_amt float64 = 0
  13458. var chineseTraditional_other_amt float64 = 0
  13459. var check_claa_sunmfee float64 = 0
  13460. var check_clab_amt float64 = 0
  13461. var check_other_amt float64 = 0
  13462. var material_claa_sunmfee float64 = 0
  13463. var material_clab_amt float64 = 0
  13464. var material_other_amt float64 = 0
  13465. var laboratory_claa_sunmfee float64 = 0
  13466. var laboratory_clab_amt float64 = 0
  13467. var laboratory_other_amt float64 = 0
  13468. var treat_claa_sunmfee float64 = 0
  13469. var treat_clab_amt float64 = 0
  13470. var treat_other_amt float64 = 0
  13471. for _, item := range order.HisOrderInfo {
  13472. if item.MedChrgitmType == "01" { //床位费
  13473. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13474. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13475. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13476. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13477. if item.ChrgitmLv == "1" {
  13478. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13479. }
  13480. if item.ChrgitmLv == "2" {
  13481. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13482. }
  13483. if item.ChrgitmLv == "3" {
  13484. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13485. }
  13486. }
  13487. if item.MedChrgitmType == "03" { //检查费
  13488. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13489. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13490. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13491. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13492. if item.ChrgitmLv == "1" {
  13493. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13494. }
  13495. if item.ChrgitmLv == "2" {
  13496. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13497. }
  13498. if item.ChrgitmLv == "3" {
  13499. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13500. }
  13501. }
  13502. if item.MedChrgitmType == "04" { //化验费
  13503. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13504. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13505. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13506. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13507. if item.ChrgitmLv == "1" {
  13508. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13509. }
  13510. if item.ChrgitmLv == "2" {
  13511. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13512. }
  13513. if item.ChrgitmLv == "3" {
  13514. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13515. }
  13516. }
  13517. if item.MedChrgitmType == "05" { //治疗费
  13518. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13519. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13520. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13521. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13522. if item.ChrgitmLv == "1" {
  13523. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13524. }
  13525. if item.ChrgitmLv == "2" {
  13526. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13527. }
  13528. if item.ChrgitmLv == "3" {
  13529. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13530. }
  13531. }
  13532. if item.MedChrgitmType == "06" { //手术费
  13533. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13534. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13535. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13536. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13537. if item.ChrgitmLv == "1" {
  13538. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13539. }
  13540. if item.ChrgitmLv == "2" {
  13541. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13542. }
  13543. if item.ChrgitmLv == "3" {
  13544. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13545. }
  13546. }
  13547. if item.MedChrgitmType == "08" { //材料费
  13548. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13549. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13550. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13551. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13552. if item.ChrgitmLv == "1" {
  13553. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13554. }
  13555. if item.ChrgitmLv == "2" {
  13556. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13557. }
  13558. if item.ChrgitmLv == "3" {
  13559. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13560. }
  13561. }
  13562. if item.MedChrgitmType == "09" { //西药费
  13563. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13564. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13565. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13566. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13567. if item.ChrgitmLv == "1" {
  13568. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13569. }
  13570. if item.ChrgitmLv == "2" {
  13571. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13572. }
  13573. if item.ChrgitmLv == "3" {
  13574. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13575. }
  13576. }
  13577. if item.MedChrgitmType == "11" { //中成费
  13578. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13579. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13580. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13581. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13582. if item.ChrgitmLv == "1" {
  13583. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13584. }
  13585. if item.ChrgitmLv == "2" {
  13586. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13587. }
  13588. if item.ChrgitmLv == "3" {
  13589. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13590. }
  13591. }
  13592. if item.MedChrgitmType == "14" { //其他费
  13593. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13594. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13595. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13596. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13597. if item.ChrgitmLv == "1" {
  13598. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13599. }
  13600. if item.ChrgitmLv == "2" {
  13601. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13602. }
  13603. if item.ChrgitmLv == "3" {
  13604. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13605. }
  13606. }
  13607. }
  13608. var iteminfoStructs []service.IteminfoStruct
  13609. if bedCostTotal != 0 {
  13610. iteminfo.MedChrgitm = "01"
  13611. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13612. iteminfo.Amt = bedCostTotal
  13613. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13614. iteminfo.ClabAmt = bed_clab_amt
  13615. iteminfo.OthAmt = bed_other_amt
  13616. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13617. }
  13618. if checkCostTotal != 0 {
  13619. iteminfo.MedChrgitm = "03"
  13620. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13621. iteminfo.Amt = checkCostTotal
  13622. iteminfo.ClaaSumfee = check_claa_sunmfee
  13623. iteminfo.ClabAmt = check_clab_amt
  13624. iteminfo.OthAmt = check_other_amt
  13625. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13626. }
  13627. if laboratoryCostTotal != 0 {
  13628. iteminfo.MedChrgitm = "04"
  13629. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13630. iteminfo.Amt = laboratoryCostTotal
  13631. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13632. iteminfo.ClabAmt = laboratory_clab_amt
  13633. iteminfo.OthAmt = laboratory_other_amt
  13634. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13635. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13636. }
  13637. if treatCostTotal != 0 {
  13638. iteminfo.MedChrgitm = "05"
  13639. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13640. iteminfo.Amt = treatCostTotal
  13641. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13642. iteminfo.ClabAmt = treat_clab_amt
  13643. iteminfo.OthAmt = treat_other_amt
  13644. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13645. //(struct4101.IteminfoStruct, iteminfo)
  13646. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13647. }
  13648. if operationCostTotal != 0 {
  13649. iteminfo.MedChrgitm = "06"
  13650. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13651. iteminfo.Amt = operationCostTotal
  13652. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13653. iteminfo.ClabAmt = operation_clab_amt
  13654. iteminfo.OthAmt = operation_other_amt
  13655. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13656. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13657. }
  13658. if materialCostTotal != 0 {
  13659. iteminfo.MedChrgitm = "08"
  13660. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13661. iteminfo.Amt = materialCostTotal
  13662. iteminfo.ClaaSumfee = material_claa_sunmfee
  13663. iteminfo.ClabAmt = material_clab_amt
  13664. iteminfo.OthAmt = material_other_amt
  13665. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13666. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13667. }
  13668. if westernMedicineCostTotal != 0 {
  13669. iteminfo.MedChrgitm = "09"
  13670. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13671. iteminfo.Amt = westernMedicineCostTotal
  13672. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13673. iteminfo.ClabAmt = westernMedicine_clab_amt
  13674. iteminfo.OthAmt = westernMedicine_other_amt
  13675. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13676. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13677. }
  13678. if chineseTraditionalMedicineCostTotal != 0 {
  13679. iteminfo.MedChrgitm = "11"
  13680. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13681. iteminfo.Amt = westernMedicineCostTotal
  13682. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13683. iteminfo.ClabAmt = westernMedicine_clab_amt
  13684. iteminfo.OthAmt = westernMedicine_other_amt
  13685. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13686. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13687. }
  13688. if otherCostTotal != 0 {
  13689. iteminfo.MedChrgitm = "14"
  13690. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13691. iteminfo.Amt = otherCostTotal
  13692. iteminfo.ClaaSumfee = other_claa_sunmfee
  13693. iteminfo.ClabAmt = other_clab_amt
  13694. iteminfo.OthAmt = other_other_amt
  13695. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13696. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13697. }
  13698. struct4101.IteminfoStruct = iteminfoStructs
  13699. struct4101.Ntly = "中国"
  13700. struct4101.AdmCaty = "A03.06"
  13701. struct4101.DoctorName = doctor.UserName
  13702. struct4101.DoctorCode = doctor.DoctorNumber
  13703. var res ResultSeventeen
  13704. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13705. struct4101.BillCode = order.Number
  13706. struct4101.BillNo = order.SetlId
  13707. var resOther ResultSeventeenOther
  13708. var pp models.PublicParams
  13709. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13710. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13711. pp.FixmedinsName = miConfig.OrgName
  13712. pp.FixmedinsCode = miConfig.Code
  13713. pp.RequestUrl = miConfig.Url
  13714. pp.Cainfo = miConfig.Cainfo
  13715. pp.SecretKey = miConfig.SecretKey
  13716. pp.AccessKey = miConfig.AccessKey
  13717. pp.OpterName = curRoles.UserName
  13718. client := &http.Client{}
  13719. var req *http.Request
  13720. data := make(map[string]interface{})
  13721. data["struct4101"] = struct4101
  13722. data["pp"] = pp
  13723. bytesData, _ := json.Marshal(data)
  13724. if miConfig.MdtrtareaAdmvs == "320921" {
  13725. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13726. } else {
  13727. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13728. }
  13729. resp, _ := client.Do(req)
  13730. defer resp.Body.Close()
  13731. body, ioErr := ioutil.ReadAll(resp.Body)
  13732. if ioErr != nil {
  13733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13735. return
  13736. }
  13737. var respJSON map[string]interface{}
  13738. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13741. return
  13742. }
  13743. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13744. userJSONBytes, _ := json.Marshal(respJSON)
  13745. fmt.Println("log")
  13746. fmt.Println(string(userJSONBytes))
  13747. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13748. utils.ErrorLog("解析失败:%v", err)
  13749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13750. return
  13751. }
  13752. res.InfRefmsgid = resOther.InfRefmsgid
  13753. res.Output = resOther.Output
  13754. res.ErrMsg = resOther.ErrMsg
  13755. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13756. res.Infcode = infocode
  13757. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13758. var pp models.PublicParams
  13759. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13760. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13761. pp.FixmedinsName = miConfig.OrgName
  13762. pp.FixmedinsCode = miConfig.Code
  13763. pp.RequestUrl = miConfig.Url
  13764. pp.Cainfo = miConfig.Cainfo
  13765. pp.SecretKey = miConfig.SecretKey
  13766. pp.AccessKey = miConfig.AccessKey
  13767. pp.OpterName = curRoles.UserName
  13768. result, _ := service.Jxyb4101(struct4101, pp)
  13769. var dat map[string]interface{}
  13770. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13771. fmt.Println(dat)
  13772. } else {
  13773. fmt.Println(err)
  13774. }
  13775. userJSONBytes, _ := json.Marshal(dat)
  13776. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13777. utils.ErrorLog("解析失败:%v", err)
  13778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13779. return
  13780. }
  13781. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13782. var pp models.PublicParams
  13783. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13784. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13785. pp.FixmedinsName = miConfig.OrgName
  13786. pp.FixmedinsCode = miConfig.Code
  13787. pp.RequestUrl = miConfig.Url
  13788. pp.Cainfo = miConfig.Cainfo
  13789. pp.SecretKey = miConfig.SecretKey
  13790. pp.AccessKey = miConfig.AccessKey
  13791. pp.OpterName = curRoles.UserName
  13792. result, _ := service.Hnyb4101(struct4101, pp)
  13793. var dat map[string]interface{}
  13794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13795. fmt.Println(dat)
  13796. } else {
  13797. fmt.Println(err)
  13798. }
  13799. userJSONBytes, _ := json.Marshal(dat)
  13800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13801. utils.ErrorLog("解析失败:%v", err)
  13802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13803. return
  13804. }
  13805. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13806. var resOther ResultSeventeenOther
  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. client := &http.Client{}
  13818. var req *http.Request
  13819. data := make(map[string]interface{})
  13820. data["struct4101"] = struct4101
  13821. data["pp"] = pp
  13822. bytesData, _ := json.Marshal(data)
  13823. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13824. resp, _ := client.Do(req)
  13825. defer resp.Body.Close()
  13826. body, ioErr := ioutil.ReadAll(resp.Body)
  13827. if ioErr != nil {
  13828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13830. return
  13831. }
  13832. var respJSON map[string]interface{}
  13833. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13836. return
  13837. }
  13838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13839. userJSONBytes, _ := json.Marshal(respJSON)
  13840. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13841. utils.ErrorLog("解析失败:%v", err)
  13842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13843. return
  13844. }
  13845. res.InfRefmsgid = resOther.InfRefmsgid
  13846. res.Output = resOther.Output
  13847. res.ErrMsg = resOther.ErrMsg
  13848. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13849. res.Infcode = infocode
  13850. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13851. var pp models.PublicParams
  13852. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13853. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13854. pp.FixmedinsName = miConfig.OrgName
  13855. pp.FixmedinsCode = miConfig.Code
  13856. pp.RequestUrl = miConfig.Url
  13857. pp.Cainfo = miConfig.Cainfo
  13858. pp.SecretKey = miConfig.SecretKey
  13859. pp.AccessKey = miConfig.AccessKey
  13860. pp.OpterName = curRoles.UserName
  13861. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13862. fmt.Println(requestLog)
  13863. fmt.Println(errMsgLog)
  13864. saveLog(result, requestLog, "4101a", "上传清单")
  13865. var dat map[string]interface{}
  13866. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13867. fmt.Println(dat)
  13868. } else {
  13869. fmt.Println(err)
  13870. }
  13871. userJSONBytes, _ := json.Marshal(dat)
  13872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13873. utils.ErrorLog("解析失败:%v", err)
  13874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13875. return
  13876. }
  13877. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13878. var pp models.PublicParams
  13879. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13880. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13881. pp.FixmedinsName = miConfig.OrgName
  13882. pp.FixmedinsCode = miConfig.Code
  13883. pp.RequestUrl = miConfig.Url
  13884. pp.Cainfo = miConfig.Cainfo
  13885. pp.SecretKey = miConfig.SecretKey
  13886. pp.AccessKey = miConfig.AccessKey
  13887. pp.OpterName = curRoles.UserName
  13888. client := &http.Client{}
  13889. var req *http.Request
  13890. data := make(map[string]interface{})
  13891. data["struct4101"] = struct4101
  13892. data["pp"] = pp
  13893. bytesData, _ := json.Marshal(data)
  13894. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13895. resp, _ := client.Do(req)
  13896. defer resp.Body.Close()
  13897. body, ioErr := ioutil.ReadAll(resp.Body)
  13898. if ioErr != nil {
  13899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13901. return
  13902. }
  13903. var respJSON map[string]interface{}
  13904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13907. return
  13908. }
  13909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13910. userJSONBytes, _ := json.Marshal(respJSON)
  13911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13912. utils.ErrorLog("解析失败:%v", err)
  13913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13914. return
  13915. }
  13916. } else {
  13917. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13918. var dat map[string]interface{}
  13919. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13920. fmt.Println(dat)
  13921. } else {
  13922. fmt.Println(err)
  13923. }
  13924. userJSONBytes, _ := json.Marshal(dat)
  13925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13926. utils.ErrorLog("解析失败:%v", err)
  13927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13928. return
  13929. }
  13930. }
  13931. if res.Infcode != 0 {
  13932. c.ServeSuccessJSON(map[string]interface{}{
  13933. "failed_code": -10,
  13934. "msg": res.ErrMsg,
  13935. })
  13936. return
  13937. } else {
  13938. //order.FaPiaoNumber = zero
  13939. //order.FaPiaoCode = last_order.FaPiaoCode
  13940. //service.UpdateOrder(order)
  13941. hisFundSettleListResult := &models.HisFundSettleListResult{
  13942. Number: res.Output.SetlListId,
  13943. Status: 1,
  13944. Ctime: time.Now().Unix(),
  13945. Mtime: time.Now().Unix(),
  13946. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13947. IsUpload: 1,
  13948. OrderId: order_id,
  13949. }
  13950. service.CreateUploadRecord(hisFundSettleListResult)
  13951. c.ServeSuccessJSON(map[string]interface{}{
  13952. "msg": "上传成功",
  13953. "result": hisFundSettleListResult,
  13954. })
  13955. return
  13956. }
  13957. }
  13958. func (c *HisApiController) GetSettleListHospital() {
  13959. order_id, _ := c.GetInt64("order_id")
  13960. admin_user_id, _ := c.GetInt64("admin_user_id")
  13961. order, _ := service.GetHisOrderByIDTwo(order_id)
  13962. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13963. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13964. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13965. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13966. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13967. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13968. if order.ID == 0 {
  13969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13970. return
  13971. }
  13972. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13973. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13974. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13975. fmt.Println(count)
  13976. var zero string
  13977. number := count + 1
  13978. if number >= 1000 {
  13979. zero = "0000" + strconv.FormatInt(number, 10)
  13980. } else if number >= 10000 {
  13981. zero = "000" + strconv.FormatInt(number, 10)
  13982. } else if number >= 100000 {
  13983. zero = "00" + strconv.FormatInt(number, 10)
  13984. } else if number >= 1000000 {
  13985. zero = "0" + strconv.FormatInt(number, 10)
  13986. } else {
  13987. zero = strconv.FormatInt(number, 10)
  13988. }
  13989. fmt.Println(zero)
  13990. struct4101 := service.Struct4101{
  13991. PsnNo: order.PsnNo,
  13992. MdtrtId: order.MdtrtId,
  13993. SetlId: order.SetlId,
  13994. PsnName: order.PsnName,
  13995. Gend: order.Gend,
  13996. Brdy: his.Brdy,
  13997. Age: int64(order.Age),
  13998. Naty: order.Naty,
  13999. PatnCertType: "01",
  14000. Certno: order.Certno,
  14001. Prfs: "90",
  14002. ConerName: roles[0].UserName,
  14003. PatnRlts: "99",
  14004. ConerAddr: miConfig.OrgName,
  14005. ConerTel: admin.Mobile,
  14006. HiType: order.Insutype,
  14007. Insuplc: miConfig.InsuplcAdmdvs,
  14008. MaindiagFlag: "1",
  14009. BillCode: order.SetlId,
  14010. BillNo: order.SetlId,
  14011. BizSn: order.Number,
  14012. PsnSelfPay: order.PsnPartAmt,
  14013. PsnOwnPay: order.PsnPartAmt,
  14014. AcctPay: order.AcctPay,
  14015. PsnCashpay: order.PsnCashPay,
  14016. HiPaymtd: "1",
  14017. Hsorg: miConfig.InsuplcAdmdvs,
  14018. HsorgOpter: miConfig.InsuplcAdmdvs,
  14019. MedinsFillPsn: curRoles.UserName,
  14020. MedinsFillDept: depart.Name,
  14021. IptMedType: "2",
  14022. AdmTime: his.InHosptialTime,
  14023. AdmEndTime: his.OutHosptialTime,
  14024. }
  14025. struct4101.SetlBegnDate = order.SetlTime
  14026. struct4101.SetlEndDate = order.SetlTime
  14027. //var rf []CustomFundPay
  14028. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  14029. //
  14030. //var tempFunPays []service.CustomStruct
  14031. //for _, item := range rf {
  14032. // var tempFunPay service.CustomStruct
  14033. // tempFunPay.FundPayamt = item.FundPayamt
  14034. // tempFunPay.FundPayType = item.FundPayType
  14035. // tempFunPays = append(tempFunPays, tempFunPay)
  14036. //}
  14037. //struct4101.CustomStruct = tempFunPays
  14038. var tempDiaginfos []service.DiaginfoStructTwo
  14039. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14040. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14041. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  14042. //for _, item := range infos {
  14043. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  14044. //}
  14045. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  14046. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  14047. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14048. fmt.Println(diagnosis_ids_arr)
  14049. if order.UserOrgId == 10210 {
  14050. var diagnosis_ids_arr_two []int64
  14051. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  14052. var config []*models.HisXtDiagnoseConfig
  14053. for _, id := range diagnosis_ids_arr_two {
  14054. //id, _ := strconv.ParseInt(item, 10, 64)
  14055. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14056. if diagnosisConfig.ID > 0 {
  14057. config = append(config, &diagnosisConfig)
  14058. }
  14059. }
  14060. for index, item := range config {
  14061. if item.ID > 0 {
  14062. if index == 0 {
  14063. var tempDiaginfo service.DiaginfoStructTwo
  14064. tempDiaginfo.DiagCode = item.CountryCode
  14065. tempDiaginfo.DiagName = item.CountryContentName
  14066. tempDiaginfo.DiagType = "1"
  14067. tempDiaginfo.MaindiagFlag = "1"
  14068. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14069. } else {
  14070. var tempDiaginfo service.DiaginfoStructTwo
  14071. tempDiaginfo.DiagCode = item.CountryCode
  14072. tempDiaginfo.DiagName = item.CountryContentName
  14073. tempDiaginfo.DiagType = "1"
  14074. tempDiaginfo.MaindiagFlag = "0"
  14075. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14076. }
  14077. }
  14078. }
  14079. struct4101.Diseinfo = tempDiaginfos
  14080. } else {
  14081. var config []*models.HisXtDiagnoseConfig
  14082. for _, item := range diagnosis_ids_arr {
  14083. id, _ := strconv.ParseInt(item, 10, 64)
  14084. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14085. if diagnosisConfig.ID > 0 {
  14086. config = append(config, &diagnosisConfig)
  14087. }
  14088. }
  14089. for index, item := range config {
  14090. if item.ID > 0 {
  14091. if index == 0 {
  14092. var tempDiaginfo service.DiaginfoStructTwo
  14093. tempDiaginfo.DiagCode = item.CountryCode
  14094. tempDiaginfo.DiagName = item.CountryContentName
  14095. tempDiaginfo.DiagType = "1"
  14096. tempDiaginfo.MaindiagFlag = "1"
  14097. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14098. } else {
  14099. var tempDiaginfo service.DiaginfoStructTwo
  14100. tempDiaginfo.DiagCode = item.CountryCode
  14101. tempDiaginfo.DiagName = item.CountryContentName
  14102. tempDiaginfo.DiagType = "1"
  14103. tempDiaginfo.MaindiagFlag = "0"
  14104. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14105. }
  14106. }
  14107. }
  14108. struct4101.Diseinfo = tempDiaginfos
  14109. }
  14110. sickConfigTwo, _ := service.FindSickById(his.SickType)
  14111. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14112. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14113. tempOpspdiseinfo2.OprnOprtCode = ""
  14114. tempOpspdiseinfo2.OprnOprtName = ""
  14115. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14116. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14117. var iteminfo service.IteminfoStruct
  14118. var bedCostTotal float64 = 0 //床位总费
  14119. var bedCostSelfTotal float64 = 0 //床位自费
  14120. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14121. var operationCostTotal float64 = 0 //手术费
  14122. var operationCostSelfTotal float64 = 0 //手术费
  14123. var operationCostPartSelfTotal float64 = 0 //手术费
  14124. var otherCostTotal float64 = 0 //其他费用
  14125. var otherCostSelfTotal float64 = 0 //其他费用
  14126. var otherCostPartSelfTotal float64 = 0 //其他费用
  14127. var materialCostTotal float64 = 0 //材料费
  14128. var materialCostSelfTotal float64 = 0 //材料费
  14129. var materialCostPartSelfTotal float64 = 0 //材料费
  14130. var westernMedicineCostTotal float64 = 0 //西药费
  14131. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14132. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14133. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14134. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14135. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14136. var checkCostTotal float64 = 0 //检查费
  14137. var checkCostSelfTotal float64 = 0 //检查费
  14138. var checkCostPartSelfTotal float64 = 0 //检查费
  14139. var laboratoryCostTotal float64 = 0 //化验费
  14140. var laboratoryCostSelfTotal float64 = 0 //化验费
  14141. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14142. var treatCostTotal float64 = 0 //治疗费用
  14143. var treatCostSelfTotal float64 = 0 //治疗费用
  14144. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14145. decimal.DivisionPrecision = 2
  14146. var bed_fulamt_ownpay_amt float64 = 0
  14147. var operation_fulamt_ownpay_amt float64 = 0
  14148. var other_fulamt_ownpay_amt float64 = 0
  14149. var westernMedicine_fulamt_ownpay_amt float64 = 0
  14150. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14151. var check_fulamt_ownpay_amt float64 = 0
  14152. var material_fulamt_ownpay_amt float64 = 0
  14153. var laboratory_fulamt_ownpay_amt float64 = 0
  14154. var treat_fulamt_ownpay_amt float64 = 0
  14155. var bed_claa_sunmfee float64 = 0
  14156. var bed_clab_amt float64 = 0
  14157. var bed_other_amt float64 = 0
  14158. var operation_claa_sunmfee float64 = 0
  14159. var operation_clab_amt float64 = 0
  14160. var operation_other_amt float64 = 0
  14161. var other_claa_sunmfee float64 = 0
  14162. var other_clab_amt float64 = 0
  14163. var other_other_amt float64 = 0
  14164. var westernMedicine_claa_sunmfee float64 = 0
  14165. var westernMedicine_clab_amt float64 = 0
  14166. var westernMedicine_other_amt float64 = 0
  14167. var chineseTraditional_claa_sunmfee float64 = 0
  14168. var chineseTraditional_clab_amt float64 = 0
  14169. var chineseTraditional_other_amt float64 = 0
  14170. var check_claa_sunmfee float64 = 0
  14171. var check_clab_amt float64 = 0
  14172. var check_other_amt float64 = 0
  14173. var material_claa_sunmfee float64 = 0
  14174. var material_clab_amt float64 = 0
  14175. var material_other_amt float64 = 0
  14176. var laboratory_claa_sunmfee float64 = 0
  14177. var laboratory_clab_amt float64 = 0
  14178. var laboratory_other_amt float64 = 0
  14179. var treat_claa_sunmfee float64 = 0
  14180. var treat_clab_amt float64 = 0
  14181. var treat_other_amt float64 = 0
  14182. for _, item := range order.HisOrderInfo {
  14183. if item.MedChrgitmType == "01" { //床位费
  14184. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14185. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14186. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14187. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14188. if item.ChrgitmLv == "1" {
  14189. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14190. }
  14191. if item.ChrgitmLv == "2" {
  14192. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14193. }
  14194. if item.ChrgitmLv == "3" {
  14195. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14196. }
  14197. }
  14198. if item.MedChrgitmType == "03" { //检查费
  14199. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14200. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14201. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14202. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14203. if item.ChrgitmLv == "1" {
  14204. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14205. }
  14206. if item.ChrgitmLv == "2" {
  14207. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14208. }
  14209. if item.ChrgitmLv == "3" {
  14210. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14211. }
  14212. }
  14213. if item.MedChrgitmType == "04" { //化验费
  14214. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14215. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14216. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14217. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14218. if item.ChrgitmLv == "1" {
  14219. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14220. }
  14221. if item.ChrgitmLv == "2" {
  14222. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14223. }
  14224. if item.ChrgitmLv == "3" {
  14225. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14226. }
  14227. }
  14228. if item.MedChrgitmType == "05" { //治疗费
  14229. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14230. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14231. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14232. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14233. if item.ChrgitmLv == "1" {
  14234. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14235. }
  14236. if item.ChrgitmLv == "2" {
  14237. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14238. }
  14239. if item.ChrgitmLv == "3" {
  14240. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14241. }
  14242. }
  14243. if item.MedChrgitmType == "06" { //手术费
  14244. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14245. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14246. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14247. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14248. if item.ChrgitmLv == "1" {
  14249. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14250. }
  14251. if item.ChrgitmLv == "2" {
  14252. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14253. }
  14254. if item.ChrgitmLv == "3" {
  14255. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14256. }
  14257. }
  14258. if item.MedChrgitmType == "08" { //材料费
  14259. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14260. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14261. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14262. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14263. if item.ChrgitmLv == "1" {
  14264. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14265. }
  14266. if item.ChrgitmLv == "2" {
  14267. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14268. }
  14269. if item.ChrgitmLv == "3" {
  14270. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14271. }
  14272. }
  14273. if item.MedChrgitmType == "09" { //西药费
  14274. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14275. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14276. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14277. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14278. if item.ChrgitmLv == "1" {
  14279. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14280. }
  14281. if item.ChrgitmLv == "2" {
  14282. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14283. }
  14284. if item.ChrgitmLv == "3" {
  14285. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14286. }
  14287. }
  14288. if item.MedChrgitmType == "11" { //中成费
  14289. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14290. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14291. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14292. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14293. if item.ChrgitmLv == "1" {
  14294. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14295. }
  14296. if item.ChrgitmLv == "2" {
  14297. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14298. }
  14299. if item.ChrgitmLv == "3" {
  14300. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14301. }
  14302. }
  14303. if item.MedChrgitmType == "14" { //其他费
  14304. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14305. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14306. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14307. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14308. if item.ChrgitmLv == "1" {
  14309. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14310. }
  14311. if item.ChrgitmLv == "2" {
  14312. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14313. }
  14314. if item.ChrgitmLv == "3" {
  14315. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14316. }
  14317. }
  14318. }
  14319. var iteminfoStructs []service.IteminfoStruct
  14320. if bedCostTotal != 0 {
  14321. iteminfo.MedChrgitm = "01"
  14322. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14323. iteminfo.Amt = bedCostTotal
  14324. iteminfo.ClaaSumfee = bed_claa_sunmfee
  14325. iteminfo.ClabAmt = bed_clab_amt
  14326. iteminfo.OthAmt = bed_other_amt
  14327. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14328. }
  14329. if checkCostTotal != 0 {
  14330. iteminfo.MedChrgitm = "03"
  14331. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14332. iteminfo.Amt = checkCostTotal
  14333. iteminfo.ClaaSumfee = check_claa_sunmfee
  14334. iteminfo.ClabAmt = check_clab_amt
  14335. iteminfo.OthAmt = check_other_amt
  14336. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14337. }
  14338. if laboratoryCostTotal != 0 {
  14339. iteminfo.MedChrgitm = "04"
  14340. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14341. iteminfo.Amt = laboratoryCostTotal
  14342. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14343. iteminfo.ClabAmt = laboratory_clab_amt
  14344. iteminfo.OthAmt = laboratory_other_amt
  14345. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14346. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14347. }
  14348. if treatCostTotal != 0 {
  14349. iteminfo.MedChrgitm = "05"
  14350. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14351. iteminfo.Amt = treatCostTotal
  14352. iteminfo.ClaaSumfee = treat_claa_sunmfee
  14353. iteminfo.ClabAmt = treat_clab_amt
  14354. iteminfo.OthAmt = treat_other_amt
  14355. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14356. //(struct4101.IteminfoStruct, iteminfo)
  14357. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14358. }
  14359. if operationCostTotal != 0 {
  14360. iteminfo.MedChrgitm = "06"
  14361. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14362. iteminfo.Amt = operationCostTotal
  14363. iteminfo.ClaaSumfee = operation_claa_sunmfee
  14364. iteminfo.ClabAmt = operation_clab_amt
  14365. iteminfo.OthAmt = operation_other_amt
  14366. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14367. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14368. }
  14369. if materialCostTotal != 0 {
  14370. iteminfo.MedChrgitm = "08"
  14371. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14372. iteminfo.Amt = materialCostTotal
  14373. iteminfo.ClaaSumfee = material_claa_sunmfee
  14374. iteminfo.ClabAmt = material_clab_amt
  14375. iteminfo.OthAmt = material_other_amt
  14376. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14377. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14378. }
  14379. if westernMedicineCostTotal != 0 {
  14380. iteminfo.MedChrgitm = "09"
  14381. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14382. iteminfo.Amt = westernMedicineCostTotal
  14383. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14384. iteminfo.ClabAmt = westernMedicine_clab_amt
  14385. iteminfo.OthAmt = westernMedicine_other_amt
  14386. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14387. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14388. }
  14389. if chineseTraditionalMedicineCostTotal != 0 {
  14390. iteminfo.MedChrgitm = "11"
  14391. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14392. iteminfo.Amt = westernMedicineCostTotal
  14393. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14394. iteminfo.ClabAmt = westernMedicine_clab_amt
  14395. iteminfo.OthAmt = westernMedicine_other_amt
  14396. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14397. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14398. }
  14399. if otherCostTotal != 0 {
  14400. iteminfo.MedChrgitm = "14"
  14401. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14402. iteminfo.Amt = otherCostTotal
  14403. iteminfo.ClaaSumfee = other_claa_sunmfee
  14404. iteminfo.ClabAmt = other_clab_amt
  14405. iteminfo.OthAmt = other_other_amt
  14406. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14407. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14408. }
  14409. struct4101.IteminfoStruct = iteminfoStructs
  14410. struct4101.Ntly = "中国"
  14411. struct4101.AdmCaty = "A03.06"
  14412. var resOther ResultSeventeenOther
  14413. var res ResultSeventeen
  14414. if miConfig.MdtrtareaAdmvs == "150499" {
  14415. var pp models.PublicParams
  14416. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14417. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14418. pp.FixmedinsName = miConfig.OrgName
  14419. pp.FixmedinsCode = miConfig.Code
  14420. pp.RequestUrl = miConfig.Url
  14421. pp.Cainfo = miConfig.Cainfo
  14422. pp.SecretKey = miConfig.SecretKey
  14423. pp.AccessKey = miConfig.AccessKey
  14424. pp.OpterName = curRoles.UserName
  14425. client := &http.Client{}
  14426. var req *http.Request
  14427. data := make(map[string]interface{})
  14428. data["struct4101"] = struct4101
  14429. data["pp"] = pp
  14430. bytesData, _ := json.Marshal(data)
  14431. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14432. resp, _ := client.Do(req)
  14433. defer resp.Body.Close()
  14434. body, ioErr := ioutil.ReadAll(resp.Body)
  14435. if ioErr != nil {
  14436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14438. return
  14439. }
  14440. var respJSON map[string]interface{}
  14441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14444. return
  14445. }
  14446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14447. userJSONBytes, _ := json.Marshal(respJSON)
  14448. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14449. utils.ErrorLog("解析失败:%v", err)
  14450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14451. return
  14452. }
  14453. res.InfRefmsgid = resOther.InfRefmsgid
  14454. res.Output = resOther.Output
  14455. res.ErrMsg = resOther.ErrMsg
  14456. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14457. res.Infcode = infocode
  14458. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14459. var pp models.PublicParams
  14460. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14461. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14462. pp.FixmedinsName = miConfig.OrgName
  14463. pp.FixmedinsCode = miConfig.Code
  14464. pp.RequestUrl = miConfig.Url
  14465. pp.Cainfo = miConfig.Cainfo
  14466. pp.SecretKey = miConfig.SecretKey
  14467. pp.AccessKey = miConfig.AccessKey
  14468. pp.OpterName = curRoles.UserName
  14469. result, _ := service.Jxyb4101(struct4101, pp)
  14470. var dat map[string]interface{}
  14471. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14472. fmt.Println(dat)
  14473. } else {
  14474. fmt.Println(err)
  14475. }
  14476. userJSONBytes, _ := json.Marshal(dat)
  14477. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14478. utils.ErrorLog("解析失败:%v", err)
  14479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14480. return
  14481. }
  14482. } else {
  14483. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14484. var dat map[string]interface{}
  14485. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14486. fmt.Println(dat)
  14487. } else {
  14488. fmt.Println(err)
  14489. }
  14490. userJSONBytes, _ := json.Marshal(dat)
  14491. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14492. utils.ErrorLog("解析失败:%v", err)
  14493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14494. return
  14495. }
  14496. }
  14497. if res.Infcode != 0 {
  14498. c.ServeSuccessJSON(map[string]interface{}{
  14499. "failed_code": -10,
  14500. "msg": res.ErrMsg,
  14501. })
  14502. return
  14503. } else {
  14504. if miConfig.MdtrtareaAdmvs != "150499" {
  14505. order.FaPiaoNumber = zero
  14506. order.FaPiaoCode = last_order.FaPiaoCode
  14507. service.UpdateOrder(order)
  14508. }
  14509. hisFundSettleListResult := &models.HisFundSettleListResult{
  14510. Number: res.Output.SetlListId,
  14511. Status: 1,
  14512. Ctime: time.Now().Unix(),
  14513. Mtime: time.Now().Unix(),
  14514. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14515. IsUpload: 1,
  14516. OrderId: order_id,
  14517. }
  14518. service.CreateUploadRecord(hisFundSettleListResult)
  14519. c.ServeSuccessJSON(map[string]interface{}{
  14520. "msg": "上传成功",
  14521. "result": hisFundSettleListResult,
  14522. })
  14523. return
  14524. }
  14525. }
  14526. //func (c *HisApiController) GetBatchSettleList() {
  14527. // orders, _ := service.GetAllHisOrder(10106)
  14528. // for _, item := range orders {
  14529. // order_id := item.ID
  14530. // order, _ := service.GetHisOrderByIDTwo(order_id)
  14531. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14532. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14533. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14534. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  14535. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14536. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14537. //
  14538. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14539. //
  14540. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14541. //
  14542. // if order.ID == 0 {
  14543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14544. // return
  14545. // }
  14546. // if his.BalanceAccountsType == 2 {
  14547. // continue
  14548. // }
  14549. // struct4101 := service.Struct4101{
  14550. // PsnNo: order.PsnNo,
  14551. // MdtrtId: order.MdtrtId,
  14552. // SetlId: order.SetlId,
  14553. // PsnName: order.PsnName,
  14554. // Gend: order.Gend,
  14555. // Brdy: his.Brdy,
  14556. // Age: his.Age,
  14557. // Naty: order.Naty,
  14558. // PatnCertType: "01",
  14559. // Certno: order.Certno,
  14560. // Prfs: "90",
  14561. // ConerName: roles[0].UserName,
  14562. // PatnRlts: "99",
  14563. // ConerAddr: miConfig.OrgName,
  14564. // ConerTel: admin.Mobile,
  14565. // HiType: order.Insutype,
  14566. // Insuplc: his.InsuplcAdmdvs,
  14567. // MaindiagFlag: "1",
  14568. // BillCode: order.SetlId,
  14569. // BillNo: order.SetlId,
  14570. // BizSn: order.Number,
  14571. // PsnSelfPay: order.PsnPartAmt,
  14572. // PsnOwnPay: order.PsnPartAmt,
  14573. // AcctPay: order.AcctPay,
  14574. // PsnCashpay: order.PsnCashPay,
  14575. // HiPaymtd: "1",
  14576. // Hsorg: his.InsuplcAdmdvs,
  14577. // HsorgOpter: his.InsuplcAdmdvs,
  14578. // MedinsFillPsn: curRoles.UserName,
  14579. // MedinsFillDept: depart.Name,
  14580. // IptMedType: "2",
  14581. // }
  14582. // struct4101.SetlBegnDate = order.SetlTime
  14583. // struct4101.SetlEndDate = order.SetlTime
  14584. // //if order.SettleType == 1 {
  14585. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  14586. // // dateStr := t.Format("2006-01-02")
  14587. // // struct4101.SetlBegnDate = dateStr
  14588. // // struct4101.SetlEndDate = dateStr
  14589. // //} else {
  14590. // // t := time.Unix(int64(order.SettleStartTime), 0)
  14591. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  14592. // // dateStartStr := t.Format("2006-01-02")
  14593. // // dateEndStr := t2.Format("2006-01-02")
  14594. // // struct4101.SetlBegnDate = dateStartStr
  14595. // // struct4101.SetlEndDate = dateEndStr
  14596. // //}
  14597. //
  14598. // var rf []CustomFundPay
  14599. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  14600. //
  14601. // var tempFunPays []service.CustomStruct
  14602. // var tempFunPay610100 service.CustomStruct
  14603. //
  14604. // for _, item := range rf {
  14605. // if item.FundPayType == "610100" {
  14606. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  14607. // tempFunPay610100.FundPayType = item.FundPayType
  14608. // } else {
  14609. // var tempFunPay service.CustomStruct
  14610. // tempFunPay.FundPayamt = item.FundPayamt
  14611. // tempFunPay.FundPayType = item.FundPayType
  14612. // tempFunPays = append(tempFunPays, tempFunPay)
  14613. // }
  14614. // }
  14615. // tempFunPays = append(tempFunPays, tempFunPay610100)
  14616. // struct4101.CustomStruct = tempFunPays
  14617. //
  14618. // var tempDiaginfos []service.DiaginfoStructTwo
  14619. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14620. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14621. //
  14622. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14623. // var config []*models.HisXtDiagnoseConfig
  14624. // for _, item := range diagnosis_ids {
  14625. // id, _ := strconv.ParseInt(item, 10, 64)
  14626. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  14627. // config = append(config, &diagnosisConfig)
  14628. // }
  14629. //
  14630. // for index, item := range config {
  14631. // if index == 0 {
  14632. // var tempDiaginfo service.DiaginfoStructTwo
  14633. // tempDiaginfo.DiagCode = item.CountryCode
  14634. // tempDiaginfo.DiagName = item.CountryContentName
  14635. // tempDiaginfo.DiagType = "1"
  14636. // tempDiaginfo.MaindiagFlag = "1"
  14637. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14638. // } else {
  14639. //
  14640. // var tempDiaginfo service.DiaginfoStructTwo
  14641. // tempDiaginfo.DiagCode = item.CountryCode
  14642. // tempDiaginfo.DiagName = item.CountryContentName
  14643. // tempDiaginfo.DiagType = "2"
  14644. // tempDiaginfo.MaindiagFlag = "0"
  14645. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14646. // }
  14647. // }
  14648. // struct4101.Diseinfo = tempDiaginfos
  14649. //
  14650. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  14651. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14652. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14653. // tempOpspdiseinfo2.OprnOprtCode = ""
  14654. // tempOpspdiseinfo2.OprnOprtName = ""
  14655. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14656. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14657. //
  14658. // var iteminfo service.IteminfoStruct
  14659. //
  14660. // var bedCostTotal float64 = 0 //床位总费
  14661. // var bedCostSelfTotal float64 = 0 //床位自费
  14662. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14663. //
  14664. // var examineCostTotal float64 = 0 //诊查总费
  14665. // var examineCostSelfTotal float64 = 0 //诊查自费
  14666. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  14667. //
  14668. // var nursingCostTotal float64 = 0 //护理总费
  14669. // var nursingCostSelfTotal float64 = 0 //护理自费
  14670. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  14671. //
  14672. // var chineseMedicineCostTotal float64 = 0 //中成药
  14673. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  14674. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  14675. //
  14676. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  14677. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  14678. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  14679. //
  14680. // var registerCostTotal float64 = 0 //一般诊疗费
  14681. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  14682. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  14683. //
  14684. // var operationCostTotal float64 = 0 //手术费
  14685. // var operationCostSelfTotal float64 = 0 //手术费
  14686. // var operationCostPartSelfTotal float64 = 0 //手术费
  14687. //
  14688. // var otherCostTotal float64 = 0 //其他费用
  14689. // var otherCostSelfTotal float64 = 0 //其他费用
  14690. // var otherCostPartSelfTotal float64 = 0 //其他费用
  14691. //
  14692. // var materialCostTotal float64 = 0 //材料费
  14693. // var materialCostSelfTotal float64 = 0 //材料费
  14694. // var materialCostPartSelfTotal float64 = 0 //材料费
  14695. //
  14696. // var westernMedicineCostTotal float64 = 0 //西药费
  14697. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  14698. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14699. //
  14700. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14701. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14702. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14703. //
  14704. // var checkCostTotal float64 = 0 //检查费
  14705. // var checkCostSelfTotal float64 = 0 //检查费
  14706. // var checkCostPartSelfTotal float64 = 0 //检查费
  14707. //
  14708. // var laboratoryCostTotal float64 = 0 //化验费
  14709. // var laboratoryCostSelfTotal float64 = 0 //化验费
  14710. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14711. //
  14712. // var treatCostTotal float64 = 0 //治疗费用
  14713. // var treatCostSelfTotal float64 = 0 //治疗费用
  14714. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  14715. //
  14716. // decimal.DivisionPrecision = 2
  14717. //
  14718. // var bed_fulamt_ownpay_amt float64 = 0
  14719. //
  14720. // var examine_fulamt_ownpay_amt float64 = 0
  14721. //
  14722. // var nursing_fulamt_ownpay_amt float64 = 0
  14723. //
  14724. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  14725. //
  14726. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  14727. //
  14728. // var register_fulamt_ownpay_amt float64 = 0
  14729. //
  14730. // var operation_fulamt_ownpay_amt float64 = 0
  14731. // var other_fulamt_ownpay_amt float64 = 0
  14732. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14733. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14734. // var check_fulamt_ownpay_amt float64 = 0
  14735. // var material_fulamt_ownpay_amt float64 = 0
  14736. // var laboratory_fulamt_ownpay_amt float64 = 0
  14737. // var treat_fulamt_ownpay_amt float64 = 0
  14738. //
  14739. // var bed_claa_sunmfee float64 = 0
  14740. // var bed_clab_amt float64 = 0
  14741. // var bed_other_amt float64 = 0
  14742. //
  14743. // var examine_claa_sunmfee float64 = 0
  14744. // var examine_clab_amt float64 = 0
  14745. // var examine_other_amt float64 = 0
  14746. //
  14747. // var nursing_claa_sunmfee float64 = 0
  14748. // var nursing_clab_amt float64 = 0
  14749. // var nursing_other_amt float64 = 0
  14750. //
  14751. // var chinese_medicine_claa_sunmfee float64 = 0
  14752. // var chinese_medicine_clab_amt float64 = 0
  14753. // var chinese_medicine_other_amt float64 = 0
  14754. //
  14755. // var commonly_treatment_claa_sunmfee float64 = 0
  14756. // var commonly_treatment_clab_amt float64 = 0
  14757. // var commonly_treatment_other_amt float64 = 0
  14758. //
  14759. // var operation_claa_sunmfee float64 = 0
  14760. // var operation_clab_amt float64 = 0
  14761. // var operation_other_amt float64 = 0
  14762. //
  14763. // var other_claa_sunmfee float64 = 0
  14764. // var other_clab_amt float64 = 0
  14765. // var other_other_amt float64 = 0
  14766. //
  14767. // var westernMedicine_claa_sunmfee float64 = 0
  14768. // var westernMedicine_clab_amt float64 = 0
  14769. // var westernMedicine_other_amt float64 = 0
  14770. //
  14771. // var chineseTraditional_claa_sunmfee float64 = 0
  14772. // var chineseTraditional_clab_amt float64 = 0
  14773. // var chineseTraditional_other_amt float64 = 0
  14774. //
  14775. // var check_claa_sunmfee float64 = 0
  14776. // var check_clab_amt float64 = 0
  14777. // var check_other_amt float64 = 0
  14778. //
  14779. // var material_claa_sunmfee float64 = 0
  14780. // var material_clab_amt float64 = 0
  14781. // var material_other_amt float64 = 0
  14782. //
  14783. // var laboratory_claa_sunmfee float64 = 0
  14784. // var laboratory_clab_amt float64 = 0
  14785. // var laboratory_other_amt float64 = 0
  14786. //
  14787. // var treat_claa_sunmfee float64 = 0
  14788. // var treat_clab_amt float64 = 0
  14789. // var treat_other_amt float64 = 0
  14790. //
  14791. // var register_claa_sunmfee float64 = 0
  14792. // var register_clab_amt float64 = 0
  14793. // var register_other_amt float64 = 0
  14794. //
  14795. // for _, item := range order.HisOrderInfo {
  14796. // if item.MedChrgitmType == "01" { //床位费
  14797. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14798. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14799. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14800. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14801. // if item.ChrgitmLv == "1" {
  14802. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14803. // }
  14804. // if item.ChrgitmLv == "2" {
  14805. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14806. //
  14807. // }
  14808. // if item.ChrgitmLv == "3" {
  14809. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14810. // }
  14811. //
  14812. // }
  14813. //
  14814. // if item.MedChrgitmType == "02" { //诊查
  14815. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14816. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14817. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14818. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14819. // if item.ChrgitmLv == "1" {
  14820. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14821. // }
  14822. // if item.ChrgitmLv == "2" {
  14823. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14824. //
  14825. // }
  14826. // if item.ChrgitmLv == "3" {
  14827. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14828. // }
  14829. //
  14830. // }
  14831. //
  14832. // if item.MedChrgitmType == "03" { //检查费
  14833. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14834. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14835. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14836. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14837. // if item.ChrgitmLv == "1" {
  14838. //
  14839. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14840. //
  14841. // }
  14842. // if item.ChrgitmLv == "2" {
  14843. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14844. //
  14845. // }
  14846. // if item.ChrgitmLv == "3" {
  14847. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14848. // }
  14849. // }
  14850. //
  14851. // if item.MedChrgitmType == "04" { //化验费
  14852. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14853. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14854. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14855. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14856. // if item.ChrgitmLv == "1" {
  14857. //
  14858. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14859. //
  14860. // }
  14861. // if item.ChrgitmLv == "2" {
  14862. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14863. //
  14864. // }
  14865. // if item.ChrgitmLv == "3" {
  14866. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14867. // }
  14868. // }
  14869. //
  14870. // if item.MedChrgitmType == "05" { //治疗费
  14871. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14872. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14873. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14874. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14875. // if item.ChrgitmLv == "1" {
  14876. //
  14877. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14878. //
  14879. // }
  14880. // if item.ChrgitmLv == "2" {
  14881. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14882. //
  14883. // }
  14884. // if item.ChrgitmLv == "3" {
  14885. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14886. // }
  14887. // }
  14888. //
  14889. // if item.MedChrgitmType == "06" { //手术费
  14890. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14891. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14892. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14893. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14894. //
  14895. // if item.ChrgitmLv == "1" {
  14896. //
  14897. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14898. //
  14899. // }
  14900. // if item.ChrgitmLv == "2" {
  14901. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14902. //
  14903. // }
  14904. // if item.ChrgitmLv == "3" {
  14905. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14906. // }
  14907. // }
  14908. //
  14909. // if item.MedChrgitmType == "07" { //手术费
  14910. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14911. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14912. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14913. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14914. //
  14915. // if item.ChrgitmLv == "1" {
  14916. //
  14917. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14918. //
  14919. // }
  14920. // if item.ChrgitmLv == "2" {
  14921. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14922. //
  14923. // }
  14924. // if item.ChrgitmLv == "3" {
  14925. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14926. // }
  14927. // }
  14928. //
  14929. // if item.MedChrgitmType == "08" { //材料费
  14930. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14931. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14932. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14933. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14934. // if item.ChrgitmLv == "1" {
  14935. //
  14936. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14937. //
  14938. // }
  14939. // if item.ChrgitmLv == "2" {
  14940. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14941. //
  14942. // }
  14943. // if item.ChrgitmLv == "3" {
  14944. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14945. // }
  14946. // }
  14947. // if item.MedChrgitmType == "09" { //西药费
  14948. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14949. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14950. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14951. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14952. // if item.ChrgitmLv == "1" {
  14953. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14954. // }
  14955. // if item.ChrgitmLv == "2" {
  14956. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14957. // }
  14958. // if item.ChrgitmLv == "3" {
  14959. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14960. // }
  14961. // }
  14962. // if item.MedChrgitmType == "10" { //中药饮片
  14963. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14964. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14965. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14966. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14967. // if item.ChrgitmLv == "1" {
  14968. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14969. // }
  14970. // if item.ChrgitmLv == "2" {
  14971. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14972. // }
  14973. // if item.ChrgitmLv == "3" {
  14974. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14975. // }
  14976. // }
  14977. //
  14978. // if item.MedChrgitmType == "11" { //中成费
  14979. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14980. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14981. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14982. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14983. // if item.ChrgitmLv == "1" {
  14984. //
  14985. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14986. //
  14987. // }
  14988. // if item.ChrgitmLv == "2" {
  14989. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14990. //
  14991. // }
  14992. // if item.ChrgitmLv == "3" {
  14993. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14994. // }
  14995. // }
  14996. //
  14997. // if item.MedChrgitmType == "12" { //中成费
  14998. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14999. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15000. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15001. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15002. // if item.ChrgitmLv == "1" {
  15003. //
  15004. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15005. //
  15006. // }
  15007. // if item.ChrgitmLv == "2" {
  15008. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15009. //
  15010. // }
  15011. // if item.ChrgitmLv == "3" {
  15012. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15013. // }
  15014. // }
  15015. //
  15016. // if item.MedChrgitmType == "13" { //中成费
  15017. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15018. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15019. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15020. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15021. // if item.ChrgitmLv == "1" {
  15022. //
  15023. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15024. //
  15025. // }
  15026. // if item.ChrgitmLv == "2" {
  15027. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15028. //
  15029. // }
  15030. // if item.ChrgitmLv == "3" {
  15031. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15032. // }
  15033. // }
  15034. //
  15035. // if item.MedChrgitmType == "14" { //其他费
  15036. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15037. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15038. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15039. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15040. // if item.ChrgitmLv == "1" {
  15041. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15042. //
  15043. // }
  15044. // if item.ChrgitmLv == "2" {
  15045. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15046. //
  15047. // }
  15048. // if item.ChrgitmLv == "3" {
  15049. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15050. // }
  15051. // }
  15052. //
  15053. // }
  15054. //
  15055. // var iteminfoStructs []service.IteminfoStruct
  15056. //
  15057. // if bedCostTotal != 0 {
  15058. // iteminfo.MedChrgitm = "01"
  15059. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15060. // iteminfo.Amt = bedCostTotal
  15061. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  15062. // iteminfo.ClabAmt = bed_clab_amt
  15063. // iteminfo.OthAmt = bed_other_amt
  15064. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15065. // }
  15066. //
  15067. // if examineCostTotal != 0 {
  15068. // iteminfo.MedChrgitm = "02"
  15069. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  15070. // iteminfo.Amt = examineCostTotal
  15071. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  15072. // iteminfo.ClabAmt = examine_clab_amt
  15073. // iteminfo.OthAmt = examine_other_amt
  15074. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15075. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15076. // }
  15077. //
  15078. // if checkCostTotal != 0 {
  15079. // iteminfo.MedChrgitm = "03"
  15080. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  15081. // iteminfo.Amt = checkCostTotal
  15082. // iteminfo.ClaaSumfee = check_claa_sunmfee
  15083. // iteminfo.ClabAmt = check_clab_amt
  15084. // iteminfo.OthAmt = check_other_amt
  15085. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15086. //
  15087. // }
  15088. //
  15089. // if laboratoryCostTotal != 0 {
  15090. // iteminfo.MedChrgitm = "04"
  15091. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  15092. // iteminfo.Amt = laboratoryCostTotal
  15093. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  15094. // iteminfo.ClabAmt = laboratory_clab_amt
  15095. // iteminfo.OthAmt = laboratory_other_amt
  15096. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15097. //
  15098. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15099. //
  15100. // }
  15101. //
  15102. // if treatCostTotal != 0 {
  15103. // iteminfo.MedChrgitm = "05"
  15104. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  15105. // iteminfo.Amt = treatCostTotal
  15106. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  15107. // iteminfo.ClabAmt = treat_clab_amt
  15108. // iteminfo.OthAmt = treat_other_amt
  15109. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15110. // //(struct4101.IteminfoStruct, iteminfo)
  15111. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15112. // }
  15113. //
  15114. // if operationCostTotal != 0 {
  15115. // iteminfo.MedChrgitm = "06"
  15116. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15117. // iteminfo.Amt = operationCostTotal
  15118. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  15119. // iteminfo.ClabAmt = operation_clab_amt
  15120. // iteminfo.OthAmt = operation_other_amt
  15121. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15122. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15123. // }
  15124. //
  15125. // if nursingCostTotal != 0 {
  15126. // iteminfo.MedChrgitm = "07"
  15127. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  15128. // iteminfo.Amt = nursingCostTotal
  15129. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  15130. // iteminfo.ClabAmt = nursing_clab_amt
  15131. // iteminfo.OthAmt = nursing_other_amt
  15132. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15133. // }
  15134. //
  15135. // if materialCostTotal != 0 {
  15136. // iteminfo.MedChrgitm = "08"
  15137. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  15138. // iteminfo.Amt = materialCostTotal
  15139. // iteminfo.ClaaSumfee = material_claa_sunmfee
  15140. // iteminfo.ClabAmt = material_clab_amt
  15141. // iteminfo.OthAmt = material_other_amt
  15142. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15143. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15144. // }
  15145. //
  15146. // if westernMedicineCostTotal != 0 {
  15147. // iteminfo.MedChrgitm = "09"
  15148. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15149. // iteminfo.Amt = westernMedicineCostTotal
  15150. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15151. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15152. // iteminfo.OthAmt = westernMedicine_other_amt
  15153. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15154. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15155. //
  15156. // }
  15157. //
  15158. // if chineseMedicineCostTotal != 0 {
  15159. // iteminfo.MedChrgitm = "10"
  15160. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  15161. // iteminfo.Amt = chineseMedicineCostTotal
  15162. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  15163. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  15164. // iteminfo.OthAmt = chinese_medicine_other_amt
  15165. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15166. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15167. //
  15168. // }
  15169. //
  15170. // if chineseTraditionalMedicineCostTotal != 0 {
  15171. // iteminfo.MedChrgitm = "11"
  15172. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15173. // iteminfo.Amt = westernMedicineCostTotal
  15174. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15175. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15176. // iteminfo.OthAmt = westernMedicine_other_amt
  15177. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15178. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15179. //
  15180. // }
  15181. //
  15182. // if commonlyTreatmentCostTotal != 0 {
  15183. // iteminfo.MedChrgitm = "12"
  15184. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  15185. // iteminfo.Amt = commonlyTreatmentCostTotal
  15186. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  15187. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  15188. // iteminfo.OthAmt = commonly_treatment_other_amt
  15189. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15190. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15191. //
  15192. // }
  15193. //
  15194. // if registerCostTotal != 0 {
  15195. // iteminfo.MedChrgitm = "13"
  15196. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  15197. // iteminfo.Amt = registerCostTotal
  15198. // iteminfo.ClaaSumfee = register_claa_sunmfee
  15199. // iteminfo.ClabAmt = register_clab_amt
  15200. // iteminfo.OthAmt = register_other_amt
  15201. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15202. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15203. //
  15204. // }
  15205. //
  15206. // if otherCostTotal != 0 {
  15207. // iteminfo.MedChrgitm = "14"
  15208. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15209. // iteminfo.Amt = otherCostTotal
  15210. // iteminfo.ClaaSumfee = other_claa_sunmfee
  15211. // iteminfo.ClabAmt = other_clab_amt
  15212. // iteminfo.OthAmt = other_other_amt
  15213. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15214. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15215. //
  15216. // }
  15217. // struct4101.IteminfoStruct = iteminfoStructs
  15218. // time_arr := strings.Split(order.SetlTime, " ")
  15219. // struct4101.AdmTime = time_arr[0]
  15220. // struct4101.AdmEndTime = time_arr[0]
  15221. //
  15222. // struct4101.DoctorName = doctor.UserName
  15223. // struct4101.DoctorCode = doctor.DoctorNumber
  15224. //
  15225. // struct4101.Ntly = "中国"
  15226. // struct4101.AdmCaty = "A03.06"
  15227. // var res ResultSeventeen
  15228. // if miConfig.MdtrtareaAdmvs == "421300" {
  15229. // data := make(map[string]interface{})
  15230. // data["struct4101"] = struct4101
  15231. // data["secret_key"] = miConfig.SecretKey
  15232. // data["org_name"] = miConfig.OrgName
  15233. // data["opera"] = curRoles.UserName
  15234. // data["code"] = miConfig.Code
  15235. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15236. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15237. //
  15238. // client := &http.Client{}
  15239. // bytesData, _ := json.Marshal(data)
  15240. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15241. // resp, _ := client.Do(req)
  15242. // defer resp.Body.Close()
  15243. // body, ioErr := ioutil.ReadAll(resp.Body)
  15244. // if ioErr != nil {
  15245. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15247. // return
  15248. // }
  15249. // var respJSON map[string]interface{}
  15250. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15251. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15253. // return
  15254. // }
  15255. //
  15256. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15257. // userJSONBytes, _ := json.Marshal(respJSON)
  15258. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15259. // utils.ErrorLog("解析失败:%v", err)
  15260. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15261. // adminUser := c.GetAdminUserInfo()
  15262. // errlog := &models.HisOrderError{
  15263. // UserOrgId: adminUser.CurrentOrgId,
  15264. // Ctime: time.Now().Unix(),
  15265. // Mtime: time.Now().Unix(),
  15266. // ErrMsg: res.ErrMsg + "解析失败",
  15267. // Status: 1,
  15268. // PatientId: order_id,
  15269. // Stage: 10088,
  15270. // }
  15271. // service.CreateErrMsgLog(errlog)
  15272. // continue
  15273. // }
  15274. //
  15275. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  15276. // data := make(map[string]interface{})
  15277. // data["struct4101"] = struct4101
  15278. // data["secret_key"] = miConfig.SecretKey
  15279. // data["org_name"] = miConfig.OrgName
  15280. // data["opera"] = curRoles.UserName
  15281. // data["code"] = miConfig.Code
  15282. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15283. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15284. //
  15285. // client := &http.Client{}
  15286. // bytesData, _ := json.Marshal(data)
  15287. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15288. // resp, _ := client.Do(req)
  15289. // defer resp.Body.Close()
  15290. // body, ioErr := ioutil.ReadAll(resp.Body)
  15291. // if ioErr != nil {
  15292. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15294. // return
  15295. // }
  15296. // var respJSON map[string]interface{}
  15297. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15298. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15300. // return
  15301. // }
  15302. //
  15303. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15304. // userJSONBytes, _ := json.Marshal(respJSON)
  15305. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15306. // utils.ErrorLog("解析失败:%v", err)
  15307. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15308. // adminUser := c.GetAdminUserInfo()
  15309. // errlog := &models.HisOrderError{
  15310. // UserOrgId: adminUser.CurrentOrgId,
  15311. // Ctime: time.Now().Unix(),
  15312. // Mtime: time.Now().Unix(),
  15313. // ErrMsg: res.ErrMsg + "解析失败",
  15314. // Status: 1,
  15315. // PatientId: order_id,
  15316. // Stage: 10088,
  15317. // }
  15318. // service.CreateErrMsgLog(errlog)
  15319. // continue
  15320. // }
  15321. //
  15322. // } else {
  15323. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  15324. // fmt.Println(result)
  15325. //
  15326. // var dat map[string]interface{}
  15327. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15328. // fmt.Println(dat)
  15329. // } else {
  15330. // fmt.Println(err)
  15331. // }
  15332. // userJSONBytes, _ := json.Marshal(dat)
  15333. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15334. // utils.ErrorLog("解析失败:%v", err)
  15335. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15336. // adminUser := c.GetAdminUserInfo()
  15337. // errlog := &models.HisOrderError{
  15338. // UserOrgId: adminUser.CurrentOrgId,
  15339. // Ctime: time.Now().Unix(),
  15340. // Mtime: time.Now().Unix(),
  15341. // ErrMsg: res.ErrMsg + "解析失败",
  15342. // Status: 1,
  15343. // PatientId: order_id,
  15344. // Stage: 10106,
  15345. // }
  15346. // service.CreateErrMsgLog(errlog)
  15347. // continue
  15348. // }
  15349. // }
  15350. //
  15351. // if res.Infcode != 0 {
  15352. // adminUser := c.GetAdminUserInfo()
  15353. // errlog := &models.HisOrderError{
  15354. // UserOrgId: adminUser.CurrentOrgId,
  15355. // Ctime: time.Now().Unix(),
  15356. // Mtime: time.Now().Unix(),
  15357. // ErrMsg: res.ErrMsg,
  15358. // Status: 1,
  15359. // PatientId: order_id,
  15360. // Stage: 10106,
  15361. // }
  15362. // service.CreateErrMsgLog(errlog)
  15363. // continue
  15364. // } else {
  15365. // hisFundSettleListResult := &models.HisFundSettleListResult{
  15366. // Number: res.Output.SetlListId,
  15367. // Status: 1,
  15368. // Ctime: time.Now().Unix(),
  15369. // Mtime: time.Now().Unix(),
  15370. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15371. // IsUpload: 1,
  15372. // OrderId: order_id,
  15373. // }
  15374. // service.CreateUploadRecord(hisFundSettleListResult)
  15375. // continue
  15376. // }
  15377. // }
  15378. //}
  15379. func (c *HisApiController) GetOrgInfo() {
  15380. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  15381. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  15382. }
  15383. func (c *HisApiController) GetHisPatientInfo() {
  15384. medical_insurance_card := c.GetString("medical_insurance_card")
  15385. id_card_type, _ := c.GetInt64("id_card_type")
  15386. id_card := c.GetString("id_card")
  15387. adminInfo := c.GetAdminUserInfo()
  15388. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15389. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15390. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  15391. IdCardNo := ""
  15392. if id_card_type == 1 {
  15393. IdCardNo = medical_insurance_card
  15394. } else if id_card_type == 2 {
  15395. IdCardNo = id_card
  15396. }
  15397. if config.IsOpen == 1 {
  15398. 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
  15399. resp, requestErr := http.Get(api)
  15400. if requestErr != nil {
  15401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15402. return
  15403. }
  15404. defer resp.Body.Close()
  15405. body, ioErr := ioutil.ReadAll(resp.Body)
  15406. if ioErr != nil {
  15407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15409. return
  15410. }
  15411. var respJSON map[string]interface{}
  15412. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15415. return
  15416. }
  15417. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15418. userJSONBytes, _ := json.Marshal(userJSON)
  15419. var res ResultTwo
  15420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15421. utils.ErrorLog("解析失败:%v", err)
  15422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15423. return
  15424. }
  15425. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15426. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15427. infoStr := string(Iinfos)
  15428. idetinfoStr := string(Idetinfos)
  15429. if res.Infcode == 0 {
  15430. his := models.VMHisPatient{
  15431. Status: 1,
  15432. Ctime: time.Now().Unix(),
  15433. Mtime: time.Now().Unix(),
  15434. PsnNo: res.Output.Baseinfo.PsnNo,
  15435. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15436. Certno: res.Output.Baseinfo.Certno,
  15437. PsnName: res.Output.Baseinfo.PsnName,
  15438. Gend: res.Output.Baseinfo.Gend,
  15439. Naty: res.Output.Baseinfo.Naty,
  15440. Iinfo: infoStr,
  15441. Idetinfo: idetinfoStr,
  15442. UserOrgId: adminInfo.CurrentOrgId,
  15443. IsReturn: 1,
  15444. IdCardType: id_card_type,
  15445. }
  15446. c.ServeSuccessJSON(map[string]interface{}{
  15447. "info": his,
  15448. })
  15449. } else {
  15450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15451. return
  15452. }
  15453. }
  15454. }
  15455. //func GetBasBaseInfo() (jsonStr string, err error) {
  15456. //
  15457. // handle := syscall.NewLazyDLL("SSCard.dll")
  15458. // add := handle.NewProc("ReadCardBas")
  15459. // str := make([]byte, 1024)
  15460. // str1 := make([]byte, 1024)
  15461. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15462. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  15463. //
  15464. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  15465. //
  15466. // fmt.Println("> Add(4,5)的结果为:", ret)
  15467. // handle.Release()
  15468. //
  15469. // return "", nil
  15470. //
  15471. //}
  15472. //func GetQRBaseInfo() (jsonStr string, err error) {
  15473. // handle := syscall.LoadDLL("SSCard.dll")
  15474. // ReadCardBas := handle.FindProc("GetQRBase")
  15475. //
  15476. // str := make([]byte, 256)
  15477. // str1 := make([]byte, 256)
  15478. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15479. //
  15480. // fmt.Println(string(str))
  15481. // fmt.Println(r)
  15482. // return string(str), nil
  15483. //}
  15484. //func CardInit() int {
  15485. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  15486. // add := DllTestDef.MustFindProc("Init")
  15487. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15488. // if err != nil {
  15489. // fmt.Println("SSCard的运算结果为:", ret)
  15490. // }
  15491. // result := int(ret)
  15492. // return result
  15493. //}
  15494. //func CardInit() int {
  15495. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15496. // if err != nil {
  15497. // fmt.Println("SSCard的运算结果为:", ret)
  15498. // }
  15499. // fmt.Println(err)
  15500. // result := int(ret)
  15501. // return result
  15502. //}
  15503. func IntPtr(n int) uintptr {
  15504. return uintptr(n)
  15505. }
  15506. func StrPtr(s string) uintptr {
  15507. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  15508. }
  15509. type Result2001 struct {
  15510. Cainfo interface{} `json:"cainfo"`
  15511. ErrMsg string `json:"err_msg"`
  15512. InfRefmsgid string `json:"inf_refmsgid"`
  15513. Infcode int64 `json:"infcode"`
  15514. Output struct {
  15515. Trtinfo struct {
  15516. PsnNo string `json:"psn_no"`
  15517. TrtChkType string `json:"trt_chk_type"`
  15518. FundPayType string `json:"fund_pay_type"`
  15519. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15520. Begndate string `json:"begndate"`
  15521. Enddate string `json:"enddate"`
  15522. TrtChkRslt string `json:"trt_chk_rslt"`
  15523. } `json:"trtinfo"`
  15524. } `json:"output"`
  15525. RefmsgTime string `json:"refmsg_time"`
  15526. RespondTime string `json:"respond_time"`
  15527. Signtype interface{} `json:"signtype"`
  15528. WarnMsg interface{} `json:"warn_msg"`
  15529. }
  15530. type Result2001Org10265 struct {
  15531. Cainfo interface{} `json:"cainfo"`
  15532. ErrMsg string `json:"err_msg"`
  15533. InfRefmsgid string `json:"inf_refmsgid"`
  15534. Infcode string `json:"infcode"`
  15535. Output struct {
  15536. Trtinfo struct {
  15537. PsnNo string `json:"psn_no"`
  15538. TrtChkType string `json:"trt_chk_type"`
  15539. FundPayType string `json:"fund_pay_type"`
  15540. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15541. Begndate string `json:"begndate"`
  15542. Enddate string `json:"enddate"`
  15543. TrtChkRslt string `json:"trt_chk_rslt"`
  15544. } `json:"trtinfo"`
  15545. } `json:"output"`
  15546. RefmsgTime string `json:"refmsg_time"`
  15547. RespondTime string `json:"respond_time"`
  15548. Signtype interface{} `json:"signtype"`
  15549. WarnMsg interface{} `json:"warn_msg"`
  15550. }
  15551. type ResultTwo struct {
  15552. ErrMsg string `json:"err_msg"`
  15553. InfRefmsgid string `json:"inf_refmsgid"`
  15554. Infcode int64 `json:"infcode"`
  15555. Output struct {
  15556. Baseinfo struct {
  15557. //Brdy string `json:"brdy"`
  15558. Certno string `json:"certno"`
  15559. Gend string `json:"gend"`
  15560. Naty string `json:"naty"`
  15561. PsnCertType string `json:"psn_cert_type"`
  15562. PsnName string `json:"psn_name"`
  15563. PsnNo string `json:"psn_no"`
  15564. } `json:"baseinfo"`
  15565. Idetinfo []interface{} `json:"idetinfo"`
  15566. Iinfo []struct {
  15567. Balc float64 `json:"balc"`
  15568. CvlservFlag string `json:"cvlserv_flag"`
  15569. EmpName string `json:"emp_name"`
  15570. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15571. Insutype string `json:"insutype"`
  15572. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15573. //PausInsuDate string `json:"paus_insu_date"`
  15574. //PsnInsuDate string `json:"psn_insu_date"`
  15575. PsnInsuStas string `json:"psn_insu_stas"`
  15576. PsnType string `json:"psn_type"`
  15577. } `json:"insuinfo"`
  15578. } `json:"output"`
  15579. RefmsgTime string `json:"refmsg_time"`
  15580. RespondTime string `json:"respond_time"`
  15581. Signtype interface{} `json:"signtype"`
  15582. WarnInfo interface{} `json:"warn_info"`
  15583. }
  15584. type ResultTwo10265 struct {
  15585. ErrMsg string `json:"err_msg"`
  15586. InfRefmsgid string `json:"inf_refmsgid"`
  15587. Infcode string `json:"infcode"`
  15588. Output struct {
  15589. Baseinfo struct {
  15590. //Brdy string `json:"brdy"`
  15591. Certno string `json:"certno"`
  15592. Gend string `json:"gend"`
  15593. Naty string `json:"naty"`
  15594. PsnCertType string `json:"psn_cert_type"`
  15595. PsnName string `json:"psn_name"`
  15596. PsnNo string `json:"psn_no"`
  15597. } `json:"baseinfo"`
  15598. Idetinfo []interface{} `json:"idetinfo"`
  15599. Iinfo []struct {
  15600. Balc float64 `json:"balc"`
  15601. CvlservFlag string `json:"cvlserv_flag"`
  15602. EmpName string `json:"emp_name"`
  15603. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15604. Insutype string `json:"insutype"`
  15605. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15606. PsnInsuStas string `json:"psn_insu_stas"`
  15607. PsnType string `json:"psn_type"`
  15608. } `json:"insuinfo"`
  15609. } `json:"output"`
  15610. RefmsgTime string `json:"refmsg_time"`
  15611. RespondTime string `json:"respond_time"`
  15612. Signtype interface{} `json:"signtype"`
  15613. WarnInfo interface{} `json:"warn_info"`
  15614. }
  15615. type ResultThree struct {
  15616. Cainfo interface{} `json:"cainfo"`
  15617. ErrMsg string `json:"err_msg"`
  15618. InfRefmsgid string `json:"inf_refmsgid"`
  15619. Infcode int64 `json:"infcode"`
  15620. Output struct {
  15621. Data struct {
  15622. IptOtpNo string `json:"ipt_otp_no"`
  15623. MdtrtID string `json:"mdtrt_id"`
  15624. PsnNo string `json:"psn_no"`
  15625. } `json:"data"`
  15626. } `json:"output"`
  15627. RefmsgTime string `json:"refmsg_time"`
  15628. RespondTime string `json:"respond_time"`
  15629. Signtype interface{} `json:"signtype"`
  15630. WarnMsg interface{} `json:"warn_msg"`
  15631. }
  15632. type ResultThree10265 struct {
  15633. Cainfo interface{} `json:"cainfo"`
  15634. ErrMsg string `json:"err_msg"`
  15635. InfRefmsgid string `json:"inf_refmsgid"`
  15636. Infcode string `json:"infcode"`
  15637. Output struct {
  15638. Data struct {
  15639. IptOtpNo string `json:"ipt_otp_no"`
  15640. MdtrtID string `json:"mdtrt_id"`
  15641. PsnNo string `json:"psn_no"`
  15642. } `json:"data"`
  15643. } `json:"output"`
  15644. RefmsgTime string `json:"refmsg_time"`
  15645. RespondTime string `json:"respond_time"`
  15646. Signtype interface{} `json:"signtype"`
  15647. WarnMsg interface{} `json:"warn_msg"`
  15648. }
  15649. type ResultFour struct {
  15650. Cainfo string `json:"cainfo"`
  15651. ErrMsg string `json:"err_msg"`
  15652. InfRefmsgid string `json:"inf_refmsgid"`
  15653. Infcode int64 `json:"infcode"`
  15654. Output struct {
  15655. Result []struct {
  15656. BasMednFlag string `json:"bas_medn_flag"`
  15657. ChldMedcFlag string `json:"chld_medc_flag"`
  15658. ChrgitmLv string `json:"chrgitm_lv"`
  15659. Cnt float64 `json:"cnt"`
  15660. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15661. DrtReimFlag string `json:"drt_reim_flag"`
  15662. FeedetlSn string `json:"feedetl_sn"`
  15663. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15664. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15665. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15666. ListSpItemFlag string `json:"list_sp_item_flag"`
  15667. LmtUsedFlag string `json:"lmt_used_flag"`
  15668. MedChrgitmType string `json:"med_chrgitm_type"`
  15669. Memo string `json:"memo"`
  15670. OverlmtAmt float64 `json:"overlmt_amt"`
  15671. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15672. Pric float64 `json:"pric"`
  15673. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15674. SelfpayProp float64 `json:"selfpay_prop"`
  15675. } `json:"result"`
  15676. } `json:"output"`
  15677. RefmsgTime string `json:"refmsg_time"`
  15678. RespondTime string `json:"respond_time"`
  15679. Signtype string `json:"signtype"`
  15680. WarnMsg string `json:"warn_msg"`
  15681. }
  15682. type ResultFour10265 struct {
  15683. Cainfo string `json:"cainfo"`
  15684. ErrMsg string `json:"err_msg"`
  15685. InfRefmsgid string `json:"inf_refmsgid"`
  15686. Infcode string `json:"infcode"`
  15687. Output struct {
  15688. Result []struct {
  15689. BasMednFlag string `json:"bas_medn_flag"`
  15690. ChldMedcFlag string `json:"chld_medc_flag"`
  15691. ChrgitmLv string `json:"chrgitm_lv"`
  15692. Cnt float64 `json:"cnt"`
  15693. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15694. DrtReimFlag string `json:"drt_reim_flag"`
  15695. FeedetlSn string `json:"feedetl_sn"`
  15696. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15697. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15698. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15699. ListSpItemFlag string `json:"list_sp_item_flag"`
  15700. LmtUsedFlag string `json:"lmt_used_flag"`
  15701. MedChrgitmType string `json:"med_chrgitm_type"`
  15702. Memo string `json:"memo"`
  15703. OverlmtAmt float64 `json:"overlmt_amt"`
  15704. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15705. Pric float64 `json:"pric"`
  15706. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15707. SelfpayProp float64 `json:"selfpay_prop"`
  15708. } `json:"result"`
  15709. } `json:"output"`
  15710. RefmsgTime string `json:"refmsg_time"`
  15711. RespondTime string `json:"respond_time"`
  15712. Signtype string `json:"signtype"`
  15713. WarnMsg string `json:"warn_msg"`
  15714. }
  15715. type ResultMemo struct {
  15716. InsuAdmdvs string `json:"insuAdmdvs"`
  15717. }
  15718. // [{"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}]
  15719. type ResultIDInfo struct {
  15720. Begntime string `json:"begntime"`
  15721. Endtime string `json:"endtime"`
  15722. Memo string `json:"memo"`
  15723. }
  15724. type ResultFive struct {
  15725. Balc float64 `json:"balc"`
  15726. CvlservFlag string `json:"cvlserv_flag"`
  15727. EmpName string `json:"emp_name"`
  15728. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15729. Insutype string `json:"insutype"`
  15730. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15731. PausInsuDate string `json:"paus_insu_date"`
  15732. PsnInsuDate string `json:"psn_insu_date"`
  15733. PsnInsuStas string `json:"psn_insu_stas"`
  15734. PsnType string `json:"psn_type"`
  15735. }
  15736. type ResultSix struct {
  15737. Cainfo interface{} `json:"cainfo"`
  15738. ErrMsg string `json:"err_msg"`
  15739. InfRefmsgid string `json:"inf_refmsgid"`
  15740. Infcode int64 `json:"infcode"`
  15741. Output struct {
  15742. } `json:"output"`
  15743. RefmsgTime string `json:"refmsg_time"`
  15744. RespondTime string `json:"respond_time"`
  15745. Signtype interface{} `json:"signtype"`
  15746. WarnMsg interface{} `json:"warn_msg"`
  15747. }
  15748. type FJ3507Result struct {
  15749. Cainfo interface{} `json:"cainfo"`
  15750. ErrMsg string `json:"err_msg"`
  15751. InfRefmsgid string `json:"inf_refmsgid"`
  15752. Infcode int64 `json:"infcode"`
  15753. Output struct {
  15754. retRslt string `json:"retRslt"`
  15755. msgRslt string `json:"msgRslt"`
  15756. } `json:"output"`
  15757. RefmsgTime string `json:"refmsg_time"`
  15758. RespondTime string `json:"respond_time"`
  15759. Signtype interface{} `json:"signtype"`
  15760. WarnMsg interface{} `json:"warn_msg"`
  15761. }
  15762. type Result2406 struct {
  15763. Cainfo interface{} `json:"cainfo"`
  15764. ErrMsg string `json:"err_msg"`
  15765. InfRefmsgid string `json:"inf_refmsgid"`
  15766. Infcode int64 `json:"infcode"`
  15767. Output struct {
  15768. Result struct {
  15769. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15770. } `json:"result"`
  15771. } `json:"output"`
  15772. RefmsgTime string `json:"refmsg_time"`
  15773. RespondTime string `json:"respond_time"`
  15774. Signtype interface{} `json:"signtype"`
  15775. WarnMsg interface{} `json:"warn_msg"`
  15776. }
  15777. type GZResultSix struct {
  15778. Cainfo interface{} `json:"cainfo"`
  15779. ErrMsg string `json:"err_msg"`
  15780. InfRefmsgid string `json:"inf_refmsgid"`
  15781. Infcode int64 `json:"infcode"`
  15782. Output string `json:"output"`
  15783. RefmsgTime string `json:"refmsg_time"`
  15784. RespondTime string `json:"respond_time"`
  15785. Signtype interface{} `json:"signtype"`
  15786. WarnMsg interface{} `json:"warn_msg"`
  15787. }
  15788. type ResultSix10265 struct {
  15789. Cainfo interface{} `json:"cainfo"`
  15790. ErrMsg string `json:"err_msg"`
  15791. InfRefmsgid string `json:"inf_refmsgid"`
  15792. Infcode string `json:"infcode"`
  15793. Output struct {
  15794. } `json:"output"`
  15795. RefmsgTime string `json:"refmsg_time"`
  15796. RespondTime string `json:"respond_time"`
  15797. Signtype interface{} `json:"signtype"`
  15798. WarnMsg interface{} `json:"warn_msg"`
  15799. }
  15800. type ResultSeven struct {
  15801. Cainfo string `json:"cainfo"`
  15802. ErrMsg string `json:"err_msg"`
  15803. InfRefmsgid string `json:"inf_refmsgid"`
  15804. Infcode int64 `json:"infcode"`
  15805. Output struct {
  15806. Setlinfo struct {
  15807. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15808. AcctPay float64 `json:"acct_pay"`
  15809. ActPayDedc float64 `json:"act_pay_dedc"`
  15810. Age float64 `json:"age"`
  15811. Balc float64 `json:"balc"`
  15812. Certno string `json:"certno"`
  15813. ClrOptins string `json:"clr_optins"`
  15814. ClrType string `json:"clr_type"`
  15815. ClrWay string `json:"clr_way"`
  15816. CvlservFlag string `json:"cvlserv_flag"`
  15817. CvlservPay float64 `json:"cvlserv_pay"`
  15818. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15819. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15820. Gend string `json:"gend"`
  15821. HifesPay float64 `json:"hifes_pay"`
  15822. HifmiPay float64 `json:"hifmi_pay"`
  15823. HifpPay float64 `json:"hifp_pay"`
  15824. HospPartAmt float64 `json:"hosp_part_amt"`
  15825. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15826. Insutype string `json:"insutype"`
  15827. MafPay float64 `json:"maf_pay"`
  15828. MdtrtCertType string `json:"mdtrt_cert_type"`
  15829. HifobPay float64 `json:"hifob_pay"`
  15830. MdtrtID string `json:"mdtrt_id"`
  15831. MedType string `json:"med_type"`
  15832. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15833. MedinsSetlID string `json:"medins_setl_id"`
  15834. Naty string `json:"naty"`
  15835. OthPay float64 `json:"oth_pay"`
  15836. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15837. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15838. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15839. PsnCashPay float64 `json:"psn_cash_pay"`
  15840. PsnCertType string `json:"psn_cert_type"`
  15841. PsnName string `json:"psn_name"`
  15842. PsnNo string `json:"psn_no"`
  15843. PsnPartAmt float64 `json:"psn_part_amt"`
  15844. PsnType string `json:"psn_type"`
  15845. SetlID string `json:"setl_id"`
  15846. SetlTime string `json:"setl_time"`
  15847. } `json:"setlinfo"`
  15848. Setldetail interface{} `json:"setldetail"`
  15849. } `json:"output"`
  15850. RefmsgTime string `json:"refmsg_time"`
  15851. RespondTime string `json:"respond_time"`
  15852. Signtype interface{} `json:"signtype"`
  15853. WarnMsg interface{} `json:"warn_msg"`
  15854. }
  15855. type ResultSevenAH struct {
  15856. Cainfo string `json:"cainfo"`
  15857. ErrMsg string `json:"err_msg"`
  15858. InfRefmsgid string `json:"inf_refmsgid"`
  15859. Infcode int64 `json:"infcode"`
  15860. Output struct {
  15861. Setlinfo struct {
  15862. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15863. AcctPay float64 `json:"acct_pay"`
  15864. ActPayDedc float64 `json:"act_pay_dedc"`
  15865. Age float64 `json:"age"`
  15866. Balc float64 `json:"balc"`
  15867. Certno string `json:"certno"`
  15868. ClrOptins string `json:"clr_optins"`
  15869. ClrType string `json:"clr_type"`
  15870. ClrWay string `json:"clr_way"`
  15871. CvlservFlag string `json:"cvlserv_flag"`
  15872. CvlservPay float64 `json:"cvlserv_pay"`
  15873. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15874. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15875. Gend string `json:"gend"`
  15876. HifesPay float64 `json:"hifes_pay"`
  15877. HifmiPay float64 `json:"hifmi_pay"`
  15878. HifpPay float64 `json:"hifp_pay"`
  15879. HospPartAmt float64 `json:"hosp_part_amt"`
  15880. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15881. Insutype string `json:"insutype"`
  15882. MafPay float64 `json:"maf_pay"`
  15883. MdtrtCertType string `json:"mdtrt_cert_type"`
  15884. HifobPay float64 `json:"hifob_pay"`
  15885. MdtrtID string `json:"mdtrt_id"`
  15886. MedType string `json:"med_type"`
  15887. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15888. MedinsSetlID string `json:"medins_setl_id"`
  15889. Naty string `json:"naty"`
  15890. OthPay float64 `json:"oth_pay"`
  15891. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15892. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15893. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15894. PsnCashPay float64 `json:"psn_cash_pay"`
  15895. PsnCertType string `json:"psn_cert_type"`
  15896. PsnName string `json:"psn_name"`
  15897. PsnNo string `json:"psn_no"`
  15898. PsnPartAmt float64 `json:"psn_part_amt"`
  15899. PsnType string `json:"psn_type"`
  15900. SetlID string `json:"setl_id"`
  15901. SetlTime int64 `json:"setl_time"`
  15902. } `json:"setlinfo"`
  15903. Setldetail interface{} `json:"setldetail"`
  15904. } `json:"output"`
  15905. RefmsgTime string `json:"refmsg_time"`
  15906. RespondTime string `json:"respond_time"`
  15907. Signtype interface{} `json:"signtype"`
  15908. WarnMsg interface{} `json:"warn_msg"`
  15909. }
  15910. type ResultSeven10265 struct {
  15911. Cainfo string `json:"cainfo"`
  15912. ErrMsg string `json:"err_msg"`
  15913. InfRefmsgid string `json:"inf_refmsgid"`
  15914. Infcode string `json:"infcode"`
  15915. Output struct {
  15916. Setlinfo struct {
  15917. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15918. AcctPay float64 `json:"acct_pay"`
  15919. ActPayDedc float64 `json:"act_pay_dedc"`
  15920. Age float64 `json:"age"`
  15921. Balc float64 `json:"balc"`
  15922. Certno string `json:"certno"`
  15923. ClrOptins string `json:"clr_optins"`
  15924. ClrType string `json:"clr_type"`
  15925. ClrWay string `json:"clr_way"`
  15926. CvlservFlag string `json:"cvlserv_flag"`
  15927. CvlservPay float64 `json:"cvlserv_pay"`
  15928. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15929. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15930. Gend string `json:"gend"`
  15931. HifesPay float64 `json:"hifes_pay"`
  15932. HifmiPay float64 `json:"hifmi_pay"`
  15933. HifpPay float64 `json:"hifp_pay"`
  15934. HospPartAmt float64 `json:"hosp_part_amt"`
  15935. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15936. Insutype string `json:"insutype"`
  15937. MafPay float64 `json:"maf_pay"`
  15938. MdtrtCertType string `json:"mdtrt_cert_type"`
  15939. HifobPay float64 `json:"hifob_pay"`
  15940. MdtrtID string `json:"mdtrt_id"`
  15941. MedType string `json:"med_type"`
  15942. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15943. MedinsSetlID string `json:"medins_setl_id"`
  15944. Naty string `json:"naty"`
  15945. OthPay float64 `json:"oth_pay"`
  15946. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15947. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15948. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15949. PsnCashPay float64 `json:"psn_cash_pay"`
  15950. PsnCertType string `json:"psn_cert_type"`
  15951. PsnName string `json:"psn_name"`
  15952. PsnNo string `json:"psn_no"`
  15953. PsnPartAmt float64 `json:"psn_part_amt"`
  15954. PsnType string `json:"psn_type"`
  15955. SetlID string `json:"setl_id"`
  15956. SetlTime string `json:"setl_time"`
  15957. } `json:"setlinfo"`
  15958. Setldetail interface{} `json:"setldetail"`
  15959. } `json:"output"`
  15960. RefmsgTime string `json:"refmsg_time"`
  15961. RespondTime string `json:"respond_time"`
  15962. Signtype interface{} `json:"signtype"`
  15963. WarnMsg interface{} `json:"warn_msg"`
  15964. }
  15965. type ResultSeven10265Two struct {
  15966. Cainfo string `json:"cainfo"`
  15967. ErrMsg string `json:"err_msg"`
  15968. InfRefmsgid string `json:"inf_refmsgid"`
  15969. Infcode string `json:"infcode"`
  15970. Output struct {
  15971. Setlinfo struct {
  15972. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15973. AcctPay float64 `json:"acct_pay"`
  15974. ActPayDedc float64 `json:"act_pay_dedc"`
  15975. Age float64 `json:"age"`
  15976. Balc float64 `json:"balc"`
  15977. Certno string `json:"certno"`
  15978. ClrOptins string `json:"clr_optins"`
  15979. ClrType string `json:"clr_type"`
  15980. ClrWay string `json:"clr_way"`
  15981. CvlservFlag string `json:"cvlserv_flag"`
  15982. CvlservPay float64 `json:"cvlserv_pay"`
  15983. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15984. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15985. Gend string `json:"gend"`
  15986. HifesPay float64 `json:"hifes_pay"`
  15987. HifmiPay float64 `json:"hifmi_pay"`
  15988. HifpPay float64 `json:"hifp_pay"`
  15989. HospPartAmt string `json:"hosp_part_amt"`
  15990. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15991. Insutype string `json:"insutype"`
  15992. MafPay float64 `json:"maf_pay"`
  15993. MdtrtCertType string `json:"mdtrt_cert_type"`
  15994. HifobPay float64 `json:"hifob_pay"`
  15995. MdtrtID string `json:"mdtrt_id"`
  15996. MedType string `json:"med_type"`
  15997. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15998. MedinsSetlID string `json:"medins_setl_id"`
  15999. Naty string `json:"naty"`
  16000. OthPay float64 `json:"oth_pay"`
  16001. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16002. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  16003. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16004. PsnCashPay float64 `json:"psn_cash_pay"`
  16005. PsnCertType string `json:"psn_cert_type"`
  16006. PsnName string `json:"psn_name"`
  16007. PsnNo string `json:"psn_no"`
  16008. PsnPartAmt float64 `json:"psn_part_amt"`
  16009. PsnType string `json:"psn_type"`
  16010. SetlID string `json:"setl_id"`
  16011. SetlTime string `json:"setl_time"`
  16012. } `json:"setlinfo"`
  16013. Setldetail interface{} `json:"setldetail"`
  16014. } `json:"output"`
  16015. RefmsgTime string `json:"refmsg_time"`
  16016. RespondTime string `json:"respond_time"`
  16017. Signtype interface{} `json:"signtype"`
  16018. WarnMsg interface{} `json:"warn_msg"`
  16019. }
  16020. type GZResultSeven10265Two struct {
  16021. Cainfo string `json:"cainfo"`
  16022. ErrMsg string `json:"err_msg"`
  16023. InfRefmsgid string `json:"inf_refmsgid"`
  16024. Infcode int64 `json:"infcode"`
  16025. Output struct {
  16026. Setlinfo struct {
  16027. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16028. AcctPay float64 `json:"acct_pay"`
  16029. ActPayDedc float64 `json:"act_pay_dedc"`
  16030. Age float64 `json:"age"`
  16031. Balc float64 `json:"balc"`
  16032. Certno string `json:"certno"`
  16033. ClrOptins string `json:"clr_optins"`
  16034. ClrType string `json:"clr_type"`
  16035. ClrWay string `json:"clr_way"`
  16036. CvlservFlag string `json:"cvlserv_flag"`
  16037. CvlservPay float64 `json:"cvlserv_pay"`
  16038. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16039. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16040. Gend string `json:"gend"`
  16041. HifesPay float64 `json:"hifes_pay"`
  16042. HifmiPay float64 `json:"hifmi_pay"`
  16043. HifpPay float64 `json:"hifp_pay"`
  16044. HospPartAmt float64 `json:"hosp_part_amt"`
  16045. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16046. Insutype string `json:"insutype"`
  16047. MafPay float64 `json:"maf_pay"`
  16048. MdtrtCertType string `json:"mdtrt_cert_type"`
  16049. HifobPay float64 `json:"hifob_pay"`
  16050. MdtrtID string `json:"mdtrt_id"`
  16051. MedType string `json:"med_type"`
  16052. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16053. MedinsSetlID string `json:"medins_setl_id"`
  16054. Naty string `json:"naty"`
  16055. OthPay float64 `json:"oth_pay"`
  16056. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16057. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  16058. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16059. PsnCashPay float64 `json:"psn_cash_pay"`
  16060. PsnCertType string `json:"psn_cert_type"`
  16061. PsnName string `json:"psn_name"`
  16062. PsnNo string `json:"psn_no"`
  16063. PsnPartAmt float64 `json:"psn_part_amt"`
  16064. PsnType string `json:"psn_type"`
  16065. SetlID string `json:"setl_id"`
  16066. SetlTime string `json:"setl_time"`
  16067. } `json:"setlinfo"`
  16068. Setldetail interface{} `json:"setldetail"`
  16069. } `json:"output"`
  16070. RefmsgTime string `json:"refmsg_time"`
  16071. RespondTime string `json:"respond_time"`
  16072. Signtype interface{} `json:"signtype"`
  16073. WarnMsg interface{} `json:"warn_msg"`
  16074. }
  16075. type ResultEight struct {
  16076. Cainfo string `json:"cainfo"`
  16077. ErrMsg string `json:"err_msg"`
  16078. InfRefmsgid string `json:"inf_refmsgid"`
  16079. Infcode int64 `json:"infcode"`
  16080. Output struct {
  16081. Stmtinfo struct {
  16082. SetlOptins string `json:"setl_optins"`
  16083. StmtRslt string `json:"stmt_rslt"`
  16084. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  16085. } `json:"stmtinfo"`
  16086. } `json:"output"`
  16087. RefmsgTime string `json:"refmsg_time"`
  16088. RespondTime string `json:"respond_time"`
  16089. Signtype interface{} `json:"signtype"`
  16090. WarnMsg interface{} `json:"warn_msg"`
  16091. }
  16092. type ResultEightFor10188 struct {
  16093. Cainfo string `json:"cainfo"`
  16094. ErrMsg string `json:"err_msg"`
  16095. InfRefmsgid string `json:"inf_refmsgid"`
  16096. Infcode string `json:"infcode"`
  16097. Output struct {
  16098. Stmtinfo struct {
  16099. SetlOptins string `json:"setl_optins"`
  16100. StmtRslt string `json:"stmt_rslt"`
  16101. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  16102. } `json:"stmtinfo"`
  16103. } `json:"output"`
  16104. RefmsgTime string `json:"refmsg_time"`
  16105. RespondTime string `json:"respond_time"`
  16106. Signtype interface{} `json:"signtype"`
  16107. WarnMsg interface{} `json:"warn_msg"`
  16108. }
  16109. type ResultNine struct {
  16110. Cainfo string `json:"cainfo"`
  16111. ErrMsg string `json:"err_msg"`
  16112. InfRefmsgid string `json:"inf_refmsgid"`
  16113. Infcode int64 `json:"infcode"`
  16114. Output struct {
  16115. FileQuryNo string `json:"file_qury_no"`
  16116. } `json:"output"`
  16117. RefmsgTime string `json:"refmsg_time"`
  16118. RespondTime string `json:"respond_time"`
  16119. Signtype interface{} `json:"signtype"`
  16120. WarnMsg interface{} `json:"warn_msg"`
  16121. }
  16122. type ResultTen struct {
  16123. Cainfo string `json:"cainfo"`
  16124. ErrMsg string `json:"err_msg"`
  16125. InfRefmsgid string `json:"inf_refmsgid"`
  16126. Infcode int64 `json:"infcode"`
  16127. Output struct {
  16128. Fileinfo struct {
  16129. DldEndtime string `json:"dld_endtime"`
  16130. FileQuryNo string `json:"file_qury_no"`
  16131. Filename string `json:"filename"`
  16132. } `json:"fileinfo"`
  16133. } `json:"output"`
  16134. RefmsgTime string `json:"refmsg_time"`
  16135. RespondTime string `json:"respond_time"`
  16136. Signtype interface{} `json:"signtype"`
  16137. WarnMsg interface{} `json:"warn_msg"`
  16138. }
  16139. type Result5262 struct {
  16140. ErrMsg string `json:"err_msg"`
  16141. InfRefmsgid string `json:"inf_refmsgid"`
  16142. Infcode int64 `json:"infcode"`
  16143. Output struct {
  16144. PageInfo struct {
  16145. Size int `json:"size"`
  16146. RecordCounts int `json:"record_counts"`
  16147. } `json:"page_info"`
  16148. Idetinfo []interface{} `json:"idetinfo"`
  16149. Result []struct {
  16150. SetlID string `json:"setl_id"`
  16151. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16152. MdtrtID string `json:"mdtrt_id"`
  16153. InitSetlID string `json:"init_setl_id,omitempty"`
  16154. PsnNo string `json:"psn_no"`
  16155. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16156. PsnName string `json:"psn_name"`
  16157. PsnCertType string `json:"psn_cert_type"`
  16158. Certno string `json:"certno"`
  16159. Gend string `json:"gend,omitempty"`
  16160. Naty string `json:"naty,omitempty"`
  16161. Brdy string `json:"brdy,omitempty"`
  16162. Age float64 `json:"age,omitempty"`
  16163. Insutype string `json:"insutype,omitempty"`
  16164. PsnType string `json:"psn_type"`
  16165. CvlservFlag string `json:"cvlserv_flag"`
  16166. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16167. SpPsnType string `json:"sp_psn_type,omitempty"`
  16168. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16169. ClctGrde string `json:"clct_grde,omitempty"`
  16170. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16171. NwbFlag string `json:"nwb_flag,omitempty"`
  16172. InsuAdmdvs string `json:"insu_admdvs"`
  16173. EmpNo string `json:"emp_no,omitempty"`
  16174. EmpName string `json:"emp_name,omitempty"`
  16175. EmpType string `json:"emp_type,omitempty"`
  16176. EconType string `json:"econ_type,omitempty"`
  16177. AfilIndu string `json:"afil_indu,omitempty"`
  16178. AfilRlts string `json:"afil_rlts,omitempty"`
  16179. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16180. PayLoc string `json:"pay_loc,omitempty"`
  16181. FixmedinsCode string `json:"fixmedins_code"`
  16182. FixmedinsName string `json:"fixmedins_name"`
  16183. HospLv string `json:"hosp_lv,omitempty"`
  16184. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16185. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16186. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16187. Begndate string `json:"begndate"`
  16188. Enddate string `json:"enddate"`
  16189. SetlTime string `json:"setl_time"`
  16190. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16191. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16192. MedType string `json:"med_type"`
  16193. SetlType string `json:"setl_type,omitempty"`
  16194. ClrType string `json:"clr_type,omitempty"`
  16195. ClrWay string `json:"clr_way,omitempty"`
  16196. PsnSetlway string `json:"psn_setlway,omitempty"`
  16197. ClrOptins string `json:"clr_optins,omitempty"`
  16198. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16199. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16200. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16201. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16202. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16203. DedcStd float64 `json:"dedc_std,omitempty"`
  16204. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16205. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16206. HifpPay float64 `json:"hifp_pay,omitempty"`
  16207. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16208. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16209. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16210. HifesPay float64 `json:"hifes_pay,omitempty"`
  16211. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16212. HifobPay float64 `json:"hifob_pay,omitempty"`
  16213. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16214. MafPay float64 `json:"maf_pay,omitempty"`
  16215. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16216. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16217. PsnPay float64 `json:"psn_pay,omitempty"`
  16218. AcctPay float64 `json:"acct_pay,omitempty"`
  16219. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16220. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16221. Balc float64 `json:"balc,omitempty"`
  16222. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16223. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16224. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16225. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16226. Year string `json:"year,omitempty"`
  16227. DiseNo string `json:"dise_no,omitempty"`
  16228. DiseName string `json:"dise_name,omitempty"`
  16229. Invono string `json:"invono,omitempty"`
  16230. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16231. ValiFlag string `json:"vali_flag,omitempty"`
  16232. Memo string `json:"memo,omitempty"`
  16233. Rid string `json:"rid"`
  16234. UpdtTime string `json:"updt_time,omitempty"`
  16235. CrterID string `json:"crter_id,omitempty"`
  16236. CrterName string `json:"crter_name,omitempty"`
  16237. CrteTime string `json:"crte_time,omitempty"`
  16238. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  16239. OpterID string `json:"opter_id,omitempty"`
  16240. OpterName string `json:"opter_name,omitempty"`
  16241. OptTime string `json:"opt_time,omitempty"`
  16242. OptinsNo string `json:"optins_no,omitempty"`
  16243. PoolareaNo string `json:"poolarea_no,omitempty"`
  16244. } `json:"result"`
  16245. } `json:"output"`
  16246. RefmsgTime string `json:"refmsg_time"`
  16247. RespondTime string `json:"respond_time"`
  16248. Signtype interface{} `json:"signtype"`
  16249. WarnInfo interface{} `json:"warn_info"`
  16250. }
  16251. type Result5267 struct {
  16252. ErrMsg string `json:"err_msg"`
  16253. InfRefmsgid string `json:"inf_refmsgid"`
  16254. Infcode int64 `json:"infcode"`
  16255. Output struct {
  16256. PageInfo struct {
  16257. Size int `json:"size"`
  16258. RecordCounts int `json:"record_counts"`
  16259. } `json:"pageinfo"`
  16260. Result []struct {
  16261. SetlID string `json:"setl_id"`
  16262. ClrOptins string `json:"clr_optins"`
  16263. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16264. MdtrtID string `json:"mdtrt_id"`
  16265. InitSetlID string `json:"init_setl_id,omitempty"`
  16266. PsnNo string `json:"psn_no"`
  16267. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16268. PsnName string `json:"psn_name"`
  16269. PsnCertType string `json:"psn_cert_type"`
  16270. Certno string `json:"certno"`
  16271. Gend string `json:"gend,omitempty"`
  16272. Naty string `json:"naty,omitempty"`
  16273. Brdy string `json:"brdy,omitempty"`
  16274. Age float64 `json:"age,omitempty"`
  16275. Insutype string `json:"insutype,omitempty"`
  16276. PsnType string `json:"psn_type"`
  16277. CvlservFlag string `json:"cvlserv_flag"`
  16278. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16279. SpPsnType string `json:"sp_psn_type,omitempty"`
  16280. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16281. ClctGrde string `json:"clct_grde,omitempty"`
  16282. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16283. NwbFlag string `json:"nwb_flag,omitempty"`
  16284. InsuAdmdvs string `json:"insu_admdvs"`
  16285. EmpNo string `json:"emp_no,omitempty"`
  16286. EmpName string `json:"emp_name,omitempty"`
  16287. EmpType string `json:"emp_type,omitempty"`
  16288. EconType string `json:"econ_type,omitempty"`
  16289. AfilIndu string `json:"afil_indu,omitempty"`
  16290. AfilRlts string `json:"afil_rlts,omitempty"`
  16291. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16292. PayLoc string `json:"pay_loc,omitempty"`
  16293. FixmedinsCode string `json:"fixmedins_code"`
  16294. FixmedinsName string `json:"fixmedins_name"`
  16295. HospLv string `json:"hosp_lv,omitempty"`
  16296. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16297. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16298. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16299. Begndate string `json:"begndate,omitempty"`
  16300. Enddate string `json:"enddate,omitempty"`
  16301. SetlTime string `json:"setl_time,omitempty"`
  16302. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16303. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16304. MedType string `json:"med_type"`
  16305. SetlType string `json:"setl_type,omitempty"`
  16306. ClrType string `json:"clr_type,omitempty"`
  16307. ClrWay string `json:"clr_way,omitempty"`
  16308. PsnSetlway string `json:"psn_setlway,omitempty"`
  16309. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16310. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16311. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16312. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16313. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16314. DedcStd float64 `json:"dedc_std,omitempty"`
  16315. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16316. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16317. HifpPay float64 `json:"hifp_pay,omitempty"`
  16318. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16319. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16320. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16321. HifesPay float64 `json:"hifes_pay,omitempty"`
  16322. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16323. HifobPay float64 `json:"hifob_pay,omitempty"`
  16324. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16325. MafPay float64 `json:"maf_pay,omitempty"`
  16326. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16327. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16328. PsnPay float64 `json:"psn_pay,omitempty"`
  16329. AcctPay float64 `json:"acct_pay,omitempty"`
  16330. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16331. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16332. Balc float64 `json:"balc,omitempty"`
  16333. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16334. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16335. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16336. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16337. Year string `json:"year,omitempty"`
  16338. DiseNo string `json:"dise_no,omitempty"`
  16339. DiseName string `json:"dise_name,omitempty"`
  16340. Invono string `json:"invono,omitempty"`
  16341. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16342. Memo string `json:"memo,omitempty"`
  16343. UpdtTime string `json:"updt_time,omitempty"`
  16344. OpterID string `json:"opter_id,omitempty"`
  16345. OpterName string `json:"opter_name,omitempty"`
  16346. OptTime string `json:"opt_time,omitempty"`
  16347. OptinsNo string `json:"optins_no,omitempty"`
  16348. PoolareaNo string `json:"poolarea_no,omitempty"`
  16349. } `json:"result"`
  16350. } `json:"output"`
  16351. RefmsgTime string `json:"refmsg_time"`
  16352. RespondTime string `json:"respond_time"`
  16353. Signtype interface{} `json:"signtype"`
  16354. WarnInfo interface{} `json:"warn_info"`
  16355. }
  16356. // type Autogenerated struct {
  16357. // Output struct {
  16358. // Setlinfo struct {
  16359. // SetlTime string `json:"setl_time"`
  16360. // CvlservPay float64 `json:"cvlserv_pay"`
  16361. // Year string `json:"year"`
  16362. // MedType string `json:"med_type"`
  16363. // PsnPay float64 `json:"psn_pay"`
  16364. // OpterID string `json:"opter_id"`
  16365. // Begndate string `json:"begndate"`
  16366. // FlxempeFlag string `json:"flxempe_flag"`
  16367. // HifmiPay float64 `json:"hifmi_pay"`
  16368. // PsnNo string `json:"psn_no"`
  16369. // ActPayDedc float64 `json:"act_pay_dedc"`
  16370. // MedinsSetlID interface{} `json:"medins_setl_id"`
  16371. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16372. // ClrWay string `json:"clr_way"`
  16373. // OthPay float64 `json:"oth_pay"`
  16374. // Gend string `json:"gend"`
  16375. // MdtrtID string `json:"mdtrt_id"`
  16376. // AcctPay float64 `json:"acct_pay"`
  16377. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  16378. // Insutype string `json:"insutype"`
  16379. // Invono interface{} `json:"invono"`
  16380. // Enddate string `json:"enddate"`
  16381. // CashPayamt float64 `json:"cash_payamt"`
  16382. // PsnType string `json:"psn_type"`
  16383. // FixmedinsName string `json:"fixmedins_name"`
  16384. // HifpPay float64 `json:"hifp_pay"`
  16385. // NewFlag interface{} `json:"new_flag"`
  16386. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16387. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  16388. // PayLoc string `json:"pay_loc"`
  16389. // ClrType string `json:"clr_type"`
  16390. // RefdSetlFlag string `json:"refd_setl_flag"`
  16391. // CvlservFlag string `json:"cvlserv_flag"`
  16392. // EmpName string `json:"emp_name"`
  16393. // Brdy string `json:"brdy"`
  16394. // Naty string `json:"naty"`
  16395. // Certno string `json:"certno"`
  16396. // DiseCode string `json:"dise_code"`
  16397. // FixmedinsCode string `json:"fixmedins_code"`
  16398. // DedcHospLv string `json:"dedc_hosp_lv"`
  16399. // OpterName string `json:"opter_name"`
  16400. // Balc float64 `json:"balc"`
  16401. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16402. // PsnCertType string `json:"psn_cert_type"`
  16403. // HifobPay float64 `json:"hifob_pay"`
  16404. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  16405. // HifesPay float64 `json:"hifes_pay"`
  16406. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16407. // OptTime string `json:"opt_time"`
  16408. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16409. // SetlID string `json:"setl_id"`
  16410. // MafPay float64 `json:"maf_pay"`
  16411. // PsnName string `json:"psn_name"`
  16412. // InsuOptins interface{} `json:"insu_optins"`
  16413. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16414. // ClrOptins string `json:"clr_optins"`
  16415. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16416. // DiseName string `json:"dise_name"`
  16417. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16418. // Age float64 `json:"age"`
  16419. // DtrtCertType string `json:"dtrt_cert_type"`
  16420. // HospLv string `json:"hosp_lv"`
  16421. // } `json:"setlinfo"`
  16422. // Setldetail []struct {
  16423. // FundPayType string `json:"fund_pay_type"`
  16424. // FundPayamt float64 `json:"fund_payamt"`
  16425. // SetlProcInfo interface{} `json:"setl_proc_info"`
  16426. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  16427. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  16428. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  16429. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16430. // } `json:"setldetail"`
  16431. // } `json:"output"`
  16432. // Infcode int `json:"infcode"`
  16433. // WarnMsg interface{} `json:"warn_msg"`
  16434. // Cainfo interface{} `json:"cainfo"`
  16435. // ErrMsg interface{} `json:"err_msg"`
  16436. // RefmsgTime string `json:"refmsg_time"`
  16437. // Signtype interface{} `json:"signtype"`
  16438. // RespondTime string `json:"respond_time"`
  16439. // InfRefmsgid string `json:"inf_refmsgid"`
  16440. // }
  16441. type Result002 struct {
  16442. Cainfo interface{} `json:"cainfo"`
  16443. ErrMsg string `json:"err_msg"`
  16444. InfRefmsgid string `json:"inf_refmsgid"`
  16445. Infcode int64 `json:"infcode"`
  16446. Output struct {
  16447. RxFile string `json:"rx_file"`
  16448. SignDigest string `json:"sign_digest"`
  16449. SignCertSn string `json:"sign_cert_sn"`
  16450. SignCertDn string `json:"sign_cert_dn"`
  16451. } `json:"output"`
  16452. RefmsgTime string `json:"refmsg_time"`
  16453. RespondTime string `json:"respond_time"`
  16454. Signtype interface{} `json:"signtype"`
  16455. WarnMsg interface{} `json:"warn_msg"`
  16456. }
  16457. type Result003 struct {
  16458. Cainfo interface{} `json:"cainfo"`
  16459. ErrMsg string `json:"err_msg"`
  16460. InfRefmsgid string `json:"inf_refmsgid"`
  16461. Infcode int64 `json:"infcode"`
  16462. Output struct {
  16463. HiRxno string `json:"hi_rxno"`
  16464. RxStasCodg string `json:"rx_stas_codg"`
  16465. RxStasName string `json:"rx_stas_name"`
  16466. } `json:"output"`
  16467. RefmsgTime string `json:"refmsg_time"`
  16468. RespondTime string `json:"respond_time"`
  16469. Signtype interface{} `json:"signtype"`
  16470. WarnMsg interface{} `json:"warn_msg"`
  16471. }
  16472. type ResultEleven struct {
  16473. Cainfo string `json:"cainfo"`
  16474. ErrMsg string `json:"err_msg"`
  16475. InfRefmsgid string `json:"inf_refmsgid"`
  16476. Infcode int64 `json:"infcode"`
  16477. Output struct {
  16478. Setlinfo struct {
  16479. SetlTime string `json:"setl_time"`
  16480. CvlservPay float64 `json:"cvlserv_pay"`
  16481. Year string `json:"year"`
  16482. MedType string `json:"med_type"`
  16483. PsnPay float64 `json:"psn_pay"`
  16484. OpterID string `json:"opter_id"`
  16485. Begndate string `json:"begndate"`
  16486. FlxempeFlag string `json:"flxempe_flag"`
  16487. HifmiPay float64 `json:"hifmi_pay"`
  16488. PsnNo string `json:"psn_no"`
  16489. ActPayDedc float64 `json:"act_pay_dedc"`
  16490. MedinsSetlID interface{} `json:"medins_setl_id"`
  16491. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16492. ClrWay string `json:"clr_way"`
  16493. OthPay float64 `json:"oth_pay"`
  16494. Gend string `json:"gend"`
  16495. MdtrtID string `json:"mdtrt_id"`
  16496. AcctPay float64 `json:"acct_pay"`
  16497. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16498. Insutype string `json:"insutype"`
  16499. Invono interface{} `json:"invono"`
  16500. Enddate string `json:"enddate"`
  16501. CashPayamt float64 `json:"cash_payamt"`
  16502. PsnType string `json:"psn_type"`
  16503. FixmedinsName string `json:"fixmedins_name"`
  16504. HifpPay float64 `json:"hifp_pay"`
  16505. NewFlag interface{} `json:"new_flag"`
  16506. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16507. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16508. PayLoc string `json:"pay_loc"`
  16509. ClrType string `json:"clr_type"`
  16510. RefdSetlFlag string `json:"refd_setl_flag"`
  16511. CvlservFlag string `json:"cvlserv_flag"`
  16512. EmpName string `json:"emp_name"`
  16513. Brdy string `json:"brdy"`
  16514. Naty string `json:"naty"`
  16515. Certno string `json:"certno"`
  16516. DiseCode string `json:"dise_code"`
  16517. FixmedinsCode string `json:"fixmedins_code"`
  16518. DedcHospLv string `json:"dedc_hosp_lv"`
  16519. OpterName string `json:"opter_name"`
  16520. Balc float64 `json:"balc"`
  16521. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16522. PsnCertType string `json:"psn_cert_type"`
  16523. HifobPay float64 `json:"hifob_pay"`
  16524. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16525. HifesPay float64 `json:"hifes_pay"`
  16526. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16527. OptTime string `json:"opt_time"`
  16528. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16529. SetlID string `json:"setl_id"`
  16530. MafPay float64 `json:"maf_pay"`
  16531. PsnName string `json:"psn_name"`
  16532. InsuOptins interface{} `json:"insu_optins"`
  16533. PrefFundPay interface{} `json:"pref_fund_pay"`
  16534. ClrOptins string `json:"clr_optins"`
  16535. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16536. DiseName string `json:"dise_name"`
  16537. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16538. Age float64 `json:"age"`
  16539. DtrtCertType string `json:"dtrt_cert_type"`
  16540. HospLv string `json:"hosp_lv"`
  16541. PsnCashPay float64 `json:"psn_cash_pay"`
  16542. } `json:"setlinfo"`
  16543. } `json:"output"`
  16544. RefmsgTime string `json:"refmsg_time"`
  16545. RespondTime string `json:"respond_time"`
  16546. Signtype interface{} `json:"signtype"`
  16547. WarnMsg interface{} `json:"warn_msg"`
  16548. }
  16549. type ResultElevenah struct {
  16550. Cainfo string `json:"cainfo"`
  16551. ErrMsg string `json:"err_msg"`
  16552. InfRefmsgid string `json:"inf_refmsgid"`
  16553. Infcode int64 `json:"infcode"`
  16554. Output struct {
  16555. Setlinfo struct {
  16556. SetlTime int64 `json:"setl_time"`
  16557. CvlservPay float64 `json:"cvlserv_pay"`
  16558. Year string `json:"year"`
  16559. MedType string `json:"med_type"`
  16560. PsnPay float64 `json:"psn_pay"`
  16561. OpterID string `json:"opter_id"`
  16562. Begndate int64 `json:"begndate"`
  16563. FlxempeFlag string `json:"flxempe_flag"`
  16564. HifmiPay float64 `json:"hifmi_pay"`
  16565. PsnNo string `json:"psn_no"`
  16566. ActPayDedc float64 `json:"act_pay_dedc"`
  16567. MedinsSetlID interface{} `json:"medins_setl_id"`
  16568. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16569. ClrWay string `json:"clr_way"`
  16570. OthPay float64 `json:"oth_pay"`
  16571. Gend string `json:"gend"`
  16572. MdtrtID string `json:"mdtrt_id"`
  16573. AcctPay float64 `json:"acct_pay"`
  16574. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16575. Insutype string `json:"insutype"`
  16576. Invono interface{} `json:"invono"`
  16577. Enddate int64 `json:"enddate"`
  16578. CashPayamt float64 `json:"cash_payamt"`
  16579. PsnType string `json:"psn_type"`
  16580. FixmedinsName string `json:"fixmedins_name"`
  16581. HifpPay float64 `json:"hifp_pay"`
  16582. NewFlag interface{} `json:"new_flag"`
  16583. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16584. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16585. PayLoc string `json:"pay_loc"`
  16586. ClrType string `json:"clr_type"`
  16587. RefdSetlFlag string `json:"refd_setl_flag"`
  16588. CvlservFlag string `json:"cvlserv_flag"`
  16589. EmpName string `json:"emp_name"`
  16590. Brdy int64 `json:"brdy"`
  16591. Naty string `json:"naty"`
  16592. Certno string `json:"certno"`
  16593. DiseCode string `json:"dise_code"`
  16594. FixmedinsCode string `json:"fixmedins_code"`
  16595. DedcHospLv string `json:"dedc_hosp_lv"`
  16596. OpterName string `json:"opter_name"`
  16597. Balc float64 `json:"balc"`
  16598. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16599. PsnCertType string `json:"psn_cert_type"`
  16600. HifobPay float64 `json:"hifob_pay"`
  16601. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16602. HifesPay float64 `json:"hifes_pay"`
  16603. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16604. OptTime int64 `json:"opt_time"`
  16605. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16606. SetlID string `json:"setl_id"`
  16607. MafPay float64 `json:"maf_pay"`
  16608. PsnName string `json:"psn_name"`
  16609. InsuOptins interface{} `json:"insu_optins"`
  16610. PrefFundPay interface{} `json:"pref_fund_pay"`
  16611. ClrOptins string `json:"clr_optins"`
  16612. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16613. DiseName string `json:"dise_name"`
  16614. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16615. Age float64 `json:"age"`
  16616. DtrtCertType string `json:"dtrt_cert_type"`
  16617. HospLv string `json:"hosp_lv"`
  16618. PsnCashPay float64 `json:"psn_cash_pay"`
  16619. } `json:"setlinfo"`
  16620. } `json:"output"`
  16621. RefmsgTime string `json:"refmsg_time"`
  16622. RespondTime string `json:"respond_time"`
  16623. Signtype interface{} `json:"signtype"`
  16624. WarnMsg interface{} `json:"warn_msg"`
  16625. }
  16626. type ResultEleven10265 struct {
  16627. Cainfo string `json:"cainfo"`
  16628. ErrMsg string `json:"err_msg"`
  16629. InfRefmsgid string `json:"inf_refmsgid"`
  16630. Infcode string `json:"infcode"`
  16631. Output struct {
  16632. Setlinfo struct {
  16633. SetlTime string `json:"setl_time"`
  16634. CvlservPay float64 `json:"cvlserv_pay"`
  16635. Year string `json:"year"`
  16636. MedType string `json:"med_type"`
  16637. PsnPay float64 `json:"psn_pay"`
  16638. OpterID string `json:"opter_id"`
  16639. Begndate string `json:"begndate"`
  16640. FlxempeFlag string `json:"flxempe_flag"`
  16641. HifmiPay float64 `json:"hifmi_pay"`
  16642. PsnNo string `json:"psn_no"`
  16643. ActPayDedc float64 `json:"act_pay_dedc"`
  16644. MedinsSetlID interface{} `json:"medins_setl_id"`
  16645. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16646. ClrWay string `json:"clr_way"`
  16647. OthPay float64 `json:"oth_pay"`
  16648. Gend string `json:"gend"`
  16649. MdtrtID string `json:"mdtrt_id"`
  16650. AcctPay float64 `json:"acct_pay"`
  16651. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16652. Insutype string `json:"insutype"`
  16653. Invono interface{} `json:"invono"`
  16654. Enddate string `json:"enddate"`
  16655. CashPayamt float64 `json:"cash_payamt"`
  16656. PsnType string `json:"psn_type"`
  16657. FixmedinsName string `json:"fixmedins_name"`
  16658. HifpPay float64 `json:"hifp_pay"`
  16659. NewFlag interface{} `json:"new_flag"`
  16660. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16661. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16662. PayLoc string `json:"pay_loc"`
  16663. ClrType string `json:"clr_type"`
  16664. RefdSetlFlag string `json:"refd_setl_flag"`
  16665. CvlservFlag string `json:"cvlserv_flag"`
  16666. EmpName string `json:"emp_name"`
  16667. Brdy string `json:"brdy"`
  16668. Naty string `json:"naty"`
  16669. Certno string `json:"certno"`
  16670. DiseCode string `json:"dise_code"`
  16671. FixmedinsCode string `json:"fixmedins_code"`
  16672. DedcHospLv string `json:"dedc_hosp_lv"`
  16673. OpterName string `json:"opter_name"`
  16674. Balc float64 `json:"balc"`
  16675. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16676. PsnCertType string `json:"psn_cert_type"`
  16677. HifobPay float64 `json:"hifob_pay"`
  16678. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16679. HifesPay float64 `json:"hifes_pay"`
  16680. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16681. OptTime string `json:"opt_time"`
  16682. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16683. SetlID string `json:"setl_id"`
  16684. MafPay float64 `json:"maf_pay"`
  16685. PsnName string `json:"psn_name"`
  16686. InsuOptins interface{} `json:"insu_optins"`
  16687. PrefFundPay interface{} `json:"pref_fund_pay"`
  16688. ClrOptins string `json:"clr_optins"`
  16689. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16690. DiseName string `json:"dise_name"`
  16691. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16692. Age float64 `json:"age"`
  16693. DtrtCertType string `json:"dtrt_cert_type"`
  16694. HospLv string `json:"hosp_lv"`
  16695. PsnCashPay float64 `json:"psn_cash_pay"`
  16696. } `json:"setlinfo"`
  16697. } `json:"output"`
  16698. RefmsgTime string `json:"refmsg_time"`
  16699. RespondTime string `json:"respond_time"`
  16700. Signtype interface{} `json:"signtype"`
  16701. WarnMsg interface{} `json:"warn_msg"`
  16702. }
  16703. type ResultTwelve struct {
  16704. Cainfo string `json:"cainfo"`
  16705. ErrMsg string `json:"err_msg"`
  16706. InfRefmsgid string `json:"inf_refmsgid"`
  16707. Infcode int64 `json:"infcode"`
  16708. Output struct {
  16709. MdtrtId string `json:"mdtrt_id"`
  16710. ChrgBchno string `json:"chrg_bchno"`
  16711. PsnNo string `json:"psn_no"`
  16712. } `json:"output"`
  16713. RefmsgTime string `json:"refmsg_time"`
  16714. RespondTime string `json:"respond_time"`
  16715. Signtype interface{} `json:"signtype"`
  16716. WarnMsg interface{} `json:"warn_msg"`
  16717. }
  16718. type ResultThirteen struct {
  16719. ErrMsg string `json:"err_msg"`
  16720. InfRefmsgid string `json:"inf_refmsgid"`
  16721. Infcode int64 `json:"infcode"`
  16722. Output struct {
  16723. Result struct {
  16724. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16725. } `json:"result"`
  16726. } `json:"output"`
  16727. RefmsgTime string `json:"refmsg_time"`
  16728. RespondTime string `json:"respond_time"`
  16729. Signtype interface{} `json:"signtype"`
  16730. WarnInfo interface{} `json:"warn_info"`
  16731. }
  16732. type ResultThirteen10265 struct {
  16733. ErrMsg string `json:"err_msg"`
  16734. InfRefmsgid string `json:"inf_refmsgid"`
  16735. Infcode string `json:"infcode"`
  16736. Output struct {
  16737. Result struct {
  16738. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16739. } `json:"result"`
  16740. } `json:"output"`
  16741. RefmsgTime string `json:"refmsg_time"`
  16742. RespondTime string `json:"respond_time"`
  16743. Signtype interface{} `json:"signtype"`
  16744. WarnInfo interface{} `json:"warn_info"`
  16745. }
  16746. type ResultFourteen struct {
  16747. ErrMsg string `json:"err_msg"`
  16748. InfRefmsgid string `json:"inf_refmsgid"`
  16749. Infcode int64 `json:"infcode"`
  16750. Output struct {
  16751. } `json:"output"`
  16752. RefmsgTime string `json:"refmsg_time"`
  16753. RespondTime string `json:"respond_time"`
  16754. Signtype interface{} `json:"signtype"`
  16755. WarnInfo interface{} `json:"warn_info"`
  16756. }
  16757. type ResultCFYLJG001 struct {
  16758. ErrMsg string `json:"err_msg"`
  16759. InfRefmsgid string `json:"inf_refmsgid"`
  16760. Infcode int64 `json:"infcode"`
  16761. Output struct {
  16762. RxTraceCode string `json:"rx_trace_code"`
  16763. HiRxno string `json:"hi_rxno"`
  16764. } `json:"output"`
  16765. RefmsgTime string `json:"refmsg_time"`
  16766. RespondTime string `json:"respond_time"`
  16767. Signtype interface{} `json:"signtype"`
  16768. WarnInfo interface{} `json:"warn_info"`
  16769. }
  16770. type ResultCFYLJG007 struct {
  16771. ErrMsg string `json:"err_msg"`
  16772. InfRefmsgid string `json:"inf_refmsgid"`
  16773. Infcode int64 `json:"infcode"`
  16774. Output struct {
  16775. HiRxno string `json:"hi_rxno"`
  16776. RxStasName string `json:"rx_stas_name"`
  16777. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16778. Seltdelts []interface{} `json:"seltdelts"`
  16779. RxUsedStasName string `json:"rx_used_stas_name"`
  16780. RxStasCodg string `json:"rx_stas_codg"`
  16781. } `json:"output"`
  16782. RefmsgTime string `json:"refmsg_time"`
  16783. RespondTime string `json:"respond_time"`
  16784. Signtype interface{} `json:"signtype"`
  16785. WarnInfo interface{} `json:"warn_info"`
  16786. }
  16787. type ResultCFYLJG002 struct {
  16788. ErrMsg string `json:"err_msg"`
  16789. InfRefmsgid string `json:"inf_refmsgid"`
  16790. Infcode int64 `json:"infcode"`
  16791. Output struct {
  16792. RxFile string `json:"rx_file"`
  16793. SignDigest string `json:"sign_digest"`
  16794. SignCertSn string `json:"sign_cert_sn"`
  16795. SignCertDn string `json:"sign_cert_dn"`
  16796. } `json:"output"`
  16797. RefmsgTime string `json:"refmsg_time"`
  16798. RespondTime string `json:"respond_time"`
  16799. Signtype interface{} `json:"signtype"`
  16800. WarnInfo interface{} `json:"warn_info"`
  16801. }
  16802. type ResultCFYLJG003 struct {
  16803. ErrMsg string `json:"err_msg"`
  16804. InfRefmsgid string `json:"inf_refmsgid"`
  16805. Infcode int64 `json:"infcode"`
  16806. Output struct {
  16807. HiRxno string `json:"hi_rxno"`
  16808. RxStasCodg string `json:"rx_stas_codg"`
  16809. RxStasName string `json:"rx_stas_name"`
  16810. } `json:"output"`
  16811. RefmsgTime string `json:"refmsg_time"`
  16812. RespondTime string `json:"respond_time"`
  16813. Signtype interface{} `json:"signtype"`
  16814. WarnInfo interface{} `json:"warn_info"`
  16815. }
  16816. type ResultCFYLJG004 struct {
  16817. ErrMsg string `json:"err_msg"`
  16818. InfRefmsgid string `json:"inf_refmsgid"`
  16819. Infcode int64 `json:"infcode"`
  16820. Output struct {
  16821. HiRxno string `json:"hi_rxno"`
  16822. RxStasCodg string `json:"rx_stas_codg"`
  16823. RxStasName string `json:"rx_stas_name"`
  16824. } `json:"output"`
  16825. RefmsgTime string `json:"refmsg_time"`
  16826. RespondTime string `json:"respond_time"`
  16827. Signtype interface{} `json:"signtype"`
  16828. WarnInfo interface{} `json:"warn_info"`
  16829. }
  16830. type ResultCFYLJG008 struct {
  16831. ErrMsg string `json:"err_msg"`
  16832. InfRefmsgid string `json:"inf_refmsgid"`
  16833. Infcode int64 `json:"infcode"`
  16834. Output struct {
  16835. PoolareaNo string `json:"poolareaNo"`
  16836. AdmdvsName string `json:"admdvsName"`
  16837. Count string `json:"count"`
  16838. } `json:"output"`
  16839. RefmsgTime string `json:"refmsg_time"`
  16840. RespondTime string `json:"respond_time"`
  16841. Signtype interface{} `json:"signtype"`
  16842. WarnInfo interface{} `json:"warn_info"`
  16843. }
  16844. type ResultCFYLJG005 struct {
  16845. ErrMsg string `json:"err_msg"`
  16846. InfRefmsgid string `json:"inf_refmsgid"`
  16847. Infcode int64 `json:"infcode"`
  16848. Output struct {
  16849. HiRxNo string `json:"hi_rxno"`
  16850. FixMedinsCode string `json:"fixmedins_code"`
  16851. FixMedinsName string `json:"fixmedins_name"`
  16852. RxStasCodg string `json:"rx_stas_codg"`
  16853. RxStasName string `json:"rx_stas_name"`
  16854. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16855. RxUserdStasName string `json:"rx_userd_stas_name"`
  16856. PrscTime string `json:"prsc_time"`
  16857. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16858. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16859. RxUsedWayName string `json:"rx_used_way_name"`
  16860. RxFrquCodg string `json:"rx_frqu_codg"`
  16861. RxFrquName string `json:"rx_frqu_name"`
  16862. RxDosunt string `json:"rx_dosunt"`
  16863. RxDoscnt float64 `json:"rx_doscnt"`
  16864. RxDrordDscr string `json:"rx_drord_dscr"`
  16865. ValiDays int64 `json:"vali_days"`
  16866. ValiEndTime string `json:"vali_end_time"`
  16867. ReptFlag string `json:"rept_flag"`
  16868. MaxReptCnt int64 `json:"max_rept_cnt"`
  16869. ReptdCnt int64 `json:"reptd_cnt"`
  16870. MinInrvDays int64 `json:"min_inrv_days"`
  16871. RxTypeCode string `json:"rx_type_code"`
  16872. RxTypeName string `json:"rx_type_name"`
  16873. LongRxFlag string `json:"long_rx_flag"`
  16874. RxDetlList []struct {
  16875. MedListCodg string `json:"med_list_codg"`
  16876. MedinsListCodg string `json:"medins_list_codg"`
  16877. HospPrepFlag string `json:"hosp_prep_flag"`
  16878. RxItemTypeCode string `json:"rx_item_type_code"`
  16879. RxItemTypeName string `json:"rx_item_type_name"`
  16880. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16881. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16882. TcmHerbFoote string `json:"tcmherb_foote"`
  16883. MednTypeCode string `json:"medn_type_code"`
  16884. MednTypeName string `json:"medn_type_name"`
  16885. MainMedcFlag string `json:"main_medc_flag"`
  16886. UrgtFlag string `json:"urgt_flag"`
  16887. BasMednFlag string `json:"bas_medn_flag"`
  16888. ImpDrugFlag string `json:"imp_drug_flag"`
  16889. ProdBarc string `json:"prod_barc"`
  16890. DrugProdname string `json:"drug_prodname"`
  16891. GennameCodg string `json:"genname_codg"`
  16892. DrugGenname string `json:"drug_genname"`
  16893. DrugDosform string `json:"drug_dosform"`
  16894. DrugSpec string `json:"drug_spec"`
  16895. PrdrName string `json:"prdr_name"`
  16896. MedcWayCodg string `json:"medc_way_codg"`
  16897. MedcWayDscr string `json:"medc_way_dscr"`
  16898. MedcBegntime string `json:"medc_begntime"`
  16899. MedcEndtime string `json:"medc_endtime"`
  16900. MedcDays float64 `json:"medc_days"`
  16901. DrugPric float64 `json:"drug_pric"`
  16902. DrugSumamt float64 `json:"drug_sumamt"`
  16903. DrugCnt float64 `json:"drug_cnt"`
  16904. DrugDosunt string `json:"drug_dosunt"`
  16905. SinDoscnt float64 `json:"sin_doscnt"`
  16906. SinDosunt string `json:"sin_dosunt"`
  16907. UsedFrquCodg string `json:"used_frqu_codg"`
  16908. UsedFrquName string `json:"used_frqu_name"`
  16909. DrugTotlcnt string `json:"drug_totlcnt"`
  16910. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16911. DiseCodg string `json:"dise_codg"`
  16912. HospApprFlag string `json:"hosp_appr_flag"`
  16913. } `json:"rx_detl_list"`
  16914. RxOtpinfo struct {
  16915. MedType string `json:"med_type"`
  16916. IptOtpNo string `json:"ipt_otp_no"`
  16917. OtpIptFlag string `json:"otp_ipt_flag"`
  16918. PatnName string `json:"patn_name"`
  16919. PatnAge float64 `json:"patn_age"`
  16920. PatnHgt float64 `json:"patn_hgt"`
  16921. PatnWt float64 `json:"patn_wt"`
  16922. Gend string `json:"gend"`
  16923. GesoVal float64 `json:"geso_val"`
  16924. NwbFlag string `json:"nwb_flag"`
  16925. NwbAge string `json:"nwb_age"`
  16926. SuckPrdFlag string `json:"suck_prd_flag"`
  16927. AlgsHis string `json:"algs_his"`
  16928. Insutype string `json:"insutype"`
  16929. PrscDeptName string `json:"prsc_dept_name"`
  16930. PrscDrName string `json:"prsc_dr_name"`
  16931. PharName string `json:"phar_name"`
  16932. PharChkTime string `json:"phar_chk_time"`
  16933. MdtrtTime string `json:"mdtrt_time"`
  16934. DiseCodg string `json:"dise_codg"`
  16935. DiseName string `json:"dise_name"`
  16936. SpDiseFlag string `json:"sp_dise_flag"`
  16937. MaindiagCode string `json:"maindiag_code"`
  16938. MaindiagName string `json:"maindiag_name"`
  16939. DiseCondDscr string `json:"dise_cond_dscr"`
  16940. FstdiagFlag string `json:"fstdiag_flag"`
  16941. } `json:"rx_otpinfo"`
  16942. RxDiseList []struct {
  16943. DiagType string `json:"diag_type"`
  16944. MaindiagFlag string `json:"maindiag_flag"`
  16945. DiagSrtNo string `json:"diag_srt_no"`
  16946. DiagCode string `json:"diag_code"`
  16947. DiagName string `json:"diag_name"`
  16948. DiagDept string `json:"diag_dept"`
  16949. DiagDrNo string `json:"diag_dr_no"`
  16950. DiagDrName string `json:"diag_dr_name"`
  16951. DiagTime string `json:"diag_time"`
  16952. TcmDiseCode string `json:"tcm_dise_code"`
  16953. TcmDiseName string `json:"tcm_dise_name"`
  16954. TcmSympCode string `json:"tcmsymp_code"`
  16955. TcmSymp string `json:"tcmsymp"`
  16956. } `json:"rx_dise_list"`
  16957. } `json:"output"`
  16958. RefmsgTime string `json:"refmsg_time"`
  16959. RespondTime string `json:"respond_time"`
  16960. Signtype interface{} `json:"signtype"`
  16961. WarnInfo interface{} `json:"warn_info"`
  16962. }
  16963. type ResultCFYLJG006 struct {
  16964. ErrMsg string `json:"err_msg"`
  16965. InfRefmsgid string `json:"inf_refmsgid"`
  16966. Infcode int64 `json:"infcode"`
  16967. Output struct {
  16968. HiRxNo string `json:"hi_rxno"`
  16969. PharCode string `json:"phar_code"`
  16970. PharName string `json:"phar_name"`
  16971. RxChkOpnn string `json:"rx_chk_opnn"`
  16972. RxChkTime string `json:"rx_chk_time"`
  16973. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16974. RxChkStasName string `json:"rx_chk_stas_name"`
  16975. RxStasCodg string `json:"rx_stas_codg"`
  16976. RxStasName string `json:"rx_stas_name"`
  16977. } `json:"output"`
  16978. RefmsgTime string `json:"refmsg_time"`
  16979. RespondTime string `json:"respond_time"`
  16980. Signtype interface{} `json:"signtype"`
  16981. WarnInfo interface{} `json:"warn_info"`
  16982. }
  16983. type ResultFourteen10265 struct {
  16984. ErrMsg string `json:"err_msg"`
  16985. InfRefmsgid string `json:"inf_refmsgid"`
  16986. Infcode string `json:"infcode"`
  16987. Output struct {
  16988. } `json:"output"`
  16989. RefmsgTime string `json:"refmsg_time"`
  16990. RespondTime string `json:"respond_time"`
  16991. Signtype interface{} `json:"signtype"`
  16992. WarnInfo interface{} `json:"warn_info"`
  16993. }
  16994. type ResultSixteen struct {
  16995. Cainfo string `json:"cainfo"`
  16996. ErrMsg string `json:"err_msg"`
  16997. InfRefmsgid string `json:"inf_refmsgid"`
  16998. Infcode int64 `json:"infcode"`
  16999. Output struct {
  17000. Setlinfo struct {
  17001. MdtrtID string `json:"mdtrt_id"`
  17002. SetlID string `json:"setl_id"`
  17003. ClrOptins string `json:"clr_optins"`
  17004. SetlTime string `json:"setl_time"`
  17005. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17006. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17007. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17008. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17009. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17010. ActPayDedc float64 `json:"act_pay_dedc"`
  17011. HifpPay float64 `json:"hifp_pay"`
  17012. PoolPropSe float64 `json:"pool_prop_selfpay"`
  17013. Lfpay float64 `json:"selfpay"`
  17014. CvlservPay float64 `json:"cvlserv_pay"`
  17015. HifesPay float64 `json:"hifes_pay"`
  17016. HifmiPay float64 `json:"hifmi_pay"`
  17017. HifobPay float64 `json:"hifob_pay"`
  17018. MafPay float64 `json:"maf_pay"`
  17019. OthPay float64 `json:"oth_pay"`
  17020. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17021. PsnPartAmt float64 `json:"psn_part_amt"`
  17022. AcctPay float64 `json:"acct_pay"`
  17023. Balc float64 `json:"balc"`
  17024. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  17025. HospPartAmt float64 `json:"hosp_part_amt"`
  17026. MedinsSetlID string `json:"medins_setl_id"`
  17027. PdnCashPay string `json:"pdn_cash_pay"`
  17028. } `json:"setlinfo"`
  17029. } `json:"output"`
  17030. RefmsgTime string `json:"refmsg_time"`
  17031. RespondTime string `json:"respond_time"`
  17032. Signtype interface{} `json:"signtype"`
  17033. WarnMsg interface{} `json:"warn_msg"`
  17034. }
  17035. type ResultSixteen10265 struct {
  17036. Cainfo string `json:"cainfo"`
  17037. ErrMsg string `json:"err_msg"`
  17038. InfRefmsgid string `json:"inf_refmsgid"`
  17039. Infcode string `json:"infcode"`
  17040. Output struct {
  17041. Setlinfo struct {
  17042. MdtrtID string `json:"mdtrt_id"`
  17043. SetlID string `json:"setl_id"`
  17044. ClrOptins string `json:"clr_optins"`
  17045. SetlTime string `json:"setl_time"`
  17046. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17047. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17048. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17049. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17050. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17051. ActPayDedc float64 `json:"act_pay_dedc"`
  17052. HifpPay float64 `json:"hifp_pay"`
  17053. PoolPropSe float64 `json:"pool_prop_selfpay"`
  17054. Lfpay float64 `json:"selfpay"`
  17055. CvlservPay float64 `json:"cvlserv_pay"`
  17056. HifesPay float64 `json:"hifes_pay"`
  17057. HifmiPay float64 `json:"hifmi_pay"`
  17058. HifobPay float64 `json:"hifob_pay"`
  17059. MafPay float64 `json:"maf_pay"`
  17060. OthPay float64 `json:"oth_pay"`
  17061. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17062. PsnPartAmt float64 `json:"psn_part_amt"`
  17063. AcctPay float64 `json:"acct_pay"`
  17064. Balc float64 `json:"balc"`
  17065. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  17066. HospPartAmt float64 `json:"hosp_part_amt"`
  17067. MedinsSetlID string `json:"medins_setl_id"`
  17068. PdnCashPay string `json:"pdn_cash_pay"`
  17069. } `json:"setlinfo"`
  17070. } `json:"output"`
  17071. RefmsgTime string `json:"refmsg_time"`
  17072. RespondTime string `json:"respond_time"`
  17073. Signtype interface{} `json:"signtype"`
  17074. WarnMsg interface{} `json:"warn_msg"`
  17075. }
  17076. type ResultSixteen10265Two struct {
  17077. Cainfo string `json:"cainfo"`
  17078. ErrMsg string `json:"err_msg"`
  17079. InfRefmsgid string `json:"inf_refmsgid"`
  17080. Infcode string `json:"infcode"`
  17081. Output struct {
  17082. Setlinfo interface{} `json:"setlinfo"`
  17083. } `json:"output"`
  17084. RefmsgTime string `json:"refmsg_time"`
  17085. RespondTime string `json:"respond_time"`
  17086. Signtype interface{} `json:"signtype"`
  17087. WarnMsg interface{} `json:"warn_msg"`
  17088. }
  17089. type ResultgzSixteen10265Two struct {
  17090. Cainfo string `json:"cainfo"`
  17091. ErrMsg string `json:"err_msg"`
  17092. InfRefmsgid string `json:"inf_refmsgid"`
  17093. Infcode int64 `json:"infcode"`
  17094. Output struct {
  17095. Setlinfo interface{} `json:"setlinfo"`
  17096. } `json:"output"`
  17097. RefmsgTime string `json:"refmsg_time"`
  17098. RespondTime string `json:"respond_time"`
  17099. Signtype interface{} `json:"signtype"`
  17100. WarnMsg interface{} `json:"warn_msg"`
  17101. }
  17102. type ResultSeventeen struct {
  17103. ErrMsg string `json:"err_msg"`
  17104. InfRefmsgid string `json:"inf_refmsgid"`
  17105. Infcode int64 `json:"infcode"`
  17106. Output struct {
  17107. SetlListId string `json:"setl_list_id"`
  17108. } `json:"output"`
  17109. RefmsgTime string `json:"refmsg_time"`
  17110. RespondTime string `json:"respond_time"`
  17111. Signtype string `json:"signtype"`
  17112. WarnInfo string `json:"warn_info"`
  17113. }
  17114. type ResultSeventeenOther struct {
  17115. ErrMsg string `json:"err_msg"`
  17116. InfRefmsgid string `json:"inf_refmsgid"`
  17117. Infcode string `json:"infcode"`
  17118. Output struct {
  17119. SetlListId string `json:"setl_list_id"`
  17120. } `json:"output"`
  17121. RefmsgTime string `json:"refmsg_time"`
  17122. RespondTime string `json:"respond_time"`
  17123. Signtype string `json:"signtype"`
  17124. WarnInfo string `json:"warn_info"`
  17125. }
  17126. type Result90991 struct {
  17127. ErrMsg string `json:"err_msg"`
  17128. InfRefmsgid string `json:"inf_refmsgid"`
  17129. Infcode int64 `json:"infcode"`
  17130. Output struct {
  17131. Result struct {
  17132. PsnNo string `json:"psn_no"`
  17133. CardStat string `json:"card_stat"`
  17134. Certno string `json:"certno"`
  17135. PsnName string `json:"psn_name"`
  17136. CheckStat string `json:"check_stat"`
  17137. SscnoCheckStat string `json:"sscno_check_stat"`
  17138. } `json:"result"`
  17139. } `json:"output"`
  17140. RefmsgTime string `json:"refmsg_time"`
  17141. RespondTime string `json:"respond_time"`
  17142. Signtype interface{} `json:"signtype"`
  17143. WarnInfo interface{} `json:"warn_info"`
  17144. }
  17145. type Result90100 struct {
  17146. ErrMsg string `json:"err_msg"`
  17147. InfRefmsgid string `json:"inf_refmsgid"`
  17148. Infcode int64 `json:"infcode"`
  17149. Output struct {
  17150. PoolareaNo string `json:"poolarea_no"`
  17151. PoolareaNoName string `json:"poolarea_no_name"`
  17152. Insutype string `json:"insutype"`
  17153. InsutypeName string `json:"insutype_name"`
  17154. ClctType string `json:"clct_type"`
  17155. ClctTypeName string `json:"clct_type_name"`
  17156. ClctFlag string `json:"clct_flag"`
  17157. ClctFlagName string `json:"clct_flag_name"`
  17158. AccrymBegn string `json:"accrym_begn"`
  17159. AccrymEnd string `json:"accrym_end"`
  17160. ClctTime string `json:"clct_time"`
  17161. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  17162. } `json:"output"`
  17163. RefmsgTime string `json:"refmsg_time"`
  17164. RespondTime string `json:"respond_time"`
  17165. Signtype interface{} `json:"signtype"`
  17166. WarnInfo interface{} `json:"warn_info"`
  17167. }
  17168. type Custom struct {
  17169. DetItemFeeSumamt string
  17170. Cut string
  17171. FeedetlSn string
  17172. Price string
  17173. MedListCodg string
  17174. Type int64
  17175. AdviceId int64
  17176. ProjectId int64
  17177. ItemId int64
  17178. }
  17179. type Result5301 struct {
  17180. ErrMsg string `json:"err_msg"`
  17181. InfRefmsgid string `json:"inf_refmsgid"`
  17182. Infcode int64 `json:"infcode"`
  17183. Output struct {
  17184. Result []struct {
  17185. OpspDiseCode string `json:"opsp_dise_code"`
  17186. OpspDiseName string `json:"opsp_dise_name"`
  17187. Begndate string `json:"begndate"`
  17188. Enddate string `json:"enddate"`
  17189. } `json:"feedetail"`
  17190. } `json:"output"`
  17191. RefmsgTime string `json:"refmsg_time"`
  17192. RespondTime string `json:"respond_time"`
  17193. Signtype interface{} `json:"signtype"`
  17194. WarnInfo interface{} `json:"warn_info"`
  17195. }
  17196. type Result5301For10265 struct {
  17197. ErrMsg string `json:"err_msg"`
  17198. InfRefmsgid string `json:"inf_refmsgid"`
  17199. Infcode string `json:"infcode"`
  17200. Output struct {
  17201. Result []struct {
  17202. OpspDiseCode string `json:"opsp_dise_code"`
  17203. OpspDiseName string `json:"opsp_dise_name"`
  17204. Begndate string `json:"begndate"`
  17205. Enddate string `json:"enddate"`
  17206. } `json:"feedetail"`
  17207. } `json:"output"`
  17208. RefmsgTime string `json:"refmsg_time"`
  17209. RespondTime string `json:"respond_time"`
  17210. Signtype interface{} `json:"signtype"`
  17211. WarnInfo interface{} `json:"warn_info"`
  17212. }
  17213. //获取个人信息----挂号-----上传就诊信息
  17214. func (c *HisApiController) GetRegisterInfo() {
  17215. id, _ := c.GetInt64("id")
  17216. record_time := c.GetString("record_time")
  17217. settlementValue, _ := c.GetInt64("settlement_value")
  17218. medical_insurance_card := c.GetString("medical_insurance_card")
  17219. name := c.GetString("name")
  17220. id_card_type, _ := c.GetInt64("id_card_type")
  17221. certificates, _ := c.GetInt64("certificates")
  17222. medical_care, _ := c.GetInt64("medical_care")
  17223. birthday := c.GetString("birthday")
  17224. id_card := c.GetString("id_card")
  17225. register_type, _ := c.GetInt64("register")
  17226. doctor, _ := c.GetInt64("doctor")
  17227. department, _ := c.GetInt64("department")
  17228. gender, _ := c.GetInt64("sex")
  17229. registration_fee, _ := c.GetFloat("registration_fee")
  17230. medical_expenses, _ := c.GetFloat("medical_expenses")
  17231. social_type, _ := c.GetInt64("social_type")
  17232. admin_user_id, _ := c.GetInt64("admin_user_id")
  17233. insuplc_admdvs := c.GetString("insuplc_admdvs")
  17234. mdtrt_type := c.GetString("mdtrt_type")
  17235. if id_card_type == 5 {
  17236. id_card_type = 4
  17237. }
  17238. timeLayout := "2006-01-02"
  17239. loc, _ := time.LoadLocation("Local")
  17240. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  17241. birthUnix := birthdays.Unix()
  17242. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17243. if err != nil {
  17244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17245. return
  17246. }
  17247. recordDateTime := theTime.Unix()
  17248. adminInfo := c.GetAdminUserInfo()
  17249. var patient service.Patients
  17250. if id == 0 {
  17251. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  17252. } else {
  17253. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  17254. }
  17255. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17256. if patientPrescription.ID == 0 {
  17257. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17258. }
  17259. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17260. if patient.ID == 0 {
  17261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17262. return
  17263. }
  17264. if len(patient.IdCardNo) == 0 {
  17265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  17266. return
  17267. }
  17268. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  17269. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  17270. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  17271. //就诊结算未完成,不能进行二次挂号
  17272. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  17273. //if len(his) >= 1 {
  17274. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  17275. // if len(his) >= 1 && order.ID == 0 {
  17276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  17277. // return
  17278. // }
  17279. //}
  17280. //var register_log string
  17281. if config.IsOpen == 1 {
  17282. var res ResultTwo
  17283. var res10265 ResultTwo10265
  17284. var PsnNo string
  17285. var PsnCertType string
  17286. var Certno string
  17287. var PsnName string
  17288. var Gend string
  17289. var Naty string
  17290. var Brdy string
  17291. var Age float64
  17292. var infoStr string
  17293. var idetinfoStr string
  17294. var infocode int64
  17295. var verify_number string
  17296. fmt.Println(verify_number)
  17297. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  17298. psn_info, _ := service.GetPsnByPatientId(id)
  17299. PsnNo = psn_info.PsnNo
  17300. PsnCertType = psn_info.PsnCertType
  17301. Certno = psn_info.Certno
  17302. PsnName = psn_info.PsnName
  17303. Gend = psn_info.Gend
  17304. Naty = psn_info.Naty
  17305. Brdy = psn_info.Brdy
  17306. Age = psn_info.Age
  17307. infoStr = psn_info.Insuinfo
  17308. idetinfoStr = psn_info.Idetinfo
  17309. infocode = 0
  17310. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17311. psn_info, _ := service.GetPsnByPatientId(id)
  17312. PsnNo = psn_info.PsnNo
  17313. PsnCertType = psn_info.PsnCertType
  17314. Certno = psn_info.Certno
  17315. PsnName = psn_info.PsnName
  17316. Gend = psn_info.Gend
  17317. Naty = psn_info.Naty
  17318. Brdy = psn_info.Brdy
  17319. Age = psn_info.Age
  17320. infoStr = psn_info.Insuinfo
  17321. idetinfoStr = psn_info.Idetinfo
  17322. infocode = 0
  17323. verify_number = psn_info.VerifyNumber
  17324. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17325. if id_card_type == 2 {
  17326. //请求内网数据
  17327. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  17328. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17329. "&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
  17330. resp, requestErr := http.Get(api)
  17331. if requestErr != nil {
  17332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17333. return
  17334. }
  17335. body, ioErr := ioutil.ReadAll(resp.Body)
  17336. if ioErr != nil {
  17337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17339. return
  17340. }
  17341. var respJSON map[string]interface{}
  17342. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17345. return
  17346. }
  17347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17348. result_byte, _ := json.Marshal(respJSON)
  17349. result := string(result_byte)
  17350. var dat map[string]interface{}
  17351. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17352. fmt.Println(dat)
  17353. } else {
  17354. fmt.Println(err)
  17355. }
  17356. userJSONBytes, _ := json.Marshal(dat)
  17357. var res ResultTwo
  17358. var resTwo10265 ResultTwo10265
  17359. if miConfig.Code == "H15049901371" {
  17360. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  17361. utils.ErrorLog("解析失败:%v", err)
  17362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17363. return
  17364. }
  17365. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  17366. res.Infcode = Infcode
  17367. res.ErrMsg = resTwo10265.ErrMsg
  17368. res.Output = resTwo10265.Output
  17369. res.InfRefmsgid = resTwo10265.InfRefmsgid
  17370. res.RespondTime = resTwo10265.RespondTime
  17371. res.WarnInfo = resTwo10265.WarnInfo
  17372. } else {
  17373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17374. utils.ErrorLog("解析失败:%v", err)
  17375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17376. return
  17377. }
  17378. }
  17379. //var insutypes []string
  17380. //var insutype string
  17381. //var is390 int = 0
  17382. //var is310 int = 0
  17383. //for _, item := range res.Output.Iinfo {
  17384. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17385. // insutypes = append(insutypes, item.Insutype)
  17386. // }
  17387. //}
  17388. //if len(insutypes) == 1 {
  17389. // insutype = insutypes[0]
  17390. //} else {
  17391. // for _, i := range insutypes {
  17392. // if i == "390" {
  17393. // is390 = 1
  17394. // }
  17395. //
  17396. // if i == "310" {
  17397. // is310 = 1
  17398. // }
  17399. // }
  17400. //}
  17401. //if is390 == 1 {
  17402. // insutype = "390"
  17403. //}
  17404. //if is310 == 1 {
  17405. // insutype = "310"
  17406. //}
  17407. //if len(insutypes) == 0 {
  17408. // insutype = "310"
  17409. //}
  17410. PsnNo = res.Output.Baseinfo.PsnNo
  17411. PsnCertType = res.Output.Baseinfo.PsnCertType
  17412. Certno = res.Output.Baseinfo.Certno
  17413. PsnName = res.Output.Baseinfo.PsnName
  17414. Gend = res.Output.Baseinfo.Gend
  17415. Naty = res.Output.Baseinfo.Naty
  17416. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17417. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17418. infoStr = string(Iinfos)
  17419. idetinfoStr = string(Idetinfos)
  17420. infocode = res.Infcode
  17421. //infocode = 0
  17422. //verify_number = psn_info.VerifyNumber
  17423. } else {
  17424. psn_info, _ := service.GetPsnByPatientId(id)
  17425. PsnNo = psn_info.PsnNo
  17426. PsnCertType = psn_info.PsnCertType
  17427. Certno = psn_info.Certno
  17428. PsnName = psn_info.PsnName
  17429. Gend = psn_info.Gend
  17430. Naty = psn_info.Naty
  17431. Brdy = psn_info.Brdy
  17432. Age = psn_info.Age
  17433. infoStr = psn_info.Insuinfo
  17434. idetinfoStr = psn_info.Idetinfo
  17435. infocode = 0
  17436. verify_number = psn_info.VerifyNumber
  17437. }
  17438. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17439. if id_card_type == 1 {
  17440. psn_info, _ := service.GetPsnByPatientId(id)
  17441. PsnNo = psn_info.PsnNo
  17442. PsnCertType = psn_info.PsnCertType
  17443. Certno = psn_info.Certno
  17444. PsnName = psn_info.PsnName
  17445. Gend = psn_info.Gend
  17446. Naty = psn_info.Naty
  17447. Brdy = psn_info.Brdy
  17448. Age = psn_info.Age
  17449. infoStr = psn_info.Insuinfo
  17450. idetinfoStr = psn_info.Idetinfo
  17451. infocode = 0
  17452. verify_number = psn_info.VerifyNumber
  17453. } else if id_card_type == 2 {
  17454. 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)
  17455. fmt.Println(errMsgLog)
  17456. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17458. utils.ErrorLog("解析失败:%v", err)
  17459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17460. return
  17461. }
  17462. PsnNo = res.Output.Baseinfo.PsnNo
  17463. PsnCertType = res.Output.Baseinfo.PsnCertType
  17464. Certno = res.Output.Baseinfo.Certno
  17465. PsnName = res.Output.Baseinfo.PsnName
  17466. Gend = res.Output.Baseinfo.Gend
  17467. Naty = res.Output.Baseinfo.Naty
  17468. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17469. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17470. infoStr = string(Iinfos)
  17471. idetinfoStr = string(Idetinfos)
  17472. infocode = res.Infcode
  17473. }
  17474. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17475. if id_card_type == 1 {
  17476. psn_info, _ := service.GetPsnByPatientId(id)
  17477. PsnNo = psn_info.PsnNo
  17478. PsnCertType = psn_info.PsnCertType
  17479. Certno = psn_info.Certno
  17480. PsnName = psn_info.PsnName
  17481. Gend = psn_info.Gend
  17482. Naty = psn_info.Naty
  17483. Brdy = psn_info.Brdy
  17484. Age = psn_info.Age
  17485. infoStr = psn_info.Insuinfo
  17486. idetinfoStr = psn_info.Idetinfo
  17487. infocode = 0
  17488. verify_number = psn_info.VerifyNumber
  17489. } else if id_card_type == 2 {
  17490. 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, "")
  17491. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17492. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17493. utils.ErrorLog("解析失败:%v", err)
  17494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17495. return
  17496. }
  17497. PsnNo = res.Output.Baseinfo.PsnNo
  17498. PsnCertType = res.Output.Baseinfo.PsnCertType
  17499. Certno = res.Output.Baseinfo.Certno
  17500. PsnName = res.Output.Baseinfo.PsnName
  17501. Gend = res.Output.Baseinfo.Gend
  17502. Naty = res.Output.Baseinfo.Naty
  17503. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17504. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17505. infoStr = string(Iinfos)
  17506. idetinfoStr = string(Idetinfos)
  17507. infocode = res.Infcode
  17508. } else {
  17509. psn_info, _ := service.GetPsnByPatientId(id)
  17510. PsnNo = psn_info.PsnNo
  17511. PsnCertType = psn_info.PsnCertType
  17512. Certno = psn_info.Certno
  17513. PsnName = psn_info.PsnName
  17514. Gend = psn_info.Gend
  17515. Naty = psn_info.Naty
  17516. Brdy = psn_info.Brdy
  17517. Age = psn_info.Age
  17518. infoStr = psn_info.Insuinfo
  17519. idetinfoStr = psn_info.Idetinfo
  17520. infocode = 0
  17521. verify_number = psn_info.VerifyNumber
  17522. }
  17523. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17524. psn_info, _ := service.GetPsnByPatientId(id)
  17525. PsnNo = psn_info.PsnNo
  17526. PsnCertType = psn_info.PsnCertType
  17527. Certno = psn_info.Certno
  17528. PsnName = psn_info.PsnName
  17529. Gend = psn_info.Gend
  17530. Naty = psn_info.Naty
  17531. Brdy = psn_info.Brdy
  17532. Age = psn_info.Age
  17533. infoStr = psn_info.Insuinfo
  17534. idetinfoStr = psn_info.Idetinfo
  17535. infocode = 0
  17536. verify_number = psn_info.VerifyNumber
  17537. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17538. if id_card_type == 1 {
  17539. psn_info, _ := service.GetPsnByPatientId(id)
  17540. PsnNo = psn_info.PsnNo
  17541. PsnCertType = psn_info.PsnCertType
  17542. Certno = psn_info.Certno
  17543. PsnName = psn_info.PsnName
  17544. Gend = psn_info.Gend
  17545. Naty = psn_info.Naty
  17546. Brdy = psn_info.Brdy
  17547. Age = psn_info.Age
  17548. infoStr = psn_info.Insuinfo
  17549. idetinfoStr = psn_info.Idetinfo
  17550. infocode = 0
  17551. verify_number = psn_info.VerifyNumber
  17552. } else if id_card_type == 2 {
  17553. 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)
  17554. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17555. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17556. utils.ErrorLog("解析失败:%v", err)
  17557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17558. return
  17559. }
  17560. PsnNo = res.Output.Baseinfo.PsnNo
  17561. PsnCertType = res.Output.Baseinfo.PsnCertType
  17562. Certno = res.Output.Baseinfo.Certno
  17563. PsnName = res.Output.Baseinfo.PsnName
  17564. Gend = res.Output.Baseinfo.Gend
  17565. Naty = res.Output.Baseinfo.Naty
  17566. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17567. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17568. infoStr = string(Iinfos)
  17569. idetinfoStr = string(Idetinfos)
  17570. infocode = res.Infcode
  17571. } else if id_card_type == 4 {
  17572. psn_info, _ := service.GetPsnByPatientId(id)
  17573. PsnNo = psn_info.PsnNo
  17574. PsnCertType = psn_info.PsnCertType
  17575. Certno = psn_info.Certno
  17576. PsnName = psn_info.PsnName
  17577. Gend = psn_info.Gend
  17578. Naty = psn_info.Naty
  17579. Brdy = psn_info.Brdy
  17580. Age = psn_info.Age
  17581. infoStr = psn_info.Insuinfo
  17582. idetinfoStr = psn_info.Idetinfo
  17583. infocode = 0
  17584. verify_number = psn_info.VerifyNumber
  17585. }
  17586. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17587. var result string
  17588. var requestLog string
  17589. 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), "")
  17590. if id_card_type == 4 {
  17591. psn_info, _ := service.GetPsnByPatientId(id)
  17592. PsnNo = psn_info.PsnNo
  17593. PsnCertType = psn_info.PsnCertType
  17594. Certno = psn_info.Certno
  17595. PsnName = psn_info.PsnName
  17596. Gend = psn_info.Gend
  17597. Naty = psn_info.Naty
  17598. Brdy = psn_info.Brdy
  17599. Age = psn_info.Age
  17600. infoStr = psn_info.Insuinfo
  17601. idetinfoStr = psn_info.Idetinfo
  17602. infocode = 0
  17603. verify_number = psn_info.VerifyNumber
  17604. } else {
  17605. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17606. if miConfig.Code == "H15049901371" {
  17607. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17608. utils.ErrorLog("解析失败:%v", err)
  17609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17610. return
  17611. }
  17612. res.ErrMsg = res10265.ErrMsg
  17613. res.Output = res10265.Output
  17614. res.InfRefmsgid = res10265.InfRefmsgid
  17615. } else {
  17616. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17617. utils.ErrorLog("解析失败:%v", err)
  17618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17619. return
  17620. }
  17621. }
  17622. PsnNo = res.Output.Baseinfo.PsnNo
  17623. PsnCertType = res.Output.Baseinfo.PsnCertType
  17624. Certno = res.Output.Baseinfo.Certno
  17625. PsnName = res.Output.Baseinfo.PsnName
  17626. Gend = res.Output.Baseinfo.Gend
  17627. Naty = res.Output.Baseinfo.Naty
  17628. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17629. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17630. infoStr = string(Iinfos)
  17631. idetinfoStr = string(Idetinfos)
  17632. if miConfig.Code == "H15049901371" {
  17633. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17634. } else {
  17635. infocode = res.Infcode
  17636. }
  17637. }
  17638. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17639. psn_info, _ := service.GetPsnByPatientId(id)
  17640. PsnNo = psn_info.PsnNo
  17641. PsnCertType = psn_info.PsnCertType
  17642. Certno = psn_info.Certno
  17643. PsnName = psn_info.PsnName
  17644. Gend = psn_info.Gend
  17645. Naty = psn_info.Naty
  17646. Brdy = psn_info.Brdy
  17647. Age = psn_info.Age
  17648. infoStr = psn_info.Insuinfo
  17649. idetinfoStr = psn_info.Idetinfo
  17650. infocode = 0
  17651. verify_number = psn_info.VerifyNumber
  17652. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17653. psn_info, _ := service.GetPsnByPatientId(id)
  17654. PsnNo = psn_info.PsnNo
  17655. PsnCertType = psn_info.PsnCertType
  17656. Certno = psn_info.Certno
  17657. PsnName = psn_info.PsnName
  17658. Gend = psn_info.Gend
  17659. Naty = psn_info.Naty
  17660. Brdy = psn_info.Brdy
  17661. Age = psn_info.Age
  17662. infoStr = psn_info.Insuinfo
  17663. idetinfoStr = psn_info.Idetinfo
  17664. infocode = 0
  17665. verify_number = psn_info.VerifyNumber
  17666. } else {
  17667. var result string
  17668. var requestLog string
  17669. //if miConfig.UserOrgId == 10138 {
  17670. if id_card_type != 4 || id_card_type != 1 {
  17671. var insa string
  17672. if len(patient.InsuplcAdmdvs) > 0 {
  17673. insa = patient.InsuplcAdmdvs
  17674. } else {
  17675. insa = miConfig.InsuplcAdmdvs
  17676. }
  17677. //psn_info, _ := service.GetPsnByPatientId(id)
  17678. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  17679. 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)
  17680. }
  17681. //}
  17682. //else {
  17683. // var insa string
  17684. // if len(patient.InsuplcAdmdvs) > 0 {
  17685. // insa = patient.InsuplcAdmdvs
  17686. // } else {
  17687. // insa = miConfig.InsuplcAdmdvs
  17688. // }
  17689. // 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)
  17690. //}
  17691. if id_card_type == 4 || id_card_type == 1 {
  17692. psn_info, _ := service.GetPsnByPatientId(id)
  17693. PsnNo = psn_info.PsnNo
  17694. PsnCertType = psn_info.PsnCertType
  17695. Certno = psn_info.Certno
  17696. PsnName = psn_info.PsnName
  17697. Gend = psn_info.Gend
  17698. Naty = psn_info.Naty
  17699. Brdy = psn_info.Brdy
  17700. Age = psn_info.Age
  17701. infoStr = psn_info.Insuinfo
  17702. idetinfoStr = psn_info.Idetinfo
  17703. infocode = 0
  17704. verify_number = psn_info.VerifyNumber
  17705. } else {
  17706. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17707. if miConfig.Code == "H15049901371" {
  17708. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17709. utils.ErrorLog("解析失败:%v", err)
  17710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17711. return
  17712. }
  17713. res.ErrMsg = res10265.ErrMsg
  17714. res.Output = res10265.Output
  17715. res.InfRefmsgid = res10265.InfRefmsgid
  17716. } else {
  17717. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17718. utils.ErrorLog("解析失败:%v", err)
  17719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17720. return
  17721. }
  17722. }
  17723. PsnNo = res.Output.Baseinfo.PsnNo
  17724. PsnCertType = res.Output.Baseinfo.PsnCertType
  17725. Certno = res.Output.Baseinfo.Certno
  17726. PsnName = res.Output.Baseinfo.PsnName
  17727. Gend = res.Output.Baseinfo.Gend
  17728. Naty = res.Output.Baseinfo.Naty
  17729. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17730. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17731. infoStr = string(Iinfos)
  17732. idetinfoStr = string(Idetinfos)
  17733. if miConfig.Code == "H15049901371" {
  17734. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17735. } else {
  17736. infocode = res.Infcode
  17737. }
  17738. }
  17739. }
  17740. if infocode == 0 {
  17741. his := models.VMHisPatient{
  17742. Name: name,
  17743. Gender: gender,
  17744. Birthday: birthUnix,
  17745. MedicalTreatmentType: medical_care,
  17746. IdType: certificates,
  17747. IdCardNo: id_card,
  17748. BalanceAccountsType: settlementValue,
  17749. SocialType: social_type,
  17750. MedicalInsuranceNumber: medical_insurance_card,
  17751. RegisterType: register_type,
  17752. RegisterCost: registration_fee,
  17753. TreatmentCost: medical_expenses,
  17754. Status: 1,
  17755. Ctime: time.Now().Unix(),
  17756. Mtime: time.Now().Unix(),
  17757. PsnNo: PsnNo,
  17758. PsnCertType: PsnCertType,
  17759. Certno: Certno,
  17760. PsnName: PsnName,
  17761. Gend: Gend,
  17762. Naty: Naty,
  17763. Brdy: Brdy,
  17764. Age: Age,
  17765. Iinfo: infoStr,
  17766. Idetinfo: idetinfoStr,
  17767. PatientId: patient.ID,
  17768. RecordDate: theTime.Unix(),
  17769. UserOrgId: adminInfo.CurrentOrgId,
  17770. AdminUserId: admin_user_id,
  17771. IsReturn: 1,
  17772. IdCardType: id_card_type,
  17773. Doctor: doctor,
  17774. Departments: department,
  17775. MdtrtGrpType: mdtrt_type,
  17776. }
  17777. timestamp := time.Now().Unix()
  17778. tempTime := time.Unix(timestamp, 0)
  17779. timeFormat := tempTime.Format("20060102150405")
  17780. chrgBchno := rand.Intn(100000) + 10000
  17781. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17782. his.Number = ipt_otp_no
  17783. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17784. department, _ := service.GetDepartMentDetail(department)
  17785. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17786. IdCardNo := ""
  17787. if id_card_type == 1 {
  17788. // IdCardNo = medical_insurance_card
  17789. IdCardNo = patient.IdCardNo
  17790. } else {
  17791. IdCardNo = patient.IdCardNo
  17792. }
  17793. var rf []*ResultFive
  17794. json.Unmarshal([]byte(his.Iinfo), &rf)
  17795. var insutypes []*ResultFive
  17796. var insutype string
  17797. var insuplc_admdvs_temp string
  17798. var is390 int = 0
  17799. var is310 int = 0
  17800. for _, item := range rf {
  17801. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17802. insutypes = append(insutypes, item)
  17803. }
  17804. }
  17805. if len(insutypes) == 1 {
  17806. insutype = insutypes[0].Insutype
  17807. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17808. if insutype == "390" {
  17809. is390 = 1
  17810. }
  17811. if insutype == "310" {
  17812. is310 = 1
  17813. }
  17814. } else {
  17815. for _, i := range insutypes {
  17816. if i.Insutype == "390" {
  17817. is390 = 1
  17818. }
  17819. if i.Insutype == "310" {
  17820. is310 = 1
  17821. }
  17822. }
  17823. }
  17824. if is390 == 1 {
  17825. insutype = "390"
  17826. }
  17827. if is310 == 1 {
  17828. insutype = "310"
  17829. }
  17830. fmt.Println(social_type)
  17831. if social_type > 0 {
  17832. insutype = strconv.FormatInt(social_type, 10)
  17833. }
  17834. var infocode int64
  17835. var resThree ResultThree
  17836. var resThree10265 ResultThree10265
  17837. if len(insuplc_admdvs) == 0 {
  17838. psn_info, _ := service.GetPsnByPatientId(id)
  17839. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17840. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17841. //}
  17842. } else {
  17843. insuplc_admdvs_temp = insuplc_admdvs
  17844. }
  17845. if miConfig.MdtrtareaAdmvs == "421300" {
  17846. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17847. psn_info, _ := service.GetPsnByPatientId(id)
  17848. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17849. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17850. "&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
  17851. resp, requestErr := http.Get(api)
  17852. if requestErr != nil {
  17853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17854. return
  17855. }
  17856. body, ioErr := ioutil.ReadAll(resp.Body)
  17857. if ioErr != nil {
  17858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17860. return
  17861. }
  17862. var respJSON map[string]interface{}
  17863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17866. return
  17867. }
  17868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17869. result, _ := json.Marshal(respJSON)
  17870. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17871. utils.ErrorLog("解析失败:%v", err)
  17872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17873. return
  17874. }
  17875. infocode = resThree.Infcode
  17876. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17877. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17878. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17879. // insuplc_admdvs_temp =
  17880. //}
  17881. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17882. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17883. //}
  17884. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17885. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17886. "&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
  17887. resp, requestErr := http.Get(api)
  17888. if requestErr != nil {
  17889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17890. return
  17891. }
  17892. body, ioErr := ioutil.ReadAll(resp.Body)
  17893. if ioErr != nil {
  17894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17896. return
  17897. }
  17898. var respJSON map[string]interface{}
  17899. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17902. return
  17903. }
  17904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17905. result, _ := json.Marshal(respJSON)
  17906. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17907. utils.ErrorLog("解析失败:%v", err)
  17908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17909. return
  17910. }
  17911. infocode = resThree.Infcode
  17912. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17913. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17914. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17915. // insuplc_admdvs_temp =
  17916. //}
  17917. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17918. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17919. //}
  17920. utils.ErrorLog("解析失败:%v", insutype)
  17921. utils.ErrorLog("解析失败:%v", PsnNo)
  17922. utils.ErrorLog("解析失败:%v", Certno)
  17923. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  17924. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  17925. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  17926. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  17927. utils.ErrorLog("解析失败:%v", PsnNo)
  17928. utils.ErrorLog("解析失败:%v", department.Number)
  17929. utils.ErrorLog("解析失败:%v", department.Name)
  17930. utils.ErrorLog("解析失败:%v", roles.UserName)
  17931. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17932. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17933. "&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
  17934. resp, requestErr := http.Get(api)
  17935. if requestErr != nil {
  17936. utils.ErrorLog("解析失败:%v", requestErr)
  17937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17938. return
  17939. }
  17940. body, ioErr := ioutil.ReadAll(resp.Body)
  17941. if ioErr != nil {
  17942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17944. return
  17945. }
  17946. var respJSON map[string]interface{}
  17947. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17950. return
  17951. }
  17952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17953. result, _ := json.Marshal(respJSON)
  17954. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17955. utils.ErrorLog("解析失败:%v", err)
  17956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17957. return
  17958. }
  17959. infocode = resThree.Infcode
  17960. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17961. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17962. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17963. // insuplc_admdvs_temp =
  17964. //}
  17965. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17966. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17967. //}
  17968. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17969. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17970. "&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
  17971. resp, requestErr := http.Get(api)
  17972. if requestErr != nil {
  17973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17974. return
  17975. }
  17976. body, ioErr := ioutil.ReadAll(resp.Body)
  17977. if ioErr != nil {
  17978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17980. return
  17981. }
  17982. var respJSON map[string]interface{}
  17983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17986. return
  17987. }
  17988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17989. result, _ := json.Marshal(respJSON)
  17990. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17991. utils.ErrorLog("解析失败:%v", err)
  17992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17993. return
  17994. }
  17995. infocode = resThree.Infcode
  17996. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17997. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17998. psn_info, _ := service.GetPsnByPatientId(id)
  17999. var verify_number string
  18000. if id_card_type == 4 {
  18001. verify_number = psn_info.VerifyNumber
  18002. } else if id_card_type == 1 {
  18003. bas := strings.Split(psn_info.CardInfo, "|")
  18004. cardNumber := bas[2]
  18005. verify_number = cardNumber
  18006. }
  18007. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18008. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18009. "&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
  18010. resp, requestErr := http.Get(api)
  18011. if requestErr != nil {
  18012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18013. return
  18014. }
  18015. body, ioErr := ioutil.ReadAll(resp.Body)
  18016. if ioErr != nil {
  18017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18019. return
  18020. }
  18021. var respJSON map[string]interface{}
  18022. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18025. return
  18026. }
  18027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18028. result, _ := json.Marshal(respJSON)
  18029. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18030. // utils.ErrorLog("解析失败:%v", err)
  18031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18032. // return
  18033. //}
  18034. //infocode = resThree.Infcode
  18035. //result, _ := json.Marshal(respJSON)
  18036. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18037. utils.ErrorLog("解析失败:%v", err)
  18038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18039. return
  18040. }
  18041. resThree.ErrMsg = resThree10265.ErrMsg
  18042. resThree.Output = resThree10265.Output
  18043. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18044. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18045. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18046. psn_info, _ := service.GetPsnByPatientId(id)
  18047. his.PsnNo = psn_info.PsnNo
  18048. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18049. var cert_no string
  18050. if id_card_type == 3 {
  18051. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  18052. cert_no = IdCardNo
  18053. } else if id_card_type == 4 {
  18054. cert_no = IdCardNo
  18055. psn_info.VerifyNumber = psn_info.VerifyNumber
  18056. } else {
  18057. bas := strings.Split(psn_info.CardInfo, "|")
  18058. cert_no = bas[2]
  18059. }
  18060. var hisPrescription []*models.HisPrescription
  18061. for _, item := range rf {
  18062. if item.Insutype == insutype {
  18063. //insuplc_admdvs = item.InsuplcAdmdvs
  18064. his.InsuplcAdmdvs = insuplc_admdvs
  18065. }
  18066. }
  18067. his.Insutype = insutype
  18068. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18069. fmt.Println(res3101)
  18070. fmt.Println(res3101.Infcode)
  18071. if res3101.Infcode == "0" {
  18072. fmt.Println("33333333")
  18073. if len(res3101.Output.Result) > 0 {
  18074. fmt.Println("222222")
  18075. for _, item := range res3101.Output.Result {
  18076. if len(res3101.ErrMsg) == 0 {
  18077. res3101.ErrMsg = item.VolaCont
  18078. } else {
  18079. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18080. }
  18081. }
  18082. c.ServeSuccessJSON(map[string]interface{}{
  18083. "failed_code": -10,
  18084. "msg": res3101.ErrMsg,
  18085. })
  18086. return
  18087. } else {
  18088. fmt.Println("11111")
  18089. var api string
  18090. if miConfig.MdtrtareaAdmvs == "320921" {
  18091. ipt_otp_no = timeFormat
  18092. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18093. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18094. "&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
  18095. } else {
  18096. ipt_otp_no = timeFormat
  18097. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18098. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18099. "&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
  18100. }
  18101. resp, requestErr := http.Get(api)
  18102. if requestErr != nil {
  18103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18104. return
  18105. }
  18106. body, ioErr := ioutil.ReadAll(resp.Body)
  18107. if ioErr != nil {
  18108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18110. return
  18111. }
  18112. var respJSON map[string]interface{}
  18113. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18116. return
  18117. }
  18118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18119. result, _ := json.Marshal(respJSON)
  18120. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18121. utils.ErrorLog("解析失败:%v", err)
  18122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18123. return
  18124. }
  18125. resThree.ErrMsg = resThree10265.ErrMsg
  18126. resThree.Output = resThree10265.Output
  18127. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18128. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18129. }
  18130. } else if res3101.Infcode != "0" {
  18131. c.ServeSuccessJSON(map[string]interface{}{
  18132. "failed_code": -10,
  18133. "msg": res3101.ErrMsg,
  18134. })
  18135. return
  18136. }
  18137. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18138. psn_info, _ := service.GetPsnByPatientId(id)
  18139. var cert_no string
  18140. if id_card_type == 1 {
  18141. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  18142. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18143. } else if id_card_type == 4 {
  18144. cert_no = psn_info.VerifyNumber
  18145. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18146. } else {
  18147. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18148. cert_no = psn_info.VerifyNumber
  18149. }
  18150. 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)
  18151. saveLog(result, requestLog, "2201", "挂号")
  18152. if miConfig.Code == "H15049901371" {
  18153. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18154. utils.ErrorLog("解析失败:%v", err)
  18155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18156. return
  18157. }
  18158. resThree.ErrMsg = resThree10265.ErrMsg
  18159. resThree.Output = resThree10265.Output
  18160. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18161. } else {
  18162. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18163. utils.ErrorLog("解析失败:%v", err)
  18164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18165. return
  18166. }
  18167. }
  18168. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18169. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  18170. psn_info, _ := service.GetPsnByPatientId(id)
  18171. var result string
  18172. var requestLog string
  18173. if id_card_type == 1 {
  18174. bas := strings.Split(psn_info.CardInfo, "|")
  18175. basNumber := bas[2]
  18176. card_sn := bas[3]
  18177. 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)
  18178. saveLog(result, requestLog, "2201A", "挂号")
  18179. } else if id_card_type == 2 {
  18180. 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, "", "", "", "", "", "")
  18181. saveLog(result, requestLog, "2201A", "挂号")
  18182. } else {
  18183. 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)
  18184. saveLog(result, requestLog, "2201A", "挂号")
  18185. }
  18186. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18187. utils.ErrorLog("解析失败:%v", err)
  18188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18189. return
  18190. }
  18191. infocode = resThree.Infcode
  18192. } else if miConfig.MdtrtareaAdmvs == "341203" {
  18193. psn_info, _ := service.GetPsnByPatientId(id)
  18194. his.PsnNo = psn_info.PsnNo
  18195. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18196. var cert_no string
  18197. if id_card_type == 1 {
  18198. bas := strings.Split(psn_info.CardInfo, "|")
  18199. cert_no = bas[2]
  18200. } else if id_card_type == 4 {
  18201. cert_no = IdCardNo
  18202. psn_info.VerifyNumber = psn_info.VerifyNumber
  18203. } else {
  18204. cert_no = IdCardNo
  18205. psn_info.VerifyNumber = cert_no
  18206. }
  18207. for _, item := range rf {
  18208. if item.Insutype == insutype {
  18209. his.InsuplcAdmdvs = insuplc_admdvs
  18210. }
  18211. }
  18212. his.Insutype = insutype
  18213. var api string
  18214. ipt_otp_no = timeFormat
  18215. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18216. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18217. "&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
  18218. resp, requestErr := http.Get(api)
  18219. if requestErr != nil {
  18220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18221. return
  18222. }
  18223. body, ioErr := ioutil.ReadAll(resp.Body)
  18224. if ioErr != nil {
  18225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18227. return
  18228. }
  18229. var respJSON map[string]interface{}
  18230. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18233. return
  18234. }
  18235. status := respJSON["data"].(map[string]interface{})["status"].(string)
  18236. if status == "0" {
  18237. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  18238. c.ServeSuccessJSON(map[string]interface{}{
  18239. "failed_code": -10,
  18240. "msg": err_msg,
  18241. })
  18242. return
  18243. }
  18244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18245. result, _ := json.Marshal(respJSON)
  18246. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18247. utils.ErrorLog("解析失败:%v", err)
  18248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18249. return
  18250. }
  18251. infocode = resThree.Infcode
  18252. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18253. psn_info, _ := service.GetPsnByPatientId(id)
  18254. var result string
  18255. var requestLog string
  18256. if id_card_type == 1 {
  18257. bas := strings.Split(psn_info.CardInfo, "|")
  18258. basNumber := bas[2]
  18259. card_sn := bas[3]
  18260. 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)
  18261. saveLog(result, requestLog, "2201A", "挂号")
  18262. } else if id_card_type == 2 {
  18263. 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, "", "")
  18264. saveLog(result, requestLog, "2201A", "挂号")
  18265. } else {
  18266. 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, "", "")
  18267. saveLog(result, requestLog, "2201A", "挂号")
  18268. }
  18269. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18270. utils.ErrorLog("解析失败:%v", err)
  18271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18272. return
  18273. }
  18274. infocode = resThree.Infcode
  18275. } else if miConfig.MdtrtareaAdmvs == "131023" {
  18276. psn_info, _ := service.GetPsnByPatientId(id)
  18277. 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)
  18278. saveLog(result, requestLog, "2201A", "挂号")
  18279. if miConfig.Code == "H15049901371" {
  18280. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18281. utils.ErrorLog("解析失败:%v", err)
  18282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18283. return
  18284. }
  18285. resThree.ErrMsg = resThree10265.ErrMsg
  18286. resThree.Output = resThree10265.Output
  18287. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18288. } else {
  18289. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18290. utils.ErrorLog("解析失败:%v", err)
  18291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18292. return
  18293. }
  18294. }
  18295. if miConfig.Code == "H15049901371" {
  18296. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18297. } else {
  18298. infocode = resThree.Infcode
  18299. }
  18300. } else {
  18301. psn_info, _ := service.GetPsnByPatientId(id)
  18302. if id_card_type == 4 || id_card_type == 1 {
  18303. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18304. }
  18305. var rf []*ResultFive
  18306. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  18307. var insutypes []*ResultFive
  18308. var insutype string
  18309. var is390 int = 0
  18310. var is310 int = 0
  18311. for _, item := range rf {
  18312. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18313. insutypes = append(insutypes, item)
  18314. }
  18315. }
  18316. if len(insutypes) == 1 {
  18317. insutype = insutypes[0].Insutype
  18318. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18319. } else {
  18320. for _, i := range insutypes {
  18321. if i.Insutype == "390" {
  18322. is390 = 1
  18323. }
  18324. if i.Insutype == "310" {
  18325. is310 = 1
  18326. }
  18327. }
  18328. }
  18329. if is390 == 1 {
  18330. insutype = "390"
  18331. }
  18332. if is310 == 1 {
  18333. insutype = "310"
  18334. }
  18335. fmt.Println(len(insutypes))
  18336. if len(insutypes) == 0 {
  18337. for index, item := range rf {
  18338. if index == 0 {
  18339. insutype = item.Insutype
  18340. insuplc_admdvs = item.InsuplcAdmdvs
  18341. }
  18342. }
  18343. fmt.Println(insutype)
  18344. fmt.Println(insuplc_admdvs)
  18345. }
  18346. if social_type > 0 {
  18347. insutype = strconv.FormatInt(social_type, 10)
  18348. }
  18349. fmt.Println("--------")
  18350. fmt.Println(psn_info)
  18351. fmt.Println(psn_info.PsnNo)
  18352. if miConfig.MdtrtareaAdmvs == "441202" {
  18353. var hisPrescription []*models.HisPrescription
  18354. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18355. if res3101.Infcode == 0 {
  18356. fmt.Println("33333333")
  18357. if len(res3101.Output.Result) > 0 {
  18358. fmt.Println("222222")
  18359. for _, item := range res3101.Output.Result {
  18360. if len(res3101.ErrMsg) == 0 {
  18361. res3101.ErrMsg = item.VolaCont
  18362. } else {
  18363. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18364. }
  18365. }
  18366. c.ServeSuccessJSON(map[string]interface{}{
  18367. "failed_code": -10,
  18368. "msg": res3101.ErrMsg,
  18369. })
  18370. return
  18371. } else {
  18372. hour := time.Now().Format("15")
  18373. min := time.Now().Format("04")
  18374. sec := time.Now().Format("05")
  18375. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18376. fmt.Println(record_time_two)
  18377. 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)
  18378. saveLog(result, requestLog, "2201A", "挂号")
  18379. if miConfig.Code == "H15049901371" {
  18380. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18381. utils.ErrorLog("解析失败:%v", err)
  18382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18383. return
  18384. }
  18385. resThree.ErrMsg = resThree10265.ErrMsg
  18386. resThree.Output = resThree10265.Output
  18387. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18388. } else {
  18389. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18390. utils.ErrorLog("解析失败:%v", err)
  18391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18392. return
  18393. }
  18394. }
  18395. if miConfig.Code == "H15049901371" {
  18396. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18397. } else {
  18398. infocode = resThree.Infcode
  18399. }
  18400. }
  18401. } else if res3101.Infcode != 0 {
  18402. c.ServeSuccessJSON(map[string]interface{}{
  18403. "failed_code": -10,
  18404. "msg": res3101.ErrMsg,
  18405. })
  18406. return
  18407. }
  18408. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18409. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18410. psn_info, _ := service.GetPsnByPatientId(id)
  18411. var verify_number string
  18412. if id_card_type == 4 {
  18413. verify_number = psn_info.VerifyNumber
  18414. } else if id_card_type == 1 {
  18415. bas := strings.Split(psn_info.CardInfo, "|")
  18416. cardNumber := bas[2]
  18417. verify_number = cardNumber
  18418. } else {
  18419. verify_number = psn_info.Certno
  18420. }
  18421. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18422. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18423. "&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
  18424. resp, requestErr := http.Get(api)
  18425. if requestErr != nil {
  18426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18427. return
  18428. }
  18429. body, ioErr := ioutil.ReadAll(resp.Body)
  18430. if ioErr != nil {
  18431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18433. return
  18434. }
  18435. var respJSON map[string]interface{}
  18436. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18439. return
  18440. }
  18441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18442. result, _ := json.Marshal(respJSON)
  18443. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18444. utils.ErrorLog("解析失败:%v", err)
  18445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18446. return
  18447. }
  18448. infocode = resThree.Infcode
  18449. } else {
  18450. hour := time.Now().Format("15")
  18451. min := time.Now().Format("04")
  18452. sec := time.Now().Format("05")
  18453. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18454. if id_card_type == 1 {
  18455. for _, item := range rf {
  18456. if item.Insutype == strconv.FormatInt(social_type, 10) {
  18457. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  18458. insuplc_admdvs_temp = item.InsuplcAdmdvs
  18459. } else if strconv.FormatInt(social_type, 10) == "390" {
  18460. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18461. } else {
  18462. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18463. }
  18464. }
  18465. }
  18466. }
  18467. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  18468. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18469. }
  18470. if id_card_type == 1 {
  18471. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  18472. bas := strings.Split(psn_info.CardInfo, "|")
  18473. basNumber := bas[1]
  18474. IdCardNo = basNumber
  18475. }
  18476. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  18477. IdCardNo = psn_info.VerifyNumber
  18478. }
  18479. 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)
  18480. saveLog(result, requestLog, "2201A", "挂号")
  18481. if miConfig.Code == "H15049901371" {
  18482. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18483. utils.ErrorLog("解析失败:%v", err)
  18484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18485. return
  18486. }
  18487. resThree.ErrMsg = resThree10265.ErrMsg
  18488. resThree.Output = resThree10265.Output
  18489. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18490. } else {
  18491. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18492. utils.ErrorLog("解析失败:%v", err)
  18493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18494. return
  18495. }
  18496. }
  18497. if miConfig.Code == "H15049901371" {
  18498. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18499. } else {
  18500. infocode = resThree.Infcode
  18501. }
  18502. }
  18503. }
  18504. if infocode != 0 {
  18505. adminUser := c.GetAdminUserInfo()
  18506. errlog := &models.HisOrderError{
  18507. UserOrgId: adminUser.CurrentOrgId,
  18508. Ctime: time.Now().Unix(),
  18509. Mtime: time.Now().Unix(),
  18510. ErrMsg: resThree.ErrMsg,
  18511. Status: 1,
  18512. PatientId: id,
  18513. RecordTime: recordDateTime,
  18514. Stage: 2,
  18515. }
  18516. service.CreateErrMsgLog(errlog)
  18517. c.ServeSuccessJSON(map[string]interface{}{
  18518. "failed_code": -10,
  18519. "msg": resThree.ErrMsg,
  18520. })
  18521. return
  18522. }
  18523. his.Number = resThree.Output.Data.MdtrtID
  18524. his.PsnNo = resThree.Output.Data.PsnNo
  18525. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  18526. his.IdCardNo = patient.IdCardNo
  18527. his.PhoneNumber = patient.Phone
  18528. his.UserOrgId = adminInfo.CurrentOrgId
  18529. his.Insutype = insutype
  18530. his.Ctime = time.Now().Unix()
  18531. his.Mtime = time.Now().Unix()
  18532. his.InsuplcAdmdvs = insuplc_admdvs_temp
  18533. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  18534. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18535. }
  18536. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  18537. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18538. }
  18539. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  18540. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18541. }
  18542. his.Status = 1
  18543. his.MdtrtGrpType = mdtrt_type
  18544. service.UpdateHisPatientStatus(&his)
  18545. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  18546. c.ServeSuccessJSON(map[string]interface{}{
  18547. "his_info": his,
  18548. })
  18549. } else {
  18550. adminUser := c.GetAdminUserInfo()
  18551. errlog := &models.HisOrderError{
  18552. UserOrgId: adminUser.CurrentOrgId,
  18553. Ctime: time.Now().Unix(),
  18554. Mtime: time.Now().Unix(),
  18555. ErrMsg: res.ErrMsg,
  18556. Status: 1,
  18557. PatientId: id,
  18558. RecordTime: recordDateTime,
  18559. Stage: 1,
  18560. }
  18561. service.CreateErrMsgLog(errlog)
  18562. c.ServeSuccessJSON(map[string]interface{}{
  18563. "failed_code": -10,
  18564. "msg": res.ErrMsg,
  18565. })
  18566. return
  18567. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  18568. }
  18569. }
  18570. }
  18571. func (c *HisApiController) GetUploadInfo() {
  18572. id, _ := c.GetInt64("id")
  18573. record_time := c.GetString("record_time")
  18574. his_patient_id, _ := c.GetInt64("his_patient_id")
  18575. order_id, _ := c.GetInt64("order_id")
  18576. pay_way, _ := c.GetInt64("pay_way")
  18577. pay_ways := c.GetString("pay_ways")
  18578. oth_desc := c.GetString("oth_desc")
  18579. pay_price, _ := c.GetFloat("pay_price")
  18580. pay_card_no := c.GetString("pay_card_no")
  18581. discount_price, _ := c.GetFloat("discount_price")
  18582. preferential_price, _ := c.GetFloat("preferential_price")
  18583. reality_price, _ := c.GetFloat("reality_price")
  18584. found_price, _ := c.GetFloat("found_price")
  18585. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  18586. private_price, _ := c.GetFloat("private_price")
  18587. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  18588. admin_user_id, _ := c.GetInt64("admin_user_id")
  18589. fapiao_code := c.GetString("fapiao_code")
  18590. fapiao_number := c.GetString("fapiao_number")
  18591. diagnosis_id := c.GetString("diagnosis")
  18592. sick_type, _ := c.GetInt64("sick_type")
  18593. reg_type, _ := c.GetInt64("p_type")
  18594. begin_time := c.GetString("begin_time")
  18595. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  18596. cash_pay := c.GetString("cash_pay")
  18597. band_card_pay := c.GetString("band_card_pay")
  18598. wechat_pay := c.GetString("wechat_pay")
  18599. ali_pay := c.GetString("ali_pay")
  18600. jifen_pay := c.GetString("jifen_pay")
  18601. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  18602. fmt.Println(acct_used_flag)
  18603. id_str := c.GetString("ids")
  18604. ids_arr := strings.Split(id_str, ",")
  18605. timeLayout := "2006-01-02"
  18606. loc, _ := time.LoadLocation("Local")
  18607. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  18608. if err != nil {
  18609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18610. return
  18611. }
  18612. recordDateTime := theTime.Unix()
  18613. adminUser := c.GetAdminUserInfo()
  18614. var tempOrder models.HisOrder
  18615. tempOrder, _ = service.GetHisOrderByID(order_id)
  18616. var prescriptions []*models.HisPrescription
  18617. var start_time int64
  18618. var end_time int64
  18619. //押金模块
  18620. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  18621. tmp_decimal := c.GetString("tmp_decimal")
  18622. var decimal float64 //本次使用的押金
  18623. var errmsg error
  18624. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  18625. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  18626. return
  18627. }
  18628. if len(tmp_decimal) > 0 {
  18629. if tmp_decimal[0] == 45 {
  18630. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  18631. return
  18632. }
  18633. }
  18634. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  18635. fmt.Println(errs)
  18636. decimal = tt
  18637. //if adminUser.CurrentOrgId == 10106{
  18638. // if len(fapiao_code) == 0{
  18639. // fapiao_code = "144072080589"
  18640. // }
  18641. // if len(fapiao_number) == 0{
  18642. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  18643. // if order.ID == 0{
  18644. // fapiao_number = "00001520"
  18645. // }else{
  18646. // //fapiao_code = "00001520"
  18647. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  18648. // var zero string
  18649. // if fpNumber >= 1000{
  18650. // zero = "0000" + strconv.Itoa(fpNumber)
  18651. // }else if fpNumber >= 10000{
  18652. // zero = "000" + strconv.Itoa(fpNumber)
  18653. // } else if fpNumber >= 100000{
  18654. // zero = "00" + strconv.Itoa(fpNumber)
  18655. // } else if fpNumber >= 1000000{
  18656. // zero = "0" + strconv.Itoa(fpNumber)
  18657. // }else {
  18658. // zero = strconv.Itoa(fpNumber)
  18659. // }
  18660. // fapiao_number = zero
  18661. // }
  18662. // }
  18663. //}
  18664. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18665. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18666. var patientPrescription models.HisPrescriptionInfo
  18667. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18668. if patientPrescription.ID == 0 {
  18669. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  18670. }
  18671. //if patientPrescription.Do
  18672. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18673. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  18674. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  18675. diagnosis_ids := strings.Split(diagnosis_id, ",")
  18676. var config []*models.HisXtDiagnoseConfig
  18677. for _, item := range diagnosis_ids {
  18678. id, _ := strconv.ParseInt(item, 10, 64)
  18679. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18680. config = append(config, &diagnosisConfig)
  18681. }
  18682. sickConfig, _ := service.FindSickById(sick_type)
  18683. //if tempOrder.ID == 0 {
  18684. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  18685. //}
  18686. if tempOrder.ID == 0 {
  18687. var result string
  18688. var requestLog string
  18689. var res2 ResultSix
  18690. var res3 GZResultSix
  18691. var ressix10265 ResultSix10265
  18692. if miConfig.MdtrtareaAdmvs == "421300" {
  18693. data := make(map[string]interface{})
  18694. client := &http.Client{}
  18695. data["psn_no"] = his.PsnNo
  18696. data["mdtrt_id"] = his.Number
  18697. data["opter"] = roles.UserName
  18698. data["org_name"] = miConfig.OrgName
  18699. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18700. data["doctor_id"] = doctor_info.DoctorNumber
  18701. data["doctor_name"] = doctor_info.UserName
  18702. data["department"] = department.Name
  18703. data["fixmedins_code"] = miConfig.Code
  18704. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18705. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18706. data["secret_key"] = miConfig.SecretKey
  18707. data["sick_code"] = sickConfig.CountryCode
  18708. data["sick_name"] = sickConfig.ClassName
  18709. data["dept"] = strconv.FormatInt(department.ID, 10)
  18710. data["config"] = config
  18711. data["begin_time"] = begin_time
  18712. bytesData, _ := json.Marshal(data)
  18713. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18714. resp, _ := client.Do(req)
  18715. defer resp.Body.Close()
  18716. body, ioErr := ioutil.ReadAll(resp.Body)
  18717. if ioErr != nil {
  18718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18720. return
  18721. }
  18722. var respJSON map[string]interface{}
  18723. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18726. return
  18727. }
  18728. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18729. userJSONBytes, _ := json.Marshal(respJSON)
  18730. fmt.Println("log")
  18731. fmt.Println(string(userJSONBytes))
  18732. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18733. utils.ErrorLog("解析失败:%v", err)
  18734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18735. return
  18736. }
  18737. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18738. data := make(map[string]interface{})
  18739. client := &http.Client{}
  18740. data["psn_no"] = his.PsnNo
  18741. data["mdtrt_id"] = his.Number
  18742. data["opter"] = roles.UserName
  18743. data["org_name"] = miConfig.OrgName
  18744. if reg_type == 11 && his.Insutype == "390" {
  18745. data["med_type"] = "110104"
  18746. } else {
  18747. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18748. }
  18749. data["doctor_id"] = doctor_info.DoctorNumber
  18750. data["doctor_name"] = doctor_info.UserName
  18751. data["department"] = department.Name
  18752. data["fixmedins_code"] = miConfig.Code
  18753. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18754. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18755. data["secret_key"] = miConfig.SecretKey
  18756. data["sick_code"] = sickConfig.CountryCode
  18757. data["sick_name"] = sickConfig.ClassName
  18758. data["dept"] = strconv.FormatInt(department.ID, 10)
  18759. data["config"] = config
  18760. data["begin_time"] = begin_time
  18761. bytesData, _ := json.Marshal(data)
  18762. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18763. resp, _ := client.Do(req)
  18764. defer resp.Body.Close()
  18765. body, ioErr := ioutil.ReadAll(resp.Body)
  18766. if ioErr != nil {
  18767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18769. return
  18770. }
  18771. var respJSON map[string]interface{}
  18772. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18775. return
  18776. }
  18777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18778. userJSONBytes, _ := json.Marshal(respJSON)
  18779. fmt.Println("log")
  18780. fmt.Println(string(userJSONBytes))
  18781. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18782. utils.ErrorLog("解析失败:%v", err)
  18783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18784. return
  18785. }
  18786. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18787. data := make(map[string]interface{})
  18788. client := &http.Client{}
  18789. data["psn_no"] = his.PsnNo
  18790. data["mdtrt_id"] = his.Number
  18791. data["opter"] = roles.UserName
  18792. data["org_name"] = miConfig.OrgName
  18793. if reg_type == 11 && his.Insutype == "390" {
  18794. data["med_type"] = "110104"
  18795. } else {
  18796. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18797. }
  18798. data["doctor_id"] = doctor_info.DoctorNumber
  18799. data["doctor_name"] = doctor_info.UserName
  18800. data["department"] = department.Name
  18801. data["fixmedins_code"] = miConfig.Code
  18802. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18803. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18804. data["secret_key"] = miConfig.SecretKey
  18805. data["sick_code"] = sickConfig.CountryCode
  18806. data["sick_name"] = sickConfig.ClassName
  18807. data["dept"] = strconv.FormatInt(department.ID, 10)
  18808. data["config"] = config
  18809. data["begin_time"] = begin_time
  18810. bytesData, _ := json.Marshal(data)
  18811. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18812. resp, _ := client.Do(req)
  18813. defer resp.Body.Close()
  18814. body, ioErr := ioutil.ReadAll(resp.Body)
  18815. if ioErr != nil {
  18816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18818. return
  18819. }
  18820. var respJSON map[string]interface{}
  18821. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18824. return
  18825. }
  18826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18827. userJSONBytes, _ := json.Marshal(respJSON)
  18828. fmt.Println("log")
  18829. fmt.Println(string(userJSONBytes))
  18830. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18831. utils.ErrorLog("解析失败:%v", err)
  18832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18833. return
  18834. }
  18835. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18836. data := make(map[string]interface{})
  18837. client := &http.Client{}
  18838. data["psn_no"] = his.PsnNo
  18839. data["mdtrt_id"] = his.Number
  18840. data["opter"] = roles.UserName
  18841. data["org_name"] = miConfig.OrgName
  18842. if reg_type == 11 && his.Insutype == "390" {
  18843. data["med_type"] = "110104"
  18844. } else {
  18845. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18846. }
  18847. data["doctor_id"] = doctor_info.DoctorNumber
  18848. data["doctor_name"] = doctor_info.UserName
  18849. data["department"] = department.Name
  18850. data["fixmedins_code"] = miConfig.Code
  18851. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18852. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18853. data["secret_key"] = miConfig.SecretKey
  18854. data["sick_code"] = sickConfig.CountryCode
  18855. data["sick_name"] = sickConfig.ClassName
  18856. data["dept"] = strconv.FormatInt(department.ID, 10)
  18857. data["config"] = config
  18858. data["begin_time"] = begin_time
  18859. bytesData, _ := json.Marshal(data)
  18860. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18861. resp, _ := client.Do(req)
  18862. defer resp.Body.Close()
  18863. body, ioErr := ioutil.ReadAll(resp.Body)
  18864. if ioErr != nil {
  18865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18867. return
  18868. }
  18869. var respJSON map[string]interface{}
  18870. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18873. return
  18874. }
  18875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18876. userJSONBytes, _ := json.Marshal(respJSON)
  18877. fmt.Println("log")
  18878. fmt.Println(string(userJSONBytes))
  18879. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18880. utils.ErrorLog("解析失败:%v", err)
  18881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18882. return
  18883. }
  18884. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18885. data := make(map[string]interface{})
  18886. client := &http.Client{}
  18887. data["psn_no"] = his.PsnNo
  18888. data["mdtrt_id"] = his.Number
  18889. data["doctor"] = roles.UserName
  18890. data["department"] = department.Name
  18891. data["org_name"] = miConfig.OrgName
  18892. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18893. data["doctor_id"] = doctor_info.DoctorNumber
  18894. data["new_doctor_name"] = doctor_info.UserName
  18895. data["fixmedins_code"] = miConfig.Code
  18896. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18897. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18898. data["secret_key"] = miConfig.SecretKey
  18899. data["sick_code"] = sickConfig.CountryCode
  18900. data["sick_name"] = sickConfig.ClassName
  18901. data["url"] = miConfig.Url
  18902. data["ak"] = miConfig.AccessKey
  18903. data["begin_time"] = begin_time
  18904. data["cainfo"] = miConfig.Cainfo
  18905. data["dept"] = strconv.FormatInt(department.ID, 10)
  18906. data["config"] = config
  18907. bytesData, _ := json.Marshal(data)
  18908. var req *http.Request
  18909. if miConfig.MdtrtareaAdmvs == "320921" {
  18910. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18911. //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 +
  18912. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18913. } else {
  18914. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18915. }
  18916. resp, _ := client.Do(req)
  18917. defer resp.Body.Close()
  18918. body, ioErr := ioutil.ReadAll(resp.Body)
  18919. if ioErr != nil {
  18920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18922. return
  18923. }
  18924. var respJSON map[string]interface{}
  18925. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18928. return
  18929. }
  18930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18931. userJSONBytes, _ := json.Marshal(respJSON)
  18932. fmt.Println("log")
  18933. fmt.Println(string(userJSONBytes))
  18934. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18935. utils.ErrorLog("解析失败:%v", err)
  18936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18937. return
  18938. }
  18939. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18940. res2.Output = ressix10265.Output
  18941. res2.ErrMsg = ressix10265.ErrMsg
  18942. res2.Cainfo = ressix10265.Cainfo
  18943. res2.WarnMsg = ressix10265.WarnMsg
  18944. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18945. res2.Infcode = infocode
  18946. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18947. data := make(map[string]interface{})
  18948. client := &http.Client{}
  18949. data["psn_no"] = his.PsnNo
  18950. data["mdtrt_id"] = his.Number
  18951. data["doctor"] = roles.UserName
  18952. data["department"] = department.Name
  18953. data["org_name"] = miConfig.OrgName
  18954. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18955. data["doctor_id"] = doctor_info.DoctorNumber
  18956. data["new_doctor_name"] = doctor_info.UserName
  18957. data["fixmedins_code"] = miConfig.Code
  18958. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18959. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18960. data["secret_key"] = miConfig.SecretKey
  18961. data["sick_code"] = sickConfig.CountryCode
  18962. data["sick_name"] = sickConfig.ClassName
  18963. data["url"] = miConfig.Url
  18964. data["ak"] = miConfig.AccessKey
  18965. data["begin_time"] = begin_time
  18966. data["cainfo"] = miConfig.Cainfo
  18967. data["dept"] = strconv.FormatInt(department.ID, 10)
  18968. data["config"] = config
  18969. bytesData, _ := json.Marshal(data)
  18970. var req *http.Request
  18971. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18972. resp, _ := client.Do(req)
  18973. defer resp.Body.Close()
  18974. body, ioErr := ioutil.ReadAll(resp.Body)
  18975. if ioErr != nil {
  18976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18978. return
  18979. }
  18980. var respJSON map[string]interface{}
  18981. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18984. return
  18985. }
  18986. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18987. userJSONBytes, _ := json.Marshal(respJSON)
  18988. fmt.Println("log")
  18989. fmt.Println(string(userJSONBytes))
  18990. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18991. utils.ErrorLog("解析失败:%v", err)
  18992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18993. return
  18994. }
  18995. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18996. res2.Output = ressix10265.Output
  18997. res2.ErrMsg = ressix10265.ErrMsg
  18998. res2.Cainfo = ressix10265.Cainfo
  18999. res2.WarnMsg = ressix10265.WarnMsg
  19000. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  19001. res2.Infcode = infocode
  19002. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19003. 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)
  19004. saveLog(result, requestLog, "2203", "上传就诊信息")
  19005. var respJSON2 map[string]interface{}
  19006. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  19007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19009. return
  19010. }
  19011. userJSONBytes2, _ := json.Marshal(respJSON2)
  19012. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  19013. utils.ErrorLog("解析失败:%v", err)
  19014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19015. return
  19016. }
  19017. 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)
  19018. fmt.Println(result2)
  19019. fmt.Println(src_request)
  19020. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19021. data := make(map[string]interface{})
  19022. client := &http.Client{}
  19023. data["psn_no"] = his.PsnNo
  19024. data["mdtrt_id"] = his.Number
  19025. data["doctor"] = roles.UserName
  19026. data["department"] = department.Name
  19027. data["org_name"] = miConfig.OrgName
  19028. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19029. data["doctor_id"] = doctor_info.DoctorNumber
  19030. data["new_doctor_name"] = doctor_info.UserName
  19031. data["fixmedins_code"] = miConfig.Code
  19032. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19033. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19034. data["secret_key"] = miConfig.SecretKey
  19035. data["sick_code"] = sickConfig.CountryCode
  19036. data["sick_name"] = sickConfig.ClassName
  19037. data["url"] = miConfig.Url
  19038. data["ak"] = miConfig.AccessKey
  19039. data["begin_time"] = begin_time
  19040. data["cainfo"] = miConfig.Cainfo
  19041. data["dept"] = strconv.FormatInt(department.ID, 10)
  19042. data["config"] = config
  19043. bytesData, _ := json.Marshal(data)
  19044. var req *http.Request
  19045. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  19046. resp, _ := client.Do(req)
  19047. defer resp.Body.Close()
  19048. body, ioErr := ioutil.ReadAll(resp.Body)
  19049. if ioErr != nil {
  19050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19052. return
  19053. }
  19054. var respJSON map[string]interface{}
  19055. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19058. return
  19059. }
  19060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19061. userJSONBytes, _ := json.Marshal(respJSON)
  19062. fmt.Println("log")
  19063. fmt.Println(string(userJSONBytes))
  19064. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19065. utils.ErrorLog("解析失败:%v", err)
  19066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19067. return
  19068. }
  19069. } else {
  19070. if miConfig.MdtrtareaAdmvs == "440781" { //
  19071. 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)
  19072. } else {
  19073. if miConfig.Code == "H15049901371" {
  19074. //赤峰地区国家医保医疗类别
  19075. //职工透析:医疗类别选特殊情况门诊990502
  19076. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19077. var med_type string
  19078. if his.Insutype == "390" {
  19079. if reg_type == 14 {
  19080. med_type = "9933"
  19081. } else if reg_type == 11 {
  19082. med_type = "11"
  19083. }
  19084. } else if his.Insutype == "310" {
  19085. if reg_type == 14 {
  19086. med_type = "990502"
  19087. } else if reg_type == 11 {
  19088. med_type = "11"
  19089. }
  19090. }
  19091. 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)
  19092. } else {
  19093. 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)
  19094. }
  19095. }
  19096. saveLog(result, requestLog, "2203", "上传就诊信息")
  19097. var respJSON2 map[string]interface{}
  19098. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  19099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19101. return
  19102. }
  19103. userJSONBytes2, _ := json.Marshal(respJSON2)
  19104. if miConfig.Code == "H15049901371" {
  19105. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  19106. utils.ErrorLog("解析失败:%v", err)
  19107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19108. return
  19109. }
  19110. res2.InfRefmsgid = ressix10265.InfRefmsgid
  19111. res2.Output = ressix10265.Output
  19112. res2.ErrMsg = ressix10265.ErrMsg
  19113. res2.Cainfo = ressix10265.Cainfo
  19114. res2.WarnMsg = ressix10265.WarnMsg
  19115. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  19116. res2.Infcode = infocode
  19117. } else {
  19118. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19119. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  19120. utils.ErrorLog("解析失败:%v", err)
  19121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19122. return
  19123. }
  19124. res2.Infcode = res3.Infcode
  19125. } else {
  19126. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  19127. utils.ErrorLog("解析失败:%v", err)
  19128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19129. return
  19130. }
  19131. }
  19132. }
  19133. }
  19134. if res2.Infcode != 0 {
  19135. adminUser := c.GetAdminUserInfo()
  19136. errlog := &models.HisOrderError{
  19137. UserOrgId: adminUser.CurrentOrgId,
  19138. Ctime: time.Now().Unix(),
  19139. Mtime: time.Now().Unix(),
  19140. ErrMsg: res2.ErrMsg,
  19141. Status: 1,
  19142. PatientId: id,
  19143. RecordTime: recordDateTime,
  19144. Stage: 3,
  19145. }
  19146. service.CreateErrMsgLog(errlog)
  19147. c.ServeSuccessJSON(map[string]interface{}{
  19148. "failed_code": -10,
  19149. "msg": res2.ErrMsg,
  19150. })
  19151. return
  19152. } else {
  19153. his.Diagnosis = diagnosis_id
  19154. his.SickType = sickConfig.ID
  19155. //var p_type int64
  19156. //if reg_type == 1111 || reg_type == 1112 {
  19157. // p_type = 11
  19158. //
  19159. //}
  19160. his.PType = fmt.Sprintf("%d", reg_type)
  19161. service.UpdateHisPatientThree(&his)
  19162. data := make(map[string]interface{})
  19163. if settle_accounts_type == 1 { //日结
  19164. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  19165. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  19166. } else {
  19167. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  19168. }
  19169. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  19170. data["pre"] = prescriptions
  19171. } else { //月结
  19172. start_time_str := c.GetString("start_time")
  19173. end_time_str := c.GetString("end_time")
  19174. timeLayout := "2006-01-02"
  19175. loc, _ := time.LoadLocation("Local")
  19176. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  19177. if err != nil {
  19178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19179. return
  19180. }
  19181. recordStartTime := theStartTime.Unix()
  19182. start_time = recordStartTime
  19183. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  19184. if err != nil {
  19185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19186. return
  19187. }
  19188. recordEndTime := theEndTime.Unix()
  19189. end_time = recordEndTime
  19190. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  19191. data["pre"] = prescriptions
  19192. }
  19193. timestamp := time.Now().Unix()
  19194. tempTime := time.Unix(timestamp, 0)
  19195. timeFormat := tempTime.Format("20060102150405")
  19196. chrgBchno := rand.Intn(100000) + 10000
  19197. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  19198. strconv.FormatInt(his.PatientId, 10)
  19199. client := &http.Client{}
  19200. data["psn_no"] = his.PsnNo
  19201. data["mdtrt_id"] = his.Number
  19202. data["chrg_bchno"] = chrg_bchno
  19203. data["org_name"] = miConfig.OrgName
  19204. data["doctor"] = doctor_info.UserName
  19205. data["doctor_id"] = doctor_info.DoctorNumber
  19206. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  19207. data["fixmedins_code"] = miConfig.Code
  19208. data["dept_code"] = department.Number
  19209. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19210. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19211. data["secret_key"] = miConfig.SecretKey
  19212. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  19213. data["url"] = miConfig.Url
  19214. data["ak"] = miConfig.AccessKey
  19215. data["new_doctor_name"] = patientPrescription.Doctor
  19216. data["diag_code"] = sickConfig.CountryCode
  19217. data["cainfo"] = miConfig.Cainfo
  19218. data["opter"] = roles.UserName
  19219. var ids []int64
  19220. for _, item := range prescriptions {
  19221. ids = append(ids, item.ID)
  19222. }
  19223. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19224. if config.IsOpen == 1 { //对接了医保,走医保流程
  19225. var res ResultFour
  19226. var resFour10265 ResultFour10265
  19227. if miConfig.MdtrtareaAdmvs == "421300" {
  19228. bytesData, _ := json.Marshal(data)
  19229. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19230. resp, _ := client.Do(req)
  19231. defer resp.Body.Close()
  19232. body, ioErr := ioutil.ReadAll(resp.Body)
  19233. if ioErr != nil {
  19234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19236. return
  19237. }
  19238. var respJSON map[string]interface{}
  19239. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19242. return
  19243. }
  19244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19245. userJSONBytes, _ := json.Marshal(respJSON)
  19246. fmt.Println("log")
  19247. fmt.Println(string(userJSONBytes))
  19248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19249. utils.ErrorLog("解析失败:%v", err)
  19250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19251. return
  19252. }
  19253. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19254. bytesData, _ := json.Marshal(data)
  19255. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19256. resp, _ := client.Do(req)
  19257. defer resp.Body.Close()
  19258. body, ioErr := ioutil.ReadAll(resp.Body)
  19259. if ioErr != nil {
  19260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19262. return
  19263. }
  19264. var respJSON map[string]interface{}
  19265. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19268. return
  19269. }
  19270. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19271. userJSONBytes, _ := json.Marshal(respJSON)
  19272. fmt.Println("log")
  19273. fmt.Println(string(userJSONBytes))
  19274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19275. utils.ErrorLog("解析失败:%v", err)
  19276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19277. return
  19278. }
  19279. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19280. bytesData, _ := json.Marshal(data)
  19281. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19282. resp, _ := client.Do(req)
  19283. defer resp.Body.Close()
  19284. body, ioErr := ioutil.ReadAll(resp.Body)
  19285. if ioErr != nil {
  19286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19288. return
  19289. }
  19290. var respJSON map[string]interface{}
  19291. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19294. return
  19295. }
  19296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19297. userJSONBytes, _ := json.Marshal(respJSON)
  19298. fmt.Println("log")
  19299. fmt.Println(string(userJSONBytes))
  19300. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19301. utils.ErrorLog("解析失败:%v", err)
  19302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19303. return
  19304. }
  19305. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19306. bytesData, _ := json.Marshal(data)
  19307. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19308. resp, _ := client.Do(req)
  19309. defer resp.Body.Close()
  19310. body, ioErr := ioutil.ReadAll(resp.Body)
  19311. if ioErr != nil {
  19312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19314. return
  19315. }
  19316. var respJSON map[string]interface{}
  19317. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19320. return
  19321. }
  19322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19323. userJSONBytes, _ := json.Marshal(respJSON)
  19324. fmt.Println("log")
  19325. fmt.Println(string(userJSONBytes))
  19326. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19327. utils.ErrorLog("解析失败:%v", err)
  19328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19329. return
  19330. }
  19331. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19332. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  19333. if result3101.Infcode == "0" {
  19334. if len(result3101.Output.Result) > 0 {
  19335. var errMsgs []string
  19336. for _, item := range result3101.Output.Result {
  19337. errMsgs = append(errMsgs, item.VolaCont)
  19338. }
  19339. c.ServeSuccessJSON(map[string]interface{}{
  19340. "failed_code": -10,
  19341. "msg": errMsgs,
  19342. })
  19343. return
  19344. }
  19345. }
  19346. bytesData, _ := json.Marshal(data)
  19347. var req *http.Request
  19348. if miConfig.MdtrtareaAdmvs == "320921" {
  19349. data["diag_code"] = sickConfig.CountryCode
  19350. fmt.Println(data)
  19351. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19352. } else {
  19353. data["diag_code"] = sickConfig.CountryCode
  19354. fmt.Println(data)
  19355. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19356. }
  19357. resp, _ := client.Do(req)
  19358. defer resp.Body.Close()
  19359. body, ioErr := ioutil.ReadAll(resp.Body)
  19360. if ioErr != nil {
  19361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19363. return
  19364. }
  19365. var respJSON map[string]interface{}
  19366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19369. return
  19370. }
  19371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19372. userJSONBytes, _ := json.Marshal(respJSON)
  19373. fmt.Println("log")
  19374. fmt.Println(string(userJSONBytes))
  19375. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19376. utils.ErrorLog("解析失败:%v", err)
  19377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19378. return
  19379. }
  19380. res.InfRefmsgid = resFour10265.InfRefmsgid
  19381. res.Output = resFour10265.Output
  19382. res.ErrMsg = resFour10265.ErrMsg
  19383. res.Cainfo = resFour10265.Cainfo
  19384. res.WarnMsg = resFour10265.WarnMsg
  19385. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19386. res.Infcode = infocode
  19387. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19388. var pagesize int = 2
  19389. var start int = 1
  19390. var stop int
  19391. var pagecount int
  19392. var curpage int
  19393. var isSuccess bool = true
  19394. data["doctor_id"] = doctor_info.DoctorNumber
  19395. //总页数,向上取整,注意除之前要先转换类型为float64
  19396. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  19397. for curpage = 1; curpage <= pagecount; curpage++ {
  19398. if curpage == 1 {
  19399. start = 1
  19400. } else {
  19401. start = (curpage-1)*pagesize + 1
  19402. }
  19403. stop = curpage * pagesize
  19404. if stop > len(prescriptions) {
  19405. stop = len(prescriptions)
  19406. }
  19407. //var requestLog string
  19408. data["pre"] = prescriptions[start-1 : stop]
  19409. fmt.Println(data["pre"])
  19410. bytesData, _ := json.Marshal(data)
  19411. var req *http.Request
  19412. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  19413. resp, _ := client.Do(req)
  19414. defer resp.Body.Close()
  19415. body, ioErr := ioutil.ReadAll(resp.Body)
  19416. if ioErr != nil {
  19417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19419. return
  19420. }
  19421. var respJSON map[string]interface{}
  19422. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19425. return
  19426. }
  19427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19428. userJSONBytes, _ := json.Marshal(respJSON)
  19429. fmt.Println("log")
  19430. fmt.Println(string(userJSONBytes))
  19431. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19432. utils.ErrorLog("解析失败:%v", err)
  19433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19434. return
  19435. }
  19436. res.InfRefmsgid = resFour10265.InfRefmsgid
  19437. res.Output = resFour10265.Output
  19438. res.ErrMsg = resFour10265.ErrMsg
  19439. res.Cainfo = resFour10265.Cainfo
  19440. res.WarnMsg = resFour10265.WarnMsg
  19441. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19442. res.Infcode = infocode
  19443. if infocode == 0 {
  19444. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  19445. } else {
  19446. isSuccess = false
  19447. errlog := &models.HisOrderError{
  19448. UserOrgId: adminUser.CurrentOrgId,
  19449. Ctime: time.Now().Unix(),
  19450. Mtime: time.Now().Unix(),
  19451. Number: chrg_bchno,
  19452. ErrMsg: "",
  19453. Status: 1,
  19454. PatientId: id,
  19455. RecordTime: recordDateTime,
  19456. Stage: 4,
  19457. }
  19458. service.CreateErrMsgLog(errlog)
  19459. c.ServeSuccessJSON(map[string]interface{}{
  19460. "failed_code": -10,
  19461. "msg": res.ErrMsg,
  19462. })
  19463. return
  19464. }
  19465. }
  19466. if isSuccess {
  19467. res.Infcode = 0
  19468. }
  19469. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19470. 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)
  19471. var dat map[string]interface{}
  19472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19473. fmt.Println(dat)
  19474. } else {
  19475. fmt.Println(err)
  19476. }
  19477. saveLog(result, request_log, "2204", "上传费用明细")
  19478. userJSONBytes, _ := json.Marshal(dat)
  19479. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19480. utils.ErrorLog("解析失败:%v", err)
  19481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19482. return
  19483. }
  19484. res.InfRefmsgid = resFour10265.InfRefmsgid
  19485. res.Output = resFour10265.Output
  19486. res.ErrMsg = resFour10265.ErrMsg
  19487. res.Cainfo = resFour10265.Cainfo
  19488. res.WarnMsg = resFour10265.WarnMsg
  19489. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19490. res.Infcode = infocode
  19491. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19492. bytesData, _ := json.Marshal(data)
  19493. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  19494. resp, _ := client.Do(req)
  19495. defer resp.Body.Close()
  19496. body, ioErr := ioutil.ReadAll(resp.Body)
  19497. if ioErr != nil {
  19498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19500. return
  19501. }
  19502. var respJSON map[string]interface{}
  19503. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19506. return
  19507. }
  19508. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19509. userJSONBytes, _ := json.Marshal(respJSON)
  19510. fmt.Println("log")
  19511. fmt.Println(string(userJSONBytes))
  19512. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19513. utils.ErrorLog("解析失败:%v", err)
  19514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19515. return
  19516. }
  19517. } else {
  19518. if miConfig.Code == "H15049901371" {
  19519. 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)
  19520. var dat map[string]interface{}
  19521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19522. fmt.Println(dat)
  19523. } else {
  19524. fmt.Println(err)
  19525. }
  19526. saveLog(result, request_log, "2204", "上传费用明细")
  19527. userJSONBytes, _ := json.Marshal(dat)
  19528. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19529. utils.ErrorLog("解析失败:%v", err)
  19530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19531. return
  19532. }
  19533. res.InfRefmsgid = resFour10265.InfRefmsgid
  19534. res.Output = resFour10265.Output
  19535. res.ErrMsg = resFour10265.ErrMsg
  19536. res.Cainfo = resFour10265.Cainfo
  19537. res.WarnMsg = resFour10265.WarnMsg
  19538. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19539. res.Infcode = infocode
  19540. } else {
  19541. 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)
  19542. var dat map[string]interface{}
  19543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19544. fmt.Println(dat)
  19545. } else {
  19546. fmt.Println(err)
  19547. }
  19548. saveLog(result, request_log, "2204", "上传费用明细")
  19549. userJSONBytes, _ := json.Marshal(dat)
  19550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19551. utils.ErrorLog("解析失败:%v", err)
  19552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19553. return
  19554. }
  19555. }
  19556. }
  19557. if res.Infcode == 0 {
  19558. order := &models.HisOrder{
  19559. UserOrgId: adminUser.CurrentOrgId,
  19560. HisPatientId: his.ID,
  19561. PatientId: his.PatientId,
  19562. SettleAccountsDate: recordDateTime,
  19563. MdtrtId: his.Number,
  19564. PsnNo: his.PsnNo,
  19565. MedType: strconv.FormatInt(reg_type, 10),
  19566. Ctime: time.Now().Unix(),
  19567. Mtime: time.Now().Unix(),
  19568. Status: 1,
  19569. Number: chrg_bchno,
  19570. Infcode: res.Infcode,
  19571. WarnMsg: res.WarnMsg,
  19572. Cainfo: res.Cainfo,
  19573. ErrMsg: res.ErrMsg,
  19574. RespondTime: res.RefmsgTime,
  19575. InfRefmsgid: res.InfRefmsgid,
  19576. OrderStatus: 1,
  19577. PayWay: pay_way,
  19578. PayWays: pay_ways,
  19579. OthDesc: oth_desc,
  19580. PayPrice: pay_price,
  19581. PayCardNo: pay_card_no,
  19582. DiscountPrice: discount_price,
  19583. PreferentialPrice: preferential_price,
  19584. RealityPrice: reality_price,
  19585. FoundPrice: found_price,
  19586. MedicalInsurancePrice: medical_insurance_price,
  19587. PrivatePrice: private_price,
  19588. IsMedicineInsurance: 1,
  19589. SettleType: settle_accounts_type,
  19590. SettleStartTime: start_time,
  19591. SettleEndTime: end_time,
  19592. Creator: roles.AdminUserId,
  19593. Modify: roles.AdminUserId,
  19594. FaPiaoNumber: fapiao_number,
  19595. FaPiaoCode: fapiao_code,
  19596. PType: 2,
  19597. Diagnosis: diagnosis_id,
  19598. CashPay: cash_pay,
  19599. WechatPay: wechat_pay,
  19600. AliPay: ali_pay,
  19601. JifenPay: jifen_pay,
  19602. BandCardPay: band_card_pay,
  19603. }
  19604. err = service.CreateOrder(order)
  19605. if err != nil {
  19606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  19607. return
  19608. }
  19609. for _, item := range res.Output.Result {
  19610. temp := strings.Split(item.FeedetlSn, "-")
  19611. var advice_id int64 = 0
  19612. var project_id int64 = 0
  19613. var types int64 = 0
  19614. id, _ := strconv.ParseInt(temp[2], 10, 64)
  19615. types, _ = strconv.ParseInt(temp[1], 10, 64)
  19616. if temp[1] == "1" {
  19617. advice_id = id
  19618. project_id = 0
  19619. } else if temp[1] == "2" {
  19620. advice_id = 0
  19621. project_id = id
  19622. }
  19623. if item.MedChrgitmType == "9" {
  19624. item.MedChrgitmType = "09"
  19625. }
  19626. info := &models.HisOrderInfo{
  19627. OrderNumber: order.Number,
  19628. FeedetlSn: item.FeedetlSn,
  19629. UploadDate: time.Now().Unix(),
  19630. AdviceId: advice_id,
  19631. DetItemFeeSumamt: item.DetItemFeeSumamt,
  19632. Cnt: item.Cnt,
  19633. Pric: float64(item.Pric),
  19634. PatientId: his.PatientId,
  19635. PricUplmtAmt: item.PricUplmtAmt,
  19636. SelfpayProp: item.SelfpayProp,
  19637. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  19638. OverlmtAmt: item.OverlmtAmt,
  19639. PreselfpayAmt: item.PreselfpayAmt,
  19640. BasMednFlag: item.BasMednFlag,
  19641. MedChrgitmType: item.MedChrgitmType,
  19642. HiNegoDrugFlag: item.HiNegoDrugFlag,
  19643. Status: 1,
  19644. Memo: item.Memo,
  19645. Mtime: time.Now().Unix(),
  19646. InscpScpAmt: item.InscpScpAmt,
  19647. DrtReimFlag: item.DrtReimFlag,
  19648. Ctime: time.Now().Unix(),
  19649. ListSpItemFlag: item.ListSpItemFlag,
  19650. ChldMedcFlag: item.ChldMedcFlag,
  19651. LmtUsedFlag: item.LmtUsedFlag,
  19652. ChrgitmLv: item.ChrgitmLv,
  19653. UserOrgId: adminUser.CurrentOrgId,
  19654. HisPatientId: his.ID,
  19655. OrderId: order.ID,
  19656. ProjectId: project_id,
  19657. Type: types,
  19658. }
  19659. service.CreateOrderInfo(info)
  19660. }
  19661. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  19662. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  19663. var total float64
  19664. for _, item := range prescriptions {
  19665. if item.Type == 1 { //药品
  19666. for _, subItem := range item.HisDoctorAdviceInfo {
  19667. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19668. total_one := price * subItem.PrescribingNumber
  19669. total = total + total_one
  19670. }
  19671. }
  19672. if item.Type == 2 { //项目
  19673. for _, subItem := range item.HisPrescriptionProject {
  19674. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  19675. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19676. total_one := price * cnt
  19677. total = total + total_one
  19678. }
  19679. }
  19680. }
  19681. allTotal := fmt.Sprintf("%.2f", total)
  19682. //if adminUser.CurrentOrgId == 9919 {
  19683. //
  19684. // allTotal = fmt.Sprintf("%.2f", total)
  19685. //
  19686. //} else {
  19687. //
  19688. // allTotal = fmt.Sprintf("%.2f", total)
  19689. //
  19690. //}
  19691. if res.Infcode == 0 {
  19692. var rf []*ResultFive
  19693. json.Unmarshal([]byte(his.Iinfo), &rf)
  19694. chrg_bchno := chrg_bchno
  19695. cert_no := his.Certno
  19696. var insutypes []string
  19697. var insutype string
  19698. var is390 int = 0
  19699. var is310 int = 0
  19700. for _, item := range rf {
  19701. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19702. insutypes = append(insutypes, item.Insutype)
  19703. }
  19704. }
  19705. if len(insutypes) == 1 {
  19706. insutype = insutypes[0]
  19707. } else {
  19708. for _, i := range insutypes {
  19709. if i == "390" {
  19710. is390 = 1
  19711. }
  19712. if i == "310" {
  19713. is310 = 1
  19714. }
  19715. }
  19716. }
  19717. if is390 == 1 {
  19718. insutype = "390"
  19719. }
  19720. if is310 == 1 {
  19721. insutype = "310"
  19722. }
  19723. if len(insutypes) == 0 {
  19724. insutype = "310"
  19725. }
  19726. if len(insutypes) == 2 {
  19727. insutype = strconv.FormatInt(his.SocialType, 10)
  19728. }
  19729. insutype = strconv.FormatInt(his.SocialType, 10)
  19730. //insutype = "390"
  19731. if his.IdCardType == 1 {
  19732. // cert_no = his.MedicalInsuranceNumber
  19733. cert_no = his.Certno
  19734. } else {
  19735. cert_no = his.Certno
  19736. }
  19737. var res ResultSeven
  19738. var resSeven10265 ResultSeven10265
  19739. var gzresSeven10265Two GZResultSeven10265Two
  19740. var src_resquest string
  19741. var result2 string
  19742. if miConfig.MdtrtareaAdmvs == "421300" {
  19743. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19744. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19745. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19746. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19747. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19748. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19749. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19750. resp, requestErr := http.Get(api)
  19751. if requestErr != nil {
  19752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19753. return
  19754. }
  19755. body, ioErr := ioutil.ReadAll(resp.Body)
  19756. if ioErr != nil {
  19757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19759. return
  19760. }
  19761. var respJSON map[string]interface{}
  19762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19765. return
  19766. }
  19767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19768. result, _ := json.Marshal(respJSON)
  19769. if miConfig.Code == "H15049901371" {
  19770. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19771. utils.ErrorLog("解析失败:%v", err)
  19772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19773. return
  19774. }
  19775. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19776. res.Output = resSeven10265.Output
  19777. res.ErrMsg = resSeven10265.ErrMsg
  19778. res.Cainfo = resSeven10265.Cainfo
  19779. res.WarnMsg = resSeven10265.WarnMsg
  19780. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19781. res.Infcode = infocode
  19782. } else {
  19783. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19784. utils.ErrorLog("解析失败:%v", err)
  19785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19786. return
  19787. }
  19788. }
  19789. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19790. if reg_type == 11 && his.Insutype == "390" {
  19791. reg_type = 110104
  19792. }
  19793. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19794. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19795. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19796. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19797. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19798. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19799. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19800. resp, requestErr := http.Get(api)
  19801. if requestErr != nil {
  19802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19803. return
  19804. }
  19805. body, ioErr := ioutil.ReadAll(resp.Body)
  19806. if ioErr != nil {
  19807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19809. return
  19810. }
  19811. var respJSON map[string]interface{}
  19812. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19815. return
  19816. }
  19817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19818. result, _ := json.Marshal(respJSON)
  19819. if miConfig.Code == "H15049901371" {
  19820. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19821. utils.ErrorLog("解析失败:%v", err)
  19822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19823. return
  19824. }
  19825. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19826. res.Output = resSeven10265.Output
  19827. res.ErrMsg = resSeven10265.ErrMsg
  19828. res.Cainfo = resSeven10265.Cainfo
  19829. res.WarnMsg = resSeven10265.WarnMsg
  19830. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19831. res.Infcode = infocode
  19832. } else {
  19833. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19834. utils.ErrorLog("解析失败:%v", err)
  19835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19836. return
  19837. }
  19838. }
  19839. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19840. if reg_type == 11 && his.Insutype == "390" {
  19841. reg_type = 110104
  19842. }
  19843. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19844. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19845. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19847. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19848. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19849. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19850. resp, requestErr := http.Get(api)
  19851. if requestErr != nil {
  19852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19853. return
  19854. }
  19855. body, ioErr := ioutil.ReadAll(resp.Body)
  19856. if ioErr != nil {
  19857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19859. return
  19860. }
  19861. var respJSON map[string]interface{}
  19862. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19865. return
  19866. }
  19867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19868. result, _ := json.Marshal(respJSON)
  19869. if miConfig.Code == "H15049901371" {
  19870. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19871. utils.ErrorLog("解析失败:%v", err)
  19872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19873. return
  19874. }
  19875. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19876. res.Output = resSeven10265.Output
  19877. res.ErrMsg = resSeven10265.ErrMsg
  19878. res.Cainfo = resSeven10265.Cainfo
  19879. res.WarnMsg = resSeven10265.WarnMsg
  19880. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19881. res.Infcode = infocode
  19882. } else {
  19883. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19884. utils.ErrorLog("解析失败:%v", err)
  19885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19886. return
  19887. }
  19888. }
  19889. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19890. if reg_type == 11 && his.Insutype == "390" {
  19891. reg_type = 110104
  19892. }
  19893. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19894. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19895. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19896. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19897. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19898. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19899. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19900. resp, requestErr := http.Get(api)
  19901. if requestErr != nil {
  19902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19903. return
  19904. }
  19905. body, ioErr := ioutil.ReadAll(resp.Body)
  19906. if ioErr != nil {
  19907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19909. return
  19910. }
  19911. var respJSON map[string]interface{}
  19912. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19915. return
  19916. }
  19917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19918. result, _ := json.Marshal(respJSON)
  19919. if miConfig.Code == "H15049901371" {
  19920. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19921. utils.ErrorLog("解析失败:%v", err)
  19922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19923. return
  19924. }
  19925. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19926. res.Output = resSeven10265.Output
  19927. res.ErrMsg = resSeven10265.ErrMsg
  19928. res.Cainfo = resSeven10265.Cainfo
  19929. res.WarnMsg = resSeven10265.WarnMsg
  19930. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19931. res.Infcode = infocode
  19932. } else {
  19933. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19934. utils.ErrorLog("解析失败:%v", err)
  19935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19936. return
  19937. }
  19938. }
  19939. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19940. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19941. if result3101.Infcode == "0" {
  19942. if len(result3101.Output.Result) > 0 {
  19943. var errMsgs []string
  19944. for _, item := range result3101.Output.Result {
  19945. errMsgs = append(errMsgs, item.VolaCont)
  19946. }
  19947. c.ServeSuccessJSON(map[string]interface{}{
  19948. "failed_code": -10,
  19949. "msg": errMsgs,
  19950. })
  19951. return
  19952. } else {
  19953. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19954. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19955. bas := strings.Split(psn_info.CardInfo, "|")
  19956. if his.IdCardType == 1 {
  19957. cert_no = bas[2]
  19958. } else if his.IdCardType == 3 {
  19959. cert_no = his.Certno
  19960. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19961. } else if his.IdCardType == 4 {
  19962. cert_no = his.Certno
  19963. psn_info.VerifyNumber = psn_info.VerifyNumber
  19964. }
  19965. var api string
  19966. if miConfig.MdtrtareaAdmvs == "320921" {
  19967. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19968. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19969. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19970. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19971. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19972. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19973. "&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
  19974. } else {
  19975. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19976. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19977. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19978. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19979. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19980. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19981. "&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
  19982. }
  19983. resp, requestErr := http.Get(api)
  19984. if requestErr != nil {
  19985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19986. return
  19987. }
  19988. body, ioErr := ioutil.ReadAll(resp.Body)
  19989. if ioErr != nil {
  19990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19992. return
  19993. }
  19994. var respJSON map[string]interface{}
  19995. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19998. return
  19999. }
  20000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20001. result, _ := json.Marshal(respJSON)
  20002. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20003. utils.ErrorLog("解析失败:%v", err)
  20004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20005. return
  20006. }
  20007. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20008. res.Output = resSeven10265.Output
  20009. res.ErrMsg = resSeven10265.ErrMsg
  20010. res.Cainfo = resSeven10265.Cainfo
  20011. res.WarnMsg = resSeven10265.WarnMsg
  20012. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20013. res.Infcode = infocode
  20014. }
  20015. }
  20016. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20017. psn_info, _ := service.GetPsnByPatientId(id)
  20018. var verify_number string
  20019. if psn_info.IdCardType == 4 {
  20020. verify_number = psn_info.VerifyNumber
  20021. } else if psn_info.IdCardType == 1 {
  20022. bas := strings.Split(psn_info.CardInfo, "|")
  20023. cardNumber := bas[2]
  20024. verify_number = cardNumber
  20025. } else {
  20026. psn_info.IdCardType = 2
  20027. verify_number = psn_info.Certno
  20028. }
  20029. var api string
  20030. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20031. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20032. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20033. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20034. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20035. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20036. "&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
  20037. resp, requestErr := http.Get(api)
  20038. if requestErr != nil {
  20039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20040. return
  20041. }
  20042. body, ioErr := ioutil.ReadAll(resp.Body)
  20043. if ioErr != nil {
  20044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20046. return
  20047. }
  20048. var respJSON map[string]interface{}
  20049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20052. return
  20053. }
  20054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20055. result, _ := json.Marshal(respJSON)
  20056. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20057. utils.ErrorLog("解析失败:%v", err)
  20058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20059. return
  20060. }
  20061. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20062. res.Output = resSeven10265.Output
  20063. res.ErrMsg = resSeven10265.ErrMsg
  20064. res.Cainfo = resSeven10265.Cainfo
  20065. res.WarnMsg = resSeven10265.WarnMsg
  20066. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20067. res.Infcode = infocode
  20068. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20069. var cert_no string
  20070. if his.IdCardType == 4 {
  20071. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20072. cert_no = psn_info.VerifyNumber
  20073. 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)
  20074. } else if his.IdCardType == 1 {
  20075. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20076. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20077. 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)
  20078. }
  20079. //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)
  20080. var dat map[string]interface{}
  20081. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20082. fmt.Println(dat)
  20083. } else {
  20084. fmt.Println(err)
  20085. }
  20086. saveLog(result2, src_resquest, "2207", "结算")
  20087. userJSONBytes, _ := json.Marshal(dat)
  20088. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20089. utils.ErrorLog("解析失败:%v", err)
  20090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20091. return
  20092. }
  20093. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20094. res.Output = resSeven10265.Output
  20095. res.ErrMsg = resSeven10265.ErrMsg
  20096. res.Cainfo = resSeven10265.Cainfo
  20097. res.WarnMsg = resSeven10265.WarnMsg
  20098. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20099. res.Infcode = infocode
  20100. } else if miConfig.MdtrtareaAdmvs == "450721" {
  20101. res2 := c.GetoleInfo()
  20102. if res2.Infcode == 0 {
  20103. var result string
  20104. var request_log string
  20105. var result_log string
  20106. if res2.Output.MdtrtCertType == "02" {
  20107. 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)
  20108. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20109. } else if res2.Output.MdtrtCertType == "01" {
  20110. 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)
  20111. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20112. } else {
  20113. 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)
  20114. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20115. }
  20116. var dat map[string]interface{}
  20117. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20118. fmt.Println(dat)
  20119. } else {
  20120. fmt.Println(err)
  20121. }
  20122. userJSONBytes, _ := json.Marshal(dat)
  20123. var res5 ResultTwo
  20124. //var resTwo10265 ResultTwo10265
  20125. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20126. utils.ErrorLog("解析失败:%v", err)
  20127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20128. return
  20129. }
  20130. if res5.Infcode == -1 {
  20131. c.ServeSuccessJSON(map[string]interface{}{
  20132. "failed_code": -10,
  20133. "msg": res5.ErrMsg,
  20134. })
  20135. return
  20136. }
  20137. var insutypes []string
  20138. var insutype string
  20139. var is390 int = 0
  20140. var is310 int = 0
  20141. for _, item := range res5.Output.Iinfo {
  20142. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20143. insutypes = append(insutypes, item.Insutype)
  20144. }
  20145. }
  20146. if len(insutypes) == 1 {
  20147. insutype = insutypes[0]
  20148. } else {
  20149. for _, i := range insutypes {
  20150. if i == "390" {
  20151. is390 = 1
  20152. }
  20153. if i == "310" {
  20154. is310 = 1
  20155. }
  20156. }
  20157. }
  20158. if is390 == 1 {
  20159. insutype = "390"
  20160. }
  20161. if is310 == 1 {
  20162. insutype = "310"
  20163. }
  20164. if len(insutypes) == 0 {
  20165. insutype = "310"
  20166. }
  20167. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20168. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20169. infoStr := string(Iinfos)
  20170. idetinfoStr := string(Idetinfos)
  20171. psn := &models.HisPsn{
  20172. PsnNo: res5.Output.Baseinfo.PsnNo,
  20173. PatientId: id,
  20174. Certno: res5.Output.Baseinfo.Certno,
  20175. Gend: res5.Output.Baseinfo.Gend,
  20176. Naty: res5.Output.Baseinfo.Naty,
  20177. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20178. PsnName: res5.Output.Baseinfo.PsnName,
  20179. Idetinfo: idetinfoStr,
  20180. Insuinfo: infoStr,
  20181. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20182. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20183. VerifyNumber: res2.Output.EcToken,
  20184. }
  20185. if res2.Output.MdtrtCertType == "01" {
  20186. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20187. psn.VerifyNumber = res2.Output.EcToken
  20188. } else if res2.Output.MdtrtCertType == "02" {
  20189. psn.VerifyNumber = res2.Output.CardNo
  20190. } else {
  20191. psn.VerifyNumber = res2.Output.MdtrtCertNo
  20192. }
  20193. service.CreateHisPsn(psn)
  20194. if res2.Output.MdtrtCertType == "01" {
  20195. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20196. token := res2.Output.EcToken
  20197. 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)
  20198. } else if res2.Output.MdtrtCertType == "02" {
  20199. 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)
  20200. } else {
  20201. 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)
  20202. }
  20203. var dat2 map[string]interface{}
  20204. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20205. fmt.Println(dat2)
  20206. } else {
  20207. fmt.Println(err)
  20208. }
  20209. userJSONBytes3, _ := json.Marshal(dat2)
  20210. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20211. utils.ErrorLog("解析失败:%v", err)
  20212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20213. return
  20214. }
  20215. saveLog(result2, src_resquest, "2207", "结算")
  20216. } else {
  20217. c.ServeSuccessJSON(map[string]interface{}{
  20218. "failed_code": -10,
  20219. "msg": res2.ErrMsg,
  20220. })
  20221. return
  20222. }
  20223. } else {
  20224. if miConfig.Code == "H15049901371" {
  20225. //赤峰地区国家医保医疗类别
  20226. //职工透析:医疗类别选特殊情况门诊990502
  20227. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20228. var med_type string
  20229. if his.Insutype == "390" {
  20230. if reg_type == 14 {
  20231. med_type = "9933"
  20232. } else if reg_type == 11 {
  20233. med_type = "11"
  20234. }
  20235. } else if his.Insutype == "310" {
  20236. if reg_type == 14 {
  20237. med_type = "990502"
  20238. } else if reg_type == 11 {
  20239. med_type = "11"
  20240. }
  20241. }
  20242. 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)
  20243. } else {
  20244. if his.IdCardType == 4 {
  20245. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20246. var token string
  20247. token = psn_info.VerifyNumber
  20248. 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)
  20249. } else {
  20250. if his.IdCardType == 1 {
  20251. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20252. bas := strings.Split(psn_info.CardInfo, "|")
  20253. basNumber := bas[2]
  20254. cert_no = basNumber
  20255. }
  20256. 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)
  20257. }
  20258. }
  20259. //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)
  20260. var dat map[string]interface{}
  20261. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20262. fmt.Println(dat)
  20263. } else {
  20264. fmt.Println(err)
  20265. }
  20266. saveLog(result2, src_resquest, "2207", "结算")
  20267. userJSONBytes, _ := json.Marshal(dat)
  20268. if miConfig.Code == "H15049901371" {
  20269. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20270. utils.ErrorLog("解析失败:%v", err)
  20271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20272. return
  20273. }
  20274. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20275. res.Output = resSeven10265.Output
  20276. res.ErrMsg = resSeven10265.ErrMsg
  20277. res.Cainfo = resSeven10265.Cainfo
  20278. res.WarnMsg = resSeven10265.WarnMsg
  20279. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20280. res.Infcode = infocode
  20281. } else {
  20282. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20283. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20284. utils.ErrorLog("解析失败:%v", err)
  20285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20286. return
  20287. }
  20288. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20289. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20290. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20291. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20292. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20293. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20294. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20295. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20296. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20297. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20298. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20299. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20300. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20301. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20302. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20303. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20304. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20305. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20306. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20307. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20308. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20309. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20310. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20311. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20312. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20313. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20314. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20315. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20316. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20317. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20318. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20319. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20320. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20321. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20322. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20323. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20324. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20325. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20326. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20327. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20328. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20329. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20330. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20331. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20332. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20333. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20334. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20335. res.Cainfo = gzresSeven10265Two.Cainfo
  20336. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20337. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20338. //res.Infcode = infocode
  20339. } else {
  20340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20341. utils.ErrorLog("解析失败:%v", err)
  20342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20343. return
  20344. }
  20345. }
  20346. }
  20347. }
  20348. if res.Infcode == -1 {
  20349. errlog := &models.HisOrderError{
  20350. UserOrgId: adminUser.CurrentOrgId,
  20351. Ctime: time.Now().Unix(),
  20352. Mtime: time.Now().Unix(),
  20353. Number: chrg_bchno,
  20354. ErrMsg: res.ErrMsg,
  20355. Status: 1,
  20356. PatientId: id,
  20357. RecordTime: recordDateTime,
  20358. Stage: 6,
  20359. }
  20360. service.CreateErrMsgLog(errlog)
  20361. c.ServeSuccessJSON(map[string]interface{}{
  20362. "failed_code": -10,
  20363. "msg": res.ErrMsg,
  20364. })
  20365. return
  20366. } else {
  20367. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20368. order.OrderStatus = 2
  20369. order.Status = 1
  20370. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20371. order.SetlId = res.Output.Setlinfo.SetlID
  20372. order.PsnNo = res.Output.Setlinfo.PsnNo
  20373. order.PsnName = res.Output.Setlinfo.PsnName
  20374. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20375. order.Certno = res.Output.Setlinfo.Certno
  20376. order.Gend = res.Output.Setlinfo.Gend
  20377. order.Naty = res.Output.Setlinfo.Naty
  20378. order.Age = res.Output.Setlinfo.Age
  20379. order.Insutype = res.Output.Setlinfo.Insutype
  20380. order.PsnType = res.Output.Setlinfo.PsnType
  20381. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20382. order.SetlTime = res.Output.Setlinfo.SetlTime
  20383. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20384. if res.Output.Setlinfo.MedType == "140101" {
  20385. order.MedType = "14"
  20386. } else {
  20387. if res.Output.Setlinfo.MedType == "110104" {
  20388. order.MedType = "11"
  20389. } else {
  20390. order.MedType = res.Output.Setlinfo.MedType
  20391. }
  20392. }
  20393. if reg_type == 1112 {
  20394. order.MedType = "1112"
  20395. }
  20396. if reg_type == 1111 {
  20397. order.MedType = "1111"
  20398. }
  20399. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20400. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20401. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20402. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20403. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20404. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20405. order.HifpPay = res.Output.Setlinfo.HifpPay
  20406. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20407. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20408. order.HifesPay = res.Output.Setlinfo.HifesPay
  20409. order.HifobPay = res.Output.Setlinfo.HifobPay
  20410. order.MafPay = res.Output.Setlinfo.MafPay
  20411. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20412. order.OthPay = res.Output.Setlinfo.OthPay
  20413. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20414. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20415. order.AcctPay = res.Output.Setlinfo.AcctPay
  20416. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20417. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20418. order.Balc = res.Output.Setlinfo.Balc
  20419. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20420. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20421. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20422. order.ClrType = res.Output.Setlinfo.ClrType
  20423. order.ClrWay = res.Output.Setlinfo.ClrWay
  20424. order.Creator = order.Creator
  20425. order.Modify = roles.AdminUserId
  20426. order.RequestLog = src_resquest
  20427. order.FaPiaoNumber = fapiao_number
  20428. order.FaPiaoCode = fapiao_code
  20429. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20430. //detailStr := string(setlDetail)
  20431. //order.SetlDetail = detailStr
  20432. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20433. err = service.UpDateOrder(order)
  20434. if err == nil {
  20435. //判断是否使用了押金
  20436. if dec_way == "true" {
  20437. tmpstring := strconv.FormatInt(order.ID, 10)
  20438. order.Decimal = decimal
  20439. service.UpDateOrder(order)
  20440. //扣押金
  20441. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20442. if errmsg != nil {
  20443. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20444. return
  20445. }
  20446. }
  20447. c.ServeSuccessJSON(map[string]interface{}{
  20448. "msg": "结算成功",
  20449. })
  20450. } else {
  20451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20452. return
  20453. }
  20454. }
  20455. } else {
  20456. adminUser := c.GetAdminUserInfo()
  20457. errlog := &models.HisOrderError{
  20458. UserOrgId: adminUser.CurrentOrgId,
  20459. Ctime: time.Now().Unix(),
  20460. Mtime: time.Now().Unix(),
  20461. ErrMsg: res.ErrMsg,
  20462. Status: 1,
  20463. PatientId: id,
  20464. RecordTime: recordDateTime,
  20465. Stage: 4,
  20466. }
  20467. service.CreateErrMsgLog(errlog)
  20468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  20469. return
  20470. }
  20471. } else {
  20472. adminUser := c.GetAdminUserInfo()
  20473. errlog := &models.HisOrderError{
  20474. UserOrgId: adminUser.CurrentOrgId,
  20475. Ctime: time.Now().Unix(),
  20476. Mtime: time.Now().Unix(),
  20477. ErrMsg: res.ErrMsg,
  20478. Status: 1,
  20479. PatientId: id,
  20480. RecordTime: recordDateTime,
  20481. Stage: 4,
  20482. }
  20483. service.CreateErrMsgLog(errlog)
  20484. c.ServeSuccessJSON(map[string]interface{}{
  20485. "failed_code": -10,
  20486. "msg": res.ErrMsg,
  20487. })
  20488. return
  20489. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  20490. //return
  20491. }
  20492. }
  20493. }
  20494. } else if tempOrder.ID > 0 {
  20495. if tempOrder.IsPre == 1 {
  20496. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  20497. var rf []*ResultFive
  20498. json.Unmarshal([]byte(his.Iinfo), &rf)
  20499. chrg_bchno := tempOrder.Number
  20500. cert_no := his.Certno
  20501. var insutypes []string
  20502. var insutype string
  20503. var is390 int = 0
  20504. var is310 int = 0
  20505. for _, item := range rf {
  20506. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20507. insutypes = append(insutypes, item.Insutype)
  20508. }
  20509. }
  20510. if len(insutypes) == 1 {
  20511. insutype = insutypes[0]
  20512. } else {
  20513. for _, i := range insutypes {
  20514. if i == "390" {
  20515. is390 = 1
  20516. }
  20517. if i == "310" {
  20518. is310 = 1
  20519. }
  20520. }
  20521. }
  20522. if is390 == 1 {
  20523. insutype = "390"
  20524. }
  20525. if is310 == 1 {
  20526. insutype = "310"
  20527. }
  20528. if len(insutypes) == 0 {
  20529. insutype = "310"
  20530. }
  20531. if len(insutypes) == 2 {
  20532. insutype = strconv.FormatInt(his.SocialType, 10)
  20533. }
  20534. //insutype = "390"
  20535. if his.IdCardType == 1 {
  20536. // cert_no = his.MedicalInsuranceNumber
  20537. cert_no = his.Certno
  20538. } else {
  20539. cert_no = his.Certno
  20540. }
  20541. var res ResultSeven
  20542. var ahres ResultSevenAH
  20543. var resSeven10265 ResultSeven10265
  20544. var gzresSeven10265Two GZResultSeven10265Two
  20545. var src_resquest string
  20546. var result2 string
  20547. if miConfig.MdtrtareaAdmvs == "450721" {
  20548. res2 := c.GetoleInfo()
  20549. if res2.Infcode == 0 {
  20550. var result string
  20551. var request_log string
  20552. var result_log string
  20553. if res2.Output.MdtrtCertType == "02" {
  20554. 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)
  20555. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20556. } else if res2.Output.MdtrtCertType == "01" {
  20557. 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)
  20558. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20559. } else {
  20560. 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)
  20561. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20562. }
  20563. var dat map[string]interface{}
  20564. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20565. fmt.Println(dat)
  20566. } else {
  20567. fmt.Println(err)
  20568. }
  20569. userJSONBytes, _ := json.Marshal(dat)
  20570. var res5 ResultTwo
  20571. //var resTwo10265 ResultTwo10265
  20572. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20573. utils.ErrorLog("解析失败:%v", err)
  20574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20575. return
  20576. }
  20577. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  20578. if res5.Infcode == -1 {
  20579. c.ServeSuccessJSON(map[string]interface{}{
  20580. "failed_code": -10,
  20581. "msg": res5.ErrMsg,
  20582. })
  20583. return
  20584. }
  20585. var insutypes []string
  20586. var insutype string
  20587. var is390 int = 0
  20588. var is310 int = 0
  20589. for _, item := range res5.Output.Iinfo {
  20590. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20591. insutypes = append(insutypes, item.Insutype)
  20592. }
  20593. }
  20594. if len(insutypes) == 1 {
  20595. insutype = insutypes[0]
  20596. } else {
  20597. for _, i := range insutypes {
  20598. if i == "390" {
  20599. is390 = 1
  20600. }
  20601. if i == "310" {
  20602. is310 = 1
  20603. }
  20604. }
  20605. }
  20606. if is390 == 1 {
  20607. insutype = "390"
  20608. }
  20609. if is310 == 1 {
  20610. insutype = "310"
  20611. }
  20612. if len(insutypes) == 0 {
  20613. insutype = "310"
  20614. }
  20615. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20616. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20617. infoStr := string(Iinfos)
  20618. idetinfoStr := string(Idetinfos)
  20619. psn := &models.HisPsn{
  20620. PsnNo: res5.Output.Baseinfo.PsnNo,
  20621. PatientId: id,
  20622. Certno: res5.Output.Baseinfo.Certno,
  20623. Gend: res5.Output.Baseinfo.Gend,
  20624. Naty: res5.Output.Baseinfo.Naty,
  20625. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20626. PsnName: res5.Output.Baseinfo.PsnName,
  20627. Idetinfo: idetinfoStr,
  20628. Insuinfo: infoStr,
  20629. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20630. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20631. VerifyNumber: res2.Output.EcToken,
  20632. }
  20633. service.CreateHisPsn(psn)
  20634. if res2.Output.MdtrtCertType == "01" {
  20635. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20636. token := res2.Output.EcToken
  20637. 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)
  20638. } else if res2.Output.MdtrtCertType == "02" {
  20639. 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)
  20640. } else {
  20641. 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)
  20642. }
  20643. var dat2 map[string]interface{}
  20644. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20645. fmt.Println(dat2)
  20646. } else {
  20647. fmt.Println(err)
  20648. }
  20649. userJSONBytes3, _ := json.Marshal(dat2)
  20650. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20651. utils.ErrorLog("解析失败:%v", err)
  20652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20653. return
  20654. }
  20655. saveLog(result2, src_resquest, "2207", "结算")
  20656. } else {
  20657. c.ServeSuccessJSON(map[string]interface{}{
  20658. "failed_code": -10,
  20659. "msg": res2.ErrMsg,
  20660. })
  20661. return
  20662. }
  20663. } else if miConfig.MdtrtareaAdmvs == "421300" {
  20664. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20665. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20666. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20667. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20668. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20669. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20670. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20671. resp, requestErr := http.Get(api)
  20672. if requestErr != nil {
  20673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20674. return
  20675. }
  20676. body, ioErr := ioutil.ReadAll(resp.Body)
  20677. if ioErr != nil {
  20678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20680. return
  20681. }
  20682. var respJSON map[string]interface{}
  20683. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20686. return
  20687. }
  20688. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20689. result, _ := json.Marshal(respJSON)
  20690. fmt.Println("log")
  20691. fmt.Println(string(result))
  20692. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20693. utils.ErrorLog("解析失败:%v", err)
  20694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20695. return
  20696. }
  20697. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20698. if reg_type == 11 && his.Insutype == "390" {
  20699. reg_type = 110104
  20700. }
  20701. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20702. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20703. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20704. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20705. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20706. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20707. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20708. resp, requestErr := http.Get(api)
  20709. if requestErr != nil {
  20710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20711. return
  20712. }
  20713. body, ioErr := ioutil.ReadAll(resp.Body)
  20714. if ioErr != nil {
  20715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20717. return
  20718. }
  20719. var respJSON map[string]interface{}
  20720. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20723. return
  20724. }
  20725. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20726. result, _ := json.Marshal(respJSON)
  20727. fmt.Println("log")
  20728. fmt.Println(string(result))
  20729. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20730. utils.ErrorLog("解析失败:%v", err)
  20731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20732. return
  20733. }
  20734. } else if miConfig.MdtrtareaAdmvs == "420902" {
  20735. if reg_type == 11 && his.Insutype == "390" {
  20736. reg_type = 110104
  20737. }
  20738. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20739. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20740. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20741. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20742. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20743. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20744. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20745. resp, requestErr := http.Get(api)
  20746. if requestErr != nil {
  20747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20748. return
  20749. }
  20750. body, ioErr := ioutil.ReadAll(resp.Body)
  20751. if ioErr != nil {
  20752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20754. return
  20755. }
  20756. var respJSON map[string]interface{}
  20757. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20760. return
  20761. }
  20762. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20763. result, _ := json.Marshal(respJSON)
  20764. fmt.Println("log")
  20765. fmt.Println(string(result))
  20766. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20767. utils.ErrorLog("解析失败:%v", err)
  20768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20769. return
  20770. }
  20771. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20772. if reg_type == 11 && his.Insutype == "390" {
  20773. reg_type = 110104
  20774. }
  20775. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20776. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20777. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20778. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20779. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20780. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20781. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20782. resp, requestErr := http.Get(api)
  20783. if requestErr != nil {
  20784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20785. return
  20786. }
  20787. body, ioErr := ioutil.ReadAll(resp.Body)
  20788. if ioErr != nil {
  20789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20791. return
  20792. }
  20793. var respJSON map[string]interface{}
  20794. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20797. return
  20798. }
  20799. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20800. result, _ := json.Marshal(respJSON)
  20801. fmt.Println("log")
  20802. fmt.Println(string(result))
  20803. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20804. utils.ErrorLog("解析失败:%v", err)
  20805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20806. return
  20807. }
  20808. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20809. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  20810. if result3101.Infcode == "0" {
  20811. if len(result3101.Output.Result) > 0 {
  20812. var errMsgs []string
  20813. for _, item := range result3101.Output.Result {
  20814. errMsgs = append(errMsgs, item.VolaCont)
  20815. }
  20816. c.ServeSuccessJSON(map[string]interface{}{
  20817. "failed_code": -10,
  20818. "msg": errMsgs,
  20819. })
  20820. return
  20821. } else {
  20822. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20823. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20824. bas := strings.Split(psn_info.CardInfo, "|")
  20825. if his.IdCardType == 1 {
  20826. cert_no = bas[2]
  20827. } else if his.IdCardType == 3 {
  20828. cert_no = his.Certno
  20829. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20830. } else if his.IdCardType == 4 {
  20831. cert_no = his.Certno
  20832. psn_info.VerifyNumber = psn_info.VerifyNumber
  20833. }
  20834. //江苏地区国家医保医疗类别
  20835. //职工透析:医疗类别选特殊情况门诊9933
  20836. //居民血透门慢: 医疗类别选门诊慢病1402
  20837. //var med_type string
  20838. //if his.Insutype == "310" {
  20839. // if reg_type == 14 {
  20840. // med_type = "9933"
  20841. // } else if reg_type == 11 {
  20842. // med_type = "11"
  20843. //
  20844. // }
  20845. //} else if his.Insutype == "390" {
  20846. // if reg_type == 14 {
  20847. // med_type = "1402"
  20848. // } else if reg_type == 11 {
  20849. // med_type = "11"
  20850. // }
  20851. //}
  20852. var api string
  20853. if miConfig.MdtrtareaAdmvs == "320921" {
  20854. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20855. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20856. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20857. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20858. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20859. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20860. "&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
  20861. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20862. } else {
  20863. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20864. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20865. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20866. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20867. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20868. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20869. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20870. "&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
  20871. }
  20872. resp, requestErr := http.Get(api)
  20873. if requestErr != nil {
  20874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20875. return
  20876. }
  20877. body, ioErr := ioutil.ReadAll(resp.Body)
  20878. if ioErr != nil {
  20879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20881. return
  20882. }
  20883. var respJSON map[string]interface{}
  20884. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20887. return
  20888. }
  20889. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20890. result, _ := json.Marshal(respJSON)
  20891. fmt.Println("log")
  20892. fmt.Println(string(result))
  20893. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20894. utils.ErrorLog("解析失败:%v", err)
  20895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20896. return
  20897. }
  20898. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20899. res.Output = resSeven10265.Output
  20900. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20901. res.ErrMsg = resSeven10265.ErrMsg
  20902. res.Cainfo = resSeven10265.Cainfo
  20903. res.WarnMsg = resSeven10265.WarnMsg
  20904. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20905. res.Infcode = infocode
  20906. }
  20907. }
  20908. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20909. psn_info, _ := service.GetPsnByPatientId(id)
  20910. var verify_number string
  20911. if psn_info.IdCardType == 4 {
  20912. verify_number = psn_info.VerifyNumber
  20913. } else if psn_info.IdCardType == 1 {
  20914. bas := strings.Split(psn_info.CardInfo, "|")
  20915. cardNumber := bas[2]
  20916. verify_number = cardNumber
  20917. } else {
  20918. verify_number = psn_info.Certno
  20919. psn_info.IdCardType = 2
  20920. }
  20921. var api string
  20922. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20923. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20924. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20925. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20926. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20927. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20928. "&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
  20929. resp, requestErr := http.Get(api)
  20930. if requestErr != nil {
  20931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20932. return
  20933. }
  20934. body, ioErr := ioutil.ReadAll(resp.Body)
  20935. if ioErr != nil {
  20936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20938. return
  20939. }
  20940. var respJSON map[string]interface{}
  20941. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20944. return
  20945. }
  20946. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20947. result, _ := json.Marshal(respJSON)
  20948. fmt.Println("log")
  20949. fmt.Println(string(result))
  20950. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20951. utils.ErrorLog("解析失败:%v", err)
  20952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20953. return
  20954. }
  20955. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20956. res.Output = resSeven10265.Output
  20957. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20958. res.ErrMsg = resSeven10265.ErrMsg
  20959. res.Cainfo = resSeven10265.Cainfo
  20960. res.WarnMsg = resSeven10265.WarnMsg
  20961. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20962. res.Infcode = infocode
  20963. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20964. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20965. var cert_no string
  20966. if his.IdCardType == 1 {
  20967. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20968. } else {
  20969. cert_no = psn_info.VerifyNumber
  20970. }
  20971. 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)
  20972. var dat map[string]interface{}
  20973. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20974. fmt.Println(dat)
  20975. } else {
  20976. fmt.Println(err)
  20977. }
  20978. saveLog(result2, src_resquest, "2207", "结算")
  20979. userJSONBytes, _ := json.Marshal(dat)
  20980. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20981. utils.ErrorLog("解析失败:%v", err)
  20982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20983. return
  20984. }
  20985. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20986. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20987. var cert_no string
  20988. var card_sn string
  20989. if his.IdCardType == 1 {
  20990. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20991. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20992. bas := strings.Split(psn_info.CardInfo, "|")
  20993. card_sn = bas[3]
  20994. } else if his.IdCardType == 2 {
  20995. cert_no = his.IdCardNo
  20996. } else {
  20997. cert_no = psn_info.VerifyNumber
  20998. }
  20999. var rf []*ResultFive
  21000. json.Unmarshal([]byte(his.Iinfo), &rf)
  21001. var psn_type string
  21002. for _, item := range rf {
  21003. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  21004. psn_type = item.PsnType
  21005. }
  21006. }
  21007. 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)
  21008. var dat map[string]interface{}
  21009. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21010. fmt.Println(dat)
  21011. } else {
  21012. fmt.Println(err)
  21013. }
  21014. saveLog(result2, src_resquest, "2207", "结算")
  21015. userJSONBytes, _ := json.Marshal(dat)
  21016. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21017. utils.ErrorLog("解析失败:%v", err)
  21018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21019. return
  21020. }
  21021. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21022. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21023. if his.IdCardType == 1 {
  21024. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21025. bas := strings.Split(psn_info.CardInfo, "|")
  21026. cert_no = bas[2]
  21027. } else if his.IdCardType == 3 {
  21028. cert_no = his.Certno
  21029. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  21030. } else if his.IdCardType == 4 {
  21031. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21032. cert_no = his.Certno
  21033. psn_info.VerifyNumber = psn_info.VerifyNumber
  21034. } else {
  21035. cert_no = his.Certno
  21036. psn_info.VerifyNumber = his.Certno
  21037. }
  21038. var api string
  21039. var med_type string
  21040. if his.Insutype == "390" {
  21041. if reg_type == 992102 {
  21042. med_type = "992102"
  21043. }
  21044. if reg_type == 140104 {
  21045. med_type = "140104"
  21046. }
  21047. if reg_type == 14 {
  21048. med_type = "14"
  21049. }
  21050. } else if his.Insutype == "310" {
  21051. if reg_type == 992102 {
  21052. med_type = "992102"
  21053. }
  21054. if reg_type == 14 {
  21055. med_type = "14"
  21056. }
  21057. }
  21058. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21059. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21060. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21061. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21062. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21063. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21064. "&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
  21065. resp, requestErr := http.Get(api)
  21066. if requestErr != nil {
  21067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21068. return
  21069. }
  21070. body, ioErr := ioutil.ReadAll(resp.Body)
  21071. if ioErr != nil {
  21072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21074. return
  21075. }
  21076. var respJSON map[string]interface{}
  21077. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21080. return
  21081. }
  21082. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21083. if status == "0" {
  21084. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21085. c.ServeSuccessJSON(map[string]interface{}{
  21086. "failed_code": -10,
  21087. "msg": err_msg,
  21088. })
  21089. return
  21090. }
  21091. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21092. result, _ := json.Marshal(respJSON)
  21093. fmt.Println("log")
  21094. fmt.Println(string(result))
  21095. if err := json.Unmarshal(result, &ahres); err != nil {
  21096. utils.ErrorLog("解析失败:%v", err)
  21097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21098. return
  21099. }
  21100. res.InfRefmsgid = ahres.InfRefmsgid
  21101. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  21102. // 创建对应的Time类型
  21103. t := time.UnixMilli(timestamp)
  21104. // 格式化成指定的日期字符串
  21105. str := t.Format("2006-01-02 15:04:05")
  21106. res.Output.Setlinfo.SetlTime = str
  21107. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  21108. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  21109. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21110. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  21111. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  21112. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  21113. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21114. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  21115. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  21116. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  21117. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  21118. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  21119. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21120. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  21121. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  21122. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  21123. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  21124. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  21125. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  21126. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21127. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  21128. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  21129. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  21130. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  21131. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  21132. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  21133. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  21134. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  21135. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  21136. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  21137. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  21138. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  21139. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  21140. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  21141. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  21142. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  21143. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  21144. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  21145. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  21146. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  21147. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  21148. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  21149. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  21150. res.Output.Setldetail = ahres.Output.Setldetail
  21151. res.ErrMsg = ahres.ErrMsg
  21152. res.Cainfo = ahres.Cainfo
  21153. res.WarnMsg = ahres.WarnMsg
  21154. res.Infcode = ahres.Infcode
  21155. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21156. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21157. var cert_no string
  21158. if his.IdCardType == 1 {
  21159. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  21160. } else if his.IdCardType == 2 {
  21161. cert_no = his.IdCardNo
  21162. } else {
  21163. cert_no = psn_info.VerifyNumber
  21164. }
  21165. 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, "")
  21166. var dat map[string]interface{}
  21167. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21168. fmt.Println(dat)
  21169. } else {
  21170. fmt.Println(err)
  21171. }
  21172. saveLog(result2, src_resquest, "2207", "结算")
  21173. userJSONBytes, _ := json.Marshal(dat)
  21174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21175. utils.ErrorLog("解析失败:%v", err)
  21176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21177. return
  21178. }
  21179. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21180. psn_info, _ := service.GetPsnByPatientId(id)
  21181. var verify_number string
  21182. if psn_info.IdCardType == 4 {
  21183. verify_number = psn_info.VerifyNumber
  21184. } else if psn_info.IdCardType == 1 {
  21185. bas := strings.Split(psn_info.CardInfo, "|")
  21186. cardNumber := bas[2]
  21187. verify_number = cardNumber
  21188. } else {
  21189. verify_number = psn_info.Certno
  21190. psn_info.IdCardType = 2
  21191. }
  21192. var api string
  21193. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21194. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21195. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21196. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21197. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21198. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21199. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  21200. resp, requestErr := http.Get(api)
  21201. if requestErr != nil {
  21202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21203. return
  21204. }
  21205. body, ioErr := ioutil.ReadAll(resp.Body)
  21206. if ioErr != nil {
  21207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21209. return
  21210. }
  21211. var respJSON map[string]interface{}
  21212. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21215. return
  21216. }
  21217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21218. result, _ := json.Marshal(respJSON)
  21219. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21220. utils.ErrorLog("解析失败:%v", err)
  21221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21222. return
  21223. }
  21224. } else {
  21225. var src_resquest string
  21226. if miConfig.Code == "H15049901371" {
  21227. //赤峰地区国家医保医疗类别
  21228. //职工透析:医疗类别选特殊情况门诊990502
  21229. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21230. var med_type string
  21231. if his.Insutype == "390" {
  21232. if reg_type == 14 {
  21233. med_type = "9933"
  21234. } else if reg_type == 11 {
  21235. med_type = "11"
  21236. }
  21237. } else if his.Insutype == "310" {
  21238. if reg_type == 14 {
  21239. med_type = "990502"
  21240. } else if reg_type == 11 {
  21241. med_type = "11"
  21242. }
  21243. }
  21244. 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)
  21245. } else {
  21246. if his.IdCardType == 4 {
  21247. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21248. token := psn_info.VerifyNumber
  21249. 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)
  21250. } else {
  21251. 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)
  21252. }
  21253. }
  21254. var dat map[string]interface{}
  21255. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21256. fmt.Println(dat)
  21257. } else {
  21258. fmt.Println(err)
  21259. }
  21260. saveLog(result2, src_resquest, "2207", "结算")
  21261. userJSONBytes, _ := json.Marshal(dat)
  21262. if miConfig.Code == "H15049901371" {
  21263. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  21264. utils.ErrorLog("解析失败:%v", err)
  21265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21266. return
  21267. }
  21268. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21269. res.Output = resSeven10265.Output
  21270. res.ErrMsg = resSeven10265.ErrMsg
  21271. res.Cainfo = resSeven10265.Cainfo
  21272. res.WarnMsg = resSeven10265.WarnMsg
  21273. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21274. res.Infcode = infocode
  21275. } else {
  21276. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21277. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  21278. utils.ErrorLog("解析失败:%v", err)
  21279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21280. return
  21281. }
  21282. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  21283. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  21284. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  21285. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21286. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  21287. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  21288. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  21289. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21290. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  21291. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21292. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21293. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21294. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21295. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21296. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  21297. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  21298. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  21299. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  21300. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  21301. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  21302. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21303. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  21304. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  21305. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  21306. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  21307. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  21308. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  21309. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  21310. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  21311. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  21312. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  21313. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  21314. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  21315. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  21316. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21317. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  21318. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  21319. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  21320. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21321. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  21322. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  21323. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  21324. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  21325. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  21326. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  21327. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  21328. res.ErrMsg = gzresSeven10265Two.ErrMsg
  21329. res.Cainfo = gzresSeven10265Two.Cainfo
  21330. res.WarnMsg = gzresSeven10265Two.WarnMsg
  21331. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21332. //res.Infcode = infocode
  21333. } else {
  21334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21335. utils.ErrorLog("解析失败:%v", err)
  21336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21337. return
  21338. }
  21339. }
  21340. }
  21341. }
  21342. if res.Infcode != 0 {
  21343. errlog := &models.HisOrderError{
  21344. UserOrgId: adminUser.CurrentOrgId,
  21345. Ctime: time.Now().Unix(),
  21346. Mtime: time.Now().Unix(),
  21347. Number: chrg_bchno,
  21348. ErrMsg: res.ErrMsg,
  21349. Status: 1,
  21350. PatientId: id,
  21351. RecordTime: recordDateTime,
  21352. Stage: 6,
  21353. }
  21354. service.CreateErrMsgLog(errlog)
  21355. c.ServeSuccessJSON(map[string]interface{}{
  21356. "failed_code": -10,
  21357. "msg": res.ErrMsg,
  21358. })
  21359. return
  21360. } else {
  21361. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  21362. order.OrderStatus = 2
  21363. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  21364. order.SetlId = res.Output.Setlinfo.SetlID
  21365. order.PsnNo = res.Output.Setlinfo.PsnNo
  21366. order.PsnName = res.Output.Setlinfo.PsnName
  21367. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  21368. order.Certno = res.Output.Setlinfo.Certno
  21369. order.Gend = res.Output.Setlinfo.Gend
  21370. order.Naty = res.Output.Setlinfo.Naty
  21371. order.Age = res.Output.Setlinfo.Age
  21372. order.Insutype = res.Output.Setlinfo.Insutype
  21373. order.PsnType = res.Output.Setlinfo.PsnType
  21374. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  21375. order.SetlTime = res.Output.Setlinfo.SetlTime
  21376. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  21377. order.PayWays = pay_ways
  21378. order.AcctUsedFlag = acct_used_flag
  21379. order.WechatPay = wechat_pay
  21380. order.AliPay = ali_pay
  21381. order.JifenPay = jifen_pay
  21382. order.BandCardPay = band_card_pay
  21383. order.CashPay = cash_pay
  21384. order.OthDesc = oth_desc
  21385. //order.MedType = res.Output.Setlinfo.MedType
  21386. if reg_type == 1112 {
  21387. order.MedType = "1112"
  21388. }
  21389. if reg_type == 1111 {
  21390. order.MedType = "1111"
  21391. }
  21392. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  21393. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  21394. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  21395. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  21396. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  21397. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  21398. order.HifpPay = res.Output.Setlinfo.HifpPay
  21399. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  21400. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  21401. order.HifesPay = res.Output.Setlinfo.HifesPay
  21402. order.HifobPay = res.Output.Setlinfo.HifobPay
  21403. order.MafPay = res.Output.Setlinfo.MafPay
  21404. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  21405. order.OthPay = res.Output.Setlinfo.OthPay
  21406. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  21407. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  21408. order.AcctPay = res.Output.Setlinfo.AcctPay
  21409. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  21410. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  21411. order.Balc = res.Output.Setlinfo.Balc
  21412. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  21413. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  21414. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  21415. order.ClrWay = res.Output.Setlinfo.ClrWay
  21416. order.Creator = order.Creator
  21417. order.ClrType = res.Output.Setlinfo.ClrType
  21418. order.Modify = roles.AdminUserId
  21419. order.RequestLog = src_resquest
  21420. order.Diagnosis = diagnosis_id
  21421. order.FaPiaoNumber = fapiao_number
  21422. order.FaPiaoCode = fapiao_code
  21423. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21424. detailStr := string(setlDetail)
  21425. order.SetlDetail = detailStr
  21426. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21427. err = service.UpDateOrder(order)
  21428. if err == nil {
  21429. //判断是否使用了押金
  21430. if dec_way == "true" {
  21431. tmpstring := strconv.FormatInt(order.ID, 10)
  21432. //扣押金
  21433. order.Decimal = decimal
  21434. service.UpDateOrder(order)
  21435. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21436. if errmsg != nil {
  21437. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21438. return
  21439. }
  21440. }
  21441. c.ServeSuccessJSON(map[string]interface{}{
  21442. "msg": "结算成功",
  21443. })
  21444. } else {
  21445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21446. return
  21447. }
  21448. }
  21449. }
  21450. }
  21451. }
  21452. // 上传明细-预结算-
  21453. func (c *HisApiController) GetPreUploadInfo() {
  21454. id, _ := c.GetInt64("id")
  21455. record_time := c.GetString("record_time")
  21456. his_patient_id, _ := c.GetInt64("his_patient_id")
  21457. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  21458. admin_user_id, _ := c.GetInt64("admin_user_id")
  21459. diagnosis_id := c.GetString("diagnosis")
  21460. sick_type, _ := c.GetInt64("sick_type")
  21461. reg_type, _ := c.GetInt64("p_type")
  21462. begin_time := c.GetString("begin_time")
  21463. acct_used_flag := c.GetString("acct_used_flag")
  21464. id_str := c.GetString("ids")
  21465. ids_arr := strings.Split(id_str, ",")
  21466. timeLayout := "2006-01-02"
  21467. loc, _ := time.LoadLocation("Local")
  21468. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21469. if err != nil {
  21470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21471. return
  21472. }
  21473. recordDateTime := theTime.Unix()
  21474. adminUser := c.GetAdminUserInfo()
  21475. diagnosis_ids := strings.Split(diagnosis_id, ",")
  21476. var config []*models.HisXtDiagnoseConfig
  21477. for _, item := range diagnosis_ids {
  21478. id, _ := strconv.ParseInt(item, 10, 64)
  21479. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21480. config = append(config, &diagnosisConfig)
  21481. }
  21482. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  21483. sickConfig, _ := service.FindSickById(sick_type)
  21484. var prescriptions []*models.HisPrescription
  21485. var start_time int64
  21486. var end_time int64
  21487. var isSuccess bool = true
  21488. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21489. fmt.Println(his_patient_id)
  21490. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21491. timestamp := time.Now().Unix()
  21492. tempTime := time.Unix(timestamp, 0)
  21493. timeFormat := tempTime.Format("20060102150405")
  21494. chrgBchno := rand.Intn(100000) + 10000
  21495. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  21496. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21497. var patientPrescription models.HisPrescriptionInfo
  21498. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21499. if patientPrescription.ID == 0 {
  21500. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  21501. }
  21502. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21503. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  21504. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  21505. strconv.FormatInt(his.PatientId, 10)
  21506. var res2406 Result2406
  21507. //安徽单病种处理
  21508. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  21509. data := make(map[string]interface{})
  21510. client := &http.Client{}
  21511. data["psn_no"] = his.PsnNo
  21512. data["mdtrt_id"] = his.Number
  21513. data["operator"] = roles.UserName
  21514. data["cert_no"] = his.IdCardNo
  21515. data["org_name"] = miConfig.OrgName
  21516. data["psn_name"] = his.Name
  21517. data["ipt_otp_no"] = his.IptOtpNo
  21518. data["ipt_psn_sp_flag_type"] = "0901"
  21519. data["ipt_psn_sp_flag"] = "1"
  21520. data["fixmedins_code"] = miConfig.Code
  21521. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21522. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21523. data["url"] = miConfig.Url
  21524. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  21525. bytesData, _ := json.Marshal(data)
  21526. var req *http.Request
  21527. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  21528. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  21529. resp, _ := client.Do(req)
  21530. defer resp.Body.Close()
  21531. body, ioErr := ioutil.ReadAll(resp.Body)
  21532. if ioErr != nil {
  21533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21535. return
  21536. }
  21537. var respJSON map[string]interface{}
  21538. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21541. return
  21542. }
  21543. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21544. if status == "0" {
  21545. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21546. c.ServeSuccessJSON(map[string]interface{}{
  21547. "failed_code": -10,
  21548. "msg": err_msg,
  21549. })
  21550. return
  21551. }
  21552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21553. userJSONBytes, _ := json.Marshal(respJSON)
  21554. fmt.Println("log")
  21555. fmt.Println(string(userJSONBytes))
  21556. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  21557. utils.ErrorLog("解析失败:%v", err)
  21558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21559. return
  21560. }
  21561. }
  21562. if res2406.Infcode != 0 {
  21563. adminUser := c.GetAdminUserInfo()
  21564. errlog := &models.HisOrderError{
  21565. UserOrgId: adminUser.CurrentOrgId,
  21566. Ctime: time.Now().Unix(),
  21567. Mtime: time.Now().Unix(),
  21568. ErrMsg: res2406.ErrMsg,
  21569. Status: 1,
  21570. PatientId: id,
  21571. RecordTime: recordDateTime,
  21572. Stage: 3,
  21573. }
  21574. service.CreateErrMsgLog(errlog)
  21575. c.ServeSuccessJSON(map[string]interface{}{
  21576. "failed_code": -10,
  21577. "msg": res2406.ErrMsg,
  21578. })
  21579. return
  21580. }
  21581. var res2 ResultSix
  21582. var res3 GZResultSix
  21583. var resSix10265 ResultSix10265
  21584. //var time_stamp string
  21585. if miConfig.MdtrtareaAdmvs == "421300" {
  21586. data := make(map[string]interface{})
  21587. client := &http.Client{}
  21588. data["psn_no"] = his.PsnNo
  21589. data["mdtrt_id"] = his.Number
  21590. data["department"] = department.Name
  21591. data["org_name"] = miConfig.OrgName
  21592. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21593. data["doctor_id"] = doctor_info.DoctorNumber
  21594. data["doctor_name"] = roles.UserName
  21595. data["fixmedins_code"] = miConfig.Code
  21596. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21597. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21598. data["secret_key"] = miConfig.SecretKey
  21599. data["sick_code"] = sickConfig.CountryCode
  21600. data["sick_name"] = sickConfig.ClassName
  21601. data["begin_time"] = begin_time
  21602. data["dept"] = strconv.FormatInt(department.ID, 10)
  21603. data["config"] = config
  21604. data["opter"] = roles.UserName
  21605. fmt.Println(data)
  21606. bytesData, _ := json.Marshal(data)
  21607. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21608. resp, _ := client.Do(req)
  21609. defer resp.Body.Close()
  21610. body, ioErr := ioutil.ReadAll(resp.Body)
  21611. if ioErr != nil {
  21612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21614. return
  21615. }
  21616. var respJSON map[string]interface{}
  21617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21620. return
  21621. }
  21622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21623. userJSONBytes, _ := json.Marshal(respJSON)
  21624. fmt.Println("log")
  21625. fmt.Println(string(userJSONBytes))
  21626. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21627. utils.ErrorLog("解析失败:%v", err)
  21628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21629. return
  21630. }
  21631. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21632. data := make(map[string]interface{})
  21633. client := &http.Client{}
  21634. data["psn_no"] = his.PsnNo
  21635. data["mdtrt_id"] = his.Number
  21636. data["department"] = department.Name
  21637. data["org_name"] = miConfig.OrgName
  21638. if reg_type == 11 && his.Insutype == "390" {
  21639. data["med_type"] = "110104"
  21640. } else {
  21641. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21642. }
  21643. data["doctor_id"] = doctor_info.DoctorNumber
  21644. data["doctor_name"] = roles.UserName
  21645. data["fixmedins_code"] = miConfig.Code
  21646. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21647. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21648. data["secret_key"] = miConfig.SecretKey
  21649. data["sick_code"] = sickConfig.CountryCode
  21650. data["sick_name"] = sickConfig.ClassName
  21651. data["begin_time"] = begin_time
  21652. data["dept"] = strconv.FormatInt(department.ID, 10)
  21653. data["config"] = config
  21654. data["opter"] = roles.UserName
  21655. fmt.Println(data)
  21656. bytesData, _ := json.Marshal(data)
  21657. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21658. resp, _ := client.Do(req)
  21659. defer resp.Body.Close()
  21660. body, ioErr := ioutil.ReadAll(resp.Body)
  21661. if ioErr != nil {
  21662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21664. return
  21665. }
  21666. var respJSON map[string]interface{}
  21667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21670. return
  21671. }
  21672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21673. userJSONBytes, _ := json.Marshal(respJSON)
  21674. fmt.Println("log")
  21675. fmt.Println(string(userJSONBytes))
  21676. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21677. utils.ErrorLog("解析失败:%v", err)
  21678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21679. return
  21680. }
  21681. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21682. data := make(map[string]interface{})
  21683. client := &http.Client{}
  21684. data["psn_no"] = his.PsnNo
  21685. data["mdtrt_id"] = his.Number
  21686. data["department"] = department.Name
  21687. data["org_name"] = miConfig.OrgName
  21688. if reg_type == 11 && his.Insutype == "390" {
  21689. data["med_type"] = "110104"
  21690. } else {
  21691. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21692. }
  21693. data["doctor_id"] = doctor_info.DoctorNumber
  21694. data["doctor_name"] = roles.UserName
  21695. data["fixmedins_code"] = miConfig.Code
  21696. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21697. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21698. data["secret_key"] = miConfig.SecretKey
  21699. data["sick_code"] = sickConfig.CountryCode
  21700. data["sick_name"] = sickConfig.ClassName
  21701. data["begin_time"] = begin_time
  21702. data["dept"] = strconv.FormatInt(department.ID, 10)
  21703. data["config"] = config
  21704. data["opter"] = roles.UserName
  21705. fmt.Println(data)
  21706. bytesData, _ := json.Marshal(data)
  21707. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21708. resp, _ := client.Do(req)
  21709. defer resp.Body.Close()
  21710. body, ioErr := ioutil.ReadAll(resp.Body)
  21711. if ioErr != nil {
  21712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21714. return
  21715. }
  21716. var respJSON map[string]interface{}
  21717. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21720. return
  21721. }
  21722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21723. userJSONBytes, _ := json.Marshal(respJSON)
  21724. fmt.Println("log")
  21725. fmt.Println(string(userJSONBytes))
  21726. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21727. utils.ErrorLog("解析失败:%v", err)
  21728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21729. return
  21730. }
  21731. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21732. data := make(map[string]interface{})
  21733. client := &http.Client{}
  21734. data["psn_no"] = his.PsnNo
  21735. data["mdtrt_id"] = his.Number
  21736. data["department"] = department.Name
  21737. data["org_name"] = miConfig.OrgName
  21738. if reg_type == 11 && his.Insutype == "390" {
  21739. data["med_type"] = "110104"
  21740. } else {
  21741. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21742. }
  21743. data["doctor_id"] = doctor_info.DoctorNumber
  21744. data["doctor_name"] = roles.UserName
  21745. data["fixmedins_code"] = miConfig.Code
  21746. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21747. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21748. data["secret_key"] = miConfig.SecretKey
  21749. data["sick_code"] = sickConfig.CountryCode
  21750. data["sick_name"] = sickConfig.ClassName
  21751. data["begin_time"] = begin_time
  21752. data["dept"] = strconv.FormatInt(department.ID, 10)
  21753. data["config"] = config
  21754. data["opter"] = roles.UserName
  21755. fmt.Println(data)
  21756. bytesData, _ := json.Marshal(data)
  21757. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21758. resp, _ := client.Do(req)
  21759. defer resp.Body.Close()
  21760. body, ioErr := ioutil.ReadAll(resp.Body)
  21761. if ioErr != nil {
  21762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21764. return
  21765. }
  21766. var respJSON map[string]interface{}
  21767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21770. return
  21771. }
  21772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21773. userJSONBytes, _ := json.Marshal(respJSON)
  21774. fmt.Println("log")
  21775. fmt.Println(string(userJSONBytes))
  21776. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21777. utils.ErrorLog("解析失败:%v", err)
  21778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21779. return
  21780. }
  21781. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21782. data := make(map[string]interface{})
  21783. client := &http.Client{}
  21784. data["psn_no"] = his.PsnNo
  21785. data["mdtrt_id"] = his.Number
  21786. data["doctor"] = roles.UserName
  21787. data["department"] = department.Name
  21788. data["org_name"] = miConfig.OrgName
  21789. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21790. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21791. data["fixmedins_code"] = miConfig.Code
  21792. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21793. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21794. data["secret_key"] = miConfig.SecretKey
  21795. data["sick_code"] = sickConfig.CountryCode
  21796. data["sick_name"] = sickConfig.ClassName
  21797. data["begin_time"] = begin_time
  21798. data["dept"] = strconv.FormatInt(department.ID, 10)
  21799. data["config"] = config
  21800. data["url"] = miConfig.Url
  21801. data["ak"] = miConfig.AccessKey
  21802. data["cainfo"] = miConfig.Cainfo
  21803. bytesData, _ := json.Marshal(data)
  21804. var req *http.Request
  21805. if miConfig.MdtrtareaAdmvs == "320921" {
  21806. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21807. } else {
  21808. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21809. }
  21810. resp, _ := client.Do(req)
  21811. defer resp.Body.Close()
  21812. body, ioErr := ioutil.ReadAll(resp.Body)
  21813. if ioErr != nil {
  21814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21816. return
  21817. }
  21818. var respJSON map[string]interface{}
  21819. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21822. return
  21823. }
  21824. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21825. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21826. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21828. userJSONBytes, _ := json.Marshal(respJSON)
  21829. fmt.Println("log")
  21830. fmt.Println(string(userJSONBytes))
  21831. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21832. utils.ErrorLog("解析失败:%v", err)
  21833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21834. return
  21835. }
  21836. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21837. res2.Output = resSix10265.Output
  21838. res2.ErrMsg = resSix10265.ErrMsg
  21839. res2.Cainfo = resSix10265.Cainfo
  21840. res2.WarnMsg = resSix10265.WarnMsg
  21841. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21842. res2.Infcode = infocode
  21843. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21844. data := make(map[string]interface{})
  21845. client := &http.Client{}
  21846. data["psn_no"] = his.PsnNo
  21847. data["mdtrt_id"] = his.Number
  21848. data["doctor"] = roles.UserName
  21849. data["department"] = department.Name
  21850. data["org_name"] = miConfig.OrgName
  21851. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21852. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21853. data["fixmedins_code"] = miConfig.Code
  21854. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21855. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21856. data["secret_key"] = miConfig.SecretKey
  21857. data["sick_code"] = sickConfig.CountryCode
  21858. data["sick_name"] = sickConfig.ClassName
  21859. data["begin_time"] = begin_time
  21860. data["dept"] = strconv.FormatInt(department.ID, 10)
  21861. data["config"] = config
  21862. //data["url"] = miConfig.Url
  21863. //data["ak"] = miConfig.AccessKey
  21864. data["cainfo"] = miConfig.Cainfo
  21865. fmt.Println(data)
  21866. bytesData, _ := json.Marshal(data)
  21867. var req *http.Request
  21868. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  21869. resp, _ := client.Do(req)
  21870. defer resp.Body.Close()
  21871. body, ioErr := ioutil.ReadAll(resp.Body)
  21872. if ioErr != nil {
  21873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21875. return
  21876. }
  21877. var respJSON map[string]interface{}
  21878. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21881. return
  21882. }
  21883. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21884. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21885. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21887. userJSONBytes, _ := json.Marshal(respJSON)
  21888. fmt.Println("log")
  21889. fmt.Println(string(userJSONBytes))
  21890. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21891. utils.ErrorLog("解析失败:%v", err)
  21892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21893. return
  21894. }
  21895. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21896. res2.Output = resSix10265.Output
  21897. res2.ErrMsg = resSix10265.ErrMsg
  21898. res2.Cainfo = resSix10265.Cainfo
  21899. res2.WarnMsg = resSix10265.WarnMsg
  21900. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21901. res2.Infcode = infocode
  21902. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21903. 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)
  21904. saveLog(result, requestLog, "2203", "上传就诊信息")
  21905. var respJSON2 map[string]interface{}
  21906. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21909. return
  21910. }
  21911. userJSONBytes2, _ := json.Marshal(respJSON2)
  21912. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21913. utils.ErrorLog("解析失败:%v", err)
  21914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21915. return
  21916. }
  21917. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21918. var result string
  21919. var requestLog string
  21920. 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, "")
  21921. saveLog(result, requestLog, "2203", "上传就诊信息")
  21922. var respJSON2 map[string]interface{}
  21923. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21926. return
  21927. }
  21928. userJSONBytes2, _ := json.Marshal(respJSON2)
  21929. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21930. utils.ErrorLog("解析失败:%v", err)
  21931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21932. return
  21933. }
  21934. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21935. data := make(map[string]interface{})
  21936. client := &http.Client{}
  21937. data["psn_no"] = his.PsnNo
  21938. data["mdtrt_id"] = his.Number
  21939. data["operator"] = roles.UserName
  21940. data["department"] = department.Name
  21941. data["org_name"] = miConfig.OrgName
  21942. var med_type string
  21943. if his.Insutype == "390" {
  21944. if reg_type == 992102 {
  21945. med_type = "992102"
  21946. data["sick_code"] = "ZDZ940"
  21947. data["sick_name"] = "慢性肾衰竭"
  21948. }
  21949. if reg_type == 140104 {
  21950. med_type = "140104"
  21951. data["sick_code"] = sickConfig.CountryCode
  21952. data["sick_name"] = sickConfig.ClassName
  21953. }
  21954. if reg_type == 14 {
  21955. med_type = "140104"
  21956. data["sick_code"] = sickConfig.CountryCode
  21957. data["sick_name"] = sickConfig.ClassName
  21958. }
  21959. } else if his.Insutype == "310" {
  21960. if reg_type == 992102 {
  21961. med_type = "992102"
  21962. data["sick_code"] = "ZDZ940"
  21963. data["sick_name"] = "慢性肾衰竭"
  21964. }
  21965. if reg_type == 140104 {
  21966. med_type = "140104"
  21967. data["sick_code"] = sickConfig.CountryCode
  21968. data["sick_name"] = sickConfig.ClassName
  21969. }
  21970. if reg_type == 14 {
  21971. med_type = "14"
  21972. data["sick_code"] = sickConfig.CountryCode
  21973. data["sick_name"] = sickConfig.ClassName
  21974. }
  21975. }
  21976. data["med_type"] = med_type
  21977. data["doctor_number"] = doctor_info.DoctorNumber
  21978. data["doctor_name"] = doctor_info.UserName
  21979. data["fixmedins_code"] = miConfig.Code
  21980. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21981. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21982. data["secret_key"] = miConfig.SecretKey
  21983. data["begin_time"] = begin_time
  21984. data["dept"] = strconv.FormatInt(department.ID, 10)
  21985. data["config"] = config
  21986. data["url"] = miConfig.Url
  21987. data["ak"] = miConfig.AccessKey
  21988. data["cainfo"] = miConfig.Cainfo
  21989. bytesData, _ := json.Marshal(data)
  21990. var req *http.Request
  21991. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  21992. resp, _ := client.Do(req)
  21993. defer resp.Body.Close()
  21994. body, ioErr := ioutil.ReadAll(resp.Body)
  21995. if ioErr != nil {
  21996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21998. return
  21999. }
  22000. var respJSON map[string]interface{}
  22001. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22004. return
  22005. }
  22006. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22007. if status == "0" {
  22008. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22009. c.ServeSuccessJSON(map[string]interface{}{
  22010. "failed_code": -10,
  22011. "msg": err_msg,
  22012. })
  22013. return
  22014. }
  22015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22016. userJSONBytes, _ := json.Marshal(respJSON)
  22017. fmt.Println("log")
  22018. fmt.Println(string(userJSONBytes))
  22019. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22020. utils.ErrorLog("解析失败:%v", err)
  22021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22022. return
  22023. }
  22024. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22025. var result string
  22026. var requestLog string
  22027. 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, "")
  22028. saveLog(result, requestLog, "2203", "上传就诊信息")
  22029. var respJSON2 map[string]interface{}
  22030. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22033. return
  22034. }
  22035. userJSONBytes2, _ := json.Marshal(respJSON2)
  22036. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22037. utils.ErrorLog("解析失败:%v", err)
  22038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22039. return
  22040. }
  22041. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22042. data := make(map[string]interface{})
  22043. client := &http.Client{}
  22044. data["psn_no"] = his.PsnNo
  22045. data["mdtrt_id"] = his.Number
  22046. data["doctor"] = roles.UserName
  22047. data["department"] = department.Name
  22048. data["org_name"] = miConfig.OrgName
  22049. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22050. data["doctor_id"] = doctor_info.DoctorNumber
  22051. data["fixmedins_code"] = miConfig.Code
  22052. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22053. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22054. data["secret_key"] = miConfig.SecretKey
  22055. data["sick_code"] = sickConfig.CountryCode
  22056. data["sick_name"] = sickConfig.ClassName
  22057. data["begin_time"] = begin_time
  22058. data["new_doctor_name"] = doctor_info.UserName
  22059. data["dept"] = strconv.FormatInt(department.ID, 10)
  22060. data["config"] = config
  22061. bytesData, _ := json.Marshal(data)
  22062. var req *http.Request
  22063. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  22064. resp, _ := client.Do(req)
  22065. defer resp.Body.Close()
  22066. body, ioErr := ioutil.ReadAll(resp.Body)
  22067. if ioErr != nil {
  22068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22070. return
  22071. }
  22072. var respJSON map[string]interface{}
  22073. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22076. return
  22077. }
  22078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22079. userJSONBytes, _ := json.Marshal(respJSON)
  22080. fmt.Println("log")
  22081. fmt.Println(string(userJSONBytes))
  22082. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22083. utils.ErrorLog("解析失败:%v", err)
  22084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22085. return
  22086. }
  22087. } else {
  22088. var result string
  22089. var requestLog string
  22090. if miConfig.MdtrtareaAdmvs == "440781" { //
  22091. 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)
  22092. } else {
  22093. if miConfig.Code == "H15049901371" {
  22094. //赤峰地区国家医保医疗类别
  22095. //职工透析:医疗类别选特殊情况门诊990502
  22096. //居民定额血透门慢: 医疗类别选门诊慢病140104
  22097. var med_type string
  22098. if his.Insutype == "390" {
  22099. if reg_type == 14 {
  22100. med_type = "9933"
  22101. } else if reg_type == 11 {
  22102. med_type = "11"
  22103. }
  22104. } else if his.Insutype == "310" {
  22105. if reg_type == 14 {
  22106. med_type = "990502"
  22107. } else if reg_type == 11 {
  22108. med_type = "11"
  22109. }
  22110. }
  22111. 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)
  22112. } else {
  22113. 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)
  22114. }
  22115. saveLog(result, requestLog, "2203", "上传就诊信息")
  22116. var respJSON2 map[string]interface{}
  22117. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22120. return
  22121. }
  22122. userJSONBytes2, _ := json.Marshal(respJSON2)
  22123. if miConfig.Code == "H15049901371" {
  22124. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  22125. utils.ErrorLog("解析失败:%v", err)
  22126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22127. return
  22128. }
  22129. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22130. res2.Output = resSix10265.Output
  22131. res2.ErrMsg = resSix10265.ErrMsg
  22132. res2.Cainfo = resSix10265.Cainfo
  22133. res2.WarnMsg = resSix10265.WarnMsg
  22134. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22135. res2.Infcode = infocode
  22136. } else {
  22137. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22138. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  22139. utils.ErrorLog("解析失败:%v", err)
  22140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22141. return
  22142. }
  22143. res2.Infcode = res3.Infcode
  22144. } else {
  22145. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22146. utils.ErrorLog("解析失败:%v", err)
  22147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22148. return
  22149. }
  22150. }
  22151. }
  22152. }
  22153. }
  22154. if res2.Infcode == -1 {
  22155. adminUser := c.GetAdminUserInfo()
  22156. errlog := &models.HisOrderError{
  22157. UserOrgId: adminUser.CurrentOrgId,
  22158. Ctime: time.Now().Unix(),
  22159. Mtime: time.Now().Unix(),
  22160. ErrMsg: res2.ErrMsg,
  22161. Status: 1,
  22162. PatientId: id,
  22163. RecordTime: recordDateTime,
  22164. Stage: 3,
  22165. }
  22166. service.CreateErrMsgLog(errlog)
  22167. c.ServeSuccessJSON(map[string]interface{}{
  22168. "failed_code": -10,
  22169. "msg": res2.ErrMsg,
  22170. })
  22171. return
  22172. }
  22173. if res2.Infcode != 0 {
  22174. adminUser := c.GetAdminUserInfo()
  22175. errlog := &models.HisOrderError{
  22176. UserOrgId: adminUser.CurrentOrgId,
  22177. Ctime: time.Now().Unix(),
  22178. Mtime: time.Now().Unix(),
  22179. ErrMsg: res2.ErrMsg,
  22180. Status: 1,
  22181. PatientId: id,
  22182. RecordTime: recordDateTime,
  22183. Stage: 3,
  22184. }
  22185. service.CreateErrMsgLog(errlog)
  22186. c.ServeSuccessJSON(map[string]interface{}{
  22187. "failed_code": -10,
  22188. "msg": res2.ErrMsg,
  22189. })
  22190. return
  22191. } else {
  22192. his.Diagnosis = diagnosis_id
  22193. his.SickType = sickConfig.ID
  22194. his.PType = fmt.Sprintf("%d", reg_type)
  22195. service.UpdateHisPatientThree(&his)
  22196. data := make(map[string]interface{})
  22197. if settle_accounts_type == 1 { //日结
  22198. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  22199. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  22200. } else {
  22201. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  22202. }
  22203. data["pre"] = prescriptions
  22204. } else { //月结
  22205. start_time_str := c.GetString("start_time")
  22206. end_time_str := c.GetString("end_time")
  22207. timeLayout := "2006-01-02"
  22208. loc, _ := time.LoadLocation("Local")
  22209. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  22210. if err != nil {
  22211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22212. return
  22213. }
  22214. recordStartTime := theStartTime.Unix()
  22215. start_time = recordStartTime
  22216. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  22217. if err != nil {
  22218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22219. return
  22220. }
  22221. recordEndTime := theEndTime.Unix()
  22222. end_time = recordEndTime
  22223. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  22224. data["pre"] = prescriptions
  22225. }
  22226. client := &http.Client{}
  22227. data["psn_no"] = his.PsnNo
  22228. data["mdtrt_id"] = his.Number
  22229. data["chrg_bchno"] = chrg_bchno
  22230. data["org_name"] = miConfig.OrgName
  22231. data["doctor"] = doctor_info.UserName
  22232. data["doctor_id"] = doctor_info.DoctorNumber
  22233. data["dept"] = department.Name
  22234. data["fixmedins_code"] = miConfig.Code
  22235. data["opter"] = roles.UserName
  22236. data["dept_code"] = department.Number
  22237. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22238. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22239. data["secret_key"] = miConfig.SecretKey
  22240. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  22241. data["url"] = miConfig.Url
  22242. data["ak"] = miConfig.AccessKey
  22243. data["new_doctor_name"] = patientPrescription.Doctor
  22244. if his.Insutype == "390" {
  22245. if reg_type == 992102 {
  22246. data["diag_code"] = "ZDZ940"
  22247. }
  22248. if reg_type == 140104 {
  22249. data["diag_code"] = sickConfig.CountryCode
  22250. }
  22251. if reg_type == 14 {
  22252. data["diag_code"] = sickConfig.CountryCode
  22253. }
  22254. } else if his.Insutype == "310" {
  22255. if reg_type == 992102 {
  22256. data["diag_code"] = "ZDZ940"
  22257. }
  22258. if reg_type == 14 {
  22259. data["diag_code"] = sickConfig.CountryCode
  22260. }
  22261. }
  22262. data["cainfo"] = miConfig.Cainfo
  22263. data["opter"] = roles.UserName
  22264. var ids []int64
  22265. for _, item := range prescriptions {
  22266. ids = append(ids, item.ID)
  22267. }
  22268. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22269. if config.IsOpen == 1 { //对接了医保,走医保流程
  22270. var res ResultFour
  22271. var resFour10265 ResultFour10265
  22272. if miConfig.MdtrtareaAdmvs == "421300" {
  22273. bytesData, _ := json.Marshal(data)
  22274. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", 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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22290. userJSONBytes, _ := json.Marshal(respJSON)
  22291. fmt.Println("log")
  22292. fmt.Println(string(userJSONBytes))
  22293. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22294. utils.ErrorLog("解析失败:%v", err)
  22295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22296. return
  22297. }
  22298. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22299. bytesData, _ := json.Marshal(data)
  22300. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22301. resp, _ := client.Do(req)
  22302. defer resp.Body.Close()
  22303. body, ioErr := ioutil.ReadAll(resp.Body)
  22304. if ioErr != nil {
  22305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22307. return
  22308. }
  22309. var respJSON map[string]interface{}
  22310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22313. return
  22314. }
  22315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22316. userJSONBytes, _ := json.Marshal(respJSON)
  22317. fmt.Println("log")
  22318. fmt.Println(string(userJSONBytes))
  22319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22320. utils.ErrorLog("解析失败:%v", err)
  22321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22322. return
  22323. }
  22324. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22325. bytesData, _ := json.Marshal(data)
  22326. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22327. resp, _ := client.Do(req)
  22328. defer resp.Body.Close()
  22329. body, ioErr := ioutil.ReadAll(resp.Body)
  22330. if ioErr != nil {
  22331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22333. return
  22334. }
  22335. var respJSON map[string]interface{}
  22336. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22339. return
  22340. }
  22341. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22342. userJSONBytes, _ := json.Marshal(respJSON)
  22343. fmt.Println("log")
  22344. fmt.Println(string(userJSONBytes))
  22345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22346. utils.ErrorLog("解析失败:%v", err)
  22347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22348. return
  22349. }
  22350. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22351. bytesData, _ := json.Marshal(data)
  22352. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22353. resp, _ := client.Do(req)
  22354. defer resp.Body.Close()
  22355. body, ioErr := ioutil.ReadAll(resp.Body)
  22356. if ioErr != nil {
  22357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22359. return
  22360. }
  22361. var respJSON map[string]interface{}
  22362. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22365. return
  22366. }
  22367. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22368. userJSONBytes, _ := json.Marshal(respJSON)
  22369. fmt.Println("log")
  22370. fmt.Println(string(userJSONBytes))
  22371. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22372. utils.ErrorLog("解析失败:%v", err)
  22373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22374. return
  22375. }
  22376. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22377. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22378. if result3101.Infcode == "0" {
  22379. if len(result3101.Output.Result) > 0 {
  22380. var errMsgs []string
  22381. for _, item := range result3101.Output.Result {
  22382. errMsgs = append(errMsgs, item.VolaCont)
  22383. }
  22384. c.ServeSuccessJSON(map[string]interface{}{
  22385. "failed_code": -10,
  22386. "msg": errMsgs,
  22387. })
  22388. return
  22389. } else {
  22390. if miConfig.MdtrtareaAdmvs == "320921" {
  22391. data["doctor_id"] = "D320923012139"
  22392. } else {
  22393. data["doctor_id"] = "D371621008686"
  22394. }
  22395. bytesData, _ := json.Marshal(data)
  22396. var req *http.Request
  22397. if miConfig.MdtrtareaAdmvs == "320921" {
  22398. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22399. } else {
  22400. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22401. }
  22402. resp, _ := client.Do(req)
  22403. defer resp.Body.Close()
  22404. body, ioErr := ioutil.ReadAll(resp.Body)
  22405. if ioErr != nil {
  22406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22408. return
  22409. }
  22410. var respJSON map[string]interface{}
  22411. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22414. return
  22415. }
  22416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22417. userJSONBytes, _ := json.Marshal(respJSON)
  22418. fmt.Println("log")
  22419. fmt.Println(string(userJSONBytes))
  22420. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22421. utils.ErrorLog("解析失败:%v", err)
  22422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22423. return
  22424. }
  22425. res.InfRefmsgid = resFour10265.InfRefmsgid
  22426. res.Output = resFour10265.Output
  22427. res.ErrMsg = resFour10265.ErrMsg
  22428. res.Cainfo = resFour10265.Cainfo
  22429. res.WarnMsg = resFour10265.WarnMsg
  22430. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22431. res.Infcode = infocode
  22432. }
  22433. }
  22434. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22435. var pagesize int = 5
  22436. var start int = 1
  22437. var stop int
  22438. var pagecount int
  22439. var curpage int
  22440. data["doctor_id"] = doctor_info.DoctorNumber
  22441. var res2 ResultFour
  22442. //var result res.
  22443. //总页数,向上取整,注意除之前要先转换类型为float64
  22444. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  22445. for curpage = 1; curpage <= pagecount; curpage++ {
  22446. if curpage == 1 {
  22447. start = 1
  22448. } else {
  22449. start = (curpage-1)*pagesize + 1
  22450. }
  22451. stop = curpage * pagesize
  22452. if stop > len(prescriptions) {
  22453. stop = len(prescriptions)
  22454. }
  22455. //var requestLog string
  22456. data["pre"] = prescriptions[start-1 : stop]
  22457. fmt.Println(data["pre"])
  22458. bytesData, _ := json.Marshal(data)
  22459. var req *http.Request
  22460. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  22461. resp, _ := client.Do(req)
  22462. defer resp.Body.Close()
  22463. body, ioErr := ioutil.ReadAll(resp.Body)
  22464. if ioErr != nil {
  22465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22467. return
  22468. }
  22469. var respJSON map[string]interface{}
  22470. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22473. return
  22474. }
  22475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22476. userJSONBytes, _ := json.Marshal(respJSON)
  22477. fmt.Println("log")
  22478. fmt.Println(string(userJSONBytes))
  22479. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22480. utils.ErrorLog("解析失败:%v", err)
  22481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22482. return
  22483. }
  22484. res.InfRefmsgid = resFour10265.InfRefmsgid
  22485. res.Output = resFour10265.Output
  22486. res.ErrMsg = resFour10265.ErrMsg
  22487. res.Cainfo = resFour10265.Cainfo
  22488. res.WarnMsg = resFour10265.WarnMsg
  22489. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22490. res.Infcode = infocode
  22491. if infocode == 0 {
  22492. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  22493. } else {
  22494. isSuccess = false
  22495. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  22496. res.Infcode = -1
  22497. res.ErrMsg = resFour10265.ErrMsg
  22498. errlog := &models.HisOrderError{
  22499. UserOrgId: adminUser.CurrentOrgId,
  22500. Ctime: time.Now().Unix(),
  22501. Mtime: time.Now().Unix(),
  22502. Number: chrg_bchno,
  22503. ErrMsg: "",
  22504. Status: 1,
  22505. PatientId: id,
  22506. RecordTime: recordDateTime,
  22507. Stage: 4,
  22508. }
  22509. service.CreateErrMsgLog(errlog)
  22510. }
  22511. }
  22512. if isSuccess {
  22513. res.Infcode = 0
  22514. res.Output.Result = res2.Output.Result
  22515. } else {
  22516. order := &models.HisOrder{
  22517. UserOrgId: adminUser.CurrentOrgId,
  22518. HisPatientId: his.ID,
  22519. PatientId: his.PatientId,
  22520. SettleAccountsDate: recordDateTime,
  22521. Ctime: time.Now().Unix(),
  22522. Mtime: time.Now().Unix(),
  22523. MdtrtId: his.Number,
  22524. PsnNo: his.PsnNo,
  22525. MedType: strconv.FormatInt(reg_type, 10),
  22526. Status: 1,
  22527. Number: chrg_bchno,
  22528. Infcode: res.Infcode,
  22529. WarnMsg: res.WarnMsg,
  22530. Cainfo: res.Cainfo,
  22531. ErrMsg: res.ErrMsg,
  22532. RespondTime: res.RefmsgTime,
  22533. InfRefmsgid: res.InfRefmsgid,
  22534. OrderStatus: 1,
  22535. IsMedicineInsurance: 1,
  22536. SettleType: settle_accounts_type,
  22537. SettleStartTime: start_time,
  22538. SettleEndTime: end_time,
  22539. Creator: roles.AdminUserId,
  22540. Modify: roles.AdminUserId,
  22541. PType: 2,
  22542. Diagnosis: diagnosis_id,
  22543. }
  22544. err = service.CreateOrder(order)
  22545. if err != nil {
  22546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22547. return
  22548. }
  22549. c.ServeSuccessJSON(map[string]interface{}{
  22550. "failed_code": -10,
  22551. "msg": res2.ErrMsg,
  22552. })
  22553. return
  22554. }
  22555. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22556. 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)
  22557. var dat map[string]interface{}
  22558. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22559. fmt.Println(dat)
  22560. } else {
  22561. fmt.Println(err)
  22562. }
  22563. saveLog(result, request_log, "2204", "上传费用明细")
  22564. userJSONBytes, _ := json.Marshal(dat)
  22565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22566. utils.ErrorLog("解析失败:%v", err)
  22567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22568. return
  22569. }
  22570. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22571. 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, "", "")
  22572. var dat map[string]interface{}
  22573. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22574. fmt.Println(dat)
  22575. } else {
  22576. fmt.Println(err)
  22577. }
  22578. saveLog(result, request_log, "2204", "上传费用明细")
  22579. userJSONBytes, _ := json.Marshal(dat)
  22580. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22581. utils.ErrorLog("解析失败:%v", err)
  22582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22583. return
  22584. }
  22585. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22586. bytesData, _ := json.Marshal(data)
  22587. var req *http.Request
  22588. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  22589. resp, _ := client.Do(req)
  22590. defer resp.Body.Close()
  22591. body, ioErr := ioutil.ReadAll(resp.Body)
  22592. if ioErr != nil {
  22593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22595. return
  22596. }
  22597. var respJSON map[string]interface{}
  22598. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22601. return
  22602. }
  22603. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22604. if status == "0" {
  22605. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22606. c.ServeSuccessJSON(map[string]interface{}{
  22607. "failed_code": -10,
  22608. "msg": err_msg,
  22609. })
  22610. return
  22611. }
  22612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22613. userJSONBytes, _ := json.Marshal(respJSON)
  22614. fmt.Println("log")
  22615. fmt.Println(string(userJSONBytes))
  22616. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22617. utils.ErrorLog("解析失败:%v", err)
  22618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22619. return
  22620. }
  22621. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22622. 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, "", "")
  22623. var dat map[string]interface{}
  22624. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22625. fmt.Println(dat)
  22626. } else {
  22627. fmt.Println(err)
  22628. }
  22629. saveLog(result, request_log, "2204", "上传费用明细")
  22630. userJSONBytes, _ := json.Marshal(dat)
  22631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22632. utils.ErrorLog("解析失败:%v", err)
  22633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22634. return
  22635. }
  22636. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22637. bytesData, _ := json.Marshal(data)
  22638. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  22639. resp, _ := client.Do(req)
  22640. defer resp.Body.Close()
  22641. body, ioErr := ioutil.ReadAll(resp.Body)
  22642. if ioErr != nil {
  22643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22645. return
  22646. }
  22647. var respJSON map[string]interface{}
  22648. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22651. return
  22652. }
  22653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22654. userJSONBytes, _ := json.Marshal(respJSON)
  22655. fmt.Println("log")
  22656. fmt.Println(string(userJSONBytes))
  22657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22658. utils.ErrorLog("解析失败:%v", err)
  22659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22660. return
  22661. }
  22662. } else {
  22663. if miConfig.MdtrtareaAdmvs == "441202" {
  22664. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22665. if result3101.Infcode == 0 {
  22666. if len(result3101.Output.Result) > 0 {
  22667. var errMsgs []string
  22668. for _, item := range result3101.Output.Result {
  22669. errMsgs = append(errMsgs, item.VolaCont)
  22670. }
  22671. c.ServeSuccessJSON(map[string]interface{}{
  22672. "failed_code": -10,
  22673. "msg": errMsgs,
  22674. })
  22675. return
  22676. } else {
  22677. 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)
  22678. var dat map[string]interface{}
  22679. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22680. fmt.Println(dat)
  22681. } else {
  22682. fmt.Println(err)
  22683. }
  22684. saveLog(result, request_log, "2204", "上传费用明细")
  22685. userJSONBytes, _ := json.Marshal(dat)
  22686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22687. utils.ErrorLog("解析失败:%v", err)
  22688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22689. return
  22690. }
  22691. }
  22692. } else {
  22693. c.ServeSuccessJSON(map[string]interface{}{
  22694. "failed_code": -10,
  22695. "msg": result3101.ErrMsg,
  22696. })
  22697. return
  22698. }
  22699. } else {
  22700. if miConfig.Code == "H15049901371" {
  22701. 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)
  22702. var dat map[string]interface{}
  22703. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22704. fmt.Println(dat)
  22705. } else {
  22706. fmt.Println(err)
  22707. }
  22708. saveLog(result, request_log, "2204", "上传费用明细")
  22709. userJSONBytes, _ := json.Marshal(dat)
  22710. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22711. utils.ErrorLog("解析失败:%v", err)
  22712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22713. return
  22714. }
  22715. res.InfRefmsgid = resFour10265.InfRefmsgid
  22716. res.Output = resFour10265.Output
  22717. res.ErrMsg = resFour10265.ErrMsg
  22718. res.Cainfo = resFour10265.Cainfo
  22719. res.WarnMsg = resFour10265.WarnMsg
  22720. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22721. res.Infcode = infocode
  22722. } else {
  22723. 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)
  22724. var dat map[string]interface{}
  22725. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22726. fmt.Println(dat)
  22727. } else {
  22728. fmt.Println(err)
  22729. }
  22730. saveLog(result, request_log, "2204", "上传费用明细")
  22731. userJSONBytes, _ := json.Marshal(dat)
  22732. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22733. utils.ErrorLog("解析失败:%v", err)
  22734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22735. return
  22736. }
  22737. }
  22738. }
  22739. }
  22740. var total_two float64
  22741. if res.Infcode == 0 {
  22742. order := &models.HisOrder{
  22743. UserOrgId: adminUser.CurrentOrgId,
  22744. HisPatientId: his.ID,
  22745. PatientId: his.PatientId,
  22746. SettleAccountsDate: recordDateTime,
  22747. Ctime: time.Now().Unix(),
  22748. Mtime: time.Now().Unix(),
  22749. MdtrtId: his.Number,
  22750. PsnNo: his.PsnNo,
  22751. MedType: strconv.FormatInt(reg_type, 10),
  22752. Status: 1,
  22753. Number: chrg_bchno,
  22754. Infcode: res.Infcode,
  22755. WarnMsg: res.WarnMsg,
  22756. Cainfo: res.Cainfo,
  22757. ErrMsg: res.ErrMsg,
  22758. RespondTime: res.RefmsgTime,
  22759. InfRefmsgid: res.InfRefmsgid,
  22760. OrderStatus: 1,
  22761. IsMedicineInsurance: 1,
  22762. SettleType: settle_accounts_type,
  22763. SettleStartTime: start_time,
  22764. SettleEndTime: end_time,
  22765. Creator: roles.AdminUserId,
  22766. Modify: roles.AdminUserId,
  22767. PType: 2,
  22768. Diagnosis: diagnosis_id,
  22769. }
  22770. err = service.CreateOrder(order)
  22771. if err != nil {
  22772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22773. return
  22774. }
  22775. for _, item := range res.Output.Result {
  22776. temp := strings.Split(item.FeedetlSn, "-")
  22777. var advice_id int64 = 0
  22778. var project_id int64 = 0
  22779. var types int64 = 0
  22780. id, _ := strconv.ParseInt(temp[2], 10, 64)
  22781. types, _ = strconv.ParseInt(temp[1], 10, 64)
  22782. if temp[1] == "1" {
  22783. advice_id = id
  22784. project_id = 0
  22785. } else if temp[1] == "2" {
  22786. advice_id = 0
  22787. project_id = id
  22788. }
  22789. total_two = total_two + item.DetItemFeeSumamt
  22790. info := &models.HisOrderInfo{
  22791. OrderNumber: order.Number,
  22792. FeedetlSn: item.FeedetlSn,
  22793. UploadDate: time.Now().Unix(),
  22794. AdviceId: advice_id,
  22795. DetItemFeeSumamt: item.DetItemFeeSumamt,
  22796. Cnt: item.Cnt,
  22797. Pric: float64(item.Pric),
  22798. PatientId: his.PatientId,
  22799. PricUplmtAmt: item.PricUplmtAmt,
  22800. SelfpayProp: item.SelfpayProp,
  22801. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  22802. OverlmtAmt: item.OverlmtAmt,
  22803. PreselfpayAmt: item.PreselfpayAmt,
  22804. BasMednFlag: item.BasMednFlag,
  22805. MedChrgitmType: item.MedChrgitmType,
  22806. HiNegoDrugFlag: item.HiNegoDrugFlag,
  22807. Status: 1,
  22808. Memo: item.Memo,
  22809. Mtime: time.Now().Unix(),
  22810. InscpScpAmt: item.InscpScpAmt,
  22811. DrtReimFlag: item.DrtReimFlag,
  22812. Ctime: time.Now().Unix(),
  22813. ListSpItemFlag: item.ListSpItemFlag,
  22814. ChldMedcFlag: item.ChldMedcFlag,
  22815. LmtUsedFlag: item.LmtUsedFlag,
  22816. ChrgitmLv: item.ChrgitmLv,
  22817. UserOrgId: adminUser.CurrentOrgId,
  22818. HisPatientId: his.ID,
  22819. OrderId: order.ID,
  22820. ProjectId: project_id,
  22821. Type: types,
  22822. }
  22823. service.CreateOrderInfo(info)
  22824. }
  22825. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  22826. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  22827. var total float64
  22828. for _, item := range prescriptions {
  22829. if item.Type == 1 { //药品
  22830. for _, subItem := range item.HisDoctorAdviceInfo {
  22831. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22832. total_one := price * subItem.PrescribingNumber
  22833. fmt.Println("subItem")
  22834. fmt.Println(subItem.Price)
  22835. fmt.Println("price")
  22836. fmt.Println(price)
  22837. fmt.Println("total_one")
  22838. fmt.Println(total_one)
  22839. total = total + total_one
  22840. fmt.Println(total)
  22841. }
  22842. }
  22843. if item.Type == 2 { //项目
  22844. for _, subItem := range item.HisPrescriptionProject {
  22845. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  22846. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22847. total_one := price * cnt
  22848. total = total + total_one
  22849. }
  22850. }
  22851. }
  22852. allTotal := fmt.Sprintf("%.2f", total)
  22853. if res.Infcode == 0 {
  22854. var rf []*ResultFive
  22855. json.Unmarshal([]byte(his.Iinfo), &rf)
  22856. chrg_bchno := chrg_bchno
  22857. cert_no := his.Certno
  22858. var insutypes []string
  22859. var insutype string
  22860. var is390 int = 0
  22861. var is310 int = 0
  22862. for _, item := range rf {
  22863. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22864. insutypes = append(insutypes, item.Insutype)
  22865. }
  22866. }
  22867. if len(insutypes) == 1 {
  22868. insutype = insutypes[0]
  22869. } else {
  22870. for _, i := range insutypes {
  22871. if i == "390" {
  22872. is390 = 1
  22873. }
  22874. if i == "310" {
  22875. is310 = 1
  22876. }
  22877. }
  22878. }
  22879. if is390 == 1 {
  22880. insutype = "390"
  22881. }
  22882. if is310 == 1 {
  22883. insutype = "310"
  22884. }
  22885. if len(insutypes) == 0 {
  22886. insutype = "390"
  22887. }
  22888. if len(insutypes) == 2 {
  22889. insutype = strconv.FormatInt(his.SocialType, 10)
  22890. }
  22891. //insutype = "390"
  22892. if his.IdCardType == 1 {
  22893. cert_no = his.MedicalInsuranceNumber
  22894. } else {
  22895. cert_no = his.Certno
  22896. }
  22897. var res ResultSeven
  22898. var ahres ResultSevenAH
  22899. var resSeven10265 ResultSeven10265
  22900. var resSeven10265Two ResultSeven10265Two
  22901. var gzresSeven10265Two GZResultSeven10265Two
  22902. if miConfig.MdtrtareaAdmvs == "421300" {
  22903. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  22904. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22905. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22906. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22907. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22908. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22909. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22910. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22911. resp, requestErr := http.Get(api)
  22912. if requestErr != nil {
  22913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22914. return
  22915. }
  22916. body, ioErr := ioutil.ReadAll(resp.Body)
  22917. if ioErr != nil {
  22918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22920. return
  22921. }
  22922. var respJSON map[string]interface{}
  22923. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22926. return
  22927. }
  22928. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22929. result, _ := json.Marshal(respJSON)
  22930. fmt.Println("log")
  22931. fmt.Println(string(result))
  22932. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22933. utils.ErrorLog("解析失败:%v", err)
  22934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22935. return
  22936. }
  22937. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22938. if reg_type == 11 && his.Insutype == "390" {
  22939. reg_type = 110104
  22940. }
  22941. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22942. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22943. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22944. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22945. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22946. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22947. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22948. resp, requestErr := http.Get(api)
  22949. if requestErr != nil {
  22950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22951. return
  22952. }
  22953. body, ioErr := ioutil.ReadAll(resp.Body)
  22954. if ioErr != nil {
  22955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22957. return
  22958. }
  22959. var respJSON map[string]interface{}
  22960. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22963. return
  22964. }
  22965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22966. result, _ := json.Marshal(respJSON)
  22967. fmt.Println("log")
  22968. fmt.Println(string(result))
  22969. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22970. utils.ErrorLog("解析失败:%v", err)
  22971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22972. return
  22973. }
  22974. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22975. if reg_type == 11 && his.Insutype == "390" {
  22976. reg_type = 110104
  22977. }
  22978. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22979. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22980. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22981. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22982. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22983. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22984. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22985. resp, requestErr := http.Get(api)
  22986. if requestErr != nil {
  22987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22988. return
  22989. }
  22990. body, ioErr := ioutil.ReadAll(resp.Body)
  22991. if ioErr != nil {
  22992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22994. return
  22995. }
  22996. var respJSON map[string]interface{}
  22997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23000. return
  23001. }
  23002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23003. result, _ := json.Marshal(respJSON)
  23004. fmt.Println("log")
  23005. fmt.Println(string(result))
  23006. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23007. utils.ErrorLog("解析失败:%v", err)
  23008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23009. return
  23010. }
  23011. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23012. if reg_type == 11 && his.Insutype == "390" {
  23013. reg_type = 110104
  23014. }
  23015. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23016. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23017. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23018. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23019. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23020. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23021. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23022. resp, requestErr := http.Get(api)
  23023. if requestErr != nil {
  23024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23025. return
  23026. }
  23027. body, ioErr := ioutil.ReadAll(resp.Body)
  23028. if ioErr != nil {
  23029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23031. return
  23032. }
  23033. var respJSON map[string]interface{}
  23034. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23037. return
  23038. }
  23039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23040. result, _ := json.Marshal(respJSON)
  23041. fmt.Println("log")
  23042. fmt.Println(string(result))
  23043. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23044. utils.ErrorLog("解析失败:%v", err)
  23045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23046. return
  23047. }
  23048. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23049. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23050. if result3101.Infcode == "0" {
  23051. if len(result3101.Output.Result) > 0 {
  23052. var errMsgs []string
  23053. for _, item := range result3101.Output.Result {
  23054. errMsgs = append(errMsgs, item.VolaCont)
  23055. }
  23056. c.ServeSuccessJSON(map[string]interface{}{
  23057. "failed_code": -10,
  23058. "msg": errMsgs,
  23059. })
  23060. return
  23061. } else {
  23062. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23063. if his.IdCardType != 4 {
  23064. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23065. bas := strings.Split(psn_info.CardInfo, "|")
  23066. if his.IdCardType == 1 {
  23067. cert_no = bas[2]
  23068. } else {
  23069. cert_no = bas[1]
  23070. }
  23071. } else {
  23072. cert_no = his.Certno
  23073. }
  23074. //江苏地区国家医保医疗类别
  23075. //职工透析:医疗类别选特殊情况门诊9933
  23076. //居民血透门慢: 医疗类别选门诊慢病1402
  23077. //var med_type string
  23078. //if his.Insutype == "310" {
  23079. // if reg_type == 14 {
  23080. // med_type = "9933"
  23081. // } else if reg_type == 11 {
  23082. // med_type = "11"
  23083. //
  23084. // }
  23085. //} else if his.Insutype == "390" {
  23086. // if reg_type == 14 {
  23087. // med_type = "1402"
  23088. // } else if reg_type == 11 {
  23089. // med_type = "11"
  23090. // }
  23091. //}
  23092. var api string
  23093. if miConfig.MdtrtareaAdmvs == "320921" {
  23094. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23095. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23096. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23097. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23098. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23099. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23100. "&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
  23101. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23102. } else {
  23103. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23104. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23105. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23106. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23107. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23108. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23109. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23110. "&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
  23111. }
  23112. resp, requestErr := http.Get(api)
  23113. if requestErr != nil {
  23114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23115. return
  23116. }
  23117. body, ioErr := ioutil.ReadAll(resp.Body)
  23118. if ioErr != nil {
  23119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23121. return
  23122. }
  23123. var respJSON map[string]interface{}
  23124. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23127. return
  23128. }
  23129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23130. result, _ := json.Marshal(respJSON)
  23131. fmt.Println("log")
  23132. fmt.Println(string(result))
  23133. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  23134. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23135. utils.ErrorLog("解析失败:%v", err)
  23136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23137. return
  23138. }
  23139. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23140. res.Output = resSeven10265.Output
  23141. res.ErrMsg = resSeven10265.ErrMsg
  23142. res.Cainfo = resSeven10265.Cainfo
  23143. res.WarnMsg = resSeven10265.WarnMsg
  23144. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23145. res.Infcode = infocode
  23146. } else {
  23147. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  23148. utils.ErrorLog("解析失败:%v", err)
  23149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23150. return
  23151. }
  23152. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  23153. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  23154. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  23155. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  23156. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23157. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  23158. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  23159. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  23160. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  23161. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  23162. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  23163. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23164. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  23165. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  23166. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23167. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23168. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  23169. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  23170. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  23171. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  23172. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  23173. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23174. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  23175. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  23176. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  23177. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  23178. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  23179. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  23180. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  23181. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  23182. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23183. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  23184. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  23185. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  23186. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23187. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23188. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23189. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23190. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  23191. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23192. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  23193. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  23194. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  23195. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  23196. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  23197. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  23198. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  23199. res.ErrMsg = resSeven10265Two.ErrMsg
  23200. res.Cainfo = resSeven10265Two.Cainfo
  23201. res.WarnMsg = resSeven10265Two.WarnMsg
  23202. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23203. res.Infcode = infocode
  23204. }
  23205. }
  23206. }
  23207. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23208. psn_info, _ := service.GetPsnByPatientId(id)
  23209. var verify_number string
  23210. if psn_info.IdCardType == 4 {
  23211. verify_number = psn_info.VerifyNumber
  23212. } else if psn_info.IdCardType == 1 {
  23213. bas := strings.Split(psn_info.CardInfo, "|")
  23214. cardNumber := bas[2]
  23215. verify_number = cardNumber
  23216. } else {
  23217. psn_info.IdCardType = 2
  23218. verify_number = psn_info.Certno
  23219. }
  23220. var api string
  23221. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23222. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23223. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23224. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23225. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  23226. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23227. "&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
  23228. resp, requestErr := http.Get(api)
  23229. if requestErr != nil {
  23230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23231. return
  23232. }
  23233. body, ioErr := ioutil.ReadAll(resp.Body)
  23234. if ioErr != nil {
  23235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23237. return
  23238. }
  23239. var respJSON map[string]interface{}
  23240. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23243. return
  23244. }
  23245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23246. result, _ := json.Marshal(respJSON)
  23247. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23248. utils.ErrorLog("解析失败:%v", err)
  23249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23250. return
  23251. }
  23252. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23253. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  23254. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  23255. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23256. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  23257. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  23258. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  23259. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  23260. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  23261. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  23262. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  23263. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  23264. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  23265. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23266. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  23267. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  23268. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  23269. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  23270. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  23271. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  23272. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23273. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  23274. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  23275. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  23276. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  23277. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  23278. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  23279. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  23280. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  23281. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  23282. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  23283. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  23284. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  23285. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  23286. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23287. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  23288. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  23289. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  23290. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  23291. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  23292. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  23293. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  23294. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  23295. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  23296. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  23297. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  23298. res.ErrMsg = resSeven10265.ErrMsg
  23299. res.Cainfo = resSeven10265.Cainfo
  23300. res.WarnMsg = resSeven10265.WarnMsg
  23301. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23302. res.Infcode = infocode
  23303. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23304. acct_used_flag := "1"
  23305. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  23306. var result string
  23307. var request_log string
  23308. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  23309. 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)
  23310. } else {
  23311. 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)
  23312. }
  23313. var dat map[string]interface{}
  23314. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23315. fmt.Println(dat)
  23316. } else {
  23317. fmt.Println(err)
  23318. }
  23319. saveLog(result, request_log, "2206", "预结算")
  23320. userJSONBytes, _ := json.Marshal(dat)
  23321. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23322. utils.ErrorLog("解析失败:%v", err)
  23323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23324. return
  23325. }
  23326. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23327. var result string
  23328. var request_log string
  23329. if his.IdCardType == 2 {
  23330. 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, "")
  23331. } else if his.IdCardType == 1 {
  23332. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23333. bas := strings.Split(psn_info.CardInfo, "|")
  23334. basNumber := bas[2]
  23335. card_sn := bas[3]
  23336. var rf []*ResultFive
  23337. json.Unmarshal([]byte(his.Iinfo), &rf)
  23338. var psn_type string
  23339. for _, item := range rf {
  23340. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  23341. psn_type = item.PsnType
  23342. }
  23343. }
  23344. 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)
  23345. } else {
  23346. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23347. 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, "")
  23348. }
  23349. var dat map[string]interface{}
  23350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23351. fmt.Println(dat)
  23352. } else {
  23353. fmt.Println(err)
  23354. }
  23355. saveLog(result, request_log, "2206", "预结算")
  23356. userJSONBytes, _ := json.Marshal(dat)
  23357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23358. utils.ErrorLog("解析失败:%v", err)
  23359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23360. return
  23361. }
  23362. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23363. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23364. if his.IdCardType == 4 {
  23365. psn_info.VerifyNumber = psn_info.VerifyNumber
  23366. cert_no = psn_info.Certno
  23367. } else if his.IdCardType == 2 {
  23368. cert_no = psn_info.Certno
  23369. psn_info.VerifyNumber = psn_info.Certno
  23370. } else {
  23371. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23372. bas := strings.Split(psn_info.CardInfo, "|")
  23373. if his.IdCardType == 1 {
  23374. cert_no = bas[2]
  23375. } else {
  23376. cert_no = bas[1]
  23377. }
  23378. }
  23379. var api string
  23380. var med_type string
  23381. if his.Insutype == "390" {
  23382. if reg_type == 992102 {
  23383. med_type = "992102"
  23384. }
  23385. if reg_type == 140104 {
  23386. med_type = "140104"
  23387. }
  23388. if reg_type == 14 {
  23389. med_type = "140104"
  23390. }
  23391. } else if his.Insutype == "310" {
  23392. if reg_type == 992102 {
  23393. med_type = "992102"
  23394. }
  23395. if reg_type == 14 {
  23396. med_type = "14"
  23397. }
  23398. }
  23399. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23400. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23401. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23402. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23403. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23404. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23405. "&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
  23406. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23407. resp, requestErr := http.Get(api)
  23408. if requestErr != nil {
  23409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23410. return
  23411. }
  23412. body, ioErr := ioutil.ReadAll(resp.Body)
  23413. if ioErr != nil {
  23414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23416. return
  23417. }
  23418. var respJSON map[string]interface{}
  23419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23422. return
  23423. }
  23424. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23425. if status == "0" {
  23426. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23427. c.ServeSuccessJSON(map[string]interface{}{
  23428. "failed_code": -10,
  23429. "msg": err_msg,
  23430. })
  23431. return
  23432. }
  23433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23434. result, _ := json.Marshal(respJSON)
  23435. fmt.Println("log")
  23436. fmt.Println(string(result))
  23437. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  23438. utils.ErrorLog("解析失败:%v", err)
  23439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23440. return
  23441. }
  23442. res.InfRefmsgid = ahres.InfRefmsgid
  23443. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23444. // 创建对应的Time类型
  23445. t := time.UnixMilli(timestamp)
  23446. // 格式化成指定的日期字符串
  23447. str := t.Format("2006-01-02 15:04:05")
  23448. res.Output.Setlinfo.SetlTime = str
  23449. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23450. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23451. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23452. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23453. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23454. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23455. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23456. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23457. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23458. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23459. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23460. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23461. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23462. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23463. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23464. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23465. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23466. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23467. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23468. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23469. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23470. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23471. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23472. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23473. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23474. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23475. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23476. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23477. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23478. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23479. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23480. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23481. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23482. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  23483. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23484. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  23485. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  23486. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  23487. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  23488. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23489. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  23490. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23491. //res.Output.Setldetail = ahres.Output.Setldetail
  23492. res.ErrMsg = ahres.ErrMsg
  23493. res.Cainfo = ahres.Cainfo
  23494. res.WarnMsg = ahres.WarnMsg
  23495. res.Infcode = ahres.Infcode
  23496. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23497. var result string
  23498. var request_log string
  23499. if his.IdCardType == 2 {
  23500. 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")
  23501. } else if his.IdCardType == 1 {
  23502. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23503. bas := strings.Split(psn_info.CardInfo, "|")
  23504. basNumber := bas[2]
  23505. card_sn := bas[3]
  23506. 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")
  23507. } else {
  23508. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23509. 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")
  23510. }
  23511. var dat map[string]interface{}
  23512. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23513. fmt.Println(dat)
  23514. } else {
  23515. fmt.Println(err)
  23516. }
  23517. saveLog(result, request_log, "2206", "预结算")
  23518. userJSONBytes, _ := json.Marshal(dat)
  23519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23520. utils.ErrorLog("解析失败:%v", err)
  23521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23522. return
  23523. }
  23524. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23525. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23526. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23527. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23528. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23529. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23530. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23531. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23532. resp, requestErr := http.Get(api)
  23533. if requestErr != nil {
  23534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23535. return
  23536. }
  23537. body, ioErr := ioutil.ReadAll(resp.Body)
  23538. if ioErr != nil {
  23539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23541. return
  23542. }
  23543. var respJSON map[string]interface{}
  23544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23547. return
  23548. }
  23549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23550. result, _ := json.Marshal(respJSON)
  23551. fmt.Println("log")
  23552. fmt.Println(string(result))
  23553. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23554. utils.ErrorLog("解析失败:%v", err)
  23555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23556. return
  23557. }
  23558. } else {
  23559. if miConfig.MdtrtareaAdmvs == "441202" {
  23560. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23561. if result3101.Infcode == 0 {
  23562. if len(result3101.Output.Result) > 0 {
  23563. var errMsgs []string
  23564. for _, item := range result3101.Output.Result {
  23565. errMsgs = append(errMsgs, item.VolaCont)
  23566. }
  23567. c.ServeSuccessJSON(map[string]interface{}{
  23568. "failed_code": -10,
  23569. "msg": errMsgs,
  23570. })
  23571. return
  23572. } else {
  23573. var result string
  23574. var request_log string
  23575. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23576. allTotal = fmt.Sprintf("%.2f", total_two)
  23577. if his.IdCardType == 4 {
  23578. 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)
  23579. } else {
  23580. 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)
  23581. }
  23582. var dat map[string]interface{}
  23583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23584. fmt.Println(dat)
  23585. } else {
  23586. fmt.Println(err)
  23587. }
  23588. saveLog(result, request_log, "2206", "预结算")
  23589. //userJSONBytes, _ := json.Marshal(dat)
  23590. //
  23591. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23592. // utils.ErrorLog("解析失败:%v", err)
  23593. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23594. // return
  23595. //}
  23596. userJSONBytes, _ := json.Marshal(dat)
  23597. if miConfig.Code == "H15049901371" {
  23598. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23599. utils.ErrorLog("解析失败:%v", err)
  23600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23601. return
  23602. }
  23603. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23604. res.Output = resSeven10265.Output
  23605. res.ErrMsg = resSeven10265.ErrMsg
  23606. res.Cainfo = resSeven10265.Cainfo
  23607. res.WarnMsg = resSeven10265.WarnMsg
  23608. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23609. res.Infcode = infocode
  23610. } else {
  23611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23612. utils.ErrorLog("解析失败:%v", err)
  23613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23614. return
  23615. }
  23616. }
  23617. }
  23618. } else {
  23619. c.ServeSuccessJSON(map[string]interface{}{
  23620. "failed_code": -10,
  23621. "msg": result3101.ErrMsg,
  23622. })
  23623. return
  23624. }
  23625. } else {
  23626. var result string
  23627. var request_log string
  23628. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23629. allTotal = fmt.Sprintf("%.2f", total_two)
  23630. if his.IdCardType == 4 {
  23631. 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)
  23632. } else {
  23633. 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)
  23634. }
  23635. var dat map[string]interface{}
  23636. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23637. fmt.Println(dat)
  23638. } else {
  23639. fmt.Println(err)
  23640. }
  23641. saveLog(result, request_log, "2206", "预结算")
  23642. //userJSONBytes, _ := json.Marshal(dat)
  23643. //
  23644. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23645. // utils.ErrorLog("解析失败:%v", err)
  23646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23647. // return
  23648. //}
  23649. userJSONBytes, _ := json.Marshal(dat)
  23650. if miConfig.Code == "H15049901371" {
  23651. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23652. utils.ErrorLog("解析失败:%v", err)
  23653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23654. return
  23655. }
  23656. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23657. res.Output = resSeven10265.Output
  23658. res.ErrMsg = resSeven10265.ErrMsg
  23659. res.Cainfo = resSeven10265.Cainfo
  23660. res.WarnMsg = resSeven10265.WarnMsg
  23661. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23662. res.Infcode = infocode
  23663. } else {
  23664. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23665. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  23666. utils.ErrorLog("解析失败:%v", err)
  23667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23668. return
  23669. }
  23670. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  23671. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  23672. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  23673. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23674. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  23675. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  23676. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  23677. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23678. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  23679. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23680. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23681. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23682. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23683. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23684. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23685. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  23686. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  23687. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  23688. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  23689. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  23690. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23691. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  23692. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  23693. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  23694. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  23695. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  23696. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  23697. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  23698. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  23699. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23700. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  23701. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  23702. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  23703. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23704. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23705. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23706. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23707. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  23708. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23709. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  23710. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  23711. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  23712. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  23713. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  23714. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  23715. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  23716. res.ErrMsg = gzresSeven10265Two.ErrMsg
  23717. res.Cainfo = gzresSeven10265Two.Cainfo
  23718. res.WarnMsg = gzresSeven10265Two.WarnMsg
  23719. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23720. //res.Infcode = infocode
  23721. } else {
  23722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23723. utils.ErrorLog("解析失败:%v", err)
  23724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23725. return
  23726. }
  23727. }
  23728. }
  23729. }
  23730. }
  23731. utils.ErrorLog("解析失败:%v", res.Infcode)
  23732. if res.Infcode == -1 {
  23733. errlog := &models.HisOrderError{
  23734. UserOrgId: adminUser.CurrentOrgId,
  23735. Ctime: time.Now().Unix(),
  23736. Mtime: time.Now().Unix(),
  23737. Number: chrg_bchno,
  23738. ErrMsg: res.ErrMsg,
  23739. Status: 1,
  23740. PatientId: id,
  23741. RecordTime: recordDateTime,
  23742. Stage: 20,
  23743. }
  23744. service.CreateErrMsgLog(errlog)
  23745. c.ServeSuccessJSON(map[string]interface{}{
  23746. "failed_code": -10,
  23747. "msg": res.ErrMsg,
  23748. })
  23749. return
  23750. }
  23751. if res.Infcode != 0 {
  23752. errlog := &models.HisOrderError{
  23753. UserOrgId: adminUser.CurrentOrgId,
  23754. Ctime: time.Now().Unix(),
  23755. Mtime: time.Now().Unix(),
  23756. Number: chrg_bchno,
  23757. ErrMsg: res.ErrMsg,
  23758. Status: 1,
  23759. PatientId: id,
  23760. RecordTime: recordDateTime,
  23761. Stage: 20,
  23762. }
  23763. service.CreateErrMsgLog(errlog)
  23764. c.ServeSuccessJSON(map[string]interface{}{
  23765. "failed_code": -10,
  23766. "msg": res.ErrMsg,
  23767. })
  23768. return
  23769. } else {
  23770. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  23771. order.OrderStatus = 1
  23772. order.IsPre = 1
  23773. order.Status = 1
  23774. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  23775. order.SetlId = res.Output.Setlinfo.SetlID
  23776. order.PsnNo = res.Output.Setlinfo.PsnNo
  23777. order.PsnName = res.Output.Setlinfo.PsnName
  23778. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  23779. order.Certno = res.Output.Setlinfo.Certno
  23780. order.Gend = res.Output.Setlinfo.Gend
  23781. order.Naty = res.Output.Setlinfo.Naty
  23782. order.Age = res.Output.Setlinfo.Age
  23783. order.Insutype = res.Output.Setlinfo.Insutype
  23784. order.PsnType = res.Output.Setlinfo.PsnType
  23785. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  23786. order.SetlTime = res.Output.Setlinfo.SetlTime
  23787. order.AcctUsedFlag = acct_used_flag
  23788. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  23789. if res.Output.Setlinfo.MedType == "140101" {
  23790. order.MedType = "14"
  23791. } else {
  23792. if res.Output.Setlinfo.MedType == "110104" {
  23793. order.MedType = "11"
  23794. } else {
  23795. order.MedType = res.Output.Setlinfo.MedType
  23796. }
  23797. }
  23798. if res.Output.Setlinfo.MedType == "992102" {
  23799. order.MedType = "992102"
  23800. }
  23801. if res.Output.Setlinfo.MedType == "140104" {
  23802. order.MedType = "140104"
  23803. }
  23804. if res.Output.Setlinfo.MedType == "14" {
  23805. order.MedType = "14"
  23806. }
  23807. if reg_type == 1112 {
  23808. order.MedType = "1112"
  23809. }
  23810. if reg_type == 1111 {
  23811. order.MedType = "1111"
  23812. }
  23813. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  23814. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  23815. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  23816. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  23817. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  23818. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  23819. order.HifpPay = res.Output.Setlinfo.HifpPay
  23820. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  23821. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  23822. order.HifesPay = res.Output.Setlinfo.HifesPay
  23823. order.HifobPay = res.Output.Setlinfo.HifobPay
  23824. order.MafPay = res.Output.Setlinfo.MafPay
  23825. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  23826. order.OthPay = res.Output.Setlinfo.OthPay
  23827. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  23828. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  23829. order.AcctPay = res.Output.Setlinfo.AcctPay
  23830. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  23831. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  23832. order.Balc = res.Output.Setlinfo.Balc
  23833. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  23834. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  23835. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  23836. order.ClrWay = res.Output.Setlinfo.ClrWay
  23837. order.Creator = order.Creator
  23838. order.Modify = roles.AdminUserId
  23839. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  23840. //detailStr := string(setlDetail)
  23841. //order.SetlDetail = detailStr
  23842. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  23843. err = service.UpDateOrder(order)
  23844. if err == nil {
  23845. c.ServeSuccessJSON(map[string]interface{}{
  23846. "msg": "预结算成功",
  23847. })
  23848. } else {
  23849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  23850. return
  23851. }
  23852. }
  23853. } else {
  23854. adminUser := c.GetAdminUserInfo()
  23855. errlog := &models.HisOrderError{
  23856. UserOrgId: adminUser.CurrentOrgId,
  23857. Ctime: time.Now().Unix(),
  23858. Mtime: time.Now().Unix(),
  23859. ErrMsg: res.ErrMsg,
  23860. Status: 1,
  23861. PatientId: id,
  23862. RecordTime: recordDateTime,
  23863. Stage: 4,
  23864. }
  23865. service.CreateErrMsgLog(errlog)
  23866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  23867. return
  23868. }
  23869. } else {
  23870. if miConfig.MdtrtareaAdmvs == "150499" {
  23871. order := &models.HisOrder{
  23872. UserOrgId: adminUser.CurrentOrgId,
  23873. HisPatientId: his.ID,
  23874. PatientId: his.PatientId,
  23875. SettleAccountsDate: recordDateTime,
  23876. Ctime: time.Now().Unix(),
  23877. Mtime: time.Now().Unix(),
  23878. MdtrtId: his.Number,
  23879. PsnNo: his.PsnNo,
  23880. MedType: strconv.FormatInt(reg_type, 10),
  23881. Status: 1,
  23882. Number: chrg_bchno,
  23883. Infcode: res.Infcode,
  23884. WarnMsg: res.WarnMsg,
  23885. Cainfo: res.Cainfo,
  23886. ErrMsg: res.ErrMsg,
  23887. RespondTime: res.RefmsgTime,
  23888. InfRefmsgid: res.InfRefmsgid,
  23889. OrderStatus: 1,
  23890. IsMedicineInsurance: 1,
  23891. SettleType: settle_accounts_type,
  23892. SettleStartTime: start_time,
  23893. SettleEndTime: end_time,
  23894. Creator: roles.AdminUserId,
  23895. Modify: roles.AdminUserId,
  23896. PType: 2,
  23897. Diagnosis: diagnosis_id,
  23898. }
  23899. err = service.CreateOrder(order)
  23900. if err != nil {
  23901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23902. return
  23903. }
  23904. }
  23905. adminUser := c.GetAdminUserInfo()
  23906. errlog := &models.HisOrderError{
  23907. UserOrgId: adminUser.CurrentOrgId,
  23908. Ctime: time.Now().Unix(),
  23909. Mtime: time.Now().Unix(),
  23910. ErrMsg: res.ErrMsg,
  23911. Status: 1,
  23912. PatientId: id,
  23913. RecordTime: recordDateTime,
  23914. Stage: 4,
  23915. }
  23916. service.CreateErrMsgLog(errlog)
  23917. c.ServeSuccessJSON(map[string]interface{}{
  23918. "failed_code": -10,
  23919. "msg": res.ErrMsg,
  23920. })
  23921. return
  23922. }
  23923. }
  23924. }
  23925. }
  23926. // 退款
  23927. func (c *HisApiController) Refund() {
  23928. order_id, _ := c.GetInt64("order_id")
  23929. admin_user_id, _ := c.GetInt64("admin_user_id")
  23930. adminUser := c.GetAdminUserInfo()
  23931. var order models.HisOrder
  23932. order, _ = service.GetHisOrderByID(order_id)
  23933. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23934. if order.ID == 0 {
  23935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23936. return
  23937. }
  23938. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23939. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23940. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23941. if config.IsOpen == 1 { //对接了医保,走医保流程
  23942. var res ResultSixteen
  23943. var ahres ResultSevenAH
  23944. var resSixteen10265 ResultSixteen10265
  23945. var resSixteen10265Two ResultSixteen10265Two
  23946. var gz ResultgzSixteen10265Two
  23947. var src_resquest string
  23948. var result string
  23949. if miConfig.MdtrtareaAdmvs == "421300" {
  23950. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23951. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23952. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23953. resp3, requestErr3 := http.Get(api3)
  23954. if requestErr3 != nil {
  23955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23956. return
  23957. }
  23958. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23959. if ioErr3 != nil {
  23960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23962. return
  23963. }
  23964. var respJSON3 map[string]interface{}
  23965. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23968. return
  23969. }
  23970. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23971. userJSONBytes3, _ := json.Marshal(respJSON3)
  23972. fmt.Println("log")
  23973. fmt.Println(string(userJSONBytes3))
  23974. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23975. utils.ErrorLog("解析失败:%v", err)
  23976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23977. return
  23978. }
  23979. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23980. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23981. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23982. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23983. resp3, requestErr3 := http.Get(api3)
  23984. if requestErr3 != nil {
  23985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23986. return
  23987. }
  23988. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23989. if ioErr3 != nil {
  23990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23992. return
  23993. }
  23994. var respJSON3 map[string]interface{}
  23995. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23998. return
  23999. }
  24000. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24001. userJSONBytes3, _ := json.Marshal(respJSON3)
  24002. fmt.Println("log")
  24003. fmt.Println(string(userJSONBytes3))
  24004. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24005. utils.ErrorLog("解析失败:%v", err)
  24006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24007. return
  24008. }
  24009. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24010. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  24011. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24012. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24013. resp3, requestErr3 := http.Get(api3)
  24014. if requestErr3 != nil {
  24015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24016. return
  24017. }
  24018. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24019. if ioErr3 != nil {
  24020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24022. return
  24023. }
  24024. var respJSON3 map[string]interface{}
  24025. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24028. return
  24029. }
  24030. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24031. userJSONBytes3, _ := json.Marshal(respJSON3)
  24032. fmt.Println("log")
  24033. fmt.Println(string(userJSONBytes3))
  24034. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24035. utils.ErrorLog("解析失败:%v", err)
  24036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24037. return
  24038. }
  24039. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24040. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  24041. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24042. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24043. resp3, requestErr3 := http.Get(api3)
  24044. if requestErr3 != nil {
  24045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24046. return
  24047. }
  24048. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24049. if ioErr3 != nil {
  24050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24052. return
  24053. }
  24054. var respJSON3 map[string]interface{}
  24055. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24058. return
  24059. }
  24060. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24061. userJSONBytes3, _ := json.Marshal(respJSON3)
  24062. fmt.Println("log")
  24063. fmt.Println(string(userJSONBytes3))
  24064. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24065. utils.ErrorLog("解析失败:%v", err)
  24066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24067. return
  24068. }
  24069. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24070. var api3 string
  24071. if miConfig.MdtrtareaAdmvs == "320921" {
  24072. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  24073. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24074. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24075. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24076. } else {
  24077. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24078. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  24079. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24080. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24081. }
  24082. resp3, requestErr3 := http.Get(api3)
  24083. if requestErr3 != nil {
  24084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24085. return
  24086. }
  24087. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24088. if ioErr3 != nil {
  24089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24091. return
  24092. }
  24093. var respJSON3 map[string]interface{}
  24094. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24097. return
  24098. }
  24099. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24100. userJSONBytes3, _ := json.Marshal(respJSON3)
  24101. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  24102. utils.ErrorLog("解析失败:%v", err)
  24103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24104. return
  24105. }
  24106. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24107. res.Output = resSixteen10265.Output
  24108. res.ErrMsg = resSixteen10265.ErrMsg
  24109. res.Cainfo = resSixteen10265.Cainfo
  24110. res.WarnMsg = resSixteen10265.WarnMsg
  24111. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24112. res.Infcode = infocode
  24113. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24114. var api3 string
  24115. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  24116. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24117. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24118. resp3, requestErr3 := http.Get(api3)
  24119. if requestErr3 != nil {
  24120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24121. return
  24122. }
  24123. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24124. if ioErr3 != nil {
  24125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24127. return
  24128. }
  24129. var respJSON3 map[string]interface{}
  24130. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24133. return
  24134. }
  24135. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24136. userJSONBytes3, _ := json.Marshal(respJSON3)
  24137. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  24138. utils.ErrorLog("解析失败:%v", err)
  24139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24140. return
  24141. }
  24142. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24143. res.Output = resSixteen10265.Output
  24144. res.ErrMsg = resSixteen10265.ErrMsg
  24145. res.Cainfo = resSixteen10265.Cainfo
  24146. res.WarnMsg = resSixteen10265.WarnMsg
  24147. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24148. res.Infcode = infocode
  24149. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24150. 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)
  24151. var dat map[string]interface{}
  24152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24153. fmt.Println(dat)
  24154. } else {
  24155. fmt.Println(err)
  24156. }
  24157. saveLog(result, src_resquest, "2208", "退费")
  24158. userJSONBytes, _ := json.Marshal(dat)
  24159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24160. utils.ErrorLog("解析失败:%v", err)
  24161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24162. return
  24163. }
  24164. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24165. 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, "")
  24166. var dat map[string]interface{}
  24167. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24168. fmt.Println(dat)
  24169. } else {
  24170. fmt.Println(err)
  24171. }
  24172. saveLog(result, src_resquest, "2208", "退费")
  24173. userJSONBytes, _ := json.Marshal(dat)
  24174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24175. utils.ErrorLog("解析失败:%v", err)
  24176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24177. return
  24178. }
  24179. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24180. var api3 string
  24181. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  24182. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24183. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24184. resp3, requestErr3 := http.Get(api3)
  24185. if requestErr3 != nil {
  24186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24187. return
  24188. }
  24189. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24190. if ioErr3 != nil {
  24191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24193. return
  24194. }
  24195. var respJSON3 map[string]interface{}
  24196. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24199. return
  24200. }
  24201. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24202. if status == "0" {
  24203. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24204. c.ServeSuccessJSON(map[string]interface{}{
  24205. "failed_code": -10,
  24206. "msg": err_msg,
  24207. })
  24208. return
  24209. }
  24210. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24211. userJSONBytes3, _ := json.Marshal(respJSON3)
  24212. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24213. // utils.ErrorLog("解析失败:%v", err)
  24214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24215. // return
  24216. //}
  24217. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  24218. utils.ErrorLog("解析失败:%v", err)
  24219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24220. return
  24221. }
  24222. res.InfRefmsgid = ahres.InfRefmsgid
  24223. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  24224. // 创建对应的Time类型
  24225. t := time.UnixMilli(timestamp)
  24226. // 格式化成指定的日期字符串
  24227. str := t.Format("2006-01-02 15:04:05")
  24228. res.Output.Setlinfo.SetlTime = str
  24229. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  24230. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  24231. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24232. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  24233. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  24234. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  24235. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24236. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  24237. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  24238. //
  24239. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  24240. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  24241. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  24242. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24243. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  24244. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  24245. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  24246. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  24247. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  24248. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  24249. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24250. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  24251. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  24252. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  24253. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  24254. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  24255. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  24256. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  24257. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  24258. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  24259. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  24260. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  24261. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  24262. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  24263. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  24264. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  24265. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  24266. //res.Output.Setldetail = ahres.Output.Setldetail
  24267. res.ErrMsg = ahres.ErrMsg
  24268. res.Cainfo = ahres.Cainfo
  24269. res.WarnMsg = ahres.WarnMsg
  24270. res.Infcode = ahres.Infcode
  24271. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24272. 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, "")
  24273. var dat map[string]interface{}
  24274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24275. fmt.Println(dat)
  24276. } else {
  24277. fmt.Println(err)
  24278. }
  24279. saveLog(result, src_resquest, "2208", "退费")
  24280. userJSONBytes, _ := json.Marshal(dat)
  24281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24282. utils.ErrorLog("解析失败:%v", err)
  24283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24284. return
  24285. }
  24286. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24287. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  24288. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24289. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24290. resp3, requestErr3 := http.Get(api3)
  24291. if requestErr3 != nil {
  24292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24293. return
  24294. }
  24295. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24296. if ioErr3 != nil {
  24297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24299. return
  24300. }
  24301. var respJSON3 map[string]interface{}
  24302. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24305. return
  24306. }
  24307. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24308. userJSONBytes3, _ := json.Marshal(respJSON3)
  24309. fmt.Println("log")
  24310. fmt.Println(string(userJSONBytes3))
  24311. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24312. utils.ErrorLog("解析失败:%v", err)
  24313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24314. return
  24315. }
  24316. } else {
  24317. if miConfig.Code == "H15049901371" {
  24318. 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)
  24319. var dat map[string]interface{}
  24320. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24321. fmt.Println(dat)
  24322. } else {
  24323. fmt.Println(err)
  24324. }
  24325. saveLog(result, src_resquest, "2208", "退费")
  24326. userJSONBytes, _ := json.Marshal(dat)
  24327. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  24328. utils.ErrorLog("解析失败:%v", err)
  24329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24330. return
  24331. }
  24332. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24333. res.Output = resSixteen10265.Output
  24334. res.ErrMsg = resSixteen10265.ErrMsg
  24335. res.Cainfo = resSixteen10265.Cainfo
  24336. res.WarnMsg = resSixteen10265.WarnMsg
  24337. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24338. res.Infcode = infocode
  24339. } else {
  24340. 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)
  24341. var dat map[string]interface{}
  24342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24343. fmt.Println(dat)
  24344. } else {
  24345. fmt.Println(err)
  24346. }
  24347. saveLog(result, src_resquest, "2208", "退费")
  24348. userJSONBytes, _ := json.Marshal(dat)
  24349. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24350. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  24351. utils.ErrorLog("解析失败:%v", err)
  24352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24353. return
  24354. }
  24355. res.Infcode = gz.Infcode
  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. }
  24365. if res.Infcode == 0 {
  24366. var res2 ResultSix
  24367. var resSix10265 ResultSix10265
  24368. if miConfig.MdtrtareaAdmvs == "421300" {
  24369. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24370. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24371. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24372. resp3, requestErr3 := http.Get(api3)
  24373. if requestErr3 != nil {
  24374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24375. return
  24376. }
  24377. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24378. if ioErr3 != nil {
  24379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24381. return
  24382. }
  24383. var respJSON3 map[string]interface{}
  24384. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24387. return
  24388. }
  24389. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24390. userJSONBytes3, _ := json.Marshal(respJSON3)
  24391. fmt.Println("log")
  24392. fmt.Println(string(userJSONBytes3))
  24393. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24394. utils.ErrorLog("解析失败:%v", err)
  24395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24396. return
  24397. }
  24398. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24399. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24400. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24401. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24402. resp3, requestErr3 := http.Get(api3)
  24403. if requestErr3 != nil {
  24404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24405. return
  24406. }
  24407. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24408. if ioErr3 != nil {
  24409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24411. return
  24412. }
  24413. var respJSON3 map[string]interface{}
  24414. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24417. return
  24418. }
  24419. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24420. userJSONBytes3, _ := json.Marshal(respJSON3)
  24421. fmt.Println("log")
  24422. fmt.Println(string(userJSONBytes3))
  24423. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24424. utils.ErrorLog("解析失败:%v", err)
  24425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24426. return
  24427. }
  24428. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24429. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24430. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24431. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24432. resp3, requestErr3 := http.Get(api3)
  24433. if requestErr3 != nil {
  24434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24435. return
  24436. }
  24437. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24438. if ioErr3 != nil {
  24439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24441. return
  24442. }
  24443. var respJSON3 map[string]interface{}
  24444. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24447. return
  24448. }
  24449. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24450. userJSONBytes3, _ := json.Marshal(respJSON3)
  24451. fmt.Println("log")
  24452. fmt.Println(string(userJSONBytes3))
  24453. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24454. utils.ErrorLog("解析失败:%v", err)
  24455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24456. return
  24457. }
  24458. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24459. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24460. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24461. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24462. resp3, requestErr3 := http.Get(api3)
  24463. if requestErr3 != nil {
  24464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24465. return
  24466. }
  24467. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24468. if ioErr3 != nil {
  24469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24471. return
  24472. }
  24473. var respJSON3 map[string]interface{}
  24474. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24477. return
  24478. }
  24479. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24480. userJSONBytes3, _ := json.Marshal(respJSON3)
  24481. fmt.Println("log")
  24482. fmt.Println(string(userJSONBytes3))
  24483. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24484. utils.ErrorLog("解析失败:%v", err)
  24485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24486. return
  24487. }
  24488. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24489. var api3 string
  24490. if miConfig.MdtrtareaAdmvs == "320921" {
  24491. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24492. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24493. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24494. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24495. } else {
  24496. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24497. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24498. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24499. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24500. }
  24501. resp3, requestErr3 := http.Get(api3)
  24502. if requestErr3 != nil {
  24503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24504. return
  24505. }
  24506. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24507. if ioErr3 != nil {
  24508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24510. return
  24511. }
  24512. var respJSON3 map[string]interface{}
  24513. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24516. return
  24517. }
  24518. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24519. userJSONBytes3, _ := json.Marshal(respJSON3)
  24520. fmt.Println("log")
  24521. fmt.Println(string(userJSONBytes3))
  24522. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24523. utils.ErrorLog("解析失败:%v", err)
  24524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24525. return
  24526. }
  24527. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24528. res2.Output = resSix10265.Output
  24529. res2.ErrMsg = resSix10265.ErrMsg
  24530. res2.Cainfo = resSix10265.Cainfo
  24531. res2.WarnMsg = resSix10265.WarnMsg
  24532. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24533. res2.Infcode = infocode
  24534. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24535. var api3 string
  24536. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24537. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24538. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24539. resp3, requestErr3 := http.Get(api3)
  24540. if requestErr3 != nil {
  24541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24542. return
  24543. }
  24544. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24545. if ioErr3 != nil {
  24546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24548. return
  24549. }
  24550. var respJSON3 map[string]interface{}
  24551. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24554. return
  24555. }
  24556. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24557. userJSONBytes3, _ := json.Marshal(respJSON3)
  24558. fmt.Println("log")
  24559. fmt.Println(string(userJSONBytes3))
  24560. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24561. utils.ErrorLog("解析失败:%v", err)
  24562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24563. return
  24564. }
  24565. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24566. res2.Output = resSix10265.Output
  24567. res2.ErrMsg = resSix10265.ErrMsg
  24568. res2.Cainfo = resSix10265.Cainfo
  24569. res2.WarnMsg = resSix10265.WarnMsg
  24570. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24571. res2.Infcode = infocode
  24572. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24573. 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)
  24574. var dat map[string]interface{}
  24575. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24576. fmt.Println(dat)
  24577. } else {
  24578. fmt.Println(err)
  24579. }
  24580. saveLog(result2, src_request, "2205", "撤销明细")
  24581. userJSONBytes, _ := json.Marshal(dat)
  24582. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24583. utils.ErrorLog("解析失败:%v", err)
  24584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24585. return
  24586. }
  24587. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24588. 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, "")
  24589. var dat map[string]interface{}
  24590. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24591. fmt.Println(dat)
  24592. } else {
  24593. fmt.Println(err)
  24594. }
  24595. saveLog(result2, src_request, "2205", "撤销明细")
  24596. userJSONBytes, _ := json.Marshal(dat)
  24597. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24598. utils.ErrorLog("解析失败:%v", err)
  24599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24600. return
  24601. }
  24602. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24603. var api3 string
  24604. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24605. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24606. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24607. resp3, requestErr3 := http.Get(api3)
  24608. if requestErr3 != nil {
  24609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24610. return
  24611. }
  24612. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24613. if ioErr3 != nil {
  24614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24616. return
  24617. }
  24618. var respJSON3 map[string]interface{}
  24619. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24622. return
  24623. }
  24624. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24625. if status == "0" {
  24626. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24627. c.ServeSuccessJSON(map[string]interface{}{
  24628. "failed_code": -10,
  24629. "msg": err_msg,
  24630. })
  24631. return
  24632. }
  24633. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24634. userJSONBytes3, _ := json.Marshal(respJSON3)
  24635. fmt.Println("log")
  24636. fmt.Println(string(userJSONBytes3))
  24637. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24638. utils.ErrorLog("解析失败:%v", err)
  24639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24640. return
  24641. }
  24642. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24643. 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, "")
  24644. var dat map[string]interface{}
  24645. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24646. fmt.Println(dat)
  24647. } else {
  24648. fmt.Println(err)
  24649. }
  24650. saveLog(result2, src_request, "2205", "撤销明细")
  24651. userJSONBytes, _ := json.Marshal(dat)
  24652. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24653. utils.ErrorLog("解析失败:%v", err)
  24654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24655. return
  24656. }
  24657. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24658. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  24659. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24660. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24661. resp3, requestErr3 := http.Get(api3)
  24662. if requestErr3 != nil {
  24663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24664. return
  24665. }
  24666. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24667. if ioErr3 != nil {
  24668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24670. return
  24671. }
  24672. var respJSON3 map[string]interface{}
  24673. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24676. return
  24677. }
  24678. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24679. userJSONBytes3, _ := json.Marshal(respJSON3)
  24680. fmt.Println("log")
  24681. fmt.Println(string(userJSONBytes3))
  24682. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24683. utils.ErrorLog("解析失败:%v", err)
  24684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24685. return
  24686. }
  24687. } else {
  24688. if miConfig.Code == "H15049901371" {
  24689. 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)
  24690. var dat map[string]interface{}
  24691. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24692. fmt.Println(dat)
  24693. } else {
  24694. fmt.Println(err)
  24695. }
  24696. saveLog(result2, src_request, "2205", "撤销明细")
  24697. userJSONBytes, _ := json.Marshal(dat)
  24698. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24699. utils.ErrorLog("解析失败:%v", err)
  24700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24701. return
  24702. }
  24703. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24704. res2.Output = resSix10265.Output
  24705. res2.ErrMsg = resSix10265.ErrMsg
  24706. res2.Cainfo = resSix10265.Cainfo
  24707. res2.WarnMsg = resSix10265.WarnMsg
  24708. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24709. res2.Infcode = infocode
  24710. } else {
  24711. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24712. res2.Infcode = 0
  24713. } else {
  24714. 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)
  24715. var dat map[string]interface{}
  24716. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24717. fmt.Println(dat)
  24718. } else {
  24719. fmt.Println(err)
  24720. }
  24721. saveLog(result2, src_request, "2205", "撤销明细")
  24722. userJSONBytes, _ := json.Marshal(dat)
  24723. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24724. utils.ErrorLog("解析失败:%v", err)
  24725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24726. return
  24727. }
  24728. }
  24729. }
  24730. }
  24731. if res2.Infcode == -1 {
  24732. c.ServeSuccessJSON(map[string]interface{}{
  24733. "failed_code": -10,
  24734. "msg": res2.ErrMsg,
  24735. })
  24736. return
  24737. }
  24738. if res2.Infcode == 0 {
  24739. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  24740. if err == nil {
  24741. //当押金不为零时产生退费记录
  24742. if order.Decimal != 0 {
  24743. tmp := strconv.FormatInt(order.ID, 10)
  24744. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  24745. if err != nil {
  24746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24747. return
  24748. }
  24749. }
  24750. c.ServeSuccessJSON(map[string]interface{}{
  24751. "msg": "退费成功",
  24752. })
  24753. } else {
  24754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24755. return
  24756. }
  24757. } else {
  24758. c.ServeSuccessJSON(map[string]interface{}{
  24759. "failed_code": -10,
  24760. "msg": res2.ErrMsg,
  24761. })
  24762. }
  24763. } else {
  24764. c.ServeSuccessJSON(map[string]interface{}{
  24765. "failed_code": -10,
  24766. "msg": res.ErrMsg,
  24767. })
  24768. }
  24769. }
  24770. }
  24771. func (c *HisApiController) RefundNumber() {
  24772. record_time := c.GetString("record_time")
  24773. //patient_id, _ := c.GetInt64("patient_id")
  24774. admin_user_id, _ := c.GetInt64("admin_user_id")
  24775. his_patient_id, _ := c.GetInt64("id")
  24776. timeLayout := "2006-01-02"
  24777. loc, _ := time.LoadLocation("Local")
  24778. adminUser := c.GetAdminUserInfo()
  24779. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24780. fmt.Println(err)
  24781. if err != nil {
  24782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24783. return
  24784. }
  24785. recordDateTime := theTime.Unix()
  24786. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24787. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  24788. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24789. //order, _ := service.GetHisOrderByID(order_id)
  24790. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24791. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24792. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24793. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  24794. if count > 0 {
  24795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  24796. return
  24797. }
  24798. if config.IsOpen == 1 { //对接了医保,走医保流程
  24799. var res2 ResultSix
  24800. var res3 GZResultSix
  24801. var resSix10265 ResultSix10265
  24802. if miConfig.MdtrtareaAdmvs == "421300" {
  24803. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24804. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24805. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24806. resp3, requestErr3 := http.Get(api3)
  24807. if requestErr3 != nil {
  24808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24809. return
  24810. }
  24811. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24812. if ioErr3 != nil {
  24813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24815. return
  24816. }
  24817. var respJSON3 map[string]interface{}
  24818. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24821. return
  24822. }
  24823. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24824. userJSONBytes3, _ := json.Marshal(respJSON3)
  24825. fmt.Println("log")
  24826. fmt.Println(string(userJSONBytes3))
  24827. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24828. utils.ErrorLog("解析失败:%v", err)
  24829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24830. return
  24831. }
  24832. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24833. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24834. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24835. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  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. fmt.Println("log")
  24856. fmt.Println(string(userJSONBytes3))
  24857. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24858. utils.ErrorLog("解析失败:%v", err)
  24859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24860. return
  24861. }
  24862. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24863. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24864. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24865. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24866. resp3, requestErr3 := http.Get(api3)
  24867. if requestErr3 != nil {
  24868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24869. return
  24870. }
  24871. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24872. if ioErr3 != nil {
  24873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24875. return
  24876. }
  24877. var respJSON3 map[string]interface{}
  24878. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24881. return
  24882. }
  24883. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24884. userJSONBytes3, _ := json.Marshal(respJSON3)
  24885. fmt.Println("log")
  24886. fmt.Println(string(userJSONBytes3))
  24887. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24888. utils.ErrorLog("解析失败:%v", err)
  24889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24890. return
  24891. }
  24892. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24893. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24894. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24895. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24896. resp3, requestErr3 := http.Get(api3)
  24897. if requestErr3 != nil {
  24898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24899. return
  24900. }
  24901. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24902. if ioErr3 != nil {
  24903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24905. return
  24906. }
  24907. var respJSON3 map[string]interface{}
  24908. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24911. return
  24912. }
  24913. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24914. userJSONBytes3, _ := json.Marshal(respJSON3)
  24915. fmt.Println("log")
  24916. fmt.Println(string(userJSONBytes3))
  24917. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24918. utils.ErrorLog("解析失败:%v", err)
  24919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24920. return
  24921. }
  24922. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24923. var api3 string
  24924. if miConfig.MdtrtareaAdmvs == "320921" {
  24925. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24926. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24927. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24928. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24929. } else {
  24930. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24931. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24932. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24933. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24934. }
  24935. resp3, requestErr3 := http.Get(api3)
  24936. if requestErr3 != nil {
  24937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24938. return
  24939. }
  24940. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24941. if ioErr3 != nil {
  24942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24944. return
  24945. }
  24946. var respJSON3 map[string]interface{}
  24947. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24950. return
  24951. }
  24952. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24953. userJSONBytes3, _ := json.Marshal(respJSON3)
  24954. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24955. utils.ErrorLog("解析失败:%v", err)
  24956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24957. return
  24958. }
  24959. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24960. res2.Output = resSix10265.Output
  24961. res2.ErrMsg = resSix10265.ErrMsg
  24962. res2.Cainfo = resSix10265.Cainfo
  24963. res2.WarnMsg = resSix10265.WarnMsg
  24964. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24965. res2.Infcode = infocode
  24966. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24967. var api3 string
  24968. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  24969. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24970. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24971. resp3, requestErr3 := http.Get(api3)
  24972. if requestErr3 != nil {
  24973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24974. return
  24975. }
  24976. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24977. if ioErr3 != nil {
  24978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24980. return
  24981. }
  24982. var respJSON3 map[string]interface{}
  24983. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24986. return
  24987. }
  24988. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24989. userJSONBytes3, _ := json.Marshal(respJSON3)
  24990. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24991. utils.ErrorLog("解析失败:%v", err)
  24992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24993. return
  24994. }
  24995. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24996. res2.Output = resSix10265.Output
  24997. res2.ErrMsg = resSix10265.ErrMsg
  24998. res2.Cainfo = resSix10265.Cainfo
  24999. res2.WarnMsg = resSix10265.WarnMsg
  25000. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25001. res2.Infcode = infocode
  25002. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25003. 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)
  25004. var dat map[string]interface{}
  25005. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25006. fmt.Println(dat)
  25007. } else {
  25008. fmt.Println(err)
  25009. }
  25010. saveLog(result, request, "2202", "退号")
  25011. userJSONBytes, _ := json.Marshal(dat)
  25012. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25013. utils.ErrorLog("解析失败:%v", err)
  25014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25015. return
  25016. }
  25017. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25018. 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, "")
  25019. var dat map[string]interface{}
  25020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25021. fmt.Println(dat)
  25022. } else {
  25023. fmt.Println(err)
  25024. }
  25025. saveLog(result, request, "2202", "退号")
  25026. userJSONBytes, _ := json.Marshal(dat)
  25027. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25028. utils.ErrorLog("解析失败:%v", err)
  25029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25030. return
  25031. }
  25032. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25033. var api3 string
  25034. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  25035. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25036. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25037. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25038. resp3, requestErr3 := http.Get(api3)
  25039. if requestErr3 != nil {
  25040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25041. return
  25042. }
  25043. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25044. if ioErr3 != nil {
  25045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25047. return
  25048. }
  25049. var respJSON3 map[string]interface{}
  25050. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25053. return
  25054. }
  25055. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25056. if status == "0" {
  25057. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25058. c.ServeSuccessJSON(map[string]interface{}{
  25059. "failed_code": -10,
  25060. "msg": err_msg,
  25061. })
  25062. return
  25063. }
  25064. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25065. userJSONBytes3, _ := json.Marshal(respJSON3)
  25066. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25067. utils.ErrorLog("解析失败:%v", err)
  25068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25069. return
  25070. }
  25071. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  25072. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25073. 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, "")
  25074. var dat map[string]interface{}
  25075. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25076. fmt.Println(dat)
  25077. } else {
  25078. fmt.Println(err)
  25079. }
  25080. saveLog(result, request, "2202", "退号")
  25081. userJSONBytes, _ := json.Marshal(dat)
  25082. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25083. utils.ErrorLog("解析失败:%v", err)
  25084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25085. return
  25086. }
  25087. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25088. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  25089. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25090. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25091. resp3, requestErr3 := http.Get(api3)
  25092. if requestErr3 != nil {
  25093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25094. return
  25095. }
  25096. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25097. if ioErr3 != nil {
  25098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25100. return
  25101. }
  25102. var respJSON3 map[string]interface{}
  25103. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25106. return
  25107. }
  25108. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25109. userJSONBytes3, _ := json.Marshal(respJSON3)
  25110. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25111. utils.ErrorLog("解析失败:%v", err)
  25112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25113. return
  25114. }
  25115. } else {
  25116. var api3 string
  25117. if miConfig.Code == "H15049901371" {
  25118. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  25119. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25120. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25121. } else {
  25122. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  25123. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25124. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25125. }
  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. if miConfig.Code == "H15049901371" {
  25146. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25147. utils.ErrorLog("解析失败:%v", err)
  25148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25149. return
  25150. }
  25151. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25152. res2.Output = resSix10265.Output
  25153. res2.ErrMsg = resSix10265.ErrMsg
  25154. res2.Cainfo = resSix10265.Cainfo
  25155. res2.WarnMsg = resSix10265.WarnMsg
  25156. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25157. res2.Infcode = infocode
  25158. } else {
  25159. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25160. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  25161. utils.ErrorLog("解析失败:%v", err)
  25162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25163. return
  25164. }
  25165. res2.Infcode = res3.Infcode
  25166. } else {
  25167. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25168. utils.ErrorLog("解析失败:%v", err)
  25169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25170. return
  25171. }
  25172. }
  25173. }
  25174. }
  25175. if res2.Infcode == -1 {
  25176. utils.ErrorLog("解析失败:%v", res2.Infcode)
  25177. c.ServeSuccessJSON(map[string]interface{}{
  25178. "failed_code": -10,
  25179. "msg": res2.ErrMsg,
  25180. })
  25181. return
  25182. }
  25183. if res2.Infcode == 0 {
  25184. if err == nil {
  25185. c.ServeSuccessJSON(map[string]interface{}{
  25186. "msg": "退号成功",
  25187. })
  25188. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  25189. } else {
  25190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25191. return
  25192. }
  25193. }
  25194. } else {
  25195. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  25196. //if err == nil {
  25197. // c.ServeSuccessJSON(map[string]interface{}{
  25198. // "msg": "退费成功",
  25199. // })
  25200. //} else {
  25201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25202. // return
  25203. //}
  25204. }
  25205. }
  25206. func (c *HisApiController) RefundDetail() {
  25207. order_id, _ := c.GetInt64("order_id")
  25208. admin_user_id, _ := c.GetInt64("admin_user_id")
  25209. //his_patient_id, _ := c.GetInt64("his_patient_id")
  25210. number := c.GetString("number")
  25211. record_time := c.GetString("record_time")
  25212. patient_id, _ := c.GetInt64("patient_id")
  25213. //med_type, _ := c.GetInt64("med_type")
  25214. timeLayout := "2006-01-02"
  25215. loc, _ := time.LoadLocation("Local")
  25216. adminUser := c.GetAdminUserInfo()
  25217. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25218. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25219. fmt.Println(err)
  25220. if err != nil {
  25221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25222. return
  25223. }
  25224. recordDateTime := theTime.Unix()
  25225. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25226. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25227. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25228. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25229. var order models.HisOrder
  25230. order, _ = service.GetHisOrderByID(order_id)
  25231. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25232. if config.IsOpen == 1 { //对接了医保,走医保流程
  25233. var res2 ResultSix
  25234. if miConfig.MdtrtareaAdmvs == "421300" {
  25235. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25236. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25237. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25238. resp3, requestErr3 := http.Get(api3)
  25239. if requestErr3 != nil {
  25240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25241. return
  25242. }
  25243. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25244. if ioErr3 != nil {
  25245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25247. return
  25248. }
  25249. var respJSON3 map[string]interface{}
  25250. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25253. return
  25254. }
  25255. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25256. userJSONBytes3, _ := json.Marshal(respJSON3)
  25257. fmt.Println("log")
  25258. fmt.Println(string(userJSONBytes3))
  25259. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25260. utils.ErrorLog("解析失败:%v", err)
  25261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25262. return
  25263. }
  25264. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25265. if err == nil {
  25266. c.ServeSuccessJSON(map[string]interface{}{
  25267. "msg": "撤销明细成功",
  25268. })
  25269. return
  25270. } else {
  25271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25272. return
  25273. }
  25274. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25275. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25276. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25277. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25278. resp3, requestErr3 := http.Get(api3)
  25279. if requestErr3 != nil {
  25280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25281. return
  25282. }
  25283. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25284. if ioErr3 != nil {
  25285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25287. return
  25288. }
  25289. var respJSON3 map[string]interface{}
  25290. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25293. return
  25294. }
  25295. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25296. userJSONBytes3, _ := json.Marshal(respJSON3)
  25297. fmt.Println("log")
  25298. fmt.Println(string(userJSONBytes3))
  25299. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25300. utils.ErrorLog("解析失败:%v", err)
  25301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25302. return
  25303. }
  25304. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25305. if err == nil {
  25306. c.ServeSuccessJSON(map[string]interface{}{
  25307. "msg": "撤销明细成功",
  25308. })
  25309. return
  25310. } else {
  25311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25312. return
  25313. }
  25314. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25315. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25316. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25317. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25318. resp3, requestErr3 := http.Get(api3)
  25319. if requestErr3 != nil {
  25320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25321. return
  25322. }
  25323. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25324. if ioErr3 != nil {
  25325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25327. return
  25328. }
  25329. var respJSON3 map[string]interface{}
  25330. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25333. return
  25334. }
  25335. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25336. userJSONBytes3, _ := json.Marshal(respJSON3)
  25337. fmt.Println("log")
  25338. fmt.Println(string(userJSONBytes3))
  25339. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25340. utils.ErrorLog("解析失败:%v", err)
  25341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25342. return
  25343. }
  25344. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25345. if err == nil {
  25346. c.ServeSuccessJSON(map[string]interface{}{
  25347. "msg": "撤销明细成功",
  25348. })
  25349. return
  25350. } else {
  25351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25352. return
  25353. }
  25354. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25355. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25356. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25357. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25358. resp3, requestErr3 := http.Get(api3)
  25359. if requestErr3 != nil {
  25360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25361. return
  25362. }
  25363. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25364. if ioErr3 != nil {
  25365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25367. return
  25368. }
  25369. var respJSON3 map[string]interface{}
  25370. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25373. return
  25374. }
  25375. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25376. userJSONBytes3, _ := json.Marshal(respJSON3)
  25377. fmt.Println("log")
  25378. fmt.Println(string(userJSONBytes3))
  25379. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25380. utils.ErrorLog("解析失败:%v", err)
  25381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25382. return
  25383. }
  25384. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25385. if err == nil {
  25386. c.ServeSuccessJSON(map[string]interface{}{
  25387. "msg": "撤销明细成功",
  25388. })
  25389. return
  25390. } else {
  25391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25392. return
  25393. }
  25394. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25395. var resSix10265 ResultSix10265
  25396. var api3 string
  25397. if miConfig.MdtrtareaAdmvs == "320921" {
  25398. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25399. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25400. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25401. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25402. } else {
  25403. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25404. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25405. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25406. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25407. }
  25408. resp3, requestErr3 := http.Get(api3)
  25409. utils.ErrorLog("接口: %v", requestErr3)
  25410. if requestErr3 != nil {
  25411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25412. return
  25413. }
  25414. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25415. if ioErr3 != nil {
  25416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25418. return
  25419. }
  25420. var respJSON3 map[string]interface{}
  25421. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25424. return
  25425. }
  25426. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25427. userJSONBytes3, _ := json.Marshal(respJSON3)
  25428. fmt.Println("log")
  25429. fmt.Println(string(userJSONBytes3))
  25430. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25431. utils.ErrorLog("解析失败:%v", err)
  25432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25433. return
  25434. }
  25435. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25436. res2.Output = resSix10265.Output
  25437. res2.ErrMsg = resSix10265.ErrMsg
  25438. res2.Cainfo = resSix10265.Cainfo
  25439. res2.WarnMsg = resSix10265.WarnMsg
  25440. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25441. res2.Infcode = infocode
  25442. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25443. if err == nil {
  25444. c.ServeSuccessJSON(map[string]interface{}{
  25445. "msg": "撤销明细成功",
  25446. })
  25447. return
  25448. } else {
  25449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25450. return
  25451. }
  25452. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25453. var api3 string
  25454. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  25455. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25456. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25457. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25458. resp3, requestErr3 := http.Get(api3)
  25459. utils.ErrorLog("接口: %v", requestErr3)
  25460. if requestErr3 != nil {
  25461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25462. return
  25463. }
  25464. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25465. if ioErr3 != nil {
  25466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25468. return
  25469. }
  25470. var respJSON3 map[string]interface{}
  25471. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25474. return
  25475. }
  25476. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25477. if status == "0" {
  25478. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25479. c.ServeSuccessJSON(map[string]interface{}{
  25480. "failed_code": -10,
  25481. "msg": err_msg,
  25482. })
  25483. return
  25484. }
  25485. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25486. userJSONBytes3, _ := json.Marshal(respJSON3)
  25487. fmt.Println("log")
  25488. fmt.Println(string(userJSONBytes3))
  25489. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25490. utils.ErrorLog("解析失败:%v", err)
  25491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25492. return
  25493. }
  25494. fmt.Println(res2.Infcode)
  25495. if res2.Infcode == -1 {
  25496. c.ServeSuccessJSON(map[string]interface{}{
  25497. "failed_code": -10,
  25498. "msg": res2.ErrMsg,
  25499. })
  25500. return
  25501. }
  25502. if res2.Infcode == 0 {
  25503. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25504. if err == nil {
  25505. c.ServeSuccessJSON(map[string]interface{}{
  25506. "msg": "撤销明细成功",
  25507. })
  25508. return
  25509. } else {
  25510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25511. return
  25512. }
  25513. } else {
  25514. c.ServeSuccessJSON(map[string]interface{}{
  25515. "failed_code": -10,
  25516. "msg": res2.ErrMsg,
  25517. })
  25518. }
  25519. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25520. if err == nil {
  25521. c.ServeSuccessJSON(map[string]interface{}{
  25522. "msg": "撤销明细成功",
  25523. })
  25524. return
  25525. } else {
  25526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25527. return
  25528. }
  25529. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25530. var resSix10265 ResultSix10265
  25531. var api3 string
  25532. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25533. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25535. resp3, requestErr3 := http.Get(api3)
  25536. if requestErr3 != nil {
  25537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25538. return
  25539. }
  25540. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25541. if ioErr3 != nil {
  25542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25544. return
  25545. }
  25546. var respJSON3 map[string]interface{}
  25547. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25550. return
  25551. }
  25552. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25553. userJSONBytes3, _ := json.Marshal(respJSON3)
  25554. fmt.Println("log")
  25555. fmt.Println(string(userJSONBytes3))
  25556. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25557. utils.ErrorLog("解析失败:%v", err)
  25558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25559. return
  25560. }
  25561. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25562. res2.Output = resSix10265.Output
  25563. res2.ErrMsg = resSix10265.ErrMsg
  25564. res2.Cainfo = resSix10265.Cainfo
  25565. res2.WarnMsg = resSix10265.WarnMsg
  25566. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25567. res2.Infcode = infocode
  25568. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25569. if err == nil {
  25570. c.ServeSuccessJSON(map[string]interface{}{
  25571. "msg": "撤销明细成功",
  25572. })
  25573. return
  25574. } else {
  25575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25576. return
  25577. }
  25578. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25579. 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)
  25580. var dat map[string]interface{}
  25581. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25582. fmt.Println(dat)
  25583. } else {
  25584. fmt.Println(err)
  25585. }
  25586. saveLog(result2, src_request, "2205", "撤销明细")
  25587. userJSONBytes, _ := json.Marshal(dat)
  25588. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25589. utils.ErrorLog("解析失败:%v", err)
  25590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25591. return
  25592. }
  25593. if res2.Infcode == 0 {
  25594. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25595. if err == nil {
  25596. c.ServeSuccessJSON(map[string]interface{}{
  25597. "msg": "撤销明细成功",
  25598. })
  25599. return
  25600. } else {
  25601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25602. return
  25603. }
  25604. } else {
  25605. c.ServeSuccessJSON(map[string]interface{}{
  25606. "failed_code": -10,
  25607. "msg": res2.ErrMsg,
  25608. })
  25609. }
  25610. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25611. 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, "")
  25612. var dat map[string]interface{}
  25613. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25614. fmt.Println(dat)
  25615. } else {
  25616. fmt.Println(err)
  25617. }
  25618. saveLog(result2, src_request, "2205", "撤销明细")
  25619. userJSONBytes, _ := json.Marshal(dat)
  25620. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25621. utils.ErrorLog("解析失败:%v", err)
  25622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25623. return
  25624. }
  25625. if res2.Infcode == 0 {
  25626. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25627. if err == nil {
  25628. c.ServeSuccessJSON(map[string]interface{}{
  25629. "msg": "撤销明细成功",
  25630. })
  25631. return
  25632. } else {
  25633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25634. return
  25635. }
  25636. } else {
  25637. c.ServeSuccessJSON(map[string]interface{}{
  25638. "failed_code": -10,
  25639. "msg": res2.ErrMsg,
  25640. })
  25641. }
  25642. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25643. 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, "")
  25644. var dat map[string]interface{}
  25645. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25646. fmt.Println(dat)
  25647. } else {
  25648. fmt.Println(err)
  25649. }
  25650. saveLog(result2, src_request, "2205", "撤销明细")
  25651. userJSONBytes, _ := json.Marshal(dat)
  25652. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25653. utils.ErrorLog("解析失败:%v", err)
  25654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25655. return
  25656. }
  25657. if res2.Infcode == 0 {
  25658. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25659. if err == nil {
  25660. c.ServeSuccessJSON(map[string]interface{}{
  25661. "msg": "撤销明细成功",
  25662. })
  25663. return
  25664. } else {
  25665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25666. return
  25667. }
  25668. } else {
  25669. c.ServeSuccessJSON(map[string]interface{}{
  25670. "failed_code": -10,
  25671. "msg": res2.ErrMsg,
  25672. })
  25673. }
  25674. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25675. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  25676. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25677. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25678. resp2, requestErr2 := http.Get(api2)
  25679. if requestErr2 != nil {
  25680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25681. return
  25682. }
  25683. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25684. if ioErr2 != nil {
  25685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25687. return
  25688. }
  25689. var respJSON2 map[string]interface{}
  25690. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25693. return
  25694. }
  25695. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25696. userJSONBytes3, _ := json.Marshal(respJSON2)
  25697. fmt.Println("log")
  25698. fmt.Println(string(userJSONBytes3))
  25699. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25700. utils.ErrorLog("解析失败:%v", err)
  25701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25702. return
  25703. }
  25704. if res2.Infcode == 0 {
  25705. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25706. if err == nil {
  25707. c.ServeSuccessJSON(map[string]interface{}{
  25708. "msg": "撤销明细成功",
  25709. })
  25710. return
  25711. } else {
  25712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25713. return
  25714. }
  25715. } else {
  25716. c.ServeSuccessJSON(map[string]interface{}{
  25717. "failed_code": -10,
  25718. "msg": res2.ErrMsg,
  25719. })
  25720. }
  25721. } else {
  25722. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  25723. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25725. resp2, requestErr2 := http.Get(api2)
  25726. if requestErr2 != nil {
  25727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25728. return
  25729. }
  25730. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25731. if ioErr2 != nil {
  25732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25734. return
  25735. }
  25736. var respJSON2 map[string]interface{}
  25737. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25740. return
  25741. }
  25742. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25743. if err == nil {
  25744. c.ServeSuccessJSON(map[string]interface{}{
  25745. "msg": "撤销明细成功",
  25746. })
  25747. return
  25748. } else {
  25749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25750. return
  25751. }
  25752. }
  25753. } else {
  25754. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25755. if err == nil {
  25756. c.ServeSuccessJSON(map[string]interface{}{
  25757. "msg": "退费成功",
  25758. })
  25759. } else {
  25760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25761. return
  25762. }
  25763. }
  25764. }
  25765. // 对账
  25766. func (c *HisApiController) GetCheckAccount() {
  25767. start_time := c.GetString("start_time")
  25768. end_time := c.GetString("end_time")
  25769. insutype := c.GetString("insutype")
  25770. clr_type := c.GetString("clr_type")
  25771. clr_org := c.GetString("clr_optins")
  25772. admin_user_id, _ := c.GetInt64("admin_user_id")
  25773. adminUser := c.GetAdminUserInfo()
  25774. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25775. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25776. if len(clr_org) == 0 {
  25777. clr_org = miConfig.InsuplcAdmdvs
  25778. }
  25779. timeLayout := "2006-01-02"
  25780. loc, _ := time.LoadLocation("Local")
  25781. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25782. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25783. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25784. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25785. fixmedins_setl_cnt := int64(len(orders))
  25786. var medfee_sumamt float64
  25787. var acct_pay float64
  25788. var fund_pay_sumamt float64
  25789. for _, item := range orders {
  25790. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25791. acct_pay = acct_pay + item.AcctPay
  25792. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25793. }
  25794. var user_name string
  25795. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25796. if role.ID == 0 {
  25797. user_name = "xxx"
  25798. } else {
  25799. user_name = role.UserName
  25800. }
  25801. var res ResultEight
  25802. var res10188 ResultEightFor10188
  25803. if config.IsOpen == 1 {
  25804. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25805. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  25806. "insutype=" + insutype +
  25807. "&clr_type=" + clr_type +
  25808. "&setl_optins=" + clr_org +
  25809. "&stmt_begndate=" + start_time +
  25810. "&stm_enddate=" + end_time +
  25811. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25812. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25813. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25814. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25815. "&fixmedins_code=" + miConfig.Code +
  25816. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25817. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25818. "&secret_key=" + miConfig.SecretKey +
  25819. "&org_name=" + miConfig.OrgName +
  25820. "&doctor=" + user_name +
  25821. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25822. fmt.Println(api)
  25823. resp, requestErr := http.Get(api)
  25824. if requestErr != nil {
  25825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25826. return
  25827. }
  25828. body, ioErr := ioutil.ReadAll(resp.Body)
  25829. fmt.Println(body)
  25830. if ioErr != nil {
  25831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25833. return
  25834. }
  25835. var respJSON map[string]interface{}
  25836. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25839. return
  25840. }
  25841. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25842. userJSONBytes, _ := json.Marshal(respJSON)
  25843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25844. utils.ErrorLog("解析失败:%v", err)
  25845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25846. return
  25847. }
  25848. res.InfRefmsgid = res10188.InfRefmsgid
  25849. res.Output = res10188.Output
  25850. res.ErrMsg = res10188.ErrMsg
  25851. res.Cainfo = res10188.Cainfo
  25852. res.WarnMsg = res10188.WarnMsg
  25853. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25854. res.Infcode = infocode
  25855. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25856. if clr_type != "9903" {
  25857. clr_type = "99" // 就诊 ID(来自2201接口返回)
  25858. }
  25859. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  25860. "insutype=" + insutype +
  25861. "&clr_type=" + clr_type +
  25862. "&setl_optins=" + clr_org +
  25863. "&stmt_begndate=" + start_time +
  25864. "&stm_enddate=" + end_time +
  25865. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25866. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25867. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25868. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25869. "&fixmedins_code=" + miConfig.Code +
  25870. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25871. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25872. "&secret_key=" + miConfig.SecretKey +
  25873. "&org_name=" + miConfig.OrgName +
  25874. "&doctor=" + user_name
  25875. resp, requestErr := http.Get(api)
  25876. if requestErr != nil {
  25877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25878. return
  25879. }
  25880. body, ioErr := ioutil.ReadAll(resp.Body)
  25881. if ioErr != nil {
  25882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25884. return
  25885. }
  25886. var respJSON map[string]interface{}
  25887. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25890. return
  25891. }
  25892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25893. result, _ := json.Marshal(respJSON)
  25894. fmt.Println("log")
  25895. fmt.Println(string(result))
  25896. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  25897. utils.ErrorLog("解析失败:%v", err)
  25898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25899. return
  25900. }
  25901. res.InfRefmsgid = res10188.InfRefmsgid
  25902. res.Output = res10188.Output
  25903. res.ErrMsg = res10188.ErrMsg
  25904. res.Cainfo = res10188.Cainfo
  25905. res.WarnMsg = res10188.WarnMsg
  25906. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25907. res.Infcode = infocode
  25908. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25909. var baseParams models.BaseParams
  25910. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25911. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25912. baseParams.SecretKey = miConfig.SecretKey
  25913. baseParams.OrgName = miConfig.OrgName
  25914. baseParams.FixmedinsCode = miConfig.Code
  25915. baseParams.EncKey = miConfig.EncKey
  25916. baseParams.AppSecret = miConfig.AppSecret
  25917. baseParams.SignKey = miConfig.SignKey
  25918. baseParams.AppID = miConfig.Code
  25919. baseParams.Doctor = role.UserName
  25920. baseParams.RequestUrl = miConfig.Url
  25921. businessParams := models.BusinessParams{
  25922. Insutype: insutype,
  25923. ClrType: clr_type,
  25924. SetlOptins: clr_org,
  25925. StmtBegndate: start_time,
  25926. StmtEnddate: end_time,
  25927. MedfeeSumamt: medfee_sumamt,
  25928. FundPaySumamt: fund_pay_sumamt,
  25929. AcctPay: acct_pay,
  25930. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25931. }
  25932. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  25933. fmt.Println(requestLog)
  25934. fmt.Println(result)
  25935. fmt.Println(err_msg)
  25936. var dat map[string]interface{}
  25937. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25938. fmt.Println(dat)
  25939. } else {
  25940. fmt.Println(err)
  25941. }
  25942. userJSONBytes, _ := json.Marshal(dat)
  25943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25944. utils.ErrorLog("解析失败:%v", err)
  25945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25946. return
  25947. }
  25948. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25949. var baseParams models.BaseParams
  25950. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25951. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25952. baseParams.SecretKey = miConfig.SecretKey
  25953. baseParams.OrgName = miConfig.OrgName
  25954. baseParams.FixmedinsCode = miConfig.Code
  25955. baseParams.EncKey = miConfig.EncKey
  25956. baseParams.AppSecret = miConfig.AppSecret
  25957. baseParams.SignKey = miConfig.SignKey
  25958. baseParams.AppID = miConfig.Code
  25959. baseParams.Doctor = role.UserName
  25960. baseParams.RequestUrl = miConfig.Url
  25961. baseParams.AccessKey = miConfig.AccessKey
  25962. businessParams := models.BusinessParams{
  25963. Insutype: insutype,
  25964. ClrType: clr_type,
  25965. SetlOptins: "430822",
  25966. StmtBegndate: start_time,
  25967. StmtEnddate: end_time,
  25968. MedfeeSumamt: medfee_sumamt,
  25969. FundPaySumamt: fund_pay_sumamt,
  25970. AcctPay: acct_pay,
  25971. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25972. }
  25973. 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)
  25974. fmt.Println(requestLog)
  25975. fmt.Println(result)
  25976. var dat map[string]interface{}
  25977. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25978. fmt.Println(dat)
  25979. } else {
  25980. fmt.Println(err)
  25981. }
  25982. userJSONBytes, _ := json.Marshal(dat)
  25983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25984. utils.ErrorLog("解析失败:%v", err)
  25985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25986. return
  25987. }
  25988. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25989. var baseParams models.BaseParams
  25990. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25991. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25992. baseParams.SecretKey = miConfig.SecretKey
  25993. baseParams.OrgName = miConfig.OrgName
  25994. baseParams.FixmedinsCode = miConfig.Code
  25995. baseParams.EncKey = miConfig.EncKey
  25996. baseParams.AppSecret = miConfig.AppSecret
  25997. baseParams.SignKey = miConfig.SignKey
  25998. baseParams.AppID = miConfig.Code
  25999. baseParams.Doctor = role.UserName
  26000. baseParams.RequestUrl = miConfig.Url
  26001. businessParams := models.BusinessParams{
  26002. Insutype: insutype,
  26003. ClrType: clr_type,
  26004. SetlOptins: clr_org,
  26005. StmtBegndate: start_time,
  26006. StmtEnddate: end_time,
  26007. MedfeeSumamt: medfee_sumamt,
  26008. FundPaySumamt: fund_pay_sumamt,
  26009. AcctPay: acct_pay,
  26010. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26011. }
  26012. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  26013. fmt.Println(requestLog)
  26014. fmt.Println(result)
  26015. fmt.Println(err_msg)
  26016. var dat map[string]interface{}
  26017. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26018. fmt.Println(dat)
  26019. } else {
  26020. fmt.Println(err)
  26021. }
  26022. userJSONBytes, _ := json.Marshal(dat)
  26023. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26024. utils.ErrorLog("解析失败:%v", err)
  26025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26026. return
  26027. }
  26028. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26029. if len(clr_type) == 0 {
  26030. clr_type = "11"
  26031. }
  26032. api := miConfig.Url + "gdyb/ten?" +
  26033. "insutype=" + insutype +
  26034. "&clr_type=" + clr_type +
  26035. "&setl_optins=" + clr_org +
  26036. "&stmt_begndate=" + start_time +
  26037. "&stm_enddate=" + end_time +
  26038. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26039. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26040. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26041. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26042. "&fixmedins_code=" + miConfig.Code +
  26043. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26044. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26045. "&secret_key=" + miConfig.SecretKey +
  26046. "&org_name=" + miConfig.OrgName +
  26047. "&doctor=" + user_name
  26048. fmt.Println(api)
  26049. resp, requestErr := http.Get(api)
  26050. if requestErr != nil {
  26051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26052. return
  26053. }
  26054. body, ioErr := ioutil.ReadAll(resp.Body)
  26055. fmt.Println(body)
  26056. if ioErr != nil {
  26057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26059. return
  26060. }
  26061. var respJSON map[string]interface{}
  26062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26065. return
  26066. }
  26067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26068. userJSONBytes, _ := json.Marshal(respJSON)
  26069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26070. utils.ErrorLog("解析失败:%v", err)
  26071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26072. return
  26073. }
  26074. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26075. var baseParams models.BaseParams
  26076. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26077. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  26078. baseParams.SecretKey = miConfig.SecretKey
  26079. baseParams.OrgName = miConfig.OrgName
  26080. baseParams.FixmedinsCode = miConfig.Code
  26081. baseParams.EncKey = miConfig.EncKey
  26082. baseParams.AppSecret = miConfig.AppSecret
  26083. baseParams.SignKey = miConfig.SignKey
  26084. baseParams.AppID = miConfig.Code
  26085. baseParams.Doctor = role.UserName
  26086. baseParams.RequestUrl = miConfig.Url
  26087. if clr_type == "9903" {
  26088. clr_type = "9901"
  26089. }
  26090. businessParams := models.BusinessParams{
  26091. Insutype: insutype,
  26092. ClrType: clr_type,
  26093. SetlOptins: "360302",
  26094. StmtBegndate: start_time,
  26095. StmtEnddate: end_time,
  26096. MedfeeSumamt: 0,
  26097. FundPaySumamt: 0,
  26098. AcctPay: 0,
  26099. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26100. }
  26101. 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))
  26102. fmt.Println(requestLog)
  26103. fmt.Println(result)
  26104. var dat map[string]interface{}
  26105. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26106. fmt.Println(dat)
  26107. } else {
  26108. fmt.Println(err)
  26109. }
  26110. userJSONBytes, _ := json.Marshal(dat)
  26111. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26112. utils.ErrorLog("解析失败:%v", err)
  26113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26114. return
  26115. }
  26116. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26117. var api string
  26118. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  26119. "&clr_type=" + clr_type +
  26120. "&setl_optins=" + clr_org +
  26121. "&stmt_begndate=" + start_time +
  26122. "&stm_enddate=" + end_time +
  26123. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26124. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26125. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26126. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  26127. "&fixmedins_code=" + miConfig.Code +
  26128. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26129. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26130. "&secret_key=" + miConfig.SecretKey +
  26131. "&org_name=" + miConfig.OrgName +
  26132. "&doctor=" + user_name + "&url=" + miConfig.Url
  26133. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26134. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26135. resp, requestErr := http.Get(api)
  26136. if requestErr != nil {
  26137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26138. return
  26139. }
  26140. body, ioErr := ioutil.ReadAll(resp.Body)
  26141. if ioErr != nil {
  26142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26144. return
  26145. }
  26146. var respJSON map[string]interface{}
  26147. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26150. return
  26151. }
  26152. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26153. if status == "0" {
  26154. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26155. c.ServeSuccessJSON(map[string]interface{}{
  26156. "failed_code": -10,
  26157. "msg": err_msg,
  26158. })
  26159. return
  26160. }
  26161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26162. userJSONBytes, _ := json.Marshal(respJSON)
  26163. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26164. utils.ErrorLog("解析失败:%v", err)
  26165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26166. return
  26167. }
  26168. } else {
  26169. if len(clr_type) == 0 {
  26170. clr_type = "11"
  26171. }
  26172. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26173. "insutype=" + insutype +
  26174. "&clr_type=" + clr_type +
  26175. "&setl_optins=" + clr_org +
  26176. "&stmt_begndate=" + start_time +
  26177. "&stm_enddate=" + end_time +
  26178. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26179. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26180. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26181. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26182. "&fixmedins_code=" + miConfig.Code +
  26183. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26184. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26185. "&secret_key=" + miConfig.SecretKey +
  26186. "&org_name=" + miConfig.OrgName +
  26187. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  26188. fmt.Println(api)
  26189. resp, requestErr := http.Get(api)
  26190. if requestErr != nil {
  26191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26192. return
  26193. }
  26194. body, ioErr := ioutil.ReadAll(resp.Body)
  26195. fmt.Println(body)
  26196. if ioErr != nil {
  26197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26199. return
  26200. }
  26201. var respJSON map[string]interface{}
  26202. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26205. return
  26206. }
  26207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26208. userJSONBytes, _ := json.Marshal(respJSON)
  26209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26210. utils.ErrorLog("解析失败:%v", err)
  26211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26212. return
  26213. }
  26214. }
  26215. if res.Infcode == 0 {
  26216. if res.Output.Stmtinfo.StmtRslt == "0" {
  26217. micc := &models.MedicalInsuranceCostCompare{
  26218. StartTime: startime.Unix(),
  26219. EndTime: endtime.Unix(),
  26220. Insutype: insutype,
  26221. CheckType: 1,
  26222. Num: fixmedins_setl_cnt,
  26223. Mtime: time.Now().Unix(),
  26224. Status: 1,
  26225. UserOrgId: adminUser.CurrentOrgId,
  26226. CostTotal: medfee_sumamt,
  26227. FuncTotal: fund_pay_sumamt,
  26228. PsnPay: acct_pay,
  26229. Creator: admin_user_id,
  26230. Ctime: time.Now().Unix(),
  26231. ClrType: clr_type,
  26232. }
  26233. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  26234. if err == nil {
  26235. c.ServeSuccessJSON(map[string]interface{}{
  26236. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26237. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26238. })
  26239. } else {
  26240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26241. }
  26242. } else {
  26243. c.ServeSuccessJSON(map[string]interface{}{
  26244. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26245. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26246. })
  26247. }
  26248. } else {
  26249. c.ServeSuccessJSON(map[string]interface{}{
  26250. "failed_code": -10,
  26251. "msg": res.ErrMsg,
  26252. })
  26253. }
  26254. }
  26255. }
  26256. func (c *HisApiController) Check310() {
  26257. adminUser := c.GetAdminUserInfo()
  26258. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26259. var user_name string
  26260. user_name = "高慧裕"
  26261. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26262. "insutype=" + "310" +
  26263. "&clr_type=" + "" +
  26264. "&setl_optins=" + "441202" +
  26265. "&stmt_begndate=" + "2022-03-01" +
  26266. "&stm_enddate=" + "2022-03-31" +
  26267. "&medfee_sumamt=" + "194930.12" +
  26268. "&fund_pay_sumamt=" + "188741.46" +
  26269. "&acct_pay=" + "0" +
  26270. "&fixmedins_setl_cnt=" + "452" +
  26271. "&fixmedins_code=" + miConfig.Code +
  26272. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26273. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26274. "&secret_key=" + miConfig.SecretKey +
  26275. "&org_name=" + miConfig.OrgName +
  26276. "&doctor=" + user_name
  26277. fmt.Println(api)
  26278. resp, requestErr := http.Get(api)
  26279. if requestErr != nil {
  26280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26281. return
  26282. }
  26283. body, ioErr := ioutil.ReadAll(resp.Body)
  26284. fmt.Println(body)
  26285. if ioErr != nil {
  26286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26288. return
  26289. }
  26290. var respJSON map[string]interface{}
  26291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26294. return
  26295. }
  26296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26297. userJSONBytes, _ := json.Marshal(respJSON)
  26298. var res ResultEight
  26299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26300. utils.ErrorLog("解析失败:%v", err)
  26301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26302. return
  26303. }
  26304. }
  26305. func (c *HisApiController) Check390() {
  26306. adminUser := c.GetAdminUserInfo()
  26307. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26308. var user_name string
  26309. user_name = "高慧裕"
  26310. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26311. "insutype=" + "390" +
  26312. "&clr_type=" + "" +
  26313. "&setl_optins=" + "441202" +
  26314. "&stmt_begndate=" + "2022-03-01" +
  26315. "&stm_enddate=" + "2022-03-31" +
  26316. "&medfee_sumamt=" + "1068448.89" +
  26317. "&fund_pay_sumamt=" + "1014677.62" +
  26318. "&acct_pay=" + "0" +
  26319. "&fixmedins_setl_cnt=" + "1950" +
  26320. "&fixmedins_code=" + miConfig.Code +
  26321. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26322. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26323. "&secret_key=" + miConfig.SecretKey +
  26324. "&org_name=" + miConfig.OrgName +
  26325. "&doctor=" + user_name
  26326. fmt.Println(api)
  26327. resp, requestErr := http.Get(api)
  26328. if requestErr != nil {
  26329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26330. return
  26331. }
  26332. body, ioErr := ioutil.ReadAll(resp.Body)
  26333. fmt.Println(body)
  26334. if ioErr != nil {
  26335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26337. return
  26338. }
  26339. var respJSON map[string]interface{}
  26340. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26343. return
  26344. }
  26345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26346. userJSONBytes, _ := json.Marshal(respJSON)
  26347. var res ResultEight
  26348. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26349. utils.ErrorLog("解析失败:%v", err)
  26350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26351. return
  26352. }
  26353. }
  26354. // 对账明细
  26355. func (c *HisApiController) GetCheckDetailAccount() {
  26356. start_time := c.GetString("start_time")
  26357. end_time := c.GetString("end_time")
  26358. admin_user_id, _ := c.GetInt64("admin_user_id")
  26359. adminUser := c.GetAdminUserInfo()
  26360. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26361. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26362. timeLayout := "2006-01-02"
  26363. loc, _ := time.LoadLocation("Local")
  26364. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26365. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  26366. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  26367. rand.Seed(time.Now().UnixNano())
  26368. num := rand.Intn(30000)
  26369. Mkdir(miConfig.OrgName)
  26370. file := strconv.FormatInt(int64(num), 10)
  26371. file_name := file + ".txt"
  26372. zip_name := file + ".zip"
  26373. zip_path := miConfig.OrgName + "/" + zip_name
  26374. file_path := miConfig.OrgName + "/" + file_name
  26375. decimal.DivisionPrecision = 2
  26376. var medfee_sumamt float64
  26377. var psn_cash_pay float64
  26378. var fund_pay_sumamt float64
  26379. fixmedins_setl_cnt := int64(len(orders))
  26380. for _, item := range orders {
  26381. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  26382. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  26383. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  26384. }
  26385. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  26386. defer f.Close()
  26387. if err != nil {
  26388. fmt.Println(err.Error())
  26389. } else {
  26390. for _, item := range orders {
  26391. var refd_setl_flag string
  26392. if item.OrderStatus == 2 {
  26393. refd_setl_flag = "0"
  26394. var str string
  26395. str = item.SetlId + " " +
  26396. item.MdtrtId + " " +
  26397. item.PsnNo + " " +
  26398. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26399. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26400. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  26401. _, err = f.Write([]byte(str))
  26402. }
  26403. if item.OrderStatus == 3 {
  26404. var str string
  26405. str = item.SetlId + " " +
  26406. item.MdtrtId + " " +
  26407. item.PsnNo + " " +
  26408. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26409. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26410. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  26411. _, err = f.Write([]byte(str))
  26412. var str2 string
  26413. str2 = item.SetlId + " " +
  26414. item.MdtrtId + " " +
  26415. item.PsnNo + " " +
  26416. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  26417. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  26418. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  26419. _, err = f.Write([]byte(str2))
  26420. }
  26421. }
  26422. }
  26423. Zip(file_path, zip_path)
  26424. fmt.Println(ReadFile(zip_path))
  26425. fmt.Println(string(ReadFile(zip_path)))
  26426. if config.IsOpen == 1 {
  26427. var user_name string
  26428. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26429. if role.ID == 0 {
  26430. user_name = "管理员"
  26431. } else {
  26432. user_name = role.UserName
  26433. }
  26434. baseParams := models.BaseParams{
  26435. SecretKey: miConfig.SecretKey,
  26436. FixmedinsCode: miConfig.Code,
  26437. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26438. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26439. OrgName: miConfig.OrgName,
  26440. Doctor: user_name,
  26441. }
  26442. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  26443. var dat map[string]interface{}
  26444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26445. fmt.Println(dat)
  26446. } else {
  26447. fmt.Println(err)
  26448. }
  26449. userJSONBytes, _ := json.Marshal(dat)
  26450. var res ResultNine
  26451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26452. utils.ErrorLog("解析失败:%v", err)
  26453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26454. return
  26455. }
  26456. if res.Infcode == 0 {
  26457. fileNo := res.Output.FileQuryNo
  26458. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  26459. "file_qury_no=" + fileNo +
  26460. "&setl_optins=" + "定点医保中心" +
  26461. "&stmt_begndate=" + start_time +
  26462. "&stm_enddate=" + end_time +
  26463. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26464. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26465. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  26466. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26467. "&fixmedins_code=" + miConfig.Code +
  26468. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26469. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26470. "&secret_key=" + miConfig.SecretKey +
  26471. "&org_name=" + miConfig.OrgName +
  26472. "&doctor=" + user_name
  26473. resp, requestErr := http.Get(api)
  26474. if requestErr != nil {
  26475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26476. return
  26477. }
  26478. body, ioErr := ioutil.ReadAll(resp.Body)
  26479. if ioErr != nil {
  26480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26482. return
  26483. }
  26484. var respJSON map[string]interface{}
  26485. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26488. return
  26489. }
  26490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26491. userJSONBytes, _ := json.Marshal(respJSON)
  26492. var res ResultTen
  26493. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26494. utils.ErrorLog("解析失败:%v", err)
  26495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26496. return
  26497. }
  26498. if res.Infcode == 0 {
  26499. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  26500. micc := &models.MedicalInsuranceCostCompare{
  26501. StartTime: startime.Unix(),
  26502. EndTime: endtime.Unix(),
  26503. Insutype: "0",
  26504. CheckType: 2,
  26505. Num: fixmedins_setl_cnt,
  26506. Mtime: time.Now().Unix(),
  26507. Status: 1,
  26508. UserOrgId: adminUser.CurrentOrgId,
  26509. CostTotal: medfee_sumamt,
  26510. FuncTotal: fund_pay_sumamt,
  26511. PsnPay: psn_cash_pay,
  26512. Creator: admin_user_id,
  26513. Ctime: time.Now().Unix(),
  26514. }
  26515. service.CreateMedicalInsuranceCostCompareRecord(micc)
  26516. c.ServeSuccessJSON(map[string]interface{}{
  26517. "msg": "明细对账成功",
  26518. })
  26519. }
  26520. } else {
  26521. }
  26522. }
  26523. }
  26524. type CustomOrderInfo struct {
  26525. Name string
  26526. Spec string
  26527. Unit string
  26528. Count float64
  26529. Price float64
  26530. Total float64
  26531. }
  26532. func (c *HisApiController) GetBatchSettleAccounts() {
  26533. admin_user_id, _ := c.GetInt64("admin_user_id")
  26534. order_ids := c.GetString("order_ids")
  26535. order_ids_arr := strings.Split(order_ids, ",")
  26536. data3 := []map[string]interface{}{}
  26537. for _, item := range order_ids_arr {
  26538. id, _ := strconv.ParseInt(item, 10, 64)
  26539. order_id := id
  26540. adminUser := c.GetAdminUserInfo()
  26541. order, _ := service.GetHisOrderByID(order_id)
  26542. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26543. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26544. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26545. orderInfos = append(orderInfos, orderInfos_two...)
  26546. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26547. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26548. var diagnosis_ids []string
  26549. if his.ID > 0 {
  26550. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26551. } else {
  26552. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26553. }
  26554. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26555. var dia_config []*models.HisXtDiagnoseConfig
  26556. var name string
  26557. for _, item := range diagnosis_ids {
  26558. id, _ := strconv.ParseInt(item, 10, 64)
  26559. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26560. dia_config = append(dia_config, &diagnosisConfig)
  26561. if len(name) == 0 {
  26562. name = diagnosisConfig.ClassName
  26563. }
  26564. //} else {
  26565. // name = name + "," + diagnosisConfig.ClassName
  26566. //}
  26567. }
  26568. var bedCostTotal float64 = 0 //床位总费
  26569. var bedCostSelfTotal float64 = 0 //床位自费
  26570. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26571. var bedSelfTotal float64 = 0 //床位部分项目自费
  26572. var bedInscpTotal float64 = 0 //床位部分项目自费
  26573. var operationCostTotal float64 = 0 //手术费
  26574. var operationCostSelfTotal float64 = 0 //手术费
  26575. var operationCostPartSelfTotal float64 = 0 //手术费
  26576. var operationSelfTotal float64 = 0 //床位部分项目自费
  26577. var operationInscpTotal float64 = 0 //床位部分项目自费
  26578. var otherCostTotal float64 = 0 //其他费用
  26579. var otherCostSelfTotal float64 = 0 //其他费用
  26580. var otherCostPartSelfTotal float64 = 0 //其他费用
  26581. var otherSelfTotal float64 = 0 //床位部分项目自费
  26582. var otherInscpTotal float64 = 0 //床位部分项目自费
  26583. var materialCostTotal float64 = 0 //材料费
  26584. var materialCostSelfTotal float64 = 0 //材料费
  26585. var materialCostPartSelfTotal float64 = 0 //材料费
  26586. var materialSelfTotal float64 = 0 //床位部分项目自费
  26587. var materialInscpTotal float64 = 0 //床位部分项目自费
  26588. var westernMedicineCostTotal float64 = 0 //西药费
  26589. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26590. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26591. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26592. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26593. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26594. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26595. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26596. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26597. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26598. var checkCostTotal float64 = 0 //检查费
  26599. var checkCostSelfTotal float64 = 0 //检查费
  26600. var checkCostPartSelfTotal float64 = 0 //检查费
  26601. var checkSelfTotal float64 = 0 //床位部分项目自费
  26602. var checkInscpTotal float64 = 0 //床位部分项目自费
  26603. var laboratoryCostTotal float64 = 0 //化验费
  26604. var laboratoryCostSelfTotal float64 = 0 //化验费
  26605. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26606. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26607. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26608. var treatCostTotal float64 = 0 //治疗费用
  26609. var treatCostSelfTotal float64 = 0 //治疗费用
  26610. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26611. var treatSelfTotal float64 = 0 //床位部分项目自费
  26612. var treatInscpTotal float64 = 0 //床位部分项目自费
  26613. decimal.DivisionPrecision = 2
  26614. for _, item := range orderInfos {
  26615. if item.MedChrgitmType == "01" { //床位费
  26616. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26617. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26618. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26619. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26620. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26621. }
  26622. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26623. if item.MedChrgitmType == "03" { //检查费
  26624. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26625. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26626. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26627. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26628. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26629. }
  26630. } else {
  26631. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26632. fmt.Println("------------")
  26633. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26634. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26635. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26636. }
  26637. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26638. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26639. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26640. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26641. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26642. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26643. }
  26644. }
  26645. if item.MedChrgitmType == "04" { //化验费
  26646. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26647. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26648. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26649. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26650. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26651. }
  26652. if item.MedChrgitmType == "05" { //治疗费
  26653. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26654. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26655. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26656. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26657. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26658. }
  26659. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26660. fmt.Println("------------")
  26661. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26662. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26663. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26664. }
  26665. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26666. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26667. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26668. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26669. }
  26670. //if item.MedChrgitmType == "06" { //手术费
  26671. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26672. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26673. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26674. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26675. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26676. //
  26677. //}
  26678. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26679. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26680. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26681. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26682. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26683. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26684. }
  26685. if item.MedChrgitmType == "09" { //西药费
  26686. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26687. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26688. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26689. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26690. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26691. }
  26692. if item.MedChrgitmType == "11" { //中成费
  26693. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26694. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26695. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26696. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26697. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26698. }
  26699. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26700. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26701. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26702. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26703. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26704. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26705. }
  26706. }
  26707. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26708. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26709. var user_name string
  26710. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26711. if role.ID == 0 {
  26712. user_name = "管理员"
  26713. } else {
  26714. user_name = role.UserName
  26715. }
  26716. baseParams := models.BaseParams{
  26717. SecretKey: miConfig.SecretKey,
  26718. FixmedinsCode: miConfig.Code,
  26719. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26720. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26721. OrgName: miConfig.OrgName,
  26722. Doctor: user_name,
  26723. RequestUrl: miConfig.Url,
  26724. AccessKey: miConfig.AccessKey,
  26725. }
  26726. businessParams := models.BusinessParams{
  26727. PsnNo: order.PsnNo,
  26728. MdtrtId: order.MdtrtId,
  26729. SetlId: order.SetlId,
  26730. }
  26731. var res ResultEleven
  26732. var resEleven10265 ResultEleven10265
  26733. if config.IsOpen == 1 {
  26734. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26735. result := service.Gdyb5203(baseParams, businessParams)
  26736. service.Gdyb5204(baseParams, businessParams)
  26737. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26738. var dat map[string]interface{}
  26739. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26740. fmt.Println(dat)
  26741. } else {
  26742. fmt.Println(err)
  26743. }
  26744. userJSONBytes, _ := json.Marshal(dat)
  26745. if miConfig.Code == "H15049901371" {
  26746. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26747. utils.ErrorLog("解析失败:%v", err)
  26748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26749. return
  26750. }
  26751. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26752. res.Output = resEleven10265.Output
  26753. res.ErrMsg = resEleven10265.ErrMsg
  26754. res.Cainfo = resEleven10265.Cainfo
  26755. res.WarnMsg = resEleven10265.WarnMsg
  26756. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26757. res.Infcode = infocode
  26758. } else {
  26759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26760. utils.ErrorLog("解析失败:%v", err)
  26761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26762. return
  26763. }
  26764. }
  26765. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26766. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26767. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26768. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26769. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26770. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26771. var doctor_name string
  26772. if roles.ID == 0 {
  26773. doctor_name = "管理员"
  26774. } else {
  26775. doctor_name = roles.UserName
  26776. }
  26777. yiliao_leibie := ""
  26778. switch order.MedType {
  26779. case "11":
  26780. yiliao_leibie = "普通门诊"
  26781. break
  26782. case "12":
  26783. yiliao_leibie = "门诊挂号"
  26784. break
  26785. case "13":
  26786. yiliao_leibie = "急诊"
  26787. break
  26788. case "14":
  26789. yiliao_leibie = "门诊特殊病"
  26790. break
  26791. case "15":
  26792. yiliao_leibie = "门诊统筹"
  26793. break
  26794. case "16":
  26795. yiliao_leibie = "门诊慢性病"
  26796. break
  26797. case "21":
  26798. yiliao_leibie = "普通住院"
  26799. break
  26800. }
  26801. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26802. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  26803. if res.Infcode == 0 {
  26804. data2 := map[string]interface{}{
  26805. "diagnosis": name,
  26806. "order_infos": orderInfos,
  26807. "number": order.MdtrtId,
  26808. "date": order.SettleAccountsDate,
  26809. "charge_admin": charge_admin,
  26810. "printor_admin": printor_admin,
  26811. "info": res.Output.Setlinfo,
  26812. "order": order,
  26813. "bedCostTotal": bedCostTotal,
  26814. "bedCostSelfTotal": bedCostSelfTotal,
  26815. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26816. "bedSelfTotal": bedSelfTotal,
  26817. "bedInscpTotal": bedInscpTotal,
  26818. "operationCostTotal": operationCostTotal,
  26819. "operationCostSelfTotal": operationCostSelfTotal,
  26820. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26821. "operationSelfTotal": operationSelfTotal,
  26822. "operationInscpTotal": operationInscpTotal,
  26823. "otherCostTotal": otherCostTotal,
  26824. "otherCostSelfTotal": otherCostSelfTotal,
  26825. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26826. "otherSelfTotal": otherSelfTotal,
  26827. "otherInscpTotal": otherInscpTotal,
  26828. "materialCostTotal": materialCostTotal,
  26829. "materialCostSelfTotal": materialCostSelfTotal,
  26830. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26831. "materialSelfTotal": materialSelfTotal,
  26832. "materialInscpTotal": materialInscpTotal,
  26833. "westernMedicineCostTotal": westernMedicineCostTotal,
  26834. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26835. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26836. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26837. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26838. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26839. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26840. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26841. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26842. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26843. "checkCostTotal": checkCostTotal,
  26844. "checkCostSelfTotal": checkCostSelfTotal,
  26845. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26846. "checkSelfTotal": checkSelfTotal,
  26847. "checkInscpTotal": checkInscpTotal,
  26848. "laboratoryCostTotal": laboratoryCostTotal,
  26849. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26850. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26851. "laboratorySelfTotal": laboratorySelfTotal,
  26852. "laboratoryInscpTotal": laboratoryInscpTotal,
  26853. "treatCostTotal": treatCostTotal,
  26854. "treatCostSelfTotal": treatCostSelfTotal,
  26855. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26856. "treatSelfTotal": treatSelfTotal,
  26857. "treatInscpTotal": treatInscpTotal,
  26858. "doctor_info": doctor_info,
  26859. "doctor_code": adminRole_two.DoctorCode,
  26860. "doctor_name": doctor_name,
  26861. "health_card_no": order.PsnNo,
  26862. "department": departments.Name,
  26863. "yiliao_leibie": yiliao_leibie,
  26864. "after_money": order.AccountPrice,
  26865. "patient": patient,
  26866. "org_name": miConfig.OrgName,
  26867. "org_code": miConfig.Code,
  26868. "order_number": order.Number,
  26869. "his_hospital": his_hospital,
  26870. "his": his,
  26871. "dia_config": dia_config,
  26872. "psn_cash_pay": order.PsnCashPay,
  26873. //"check_order_info": cus_slice,
  26874. }
  26875. data3 = append(data3, data2)
  26876. }
  26877. }
  26878. }
  26879. c.ServeSuccessJSON(map[string]interface{}{
  26880. "infos": data3,
  26881. })
  26882. }
  26883. func (c *HisApiController) GetSettleAccounts() {
  26884. //id, _ := c.GetInt64("id")
  26885. //record_time := c.GetString("record_time")
  26886. order_id, _ := c.GetInt64("order_id")
  26887. admin_user_id, _ := c.GetInt64("admin_user_id")
  26888. //timeLayout := "2006-01-02"
  26889. //loc, _ := time.LoadLocation("Local")
  26890. //
  26891. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26892. //if err != nil {
  26893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26894. // return
  26895. //}Hbyb5203
  26896. //recordDateTime := theTime.Unix()
  26897. adminUser := c.GetAdminUserInfo()
  26898. order, _ := service.GetHisOrderByID(order_id)
  26899. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26900. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26901. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26902. orderInfos = append(orderInfos, orderInfos_two...)
  26903. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26904. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26905. var diagnosis_ids []string
  26906. if his.ID > 0 {
  26907. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26908. } else {
  26909. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26910. }
  26911. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26912. var dia_config []*models.HisXtDiagnoseConfig
  26913. var name string
  26914. for _, item := range diagnosis_ids {
  26915. id, _ := strconv.ParseInt(item, 10, 64)
  26916. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26917. dia_config = append(dia_config, &diagnosisConfig)
  26918. if len(name) == 0 {
  26919. name = diagnosisConfig.ClassName
  26920. } else {
  26921. name = name + "," + diagnosisConfig.ClassName
  26922. }
  26923. }
  26924. if patient.UserOrgId == 10215 {
  26925. name = "慢性肾功能不全(血透治疗)"
  26926. }
  26927. var bedCostTotal float64 = 0 //床位总费
  26928. var bedCostSelfTotal float64 = 0 //床位自费
  26929. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26930. var bedSelfTotal float64 = 0 //床位部分项目自费
  26931. var bedInscpTotal float64 = 0 //床位部分项目自费
  26932. var operationCostTotal float64 = 0 //手术费
  26933. var operationCostSelfTotal float64 = 0 //手术费
  26934. var operationCostPartSelfTotal float64 = 0 //手术费
  26935. var operationSelfTotal float64 = 0 //床位部分项目自费
  26936. var operationInscpTotal float64 = 0 //床位部分项目自费
  26937. var otherCostTotal float64 = 0 //其他费用
  26938. var otherCostSelfTotal float64 = 0 //其他费用
  26939. var otherCostPartSelfTotal float64 = 0 //其他费用
  26940. var otherSelfTotal float64 = 0 //床位部分项目自费
  26941. var otherInscpTotal float64 = 0 //床位部分项目自费
  26942. var materialCostTotal float64 = 0 //材料费
  26943. var materialCostSelfTotal float64 = 0 //材料费
  26944. var materialCostPartSelfTotal float64 = 0 //材料费
  26945. var materialSelfTotal float64 = 0 //床位部分项目自费
  26946. var materialInscpTotal float64 = 0 //床位部分项目自费
  26947. var westernMedicineCostTotal float64 = 0 //西药费
  26948. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26949. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26950. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26951. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26952. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26953. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26954. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26955. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26956. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26957. var checkCostTotal float64 = 0 //检查费
  26958. var checkCostSelfTotal float64 = 0 //检查费
  26959. var checkCostPartSelfTotal float64 = 0 //检查费
  26960. var checkSelfTotal float64 = 0 //床位部分项目自费
  26961. var checkInscpTotal float64 = 0 //床位部分项目自费
  26962. var laboratoryCostTotal float64 = 0 //化验费
  26963. var laboratoryCostSelfTotal float64 = 0 //化验费
  26964. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26965. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26966. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26967. var treatCostTotal float64 = 0 //治疗费用
  26968. var treatCostSelfTotal float64 = 0 //治疗费用
  26969. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26970. var treatSelfTotal float64 = 0 //床位部分项目自费
  26971. var treatInscpTotal float64 = 0 //床位部分项目自费
  26972. decimal.DivisionPrecision = 2
  26973. for _, item := range orderInfos {
  26974. if item.MedChrgitmType == "01" { //床位费
  26975. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26976. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26977. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26978. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26979. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26980. }
  26981. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26982. if item.MedChrgitmType == "03" { //检查费
  26983. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26984. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26985. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26986. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26987. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26988. }
  26989. } else {
  26990. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26991. fmt.Println("------------")
  26992. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26993. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26994. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26995. }
  26996. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26997. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26998. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26999. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27000. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27001. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27002. }
  27003. }
  27004. if item.MedChrgitmType == "04" { //化验费
  27005. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27006. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27007. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27008. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27009. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27010. }
  27011. if item.MedChrgitmType == "05" { //治疗费
  27012. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27013. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27014. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27015. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27016. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27017. }
  27018. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  27019. fmt.Println("------------")
  27020. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27021. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27022. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27023. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27024. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27025. }
  27026. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  27027. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27028. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27029. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27030. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27031. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27032. }
  27033. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  27034. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27035. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27036. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27037. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27038. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27039. }
  27040. if item.MedChrgitmType == "09" { //西药费
  27041. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27042. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27043. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27044. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27045. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27046. }
  27047. if item.MedChrgitmType == "11" { //中成费
  27048. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27049. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27050. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27051. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27052. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27053. }
  27054. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  27055. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27056. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27057. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27058. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27059. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27060. }
  27061. }
  27062. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27063. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27064. var user_name string
  27065. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27066. if role.ID == 0 {
  27067. user_name = "管理员"
  27068. } else {
  27069. user_name = role.UserName
  27070. }
  27071. baseParams := models.BaseParams{
  27072. SecretKey: miConfig.SecretKey,
  27073. FixmedinsCode: miConfig.Code,
  27074. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27075. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27076. OrgName: miConfig.OrgName,
  27077. Doctor: user_name,
  27078. RequestUrl: miConfig.Url,
  27079. AccessKey: miConfig.AccessKey,
  27080. }
  27081. businessParams := models.BusinessParams{
  27082. PsnNo: order.PsnNo,
  27083. MdtrtId: order.MdtrtId,
  27084. SetlId: order.SetlId,
  27085. }
  27086. var res ResultEleven
  27087. var resah ResultElevenah
  27088. var resEleven10265 ResultEleven10265
  27089. if config.IsOpen == 1 {
  27090. if miConfig.MdtrtareaAdmvs == "421300" {
  27091. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27092. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27093. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27094. resp, requestErr := http.Get(api)
  27095. if requestErr != nil {
  27096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27097. return
  27098. }
  27099. body, ioErr := ioutil.ReadAll(resp.Body)
  27100. if ioErr != nil {
  27101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27103. return
  27104. }
  27105. var respJSON map[string]interface{}
  27106. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27109. return
  27110. }
  27111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27112. result, _ := json.Marshal(respJSON)
  27113. fmt.Println("log")
  27114. fmt.Println(string(result))
  27115. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27116. utils.ErrorLog("解析失败:%v", err)
  27117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27118. return
  27119. }
  27120. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27121. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27122. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27123. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27124. resp, requestErr := http.Get(api)
  27125. if requestErr != nil {
  27126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27127. return
  27128. }
  27129. body, ioErr := ioutil.ReadAll(resp.Body)
  27130. if ioErr != nil {
  27131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27133. return
  27134. }
  27135. var respJSON map[string]interface{}
  27136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27139. return
  27140. }
  27141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27142. result, _ := json.Marshal(respJSON)
  27143. fmt.Println("log")
  27144. fmt.Println(string(result))
  27145. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27146. utils.ErrorLog("解析失败:%v", err)
  27147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27148. return
  27149. }
  27150. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27151. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27152. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27153. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27154. resp, requestErr := http.Get(api)
  27155. if requestErr != nil {
  27156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27157. return
  27158. }
  27159. body, ioErr := ioutil.ReadAll(resp.Body)
  27160. if ioErr != nil {
  27161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27163. return
  27164. }
  27165. var respJSON map[string]interface{}
  27166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27169. return
  27170. }
  27171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27172. result, _ := json.Marshal(respJSON)
  27173. fmt.Println("log")
  27174. fmt.Println(string(result))
  27175. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27176. utils.ErrorLog("解析失败:%v", err)
  27177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27178. return
  27179. }
  27180. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27181. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27182. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27183. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  27184. resp, requestErr := http.Get(api)
  27185. if requestErr != nil {
  27186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27187. return
  27188. }
  27189. body, ioErr := ioutil.ReadAll(resp.Body)
  27190. if ioErr != nil {
  27191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27193. return
  27194. }
  27195. var respJSON map[string]interface{}
  27196. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27199. return
  27200. }
  27201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27202. result, _ := json.Marshal(respJSON)
  27203. fmt.Println("log")
  27204. fmt.Println(string(result))
  27205. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27206. utils.ErrorLog("解析失败:%v", err)
  27207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27208. return
  27209. }
  27210. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27211. var api string
  27212. if miConfig.MdtrtareaAdmvs == "320921" {
  27213. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27214. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27215. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27216. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27217. } else {
  27218. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27219. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27220. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27221. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27222. }
  27223. resp, requestErr := http.Get(api)
  27224. if requestErr != nil {
  27225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27226. return
  27227. }
  27228. body, ioErr := ioutil.ReadAll(resp.Body)
  27229. if ioErr != nil {
  27230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27232. return
  27233. }
  27234. var respJSON map[string]interface{}
  27235. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27238. return
  27239. }
  27240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27241. result, _ := json.Marshal(respJSON)
  27242. fmt.Println("log")
  27243. fmt.Println(string(result))
  27244. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27245. utils.ErrorLog("解析失败:%v", err)
  27246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27247. return
  27248. }
  27249. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27250. res.Output = resEleven10265.Output
  27251. res.ErrMsg = resEleven10265.ErrMsg
  27252. res.Cainfo = resEleven10265.Cainfo
  27253. res.WarnMsg = resEleven10265.WarnMsg
  27254. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27255. res.Infcode = infocode
  27256. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27257. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  27258. saveLog(result, requestLog, "5203", "结算单")
  27259. var dat map[string]interface{}
  27260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27261. fmt.Println(dat)
  27262. } else {
  27263. fmt.Println(err)
  27264. }
  27265. userJSONBytes, _ := json.Marshal(dat)
  27266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27267. utils.ErrorLog("解析失败:%v", err)
  27268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27269. return
  27270. }
  27271. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27272. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  27273. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  27274. fmt.Println(result3)
  27275. fmt.Println(requestLog3)
  27276. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  27277. fmt.Println(result2)
  27278. fmt.Println(requestLog2)
  27279. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  27280. saveLog(result, requestLog, "5203", "结算单")
  27281. var dat map[string]interface{}
  27282. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27283. fmt.Println(dat)
  27284. } else {
  27285. fmt.Println(err)
  27286. }
  27287. userJSONBytes, _ := json.Marshal(dat)
  27288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27289. utils.ErrorLog("解析失败:%v", err)
  27290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27291. return
  27292. }
  27293. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27294. var api string
  27295. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27296. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27297. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27298. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27299. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27300. resp, requestErr := http.Get(api)
  27301. if requestErr != nil {
  27302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27303. return
  27304. }
  27305. body, ioErr := ioutil.ReadAll(resp.Body)
  27306. if ioErr != nil {
  27307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27309. return
  27310. }
  27311. var respJSON map[string]interface{}
  27312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27315. return
  27316. }
  27317. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27318. if status == "0" {
  27319. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27320. c.ServeSuccessJSON(map[string]interface{}{
  27321. "failed_code": -10,
  27322. "msg": err_msg,
  27323. })
  27324. return
  27325. }
  27326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27327. result, _ := json.Marshal(respJSON)
  27328. fmt.Println("log")
  27329. fmt.Println(string(result))
  27330. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  27331. utils.ErrorLog("解析失败:%v", err)
  27332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27333. return
  27334. }
  27335. res.InfRefmsgid = resah.InfRefmsgid
  27336. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27337. // 创建对应的Time类型
  27338. t := time.UnixMilli(timestamp)
  27339. // 格式化成指定的日期字符串
  27340. str := t.Format("2006-01-02 15:04:05")
  27341. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27342. // 创建对应的Time类型
  27343. t3 := time.UnixMilli(timestamp2)
  27344. // 格式化成指定的日期字符串
  27345. str2 := t3.Format("2006-01-02 15:04:05")
  27346. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  27347. // 创建对应的Time类型
  27348. t4 := time.UnixMilli(timestamp3)
  27349. // 格式化成指定的日期字符串
  27350. str3 := t4.Format("2006-01-02 15:04:05")
  27351. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  27352. // 创建对应的Time类型
  27353. t5 := time.UnixMilli(timestamp4)
  27354. // 格式化成指定的日期字符串
  27355. str5 := t5.Format("2006-01-02 15:04:05")
  27356. res.Output.Setlinfo.Brdy = str2
  27357. res.Output.Setlinfo.SetlTime = str
  27358. res.Output.Setlinfo.Begndate = str3
  27359. res.Output.Setlinfo.Enddate = str5
  27360. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  27361. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  27362. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  27363. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  27364. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27365. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27366. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  27367. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  27368. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27369. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  27370. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  27371. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  27372. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27373. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  27374. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  27375. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  27376. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  27377. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  27378. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27379. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  27380. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  27381. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27382. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  27383. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  27384. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  27385. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27386. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  27387. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  27388. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  27389. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  27390. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27391. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  27392. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27393. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  27394. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  27395. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  27396. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  27397. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  27398. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  27399. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  27400. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  27401. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  27402. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  27403. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  27404. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  27405. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27406. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  27407. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  27408. //res.Output.Setldetail = resah.Output.Setldetail
  27409. res.ErrMsg = resah.ErrMsg
  27410. res.Cainfo = resah.Cainfo
  27411. res.WarnMsg = resah.WarnMsg
  27412. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27413. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  27414. saveLog(result, requestLog, "5203", "结算单")
  27415. var dat map[string]interface{}
  27416. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27417. fmt.Println(dat)
  27418. } else {
  27419. fmt.Println(err)
  27420. }
  27421. userJSONBytes, _ := json.Marshal(dat)
  27422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27423. utils.ErrorLog("解析失败:%v", err)
  27424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27425. return
  27426. }
  27427. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27428. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27429. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27430. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27431. resp, requestErr := http.Get(api)
  27432. if requestErr != nil {
  27433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27434. return
  27435. }
  27436. body, ioErr := ioutil.ReadAll(resp.Body)
  27437. if ioErr != nil {
  27438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27440. return
  27441. }
  27442. var respJSON map[string]interface{}
  27443. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27446. return
  27447. }
  27448. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27449. result, _ := json.Marshal(respJSON)
  27450. fmt.Println("log")
  27451. fmt.Println(string(result))
  27452. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27453. utils.ErrorLog("解析失败:%v", err)
  27454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27455. return
  27456. }
  27457. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27458. res.Output = resEleven10265.Output
  27459. res.ErrMsg = resEleven10265.ErrMsg
  27460. res.Cainfo = resEleven10265.Cainfo
  27461. res.WarnMsg = resEleven10265.WarnMsg
  27462. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27463. res.Infcode = infocode
  27464. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27465. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27466. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27467. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27468. resp, requestErr := http.Get(api)
  27469. if requestErr != nil {
  27470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27471. return
  27472. }
  27473. body, ioErr := ioutil.ReadAll(resp.Body)
  27474. if ioErr != nil {
  27475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27477. return
  27478. }
  27479. var respJSON map[string]interface{}
  27480. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27483. return
  27484. }
  27485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27486. result, _ := json.Marshal(respJSON)
  27487. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27488. utils.ErrorLog("解析失败:%v", err)
  27489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27490. return
  27491. }
  27492. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27493. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  27494. //return
  27495. } else {
  27496. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27497. if len(his.InsuplcAdmdvs) == 0 {
  27498. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  27499. } else {
  27500. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27501. }
  27502. result := service.Gdyb5203(baseParams, businessParams)
  27503. //service.Gdyb5204(baseParams, businessParams)
  27504. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27505. var dat map[string]interface{}
  27506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27507. fmt.Println(dat)
  27508. } else {
  27509. fmt.Println(err)
  27510. }
  27511. userJSONBytes, _ := json.Marshal(dat)
  27512. if miConfig.Code == "H15049901371" {
  27513. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27514. utils.ErrorLog("解析失败:%v", err)
  27515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27516. return
  27517. }
  27518. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27519. res.Output = resEleven10265.Output
  27520. res.ErrMsg = resEleven10265.ErrMsg
  27521. res.Cainfo = resEleven10265.Cainfo
  27522. res.WarnMsg = resEleven10265.WarnMsg
  27523. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27524. res.Infcode = infocode
  27525. } else {
  27526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27527. utils.ErrorLog("解析失败:%v", err)
  27528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27529. return
  27530. }
  27531. }
  27532. }
  27533. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27534. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27535. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27536. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27537. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27538. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27539. var doctor_name string
  27540. if roles.ID == 0 {
  27541. doctor_name = "管理员"
  27542. } else {
  27543. doctor_name = roles.UserName
  27544. }
  27545. yiliao_leibie := ""
  27546. switch order.MedType {
  27547. case "11":
  27548. yiliao_leibie = "普通门诊"
  27549. break
  27550. case "12":
  27551. yiliao_leibie = "门诊挂号"
  27552. break
  27553. case "13":
  27554. yiliao_leibie = "急诊"
  27555. break
  27556. case "14":
  27557. yiliao_leibie = "门诊特殊病"
  27558. break
  27559. case "15":
  27560. yiliao_leibie = "门诊统筹"
  27561. break
  27562. case "16":
  27563. yiliao_leibie = "门诊慢性病"
  27564. break
  27565. case "21":
  27566. yiliao_leibie = "普通住院"
  27567. break
  27568. }
  27569. //var rf []CustomFundPay
  27570. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  27571. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27572. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  27573. if res.Infcode == 0 {
  27574. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  27575. c.ServeSuccessJSON(map[string]interface{}{
  27576. "diagnosis": name,
  27577. "order_infos": orderInfos,
  27578. "number": order.MdtrtId,
  27579. "date": order.SettleAccountsDate,
  27580. "charge_admin": charge_admin,
  27581. "printor_admin": printor_admin,
  27582. "info": res.Output.Setlinfo,
  27583. "order": order,
  27584. "bedCostTotal": bedCostTotal,
  27585. "bedCostSelfTotal": bedCostSelfTotal,
  27586. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27587. "bedSelfTotal": bedSelfTotal,
  27588. "bedInscpTotal": bedInscpTotal,
  27589. "operationCostTotal": operationCostTotal,
  27590. "operationCostSelfTotal": operationCostSelfTotal,
  27591. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27592. "operationSelfTotal": operationSelfTotal,
  27593. "operationInscpTotal": operationInscpTotal,
  27594. "otherCostTotal": otherCostTotal,
  27595. "otherCostSelfTotal": otherCostSelfTotal,
  27596. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27597. "otherSelfTotal": otherSelfTotal,
  27598. "otherInscpTotal": otherInscpTotal,
  27599. "materialCostTotal": materialCostTotal,
  27600. "materialCostSelfTotal": materialCostSelfTotal,
  27601. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27602. "materialSelfTotal": materialSelfTotal,
  27603. "materialInscpTotal": materialInscpTotal,
  27604. "westernMedicineCostTotal": westernMedicineCostTotal,
  27605. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27606. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27607. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27608. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27609. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27610. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27611. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27612. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27613. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27614. "checkCostTotal": checkCostTotal,
  27615. "checkCostSelfTotal": checkCostSelfTotal,
  27616. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27617. "checkSelfTotal": checkSelfTotal,
  27618. "checkInscpTotal": checkInscpTotal,
  27619. "laboratoryCostTotal": laboratoryCostTotal,
  27620. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27621. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27622. "laboratorySelfTotal": laboratorySelfTotal,
  27623. "laboratoryInscpTotal": laboratoryInscpTotal,
  27624. "treatCostTotal": treatCostTotal,
  27625. "treatCostSelfTotal": treatCostSelfTotal,
  27626. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27627. "treatSelfTotal": treatSelfTotal,
  27628. "treatInscpTotal": treatInscpTotal,
  27629. "doctor_info": doctor_info,
  27630. "doctor_code": adminRole_two.DoctorCode,
  27631. "doctor_name": doctor_name,
  27632. "health_card_no": order.PsnNo,
  27633. "department": departments.Name,
  27634. "yiliao_leibie": yiliao_leibie,
  27635. "after_money": order.AccountPrice,
  27636. "patient": patient,
  27637. "org_name": miConfig.OrgName,
  27638. "org_code": miConfig.Code,
  27639. "order_number": order.Number,
  27640. "his_hospital": his_hospital,
  27641. "his": his,
  27642. "dia_config": dia_config,
  27643. "psn_cash_pay": order.PsnCashPay,
  27644. //"funds": rf,
  27645. //"check_order_info": cus_slice,
  27646. })
  27647. } else {
  27648. c.ServeSuccessJSON(map[string]interface{}{
  27649. "diagnosis": name,
  27650. "order_infos": orderInfos,
  27651. "number": order.MdtrtId,
  27652. "date": order.SettleAccountsDate,
  27653. "charge_admin": charge_admin,
  27654. "printor_admin": printor_admin,
  27655. "info": order,
  27656. "order": order,
  27657. "bedCostTotal": bedCostTotal,
  27658. "bedCostSelfTotal": bedCostSelfTotal,
  27659. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27660. "bedSelfTotal": bedSelfTotal,
  27661. "bedInscpTotal": bedInscpTotal,
  27662. "operationCostTotal": operationCostTotal,
  27663. "operationCostSelfTotal": operationCostSelfTotal,
  27664. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27665. "operationSelfTotal": operationSelfTotal,
  27666. "operationInscpTotal": operationInscpTotal,
  27667. "otherCostTotal": otherCostTotal,
  27668. "otherCostSelfTotal": otherCostSelfTotal,
  27669. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27670. "otherSelfTotal": otherSelfTotal,
  27671. "otherInscpTotal": otherInscpTotal,
  27672. "materialCostTotal": materialCostTotal,
  27673. "materialCostSelfTotal": materialCostSelfTotal,
  27674. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27675. "materialSelfTotal": materialSelfTotal,
  27676. "materialInscpTotal": materialInscpTotal,
  27677. "westernMedicineCostTotal": westernMedicineCostTotal,
  27678. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27679. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27680. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27681. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27682. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27683. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27684. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27685. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27686. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27687. "checkCostTotal": checkCostTotal,
  27688. "checkCostSelfTotal": checkCostSelfTotal,
  27689. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27690. "checkSelfTotal": checkSelfTotal,
  27691. "checkInscpTotal": checkInscpTotal,
  27692. "laboratoryCostTotal": laboratoryCostTotal,
  27693. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27694. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27695. "laboratorySelfTotal": laboratorySelfTotal,
  27696. "laboratoryInscpTotal": laboratoryInscpTotal,
  27697. "treatCostTotal": treatCostTotal,
  27698. "treatCostSelfTotal": treatCostSelfTotal,
  27699. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27700. "treatSelfTotal": treatSelfTotal,
  27701. "treatInscpTotal": treatInscpTotal,
  27702. "doctor_info": doctor_info,
  27703. "doctor_code": adminRole_two.DoctorCode,
  27704. "doctor_name": doctor_name,
  27705. "health_card_no": order.PsnNo,
  27706. "department": departments.Name,
  27707. "yiliao_leibie": yiliao_leibie,
  27708. "after_money": order.AccountPrice,
  27709. "patient": patient,
  27710. "org_name": miConfig.OrgName,
  27711. "org_code": miConfig.Code,
  27712. "order_number": order.Number,
  27713. "his_hospital": his_hospital,
  27714. "his": his,
  27715. "dia_config": dia_config,
  27716. "psn_cash_pay": order.PsnCashPay,
  27717. //"funds": rf,
  27718. //"check_order_info": cus_slice,
  27719. })
  27720. }
  27721. }
  27722. }
  27723. }
  27724. //func (c *HisApiController) CheckTreatment() {
  27725. // patient_id, _ := c.GetInt64("patient_id")
  27726. // id_card_no := c.GetString("id_card_no")
  27727. // insutype := c.GetString("insutype")
  27728. // med_type := c.GetString("med_type")
  27729. // admin_user_id, _ := c.GetInt64("admin_user_id")
  27730. //
  27731. // adminUser := c.GetAdminUserInfo()
  27732. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27733. //
  27734. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27735. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27736. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27737. //
  27738. // if miConfig.MdtrtareaAdmvs == "421300" {
  27739. // var res ResultTwo
  27740. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  27741. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27742. // "&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)
  27743. // resp, requestErr := http.Get(api)
  27744. // if requestErr != nil {
  27745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27746. // return
  27747. // }
  27748. //
  27749. // body, ioErr := ioutil.ReadAll(resp.Body)
  27750. // if ioErr != nil {
  27751. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27753. // return
  27754. // }
  27755. // var respJSON map[string]interface{}
  27756. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27757. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27759. // return
  27760. // }
  27761. //
  27762. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27763. // result, _ := json.Marshal(respJSON)
  27764. //
  27765. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27766. // utils.ErrorLog("解析失败:%v", err)
  27767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27768. // return
  27769. // }
  27770. //
  27771. // if res.Infcode == 0 {
  27772. //
  27773. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  27774. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27775. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  27776. // resp, requestErr := http.Get(api)
  27777. // if requestErr != nil {
  27778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27779. // return
  27780. // }
  27781. //
  27782. // body, ioErr := ioutil.ReadAll(resp.Body)
  27783. // if ioErr != nil {
  27784. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27786. // return
  27787. // }
  27788. // var respJSON map[string]interface{}
  27789. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27790. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27792. // return
  27793. // }
  27794. // var res Result2001
  27795. //
  27796. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27797. // result2, _ := json.Marshal(respJSON)
  27798. //
  27799. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  27800. // utils.ErrorLog("解析失败:%v", err)
  27801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27802. // return
  27803. // }
  27804. //
  27805. // if res.Infcode == 0 {
  27806. // c.ServeSuccessJSON(map[string]interface{}{
  27807. // "msg": res.Output.Trtinfo,
  27808. // })
  27809. // }
  27810. //
  27811. // } else {
  27812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27813. // return
  27814. // }
  27815. //
  27816. // } else {
  27817. //
  27818. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27819. // var dat map[string]interface{}
  27820. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27821. // fmt.Println(dat)
  27822. // } else {
  27823. // fmt.Println(err)
  27824. // }
  27825. // userJSONBytes, _ := json.Marshal(dat)
  27826. // var res ResultTwo
  27827. // var res10265 ResultTwo10265
  27828. // if miConfig.Code == "H15049901371" {
  27829. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27830. // utils.ErrorLog("解析失败:%v", err)
  27831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27832. // return
  27833. // }
  27834. // res.ErrMsg = res10265.ErrMsg
  27835. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27836. // res.Infcode = infocode
  27837. // res.Output = res10265.Output
  27838. // res.InfRefmsgid = res10265.InfRefmsgid
  27839. // } else {
  27840. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27841. // utils.ErrorLog("解析失败:%v", err)
  27842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27843. // return
  27844. // }
  27845. // }
  27846. //
  27847. // var user_name string
  27848. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  27849. // if role.ID == 0 {
  27850. // user_name = "xxx"
  27851. // } else {
  27852. // user_name = role.UserName
  27853. // }
  27854. //
  27855. // baseParams := models.BaseParams{
  27856. // SecretKey: miConfig.SecretKey,
  27857. // FixmedinsCode: miConfig.Code,
  27858. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27859. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27860. // OrgName: miConfig.OrgName,
  27861. // Doctor: user_name,
  27862. // }
  27863. //
  27864. // if config.IsOpen == 1 {
  27865. // if miConfig.Code == "H15049901371" {
  27866. // if med_type == "14" {
  27867. // if insutype == "390" {
  27868. // med_type = "9933"
  27869. // } else if insutype == "310" {
  27870. // med_type = "990502"
  27871. // }
  27872. // } else if med_type == "11" {
  27873. // med_type = "11"
  27874. // }
  27875. // }
  27876. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  27877. // var dat map[string]interface{}
  27878. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27879. // fmt.Println(dat)
  27880. // } else {
  27881. // fmt.Println(err)
  27882. // }
  27883. // var res Result2001
  27884. // var res10265 Result2001Org10265
  27885. // if miConfig.Code == "H15049901371" {
  27886. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27887. // utils.ErrorLog("解析失败:%v", err)
  27888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27889. // return
  27890. // }
  27891. // res.ErrMsg = res10265.ErrMsg
  27892. // res.Output = res10265.Output
  27893. // res.InfRefmsgid = res10265.InfRefmsgid
  27894. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27895. // res.Infcode = infocode
  27896. // } else {
  27897. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27898. // utils.ErrorLog("解析失败:%v", err)
  27899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27900. // return
  27901. // }
  27902. // }
  27903. // if res.Infcode == 0 {
  27904. // c.ServeSuccessJSON(map[string]interface{}{
  27905. // "msg": res.Output.Trtinfo,
  27906. // })
  27907. // }
  27908. // }
  27909. // }
  27910. //}
  27911. //func (c *HisApiController) PutRecord() {
  27912. // id, _ := c.GetInt64("id")
  27913. // record_time := c.GetString("record_time")
  27914. // timeLayout := "2006-01-02"
  27915. // loc, _ := time.LoadLocation("Local")
  27916. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27917. // if err != nil {
  27918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27919. // return
  27920. // }
  27921. // recordDateTime := theTime.Unix()
  27922. //
  27923. // adminInfo := c.GetAdminUserInfo()
  27924. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  27925. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27926. //
  27927. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27928. //
  27929. // fmt.Println(miConfig.SecretKey)
  27930. //
  27931. // if patient == nil {
  27932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27933. // return
  27934. // }
  27935. // if len(patient.IdCardNo) == 0 {
  27936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  27937. // return
  27938. // }
  27939. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  27940. // if config.IsOpen == 1 {
  27941. // 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
  27942. // resp, requestErr := http.Get(api)
  27943. // if requestErr != nil {
  27944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27945. // return
  27946. // }
  27947. // defer resp.Body.Close()
  27948. // body, ioErr := ioutil.ReadAll(resp.Body)
  27949. // if ioErr != nil {
  27950. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27951. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27952. // return
  27953. // }
  27954. // var respJSON map[string]interface{}
  27955. //
  27956. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27957. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27959. // return
  27960. // }
  27961. //
  27962. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27963. // userJSONBytes, _ := json.Marshal(userJSON)
  27964. // var res ResultTwo
  27965. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27966. // utils.ErrorLog("解析失败:%v", err)
  27967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27968. // return
  27969. // }
  27970. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27971. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27972. // infoStr := string(Iinfos)
  27973. // idetinfoStr := string(Idetinfos)
  27974. //
  27975. // if res.Infcode == 0 {
  27976. // his := models.VMHisPatient{
  27977. // Status: 1,
  27978. // Ctime: time.Now().Unix(),
  27979. // Mtime: time.Now().Unix(),
  27980. // PsnNo: res.Output.Baseinfo.PsnNo,
  27981. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  27982. // Certno: res.Output.Baseinfo.Certno,
  27983. // PsnName: res.Output.Baseinfo.PsnName,
  27984. // Gend: res.Output.Baseinfo.Gend,
  27985. // Naty: res.Output.Baseinfo.Naty,
  27986. // Brdy: res.Output.Baseinfo.Brdy,
  27987. // Age: res.Output.Baseinfo.Age,
  27988. // Iinfo: infoStr,
  27989. // Idetinfo: idetinfoStr,
  27990. // PatientId: patient.ID,
  27991. // RecordDate: theTime.Unix(),
  27992. // UserOrgId: adminInfo.CurrentOrgId,
  27993. // AdminUserId: adminInfo.AdminUser.Id,
  27994. // IsReturn: 1,
  27995. // }
  27996. //
  27997. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  27998. // //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")
  27999. // //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")
  28000. //
  28001. // //var dat map[string]interface{}
  28002. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28003. // // fmt.Println(dat)
  28004. // //} else {
  28005. // // fmt.Println(err)
  28006. // //}
  28007. //
  28008. // var dat2 map[string]interface{}
  28009. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28010. // fmt.Println(dat2)
  28011. // } else {
  28012. // fmt.Println(err)
  28013. // }
  28014. //
  28015. // } else {
  28016. // adminUser := c.GetAdminUserInfo()
  28017. // errlog := &models.HisOrderError{
  28018. // UserOrgId: adminUser.CurrentOrgId,
  28019. // Ctime: time.Now().Unix(),
  28020. // Mtime: time.Now().Unix(),
  28021. // ErrMsg: res.ErrMsg,
  28022. // Status: 1,
  28023. // PatientId: id,
  28024. // RecordTime: recordDateTime,
  28025. // Stage: 1,
  28026. // }
  28027. // service.CreateErrMsgLog(errlog)
  28028. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  28029. // return
  28030. // }
  28031. // }
  28032. //
  28033. //}
  28034. //func (c *HisApiController) GetUploadDiag() {
  28035. // id, _ := c.GetInt64("id")
  28036. // record_time := c.GetString("record_time")
  28037. //
  28038. // diagnosis_id, _ := c.GetInt64("diagnosis")
  28039. // sick_type, _ := c.GetInt64("sick_type")
  28040. // reg_type, _ := c.GetInt64("reg_type")
  28041. //
  28042. // timeLayout := "2006-01-02"
  28043. // loc, _ := time.LoadLocation("Local")
  28044. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28045. // if err != nil {
  28046. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28047. // return
  28048. // }
  28049. //
  28050. // var patientPrescription models.HisPrescriptionInfo
  28051. // recordDateTime := theTime.Unix()
  28052. // adminInfo := c.GetAdminUserInfo()
  28053. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28054. //
  28055. // if patientPrescription.ID == 0 {
  28056. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28057. // }
  28058. //
  28059. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  28060. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28061. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28062. // sickConfig, _ := service.FindSickById(sick_type)
  28063. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28064. //
  28065. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  28066. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  28067. // "&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 +
  28068. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  28069. // resp2, requestErr2 := http.Get(api2)
  28070. // if requestErr2 != nil {
  28071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28072. // return
  28073. // }
  28074. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  28075. // if ioErr2 != nil {
  28076. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  28077. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28078. // return
  28079. // }
  28080. // var respJSON2 map[string]interface{}
  28081. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  28082. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28084. // return
  28085. // }
  28086. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28087. // userJSONBytes2, _ := json.Marshal(respJSON2)
  28088. //
  28089. // var res2 ResultSix
  28090. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28091. // utils.ErrorLog("解析失败:%v", err)
  28092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28093. // return
  28094. // }
  28095. // if res2.Infcode != 0 {
  28096. // adminUser := c.GetAdminUserInfo()
  28097. // errlog := &models.HisOrderError{
  28098. // UserOrgId: adminUser.CurrentOrgId,
  28099. // Ctime: time.Now().Unix(),
  28100. // Mtime: time.Now().Unix(),
  28101. // ErrMsg: res2.ErrMsg,
  28102. // Status: 1,
  28103. // PatientId: id,
  28104. // RecordTime: recordDateTime,
  28105. // Stage: 3,
  28106. // }
  28107. // service.CreateErrMsgLog(errlog)
  28108. //
  28109. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  28110. // return
  28111. // }
  28112. //
  28113. // c.ServeSuccessJSON(map[string]interface{}{
  28114. // "msg": "上传成功",
  28115. // })
  28116. //
  28117. //}
  28118. type QueryResult struct {
  28119. ID int64
  28120. Name string
  28121. Code string
  28122. List_type_code string
  28123. }
  28124. func (c *HisApiController) GetCheckCode() {
  28125. ids_str := c.GetString("ids")
  28126. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  28127. ids_arr := strings.Split(ids_str, ",")
  28128. var queryResult []QueryResult
  28129. ids := make([]int64, 0)
  28130. for _, item := range ids_arr {
  28131. id, _ := strconv.ParseInt(item, 10, 64)
  28132. ids = append(ids, id)
  28133. }
  28134. if record_type == 1 {
  28135. drugs, _ := service.GetBatchDrugList(ids)
  28136. for _, item := range drugs {
  28137. result := QueryResult{
  28138. ID: item.ID,
  28139. Name: item.DrugName,
  28140. Code: item.MedicalInsuranceNumber,
  28141. List_type_code: "101",
  28142. }
  28143. queryResult = append(queryResult, result)
  28144. }
  28145. } else if record_type == 2 {
  28146. goods, _ := service.GetBatchGoodInformationList(ids)
  28147. fmt.Println(goods)
  28148. for _, item := range goods {
  28149. result := QueryResult{
  28150. ID: item.ID,
  28151. Name: item.GoodName,
  28152. Code: item.SocialSecurityDirectoryCode,
  28153. List_type_code: "301",
  28154. }
  28155. queryResult = append(queryResult, result)
  28156. }
  28157. } else if record_type == 3 {
  28158. projects, _ := service.GetBathchMyPorjecgList(ids)
  28159. for _, item := range projects {
  28160. result := QueryResult{
  28161. ID: item.ID,
  28162. Name: item.ProjectName,
  28163. Code: item.MedicalCode,
  28164. List_type_code: "201",
  28165. }
  28166. queryResult = append(queryResult, result)
  28167. }
  28168. }
  28169. admin_user_id, _ := c.GetInt64("admin_user_id")
  28170. adminUser := c.GetAdminUserInfo()
  28171. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28172. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28173. var user_name string
  28174. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28175. if role.ID == 0 {
  28176. user_name = "管理员"
  28177. } else {
  28178. user_name = role.UserName
  28179. }
  28180. baseParams := models.BaseParams{
  28181. SecretKey: miConfig.SecretKey,
  28182. FixmedinsCode: miConfig.Code,
  28183. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28184. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28185. OrgName: miConfig.OrgName,
  28186. Doctor: user_name,
  28187. }
  28188. var result string
  28189. if miConfig.MdtrtareaAdmvs == "430800" {
  28190. for _, item := range queryResult {
  28191. if record_type == 1 {
  28192. 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)
  28193. } else if record_type == 2 {
  28194. fmt.Println(item.Code)
  28195. 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)
  28196. } else if record_type == 3 {
  28197. 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)
  28198. }
  28199. var dat map[string]interface{}
  28200. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28201. fmt.Println(dat)
  28202. } else {
  28203. fmt.Println(err)
  28204. }
  28205. userJSONBytes, _ := json.Marshal(dat)
  28206. var res ResultSix
  28207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28208. utils.ErrorLog("解析失败:%v", err)
  28209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28210. return
  28211. }
  28212. if res.Infcode == 0 {
  28213. if record_type == 1 {
  28214. service.UpdateBaseDrugById(item.ID)
  28215. } else if record_type == 2 {
  28216. service.UpdateGoodInformaitonByDetail(item.ID)
  28217. } else if record_type == 3 {
  28218. service.UpdateProjectById(item.ID)
  28219. }
  28220. c.ServeSuccessJSON(map[string]interface{}{
  28221. "failed_code": 0,
  28222. "msg": "目录对照成功",
  28223. })
  28224. } else {
  28225. c.ServeSuccessJSON(map[string]interface{}{
  28226. "failed_code": -10,
  28227. "msg": res.ErrMsg,
  28228. })
  28229. }
  28230. }
  28231. } else {
  28232. for _, item := range queryResult {
  28233. var result string
  28234. if record_type == 1 {
  28235. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28236. } else if record_type == 2 {
  28237. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28238. } else if record_type == 3 {
  28239. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28240. }
  28241. var dat map[string]interface{}
  28242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28243. fmt.Println(dat)
  28244. } else {
  28245. fmt.Println(err)
  28246. }
  28247. userJSONBytes, _ := json.Marshal(dat)
  28248. var res ResultSix
  28249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28250. utils.ErrorLog("解析失败:%v", err)
  28251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28252. return
  28253. }
  28254. if res.Infcode == 0 {
  28255. if record_type == 1 {
  28256. service.UpdateBaseDrugById(item.ID)
  28257. } else if record_type == 2 {
  28258. service.UpdateGoodInformaitonByDetail(item.ID)
  28259. } else if record_type == 3 {
  28260. service.UpdateProjectById(item.ID)
  28261. }
  28262. c.ServeSuccessJSON(map[string]interface{}{
  28263. "failed_code": 0,
  28264. "msg": "目录对照成功",
  28265. })
  28266. } else {
  28267. c.ServeSuccessJSON(map[string]interface{}{
  28268. "failed_code": -10,
  28269. "msg": res.ErrMsg,
  28270. })
  28271. }
  28272. }
  28273. }
  28274. }
  28275. func (c *HisApiController) UnCheckCode() {
  28276. ids_str := c.GetString("ids")
  28277. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  28278. admin_user_id, _ := c.GetInt64("admin_user_id")
  28279. ids_arr := strings.Split(ids_str, ",")
  28280. var queryResult []QueryResult
  28281. ids := make([]int64, 0)
  28282. for _, item := range ids_arr {
  28283. id, _ := strconv.ParseInt(item, 10, 64)
  28284. ids = append(ids, id)
  28285. }
  28286. if record_type == 1 {
  28287. drugs, _ := service.GetBatchDrugList(ids)
  28288. for _, item := range drugs {
  28289. result := QueryResult{
  28290. ID: item.ID,
  28291. Name: item.DrugName,
  28292. Code: item.MedicalInsuranceNumber,
  28293. List_type_code: "101",
  28294. }
  28295. queryResult = append(queryResult, result)
  28296. }
  28297. } else if record_type == 2 {
  28298. goods, _ := service.GetBatchGoodInformationList(ids)
  28299. for _, item := range goods {
  28300. result := QueryResult{
  28301. ID: item.ID,
  28302. Name: item.GoodName,
  28303. Code: item.SocialSecurityDirectoryCode,
  28304. List_type_code: "301",
  28305. }
  28306. queryResult = append(queryResult, result)
  28307. }
  28308. } else if record_type == 3 {
  28309. projects, _ := service.GetBathchMyPorjecgList(ids)
  28310. for _, item := range projects {
  28311. result := QueryResult{
  28312. ID: item.ID,
  28313. Name: item.ProjectName,
  28314. Code: item.MedicalCode,
  28315. List_type_code: "201",
  28316. }
  28317. queryResult = append(queryResult, result)
  28318. }
  28319. }
  28320. adminUser := c.GetAdminUserInfo()
  28321. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28322. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28323. var user_name string
  28324. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28325. if role.ID == 0 {
  28326. user_name = "xxx"
  28327. } else {
  28328. user_name = role.UserName
  28329. }
  28330. baseParams := &models.BaseParams{
  28331. SecretKey: miConfig.SecretKey,
  28332. FixmedinsCode: miConfig.Code,
  28333. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28334. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28335. OrgName: miConfig.OrgName,
  28336. Doctor: user_name,
  28337. }
  28338. if config.IsOpen == 1 {
  28339. if miConfig.MdtrtareaAdmvs == "430800" {
  28340. for _, item := range queryResult {
  28341. var result string
  28342. if record_type == 1 {
  28343. 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)
  28344. } else if record_type == 2 {
  28345. fmt.Println(item.Code)
  28346. 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)
  28347. } else if record_type == 3 {
  28348. 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)
  28349. }
  28350. var dat map[string]interface{}
  28351. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28352. fmt.Println(dat)
  28353. } else {
  28354. fmt.Println(err)
  28355. }
  28356. userJSONBytes, _ := json.Marshal(dat)
  28357. var res ResultSix
  28358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28359. utils.ErrorLog("解析失败:%v", err)
  28360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28361. return
  28362. }
  28363. if res.Infcode == 0 {
  28364. if record_type == 1 {
  28365. service.UpdateBaseDrugById(item.ID)
  28366. } else if record_type == 2 {
  28367. service.UpdateGoodInformaitonByDetail(item.ID)
  28368. } else if record_type == 3 {
  28369. service.UpdateProjectById(item.ID)
  28370. }
  28371. c.ServeSuccessJSON(map[string]interface{}{
  28372. "failed_code": 0,
  28373. "msg": "目录对照成功",
  28374. })
  28375. } else {
  28376. c.ServeSuccessJSON(map[string]interface{}{
  28377. "failed_code": -10,
  28378. "msg": res.ErrMsg,
  28379. })
  28380. }
  28381. }
  28382. } else {
  28383. for _, item := range queryResult {
  28384. var result string
  28385. if record_type == 1 {
  28386. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28387. } else if record_type == 2 {
  28388. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28389. } else if record_type == 3 {
  28390. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28391. }
  28392. var dat2 map[string]interface{}
  28393. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28394. fmt.Println(dat2)
  28395. } else {
  28396. fmt.Println(err)
  28397. }
  28398. userJSONBytes, _ := json.Marshal(dat2)
  28399. var res ResultSix
  28400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28401. utils.ErrorLog("解析失败:%v", err)
  28402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28403. return
  28404. }
  28405. if res.Infcode == 0 {
  28406. if record_type == 1 {
  28407. service.UpdateDrugByIdDetail(item.ID)
  28408. } else if record_type == 2 {
  28409. service.UpdateGoodInfoById(item.ID)
  28410. } else if record_type == 3 {
  28411. service.UpdateMyProjectById(item.ID)
  28412. }
  28413. c.ServeSuccessJSON(map[string]interface{}{
  28414. "failed_code": 0,
  28415. "msg": "撤销目录对照成功",
  28416. })
  28417. } else {
  28418. c.ServeSuccessJSON(map[string]interface{}{
  28419. "failed_code": -10,
  28420. "msg": res.ErrMsg,
  28421. })
  28422. }
  28423. }
  28424. }
  28425. }
  28426. }
  28427. func (c *HisApiController) GetPatientInfo() {
  28428. id_card_no := c.GetString("id_card_no")
  28429. admin_user_id, _ := c.GetInt64("admin_user_id")
  28430. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  28431. if patient.ID == 0 {
  28432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28433. return
  28434. }
  28435. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  28436. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28437. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  28438. var res ResultTwo
  28439. var res10265 ResultTwo10265
  28440. if config.IsOpen == 1 {
  28441. if miConfig.MdtrtareaAdmvs == "150499" {
  28442. //请求内网数据
  28443. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  28444. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28445. "&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
  28446. resp, requestErr := http.Get(api)
  28447. if requestErr != nil {
  28448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28449. return
  28450. }
  28451. body, ioErr := ioutil.ReadAll(resp.Body)
  28452. if ioErr != nil {
  28453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28455. return
  28456. }
  28457. var respJSON map[string]interface{}
  28458. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28461. return
  28462. }
  28463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28464. result_byte, _ := json.Marshal(respJSON)
  28465. result := string(result_byte)
  28466. var dat map[string]interface{}
  28467. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28468. fmt.Println(dat)
  28469. } else {
  28470. fmt.Println(err)
  28471. }
  28472. userJSONBytes, _ := json.Marshal(dat)
  28473. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28474. utils.ErrorLog("解析失败:%v", err)
  28475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28476. return
  28477. }
  28478. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28479. res.Infcode = Infcode
  28480. res.ErrMsg = res10265.ErrMsg
  28481. res.Output = res10265.Output
  28482. res.InfRefmsgid = res10265.InfRefmsgid
  28483. res.RespondTime = res10265.RespondTime
  28484. res.WarnInfo = res10265.WarnInfo
  28485. } else {
  28486. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28487. var dat map[string]interface{}
  28488. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28489. fmt.Println(dat)
  28490. } else {
  28491. fmt.Println(err)
  28492. }
  28493. userJSONBytes, _ := json.Marshal(dat)
  28494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28495. utils.ErrorLog("解析失败:%v", err)
  28496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28497. return
  28498. }
  28499. }
  28500. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28501. // utils.ErrorLog("解析失败:%v", err)
  28502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28503. // return
  28504. //}
  28505. for index, item := range res.Output.Iinfo {
  28506. if item.PsnInsuStas == "2" {
  28507. fmt.Println("--------")
  28508. res.Output.Iinfo[index].Insutype = "300"
  28509. res.Output.Iinfo[index].PsnInsuStas = "1"
  28510. }
  28511. }
  28512. fmt.Println(res.Output.Iinfo)
  28513. if res.Infcode != 0 {
  28514. c.ServeSuccessJSON(map[string]interface{}{
  28515. "failed_code": -10,
  28516. "msg": res.ErrMsg,
  28517. })
  28518. } else {
  28519. c.ServeSuccessJSON(map[string]interface{}{
  28520. "failed_code": 0,
  28521. "info": res,
  28522. })
  28523. }
  28524. }
  28525. }
  28526. func (c *HisApiController) PsnPutOnRecord() {
  28527. record_type, _ := c.GetInt64("type")
  28528. patient_id, _ := c.GetInt64("patient_id")
  28529. admin_user_id, _ := c.GetInt64("admin_user_id")
  28530. start_time := c.GetString("start_time")
  28531. end_time := c.GetString("end_time")
  28532. adminUser := c.GetAdminUserInfo()
  28533. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28534. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28535. var patients []*models.Patients
  28536. if record_type == 1 { //全部备案
  28537. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  28538. patients = append(patients, patient...)
  28539. } else { //单个备案
  28540. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28541. patients = append(patients, patient)
  28542. }
  28543. var user_name string
  28544. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28545. if role.ID == 0 {
  28546. user_name = "xxx"
  28547. } else {
  28548. user_name = role.UserName
  28549. }
  28550. if config.IsOpen == 1 {
  28551. for _, item := range patients {
  28552. 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
  28553. resp, requestErr := http.Get(api)
  28554. if requestErr != nil {
  28555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28556. return
  28557. }
  28558. defer resp.Body.Close()
  28559. body, ioErr := ioutil.ReadAll(resp.Body)
  28560. if ioErr != nil {
  28561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28563. return
  28564. }
  28565. var respJSON map[string]interface{}
  28566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28569. return
  28570. }
  28571. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28572. userJSONBytes, _ := json.Marshal(userJSON)
  28573. var res ResultTwo
  28574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28575. utils.ErrorLog("解析失败:%v", err)
  28576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28577. return
  28578. }
  28579. if res.Infcode == 0 {
  28580. 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)
  28581. var dat map[string]interface{}
  28582. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28583. fmt.Println(dat)
  28584. } else {
  28585. fmt.Println(err)
  28586. }
  28587. userJSONBytes, _ := json.Marshal(dat)
  28588. var res2 ResultThirteen
  28589. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28590. utils.ErrorLog("解析失败:%v", err)
  28591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28592. return
  28593. }
  28594. if res2.Infcode == 0 {
  28595. psnResult := &models.GdybPsnRecord{
  28596. UserOrgId: adminUser.CurrentOrgId,
  28597. PatientId: item.ID,
  28598. PsnNo: res.Output.Baseinfo.PsnNo,
  28599. Ctime: time.Now().Unix(),
  28600. Mtime: time.Now().Unix(),
  28601. Status: 1,
  28602. IsCancel: 1,
  28603. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28604. }
  28605. service.CreatePsnRecord(psnResult)
  28606. } else {
  28607. c.ServeSuccessJSON(map[string]interface{}{
  28608. "failed_code": -10,
  28609. "msg": res2.ErrMsg,
  28610. })
  28611. return
  28612. }
  28613. }
  28614. }
  28615. }
  28616. }
  28617. func (c *HisApiController) PsnUnPutOnRecord() {
  28618. id, _ := c.GetInt64("id")
  28619. //record_type, _ := c.GetInt64("type")
  28620. admin_user_id, _ := c.GetInt64("admin_user_id")
  28621. adminUser := c.GetAdminUserInfo()
  28622. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28623. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28624. var user_name string
  28625. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28626. if role.ID == 0 {
  28627. user_name = "xxx"
  28628. } else {
  28629. user_name = role.UserName
  28630. }
  28631. psn_record, _ := service.GetPsnRecordById(id)
  28632. if psn_record.ID == 0 {
  28633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28634. return
  28635. }
  28636. if config.IsOpen == 1 {
  28637. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28638. var dat map[string]interface{}
  28639. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28640. fmt.Println(dat)
  28641. } else {
  28642. fmt.Println(err)
  28643. }
  28644. userJSONBytes, _ := json.Marshal(dat)
  28645. var res ResultFourteen
  28646. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28647. utils.ErrorLog("解析失败:%v", err)
  28648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28649. return
  28650. }
  28651. if res.Infcode == 0 {
  28652. psn_record.IsCancel = 2
  28653. service.CreatePsnRecord(&psn_record)
  28654. } else {
  28655. c.ServeSuccessJSON(map[string]interface{}{
  28656. "failed_code": -10,
  28657. "msg": res.ErrMsg,
  28658. })
  28659. return
  28660. }
  28661. }
  28662. }
  28663. func (c *HisApiController) PsnPutNCDSOnRecord() {
  28664. patient_id, _ := c.GetInt64("patient_id")
  28665. insutype_two := c.GetString("insutype")
  28666. psn_no := c.GetString("psn_no")
  28667. doctor_id, _ := c.GetInt64("doctor_id")
  28668. sick_id, _ := c.GetInt64("sick_id")
  28669. department_id, _ := c.GetInt64("department_id")
  28670. start_time := c.GetString("start_time")
  28671. end_time := c.GetString("end_time")
  28672. check_time := c.GetString("check_time")
  28673. hospital_code := c.GetString("hospital_code")
  28674. hospital_name := c.GetString("hospital_name")
  28675. adminUser := c.GetAdminUserInfo()
  28676. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28677. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28678. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28679. sick, _ := service.FindSickById(sick_id)
  28680. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28681. if len(hospital_code) == 0 {
  28682. hospital_code = miConfig.Code
  28683. }
  28684. if len(hospital_name) == 0 {
  28685. hospital_name = miConfig.OrgName
  28686. }
  28687. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28688. var res ResultTwo
  28689. var res10265 ResultTwo10265
  28690. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28691. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  28692. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  28693. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28694. "&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
  28695. resp, requestErr := http.Get(api)
  28696. if requestErr != nil {
  28697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28698. return
  28699. }
  28700. body, ioErr := ioutil.ReadAll(resp.Body)
  28701. if ioErr != nil {
  28702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28704. return
  28705. }
  28706. var respJSON map[string]interface{}
  28707. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28710. return
  28711. }
  28712. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28713. result, _ := json.Marshal(respJSON)
  28714. fmt.Println("log")
  28715. fmt.Println(string(result))
  28716. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28717. utils.ErrorLog("解析失败:%v", err)
  28718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28719. return
  28720. }
  28721. res.ErrMsg = res10265.ErrMsg
  28722. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28723. res.Infcode = infocode
  28724. res.Output = res10265.Output
  28725. res.InfRefmsgid = res10265.InfRefmsgid
  28726. } else {
  28727. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28728. if miConfig.Code == "H15049901371" {
  28729. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28730. utils.ErrorLog("解析失败:%v", err)
  28731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28732. return
  28733. }
  28734. res.ErrMsg = res10265.ErrMsg
  28735. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28736. res.Infcode = infocode
  28737. res.Output = res10265.Output
  28738. res.InfRefmsgid = res10265.InfRefmsgid
  28739. } else {
  28740. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28741. utils.ErrorLog("解析失败:%v", err)
  28742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28743. return
  28744. }
  28745. }
  28746. }
  28747. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28748. infoStr := string(Iinfos)
  28749. var rf []*ResultFive
  28750. json.Unmarshal([]byte(infoStr), &rf)
  28751. var insuplc_admdvs string
  28752. var insutype string
  28753. var is390 int = 0
  28754. var is310 int = 0
  28755. var insutypes []*ResultFive
  28756. for _, item := range rf {
  28757. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28758. insutypes = append(insutypes, item)
  28759. }
  28760. }
  28761. if len(insutypes) == 1 {
  28762. insutype = insutypes[0].Insutype
  28763. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28764. } else {
  28765. for _, i := range insutypes {
  28766. if i.Insutype == "390" {
  28767. is390 = 1
  28768. }
  28769. if i.Insutype == "310" {
  28770. is310 = 1
  28771. }
  28772. }
  28773. }
  28774. if is390 == 1 {
  28775. insutype = "390"
  28776. }
  28777. if is310 == 1 {
  28778. insutype = "310"
  28779. }
  28780. if len(insutypes) == 2 {
  28781. insutype = insutype_two
  28782. }
  28783. if len(insutypes) == 0 {
  28784. insutype = "310"
  28785. }
  28786. insutype = insutype_two
  28787. fmt.Println(insutype)
  28788. for _, item := range rf {
  28789. fmt.Println(item.Insutype)
  28790. fmt.Println(insutype)
  28791. if item.Insutype == insutype {
  28792. fmt.Println(item.Insutype)
  28793. fmt.Println(insutype)
  28794. insuplc_admdvs = item.InsuplcAdmdvs
  28795. }
  28796. }
  28797. fmt.Println(insuplc_admdvs)
  28798. var res2 ResultThirteen
  28799. var res10265_2 ResultThirteen10265
  28800. if config.IsOpen == 1 {
  28801. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28802. } else {
  28803. if miConfig.MdtrtareaAdmvs == "150499" {
  28804. //
  28805. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  28806. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28807. // "&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
  28808. //resp, requestErr := http.Get(api)
  28809. //if requestErr != nil {
  28810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28811. // return
  28812. //}
  28813. //
  28814. //body, ioErr := ioutil.ReadAll(resp.Body)
  28815. //if ioErr != nil {
  28816. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28818. // return
  28819. //}
  28820. //var respJSON map[string]interface{}
  28821. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28822. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28824. // return
  28825. //}
  28826. //
  28827. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28828. //result, _ := json.Marshal(respJSON)
  28829. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  28830. // utils.ErrorLog("解析失败:%v", err)
  28831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28832. // return
  28833. //}
  28834. //infocode = resThree.Infcode
  28835. //result, _ := json.Marshal(respJSON)
  28836. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  28837. // utils.ErrorLog("解析失败:%v", err)
  28838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28839. // return
  28840. //}
  28841. //
  28842. //resThree.ErrMsg = resThree10265.ErrMsg
  28843. //
  28844. //resThree.Output = resThree10265.Output
  28845. //
  28846. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  28847. //
  28848. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  28849. //
  28850. } else {
  28851. 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)
  28852. var dat map[string]interface{}
  28853. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28854. fmt.Println(dat)
  28855. } else {
  28856. fmt.Println(err)
  28857. }
  28858. userJSONBytes, _ := json.Marshal(dat)
  28859. if miConfig.Code == "H15049901371" {
  28860. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  28861. utils.ErrorLog("解析失败:%v", err)
  28862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28863. return
  28864. }
  28865. res2.ErrMsg = res10265_2.ErrMsg
  28866. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  28867. res2.Infcode = infocode
  28868. res2.Output = res10265_2.Output
  28869. res2.InfRefmsgid = res10265_2.InfRefmsgid
  28870. } else {
  28871. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28872. utils.ErrorLog("解析失败:%v", err)
  28873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28874. return
  28875. }
  28876. }
  28877. }
  28878. }
  28879. if res2.Infcode == 0 {
  28880. psnResult := &models.GdybPsnNcdsRecord{
  28881. UserOrgId: adminUser.CurrentOrgId,
  28882. PatientId: patient.ID,
  28883. PsnNo: psn_no,
  28884. DoctorId: doctor.AdminUserId,
  28885. DepartmentId: department_id,
  28886. SickType: sick_id,
  28887. Insutype: insutype,
  28888. Ctime: time.Now().Unix(),
  28889. Mtime: time.Now().Unix(),
  28890. Status: 1,
  28891. IsCancel: 1,
  28892. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28893. }
  28894. service.CreatePsnNCDSRecord(psnResult)
  28895. c.ServeSuccessJSON(map[string]interface{}{
  28896. "failed_code": 0,
  28897. "msg": "备案成功",
  28898. "result": psnResult,
  28899. })
  28900. } else {
  28901. c.ServeSuccessJSON(map[string]interface{}{
  28902. "failed_code": -10,
  28903. "msg": res2.ErrMsg,
  28904. })
  28905. return
  28906. }
  28907. }
  28908. }
  28909. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  28910. id, _ := c.GetInt64("id")
  28911. admin_user_id, _ := c.GetInt64("admin_user_id")
  28912. adminUser := c.GetAdminUserInfo()
  28913. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28914. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28915. //config, _ := service.Ge(adminUser.CurrentOrgId)
  28916. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  28917. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28918. //var user_name string
  28919. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28920. //if role.ID == 0 {
  28921. // user_name = "xxx"
  28922. //} else {
  28923. // user_name = role.UserName
  28924. //}
  28925. psn_record, _ := service.GetPsnNCDSRecordById(id)
  28926. if psn_record.ID == 0 {
  28927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28928. return
  28929. }
  28930. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28931. var res ResultTwo
  28932. var res10265 ResultTwo10265
  28933. if miConfig.Code == "H15049901371" {
  28934. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28935. utils.ErrorLog("解析失败:%v", err)
  28936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28937. return
  28938. }
  28939. res.ErrMsg = res10265.ErrMsg
  28940. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28941. res.Infcode = infocode
  28942. res.Output = res10265.Output
  28943. res.InfRefmsgid = res10265.InfRefmsgid
  28944. } else {
  28945. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28946. utils.ErrorLog("解析失败:%v", err)
  28947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28948. return
  28949. }
  28950. }
  28951. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28952. infoStr := string(Iinfos)
  28953. var rf []*ResultFive
  28954. json.Unmarshal([]byte(infoStr), &rf)
  28955. var insuplc_admdvs string
  28956. var insutype string
  28957. var is390 int = 0
  28958. var is310 int = 0
  28959. var insutypes []*ResultFive
  28960. for _, item := range rf {
  28961. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28962. insutypes = append(insutypes, item)
  28963. }
  28964. }
  28965. if len(insutypes) == 1 {
  28966. insutype = insutypes[0].Insutype
  28967. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28968. } else {
  28969. for _, i := range insutypes {
  28970. if i.Insutype == "390" {
  28971. is390 = 1
  28972. }
  28973. if i.Insutype == "310" {
  28974. is310 = 1
  28975. }
  28976. }
  28977. }
  28978. if is390 == 1 {
  28979. insutype = "390"
  28980. }
  28981. if is310 == 1 {
  28982. insutype = "310"
  28983. }
  28984. if len(insutypes) == 0 {
  28985. insutype = "310"
  28986. }
  28987. insutype = psn_record.Insutype
  28988. for _, item := range rf {
  28989. if item.Insutype == insutype {
  28990. insuplc_admdvs = item.InsuplcAdmdvs
  28991. }
  28992. }
  28993. if config.IsOpen == 1 {
  28994. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  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 ResultFourteen
  29003. var res10265 ResultFourteen10265
  29004. if miConfig.Code == "H15049901371" {
  29005. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  29006. utils.ErrorLog("解析失败:%v", err)
  29007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29008. return
  29009. }
  29010. res.ErrMsg = res10265.ErrMsg
  29011. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29012. res.Infcode = infocode
  29013. res.Output = res10265.Output
  29014. res.InfRefmsgid = res10265.InfRefmsgid
  29015. } else {
  29016. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29017. utils.ErrorLog("解析失败:%v", err)
  29018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29019. return
  29020. }
  29021. }
  29022. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29023. // utils.ErrorLog("解析失败:%v", err)
  29024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29025. // return
  29026. //}
  29027. if res.Infcode == 0 {
  29028. psn_record.IsCancel = 2
  29029. service.CreatePsnNCDSRecord(&psn_record)
  29030. c.ServeSuccessJSON(map[string]interface{}{
  29031. "failed_code": 0,
  29032. "msg": "撤销备案成功",
  29033. })
  29034. } else {
  29035. c.ServeSuccessJSON(map[string]interface{}{
  29036. "failed_code": -10,
  29037. "msg": res.ErrMsg,
  29038. })
  29039. return
  29040. }
  29041. }
  29042. }
  29043. func (c *HisApiController) TestTest() {
  29044. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  29045. fmt.Println(patient.Iinfo)
  29046. }
  29047. type CustomData struct {
  29048. MsgId string
  29049. PsnNo string
  29050. Info string
  29051. }
  29052. func (c *HisApiController) ReversalData() {
  29053. var customData []*CustomData
  29054. custom := &CustomData{
  29055. MsgId: "H44022900158202103301714472004",
  29056. PsnNo: "44020000001101329945",
  29057. Info: "2207",
  29058. }
  29059. customData = append(customData, custom)
  29060. custom1 := &CustomData{
  29061. MsgId: "H4402290015820210330172057803",
  29062. PsnNo: "44020000001101161813",
  29063. Info: "2207",
  29064. }
  29065. customData = append(customData, custom1)
  29066. custom2 := &CustomData{
  29067. MsgId: "H44022900158202103301705198813",
  29068. PsnNo: "44190000133097375417",
  29069. Info: "2207",
  29070. }
  29071. customData = append(customData, custom2)
  29072. custom3 := &CustomData{
  29073. MsgId: "H44022900158202103301715524756",
  29074. PsnNo: "44020000001100187221",
  29075. Info: "2207",
  29076. }
  29077. customData = append(customData, custom3)
  29078. custom4 := &CustomData{
  29079. MsgId: "H44022900158202103301730376224",
  29080. PsnNo: "44020000001101959155",
  29081. Info: "2207",
  29082. }
  29083. customData = append(customData, custom4)
  29084. custom5 := &CustomData{
  29085. MsgId: "H44022900158202103301748008725",
  29086. PsnNo: "44020000001104246641",
  29087. Info: "2207",
  29088. }
  29089. customData = append(customData, custom5)
  29090. custom6 := &CustomData{
  29091. MsgId: "H44022900158202103301718096755",
  29092. PsnNo: "44020000001102211860",
  29093. Info: "2207",
  29094. }
  29095. customData = append(customData, custom6)
  29096. custom7 := &CustomData{
  29097. MsgId: "H44022900158202103301736551640",
  29098. PsnNo: "44020000001102687718",
  29099. Info: "2207",
  29100. }
  29101. customData = append(customData, custom7)
  29102. custom8 := &CustomData{
  29103. MsgId: "H44022900158202103301743097676",
  29104. PsnNo: "44020000001102127785",
  29105. Info: "2207",
  29106. }
  29107. customData = append(customData, custom8)
  29108. custom9 := &CustomData{
  29109. MsgId: "H44022900158202103301712304203",
  29110. PsnNo: "44020000001101518097",
  29111. Info: "2207",
  29112. }
  29113. customData = append(customData, custom9)
  29114. custom10 := &CustomData{
  29115. MsgId: "H44022900158202103301738448785",
  29116. PsnNo: "44020000001100500813",
  29117. Info: "2207",
  29118. }
  29119. customData = append(customData, custom10)
  29120. custom11 := &CustomData{
  29121. MsgId: "H44022900158202103301732455843",
  29122. PsnNo: "44020000001102690557",
  29123. Info: "2207",
  29124. }
  29125. customData = append(customData, custom11)
  29126. custom12 := &CustomData{
  29127. MsgId: "H44022900158202103301745421708",
  29128. PsnNo: "44020000001102211928",
  29129. Info: "2207",
  29130. }
  29131. customData = append(customData, custom12)
  29132. custom1212 := &CustomData{
  29133. MsgId: "H440229001582021033017351627",
  29134. PsnNo: "44020000001102481733",
  29135. Info: "2207",
  29136. }
  29137. customData = append(customData, custom1212)
  29138. custom13 := &CustomData{
  29139. MsgId: "H44022900158202103301740327951",
  29140. PsnNo: "44020000001103174866",
  29141. Info: "2207",
  29142. }
  29143. customData = append(customData, custom13)
  29144. custom14 := &CustomData{
  29145. MsgId: "H4402290015820210330174922668",
  29146. PsnNo: "44020000001102927272",
  29147. Info: "2207",
  29148. }
  29149. customData = append(customData, custom14)
  29150. custom15 := &CustomData{
  29151. MsgId: "H44022900158202103301752362273",
  29152. PsnNo: "44020000001102942890",
  29153. Info: "2207",
  29154. }
  29155. customData = append(customData, custom15)
  29156. custom16 := &CustomData{
  29157. MsgId: "H44022900158202103301751082917",
  29158. PsnNo: "44020000001101662162",
  29159. Info: "2207",
  29160. }
  29161. customData = append(customData, custom16)
  29162. custom17 := &CustomData{
  29163. MsgId: "H44022900158202103301754147728",
  29164. PsnNo: "44020000000229014511",
  29165. Info: "2207",
  29166. }
  29167. customData = append(customData, custom17)
  29168. adminUser := c.GetAdminUserInfo()
  29169. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29170. for _, item := range customData {
  29171. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29172. fmt.Println(result)
  29173. }
  29174. }
  29175. func (c *HisApiController) GetAllopatry() {
  29176. year := c.GetString("year")
  29177. month := c.GetString("month")
  29178. admin_user_id, _ := c.GetInt64("admin_user_id")
  29179. adminUser := c.GetAdminUserInfo()
  29180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29181. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29182. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29183. var dat map[string]interface{}
  29184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29185. fmt.Println(dat)
  29186. } else {
  29187. fmt.Println(err)
  29188. }
  29189. userJSONBytes, _ := json.Marshal(dat)
  29190. var res models.Result9001
  29191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29192. utils.ErrorLog("解析失败:%v", err)
  29193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29194. return
  29195. }
  29196. fmt.Println(res.Output.Signinoutb)
  29197. fmt.Println(res.Output.Signinoutb.SignNo)
  29198. fmt.Println(string(userJSONBytes))
  29199. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29200. var dat3 map[string]interface{}
  29201. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  29202. fmt.Println(dat3)
  29203. } else {
  29204. fmt.Println(err)
  29205. }
  29206. userJSONBytes3, _ := json.Marshal(dat3)
  29207. var res3 models.Result3260
  29208. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29209. utils.ErrorLog("解析失败:%v", err)
  29210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29211. return
  29212. }
  29213. var curpage int
  29214. var pagesize int = 100
  29215. var start int = 1
  29216. //var stop int
  29217. //pagecount := 10
  29218. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  29219. var res22 []models.Result3260
  29220. for curpage = 1; curpage <= pagecount; curpage++ {
  29221. if curpage == 1 {
  29222. start = 0
  29223. } else {
  29224. start = (curpage-1)*pagesize + 1
  29225. }
  29226. fmt.Println(start)
  29227. //stop = curpage * pagesize
  29228. //if stop > int(res3.Output.Totalrow) {
  29229. // stop =int(res3.Output.Totalrow)
  29230. //}
  29231. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  29232. var dat2 map[string]interface{}
  29233. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29234. fmt.Println(dat)
  29235. } else {
  29236. fmt.Println(err)
  29237. }
  29238. userJSONBytes2, _ := json.Marshal(dat2)
  29239. var res2 models.Result3260
  29240. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29241. utils.ErrorLog("解析失败:%v", err)
  29242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29243. return
  29244. }
  29245. if res2.Infcode == 0 {
  29246. res22 = append(res22, res2)
  29247. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29248. //var dat2 map[string]interface{}
  29249. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29250. // fmt.Println(dat)
  29251. //} else {
  29252. // fmt.Println(err)
  29253. //}
  29254. //c.ServeSuccessJSON(map[string]interface{}{
  29255. // "list": res2.Output.Data,
  29256. //})
  29257. //continue
  29258. }
  29259. }
  29260. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29261. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29262. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  29263. //var dat2 map[string]interface{}
  29264. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29265. // fmt.Println(dat)
  29266. //} else {
  29267. // fmt.Println(err)
  29268. //}
  29269. //userJSONBytes2, _ := json.Marshal(dat2)
  29270. //var res2 models.Result3260
  29271. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29272. // utils.ErrorLog("解析失败:%v", err)
  29273. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29274. // return
  29275. //}
  29276. //if res2.Infcode == 0 {
  29277. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29278. // var dat2 map[string]interface{}
  29279. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29280. // fmt.Println(dat)
  29281. // } else {
  29282. // fmt.Println(err)
  29283. // }
  29284. // c.ServeSuccessJSON(map[string]interface{}{
  29285. // "list": res2.Output.Data,
  29286. // })
  29287. //}
  29288. }
  29289. func (c *HisApiController) ComfirmAllopatry() {
  29290. year := c.GetString("year")
  29291. month := c.GetString("month")
  29292. admin_user_id, _ := c.GetInt64("admin_user_id")
  29293. adminUser := c.GetAdminUserInfo()
  29294. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29295. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29296. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29297. var dat map[string]interface{}
  29298. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29299. fmt.Println(dat)
  29300. } else {
  29301. fmt.Println(err)
  29302. }
  29303. userJSONBytes, _ := json.Marshal(dat)
  29304. var res models.Result9001
  29305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29306. utils.ErrorLog("解析失败:%v", err)
  29307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29308. return
  29309. }
  29310. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29311. var dat2 map[string]interface{}
  29312. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29313. fmt.Println(dat)
  29314. } else {
  29315. fmt.Println(err)
  29316. }
  29317. userJSONBytes2, _ := json.Marshal(dat2)
  29318. var res2 models.Result3260
  29319. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29320. utils.ErrorLog("解析失败:%v", err)
  29321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29322. return
  29323. }
  29324. //if res2.Infcode == 0 {
  29325. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29326. // var dat map[string]interface{}
  29327. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29328. // fmt.Println(dat)
  29329. // } else {
  29330. // fmt.Println(err)
  29331. // }
  29332. // userJSONBytes, _ := json.Marshal(dat)
  29333. // var res3 models.Result3261
  29334. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  29335. // utils.ErrorLog("解析失败:%v", err)
  29336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29337. // return
  29338. // }
  29339. //
  29340. // if res3.Infcode == 0 {
  29341. // record := &models.HisYidiClearRecord{
  29342. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29343. // Ctime: time.Now().Unix(),
  29344. // Mtime: time.Now().Unix(),
  29345. // Status: 1,
  29346. // MsgId: msgId,
  29347. // }
  29348. // service.SaveClearRecord(record)
  29349. // c.ServeSuccessJSON(map[string]interface{}{
  29350. // "msg": "提取成功",
  29351. // })
  29352. // }
  29353. //}
  29354. }
  29355. func (c *HisApiController) RefundAllopatry() {
  29356. year := c.GetString("year")
  29357. month := c.GetString("month")
  29358. //id, _ := c.GetInt64("id")
  29359. admin_user_id, _ := c.GetInt64("admin_user_id")
  29360. adminUser := c.GetAdminUserInfo()
  29361. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29362. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29363. //record, _ := service.GetClearRecordById(id)
  29364. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29365. var dat map[string]interface{}
  29366. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29367. fmt.Println(dat)
  29368. } else {
  29369. fmt.Println(err)
  29370. }
  29371. userJSONBytes, _ := json.Marshal(dat)
  29372. var res models.Result9001
  29373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29374. utils.ErrorLog("解析失败:%v", err)
  29375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29376. return
  29377. }
  29378. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  29379. var dat2 map[string]interface{}
  29380. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  29381. fmt.Println(dat)
  29382. } else {
  29383. fmt.Println(err)
  29384. }
  29385. userJSONBytes2, _ := json.Marshal(dat2)
  29386. var empty ResultFourteen
  29387. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  29388. utils.ErrorLog("解析失败:%v", err)
  29389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29390. return
  29391. }
  29392. if empty.Infcode == 0 {
  29393. c.ServeSuccessJSON(map[string]interface{}{
  29394. "msg": "撤销成功",
  29395. })
  29396. return
  29397. }
  29398. }
  29399. func (c *HisApiController) ReversalOtherData() {
  29400. var customData []*CustomData
  29401. custom := &CustomData{
  29402. MsgId: "H44022900158202103301714472004",
  29403. PsnNo: "44020000001101329945",
  29404. Info: "2208",
  29405. }
  29406. customData = append(customData, custom)
  29407. custom1 := &CustomData{
  29408. MsgId: "H4402290015820210330172057803",
  29409. PsnNo: "44020000001101161813",
  29410. Info: "2208",
  29411. }
  29412. customData = append(customData, custom1)
  29413. custom2 := &CustomData{
  29414. MsgId: "H44022900158202103301705198813",
  29415. PsnNo: "44190000133097375417",
  29416. Info: "2208",
  29417. }
  29418. customData = append(customData, custom2)
  29419. custom3 := &CustomData{
  29420. MsgId: "H44022900158202103301715524756",
  29421. PsnNo: "44020000001100187221",
  29422. Info: "2208",
  29423. }
  29424. customData = append(customData, custom3)
  29425. custom4 := &CustomData{
  29426. MsgId: "H44022900158202103301730376224",
  29427. PsnNo: "44020000001101959155",
  29428. Info: "2208",
  29429. }
  29430. customData = append(customData, custom4)
  29431. custom5 := &CustomData{
  29432. MsgId: "H44022900158202103301748008725",
  29433. PsnNo: "44020000001104246641",
  29434. Info: "2208",
  29435. }
  29436. customData = append(customData, custom5)
  29437. custom6 := &CustomData{
  29438. MsgId: "H44022900158202103301718096755",
  29439. PsnNo: "44020000001102211860",
  29440. Info: "2208",
  29441. }
  29442. customData = append(customData, custom6)
  29443. custom7 := &CustomData{
  29444. MsgId: "H44022900158202103301736551640",
  29445. PsnNo: "44020000001102687718",
  29446. Info: "2208",
  29447. }
  29448. customData = append(customData, custom7)
  29449. custom8 := &CustomData{
  29450. MsgId: "H44022900158202103301743097676",
  29451. PsnNo: "44020000001102127785",
  29452. Info: "2208",
  29453. }
  29454. customData = append(customData, custom8)
  29455. custom9 := &CustomData{
  29456. MsgId: "H44022900158202103301712304203",
  29457. PsnNo: "44020000001101518097",
  29458. Info: "2208",
  29459. }
  29460. customData = append(customData, custom9)
  29461. custom10 := &CustomData{
  29462. MsgId: "H44022900158202103301738448785",
  29463. PsnNo: "44020000001100500813",
  29464. Info: "2208",
  29465. }
  29466. customData = append(customData, custom10)
  29467. custom11 := &CustomData{
  29468. MsgId: "H44022900158202103301732455843",
  29469. PsnNo: "44020000001102690557",
  29470. Info: "2208",
  29471. }
  29472. customData = append(customData, custom11)
  29473. custom12 := &CustomData{
  29474. MsgId: "H44022900158202103301745421708",
  29475. PsnNo: "44020000001102211928",
  29476. Info: "2208",
  29477. }
  29478. customData = append(customData, custom12)
  29479. custom1212 := &CustomData{
  29480. MsgId: "H440229001582021033017351627",
  29481. PsnNo: "44020000001102481733",
  29482. Info: "2208",
  29483. }
  29484. customData = append(customData, custom1212)
  29485. custom13 := &CustomData{
  29486. MsgId: "H44022900158202103301740327951",
  29487. PsnNo: "44020000001103174866",
  29488. Info: "2208",
  29489. }
  29490. customData = append(customData, custom13)
  29491. custom14 := &CustomData{
  29492. MsgId: "H4402290015820210330174922668",
  29493. PsnNo: "44020000001102927272",
  29494. Info: "2208",
  29495. }
  29496. customData = append(customData, custom14)
  29497. custom15 := &CustomData{
  29498. MsgId: "H44022900158202103301752362273",
  29499. PsnNo: "44020000001102942890",
  29500. Info: "2208",
  29501. }
  29502. customData = append(customData, custom15)
  29503. custom16 := &CustomData{
  29504. MsgId: "H44022900158202103301751082917",
  29505. PsnNo: "44020000001101662162",
  29506. Info: "2208",
  29507. }
  29508. customData = append(customData, custom16)
  29509. custom17 := &CustomData{
  29510. MsgId: "H44022900158202103301754147728",
  29511. PsnNo: "44020000000229014511",
  29512. Info: "2208",
  29513. }
  29514. customData = append(customData, custom17)
  29515. adminUser := c.GetAdminUserInfo()
  29516. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29517. for _, item := range customData {
  29518. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29519. fmt.Println(result)
  29520. }
  29521. }
  29522. func PathExists(path string) (bool, error) {
  29523. _, err := os.Stat(path)
  29524. if err == nil {
  29525. return true, nil
  29526. }
  29527. if os.IsNotExist(err) {
  29528. return false, nil
  29529. }
  29530. return false, err
  29531. }
  29532. // 创建文件夹
  29533. func Mkdir(dir string) {
  29534. // 创建文件夹
  29535. exist, err := PathExists(dir)
  29536. if err != nil {
  29537. fmt.Println(err.Error())
  29538. } else {
  29539. if exist {
  29540. fmt.Println(dir + "文件夹已存在!")
  29541. } else {
  29542. // 文件夹名称,权限
  29543. err := os.Mkdir(dir, os.ModePerm)
  29544. if err != nil {
  29545. fmt.Println(dir+"文件夹创建失败:", err.Error())
  29546. } else {
  29547. fmt.Println(dir + "文件夹创建成功!")
  29548. }
  29549. }
  29550. }
  29551. }
  29552. // 压缩文件
  29553. func Zip(srcFile string, destZip string) error {
  29554. zipfile, err := os.Create(destZip)
  29555. if err != nil {
  29556. return err
  29557. }
  29558. defer zipfile.Close()
  29559. archive := zip.NewWriter(zipfile)
  29560. defer archive.Close()
  29561. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  29562. if err != nil {
  29563. return err
  29564. }
  29565. header, err := zip.FileInfoHeader(info)
  29566. if err != nil {
  29567. return err
  29568. }
  29569. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  29570. // header.Name = path
  29571. if info.IsDir() {
  29572. header.Name += "/"
  29573. } else {
  29574. header.Method = zip.Deflate
  29575. }
  29576. writer, err := archive.CreateHeader(header)
  29577. if err != nil {
  29578. return err
  29579. }
  29580. if !info.IsDir() {
  29581. file, err := os.Open(path)
  29582. if err != nil {
  29583. return err
  29584. }
  29585. defer file.Close()
  29586. _, err = io.Copy(writer, file)
  29587. }
  29588. return err
  29589. })
  29590. return err
  29591. }
  29592. func ReadFile(filePath string) []byte {
  29593. f, err := os.Open(filePath)
  29594. if err != nil {
  29595. fmt.Println("read file fail", err)
  29596. return nil
  29597. }
  29598. defer f.Close()
  29599. fd, err := ioutil.ReadAll(f)
  29600. if err != nil {
  29601. fmt.Println("read to fd fail", err)
  29602. return nil
  29603. }
  29604. return fd
  29605. }
  29606. func saveLogq(result string, request string, infno string, desc string) {
  29607. dir := "日志"
  29608. utils.Mkdir(dir)
  29609. month := time.Unix(1557042972, 0).Format("1")
  29610. year := time.Now().Format("2006")
  29611. month = time.Now().Format("01")
  29612. day := time.Now().Format("02")
  29613. hour := time.Now().Format("15")
  29614. min := time.Now().Format("04")
  29615. sec := time.Now().Format("05")
  29616. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29617. file := year + month + day + "_log"
  29618. file_name := file + ".txt"
  29619. file_path := "日志" + "/" + file_name
  29620. exist, _ := utils.PathExists(file_path)
  29621. if exist { //存在
  29622. fmt.Println("存在")
  29623. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29624. if err != nil {
  29625. fmt.Println("read fail")
  29626. }
  29627. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29628. n, _ := f.Seek(0, 2)
  29629. _, err = f.WriteAt([]byte(content), n)
  29630. } else { //不存在
  29631. fmt.Println("文件不存在,创建文件")
  29632. f, err := os.Create("日志" + "/" + file_name)
  29633. defer f.Close()
  29634. if err != nil {
  29635. } else {
  29636. _, err = f.Write([]byte("记录日志"))
  29637. }
  29638. }
  29639. }
  29640. func saveLog(result string, request string, infno string, desc string) {
  29641. org_id, _ := beego.AppConfig.Int64("org_id")
  29642. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29643. dir := miConfig.OrgName + "日志"
  29644. utils.Mkdir(dir)
  29645. month := time.Unix(1557042972, 0).Format("1")
  29646. year := time.Now().Format("2006")
  29647. month = time.Now().Format("01")
  29648. day := time.Now().Format("02")
  29649. hour := time.Now().Format("15")
  29650. min := time.Now().Format("04")
  29651. sec := time.Now().Format("05")
  29652. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29653. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  29654. file_name := file + ".txt"
  29655. file_path := miConfig.OrgName + "日志" + "/" + file_name
  29656. exist, _ := utils.PathExists(file_path)
  29657. if exist { //存在
  29658. fmt.Println("存在")
  29659. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29660. if err != nil {
  29661. fmt.Println("read fail")
  29662. }
  29663. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29664. n, _ := f.Seek(0, 2)
  29665. _, err = f.WriteAt([]byte(content), n)
  29666. } else { //不存在
  29667. fmt.Println("文件不存在,创建文件")
  29668. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  29669. defer f.Close()
  29670. if err != nil {
  29671. } else {
  29672. _, err = f.Write([]byte("记录日志"))
  29673. }
  29674. }
  29675. }
  29676. type Charset string
  29677. const (
  29678. UTF8 = Charset("UTF-8")
  29679. GB18030 = Charset("GB18030")
  29680. )
  29681. func ConvertToString(src string, srcCode string, tagCode string) string {
  29682. srcCoder := mahonia.NewDecoder(srcCode)
  29683. srcResult := srcCoder.ConvertString(src)
  29684. tagCoder := mahonia.NewDecoder(tagCode)
  29685. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  29686. result := string(cdata)
  29687. return result
  29688. }
  29689. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  29690. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29691. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29692. var token string
  29693. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29694. var api string
  29695. if miConfig.MdtrtareaAdmvs == "320921" {
  29696. 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 +
  29697. "&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
  29698. fmt.Println(api)
  29699. } else {
  29700. 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 +
  29701. "&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
  29702. }
  29703. resp, requestErr := http.Get(api)
  29704. if requestErr != nil {
  29705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29706. return ""
  29707. }
  29708. body, ioErr := ioutil.ReadAll(resp.Body)
  29709. if ioErr != nil {
  29710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29712. return ""
  29713. }
  29714. var respJSON map[string]interface{}
  29715. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29718. return ""
  29719. }
  29720. var status string
  29721. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29722. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29723. var res ResultTwo //1101结果
  29724. var res10265 ResultTwo10265 //1101结果
  29725. if status == "0" { //读卡成功
  29726. var card_info string //卡信息
  29727. var busi_card_info string
  29728. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29729. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29730. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29731. fmt.Println(card_info)
  29732. fmt.Println(busi_card_info)
  29733. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29734. result, _ := json.Marshal(respJSON)
  29735. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29736. utils.ErrorLog("解析失败:%v", err)
  29737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29738. return ""
  29739. }
  29740. res.ErrMsg = res10265.ErrMsg
  29741. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29742. res.Infcode = infocode
  29743. res.Output = res10265.Output
  29744. res.InfRefmsgid = res10265.InfRefmsgid
  29745. if res.Infcode == 0 {
  29746. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29747. if err == gorm.ErrRecordNotFound {
  29748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29749. return ""
  29750. } else if err != nil {
  29751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29752. return ""
  29753. } else {
  29754. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29755. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29756. infoStr := string(Iinfos)
  29757. idetinfoStr := string(Idetinfos)
  29758. psn := &models.HisPsn{
  29759. PsnNo: res.Output.Baseinfo.PsnNo,
  29760. PatientId: patient.ID,
  29761. Certno: res.Output.Baseinfo.Certno,
  29762. Gend: res.Output.Baseinfo.Gend,
  29763. Naty: res.Output.Baseinfo.Naty,
  29764. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29765. PsnName: res.Output.Baseinfo.PsnName,
  29766. Idetinfo: idetinfoStr,
  29767. Insuinfo: infoStr,
  29768. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29769. CardInfo: card_info,
  29770. VerifyNumber: token,
  29771. }
  29772. service.CreateHisPsn(psn)
  29773. return token
  29774. }
  29775. }
  29776. } else {
  29777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29778. return ""
  29779. }
  29780. } else { //读卡失败
  29781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29782. return ""
  29783. }
  29784. return token
  29785. }
  29786. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  29787. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29788. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29789. var token string
  29790. var api string
  29791. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29792. "&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
  29793. fmt.Println(api)
  29794. resp, requestErr := http.Get(api)
  29795. if requestErr != nil {
  29796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29797. return ""
  29798. }
  29799. body, ioErr := ioutil.ReadAll(resp.Body)
  29800. if ioErr != nil {
  29801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29803. return ""
  29804. }
  29805. var respJSON map[string]interface{}
  29806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29809. return ""
  29810. }
  29811. var status string
  29812. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29813. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29814. var res ResultTwo //1101结果
  29815. if status == "1" { //读卡成功
  29816. var card_info string //卡信息
  29817. var busi_card_info string
  29818. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29819. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29820. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29821. fmt.Println(card_info)
  29822. fmt.Println(busi_card_info)
  29823. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29824. result, _ := json.Marshal(respJSON)
  29825. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29826. utils.ErrorLog("解析失败:%v", err)
  29827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29828. return ""
  29829. }
  29830. if res.Infcode == 0 {
  29831. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29832. if err == gorm.ErrRecordNotFound {
  29833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29834. return ""
  29835. } else if err != nil {
  29836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29837. return ""
  29838. } else {
  29839. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29840. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29841. infoStr := string(Iinfos)
  29842. idetinfoStr := string(Idetinfos)
  29843. psn := &models.HisPsn{
  29844. PsnNo: res.Output.Baseinfo.PsnNo,
  29845. PatientId: patient.ID,
  29846. Certno: res.Output.Baseinfo.Certno,
  29847. Gend: res.Output.Baseinfo.Gend,
  29848. Naty: res.Output.Baseinfo.Naty,
  29849. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29850. PsnName: res.Output.Baseinfo.PsnName,
  29851. Idetinfo: idetinfoStr,
  29852. Insuinfo: infoStr,
  29853. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29854. CardInfo: card_info,
  29855. VerifyNumber: token,
  29856. }
  29857. service.CreateHisPsn(psn)
  29858. return token
  29859. }
  29860. }
  29861. } else {
  29862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29863. return ""
  29864. }
  29865. return token
  29866. }
  29867. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  29868. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29869. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29870. var token string
  29871. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29872. var api string
  29873. if miConfig.MdtrtareaAdmvs == "320921" {
  29874. 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 +
  29875. "&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
  29876. fmt.Println(api)
  29877. } else {
  29878. 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 +
  29879. "&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
  29880. }
  29881. resp, requestErr := http.Get(api)
  29882. if requestErr != nil {
  29883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29884. return ""
  29885. }
  29886. body, ioErr := ioutil.ReadAll(resp.Body)
  29887. if ioErr != nil {
  29888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29890. return ""
  29891. }
  29892. var respJSON map[string]interface{}
  29893. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29896. return ""
  29897. }
  29898. var status string
  29899. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29900. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29901. var res ResultTwo //1101结果
  29902. var res10265 ResultTwo10265 //1101结果
  29903. if status == "0" { //读卡成功
  29904. var card_info string //卡信息
  29905. var busi_card_info string
  29906. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29907. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29908. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29909. fmt.Println(card_info)
  29910. fmt.Println(busi_card_info)
  29911. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29912. result, _ := json.Marshal(respJSON)
  29913. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29914. utils.ErrorLog("解析失败:%v", err)
  29915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29916. return ""
  29917. }
  29918. res.ErrMsg = res10265.ErrMsg
  29919. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29920. res.Infcode = infocode
  29921. res.Output = res10265.Output
  29922. res.InfRefmsgid = res10265.InfRefmsgid
  29923. if res.Infcode == 0 {
  29924. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29925. if err == gorm.ErrRecordNotFound {
  29926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29927. return ""
  29928. } else if err != nil {
  29929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29930. return ""
  29931. } else {
  29932. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29933. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29934. infoStr := string(Iinfos)
  29935. idetinfoStr := string(Idetinfos)
  29936. psn := &models.HisPsn{
  29937. PsnNo: res.Output.Baseinfo.PsnNo,
  29938. PatientId: patient.ID,
  29939. Certno: res.Output.Baseinfo.Certno,
  29940. Gend: res.Output.Baseinfo.Gend,
  29941. Naty: res.Output.Baseinfo.Naty,
  29942. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29943. PsnName: res.Output.Baseinfo.PsnName,
  29944. Idetinfo: idetinfoStr,
  29945. Insuinfo: infoStr,
  29946. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29947. CardInfo: card_info,
  29948. VerifyNumber: token,
  29949. }
  29950. service.CreateHisPsn(psn)
  29951. return token
  29952. }
  29953. }
  29954. } else {
  29955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29956. return ""
  29957. }
  29958. } else { //读卡失败
  29959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29960. return ""
  29961. }
  29962. return token
  29963. }
  29964. func DeleteExtraSpaceTwo(s string) string {
  29965. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29966. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29967. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29968. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29969. s2 := make([]byte, len(s1)) //定义字符数组切片
  29970. copy(s2, s1) //将字符串复制到切片
  29971. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29972. for len(spc_index) > 0 { //找到适配项
  29973. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29974. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29975. }
  29976. return string(s2)
  29977. }
  29978. func Remove0000(s string) string {
  29979. str := make([]rune, 0, len(s))
  29980. for _, v := range []rune(s) {
  29981. if v == 0 {
  29982. continue
  29983. }
  29984. str = append(str, v)
  29985. }
  29986. return string(str)
  29987. }
  29988. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  29989. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  29990. readCard := DllDef.MustFindProc("EcQuery")
  29991. pCardInfo := make([]byte, 8192)
  29992. pBusiCardInfo := make([]byte, 8192)
  29993. data := make(map[string]interface{})
  29994. //pData := make(map[string]interface{})
  29995. inputData := make(map[string]interface{})
  29996. inputData["orgId"] = code
  29997. inputData["businessType"] = "01101"
  29998. inputData["operatorId"] = operator_id
  29999. inputData["operatorName"] = operator_name
  30000. inputData["officeId"] = "001"
  30001. inputData["officeName"] = "血透室"
  30002. //
  30003. data["data"] = inputData
  30004. data["transType"] = "ec.query"
  30005. data["orgId"] = code
  30006. bytesData, _ := json.Marshal(data)
  30007. pCardInfo = bytesData
  30008. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  30009. fmt.Println(ret2)
  30010. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  30011. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  30012. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  30013. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  30014. if ret2 != 0 {
  30015. return "", ""
  30016. }
  30017. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  30018. }
  30019. func DeleteExtraSpace(s string) string {
  30020. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  30021. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  30022. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  30023. reg, _ := regexp.Compile(regstr) //编译正则表达式
  30024. s2 := make([]byte, len(s1)) //定义字符数组切片
  30025. copy(s2, s1) //将字符串复制到切片
  30026. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  30027. for len(spc_index) > 0 { //找到适配项
  30028. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  30029. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  30030. }
  30031. return string(s2)
  30032. }
  30033. // 对账
  30034. func (c *HisApiController) Post3202() {
  30035. start_time := c.GetString("start_time")
  30036. end_time := c.GetString("end_time")
  30037. //insutype := c.GetString("insutype")
  30038. clr_type := c.GetString("clr_type")
  30039. clr_org := c.GetString("clr_optins")
  30040. admin_user_id, _ := c.GetInt64("admin_user_id")
  30041. adminUser := c.GetAdminUserInfo()
  30042. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30043. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30044. if len(clr_org) == 0 {
  30045. clr_org = miConfig.MdtrtareaAdmvs
  30046. }
  30047. timeLayout := "2006-01-02"
  30048. loc, _ := time.LoadLocation("Local")
  30049. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30050. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30051. var orders []*models.HisOrder
  30052. if clr_org == "421300" {
  30053. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30054. } else {
  30055. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30056. }
  30057. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30058. //fixmedins_setl_cnt := int64(len(orders))
  30059. var medfee_sumamt float64
  30060. var acct_pay float64
  30061. var fund_pay_sumamt float64
  30062. for _, item := range orders {
  30063. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30064. acct_pay = acct_pay + item.AcctPay
  30065. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30066. }
  30067. //var medfee_sumamt_two float64
  30068. //var acct_pay_two float64
  30069. //var fund_pay_sumamt_two float64
  30070. //for _, item := range orders_two {
  30071. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30072. // acct_pay_two = acct_pay_two + item.AcctPay
  30073. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30074. //}
  30075. //var user_name string
  30076. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30077. //if role.ID == 0 {
  30078. // user_name = "xxx"
  30079. //} else {
  30080. // user_name = role.UserName
  30081. //}
  30082. var res ResultSix
  30083. if config.IsOpen == 1 {
  30084. var bps []*models.BusinessParamsTwo
  30085. var bp models.BusinessParamsTwo
  30086. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30087. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30088. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  30089. bp.MedfeeSumamt = medfee_sumamt_str
  30090. bp.AcctPay = acct_pay_str
  30091. bp.FundPaySumamt = fund_pay_sumamt_str
  30092. bp.Insutype = ""
  30093. bp.StmtBegndate = start_time
  30094. bp.ClrType = clr_type
  30095. bp.SetlOptins = clr_org
  30096. bp.StmtEnddate = end_time
  30097. bps = append(bps, &bp)
  30098. data := make(map[string]interface{})
  30099. data["bps"] = bps
  30100. data["org_name"] = miConfig.OrgName
  30101. data["doctor"] = role.UserName
  30102. data["fixmedins_code"] = miConfig.Code
  30103. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30104. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30105. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30106. if miConfig.MdtrtareaAdmvs == "421300" {
  30107. client := &http.Client{}
  30108. bytesData, _ := json.Marshal(data)
  30109. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  30110. resp, _ := client.Do(req)
  30111. defer resp.Body.Close()
  30112. body, ioErr := ioutil.ReadAll(resp.Body)
  30113. if ioErr != nil {
  30114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30116. return
  30117. }
  30118. var respJSON map[string]interface{}
  30119. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30122. return
  30123. }
  30124. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30125. userJSONBytes, _ := json.Marshal(respJSON)
  30126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30127. utils.ErrorLog("解析失败:%v", err)
  30128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30129. return
  30130. }
  30131. }
  30132. if miConfig.MdtrtareaAdmvs == "420200" {
  30133. client := &http.Client{}
  30134. bytesData, _ := json.Marshal(data)
  30135. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  30136. resp, _ := client.Do(req)
  30137. defer resp.Body.Close()
  30138. body, ioErr := ioutil.ReadAll(resp.Body)
  30139. if ioErr != nil {
  30140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30142. return
  30143. }
  30144. var respJSON map[string]interface{}
  30145. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30148. return
  30149. }
  30150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30151. userJSONBytes, _ := json.Marshal(respJSON)
  30152. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30153. utils.ErrorLog("解析失败:%v", err)
  30154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30155. return
  30156. }
  30157. }
  30158. if miConfig.MdtrtareaAdmvs == "421182" {
  30159. client := &http.Client{}
  30160. bytesData, _ := json.Marshal(data)
  30161. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  30162. resp, _ := client.Do(req)
  30163. defer resp.Body.Close()
  30164. body, ioErr := ioutil.ReadAll(resp.Body)
  30165. if ioErr != nil {
  30166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30168. return
  30169. }
  30170. var respJSON map[string]interface{}
  30171. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30174. return
  30175. }
  30176. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30177. userJSONBytes, _ := json.Marshal(respJSON)
  30178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30179. utils.ErrorLog("解析失败:%v", err)
  30180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30181. return
  30182. }
  30183. }
  30184. if res.Infcode == 0 {
  30185. c.ServeSuccessJSON(map[string]interface{}{
  30186. "msg": "发起成功",
  30187. })
  30188. } else {
  30189. c.ServeSuccessJSON(map[string]interface{}{
  30190. "failed_code": -10,
  30191. "msg": res.ErrMsg,
  30192. })
  30193. }
  30194. }
  30195. }
  30196. func (c *HisApiController) Post3202b() {
  30197. start_time := c.GetString("start_time")
  30198. end_time := c.GetString("end_time")
  30199. //insutype := c.GetString("insutype")
  30200. clr_type := c.GetString("clr_type")
  30201. clr_org := c.GetString("clr_optins")
  30202. admin_user_id, _ := c.GetInt64("admin_user_id")
  30203. adminUser := c.GetAdminUserInfo()
  30204. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30205. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30206. if len(clr_org) == 0 {
  30207. clr_org = miConfig.MdtrtareaAdmvs
  30208. }
  30209. timeLayout := "2006-01-02"
  30210. loc, _ := time.LoadLocation("Local")
  30211. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30212. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30213. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30214. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30215. //fixmedins_setl_cnt := int64(len(orders))
  30216. var medfee_sumamt float64
  30217. var acct_pay float64
  30218. var fund_pay_sumamt float64
  30219. for _, item := range orders {
  30220. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30221. acct_pay = acct_pay + item.AcctPay
  30222. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30223. }
  30224. //var medfee_sumamt_two float64
  30225. //var acct_pay_two float64
  30226. //var fund_pay_sumamt_two float64
  30227. //for _, item := range orders_two {
  30228. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30229. // acct_pay_two = acct_pay_two + item.AcctPay
  30230. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30231. //}
  30232. //var user_name string
  30233. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30234. //if role.ID == 0 {
  30235. // user_name = "xxx"
  30236. //} else {
  30237. // user_name = role.UserName
  30238. //}
  30239. var res ResultSix
  30240. if config.IsOpen == 1 {
  30241. var bps []*models.BusinessParamsTwo
  30242. var bp models.BusinessParamsTwo
  30243. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30244. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30245. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  30246. bp.MedfeeSumamt = medfee_sumamt_str
  30247. bp.AcctPay = acct_pay_str
  30248. bp.FundPaySumamt = fund_pay_sumamt_str
  30249. bp.Insutype = "390"
  30250. bp.StmtBegndate = start_time
  30251. bp.ClrType = clr_type
  30252. bp.SetlOptins = clr_org
  30253. bp.StmtEnddate = end_time
  30254. bps = append(bps, &bp)
  30255. data := make(map[string]interface{})
  30256. data["bps"] = bps
  30257. data["org_name"] = miConfig.OrgName
  30258. data["doctor"] = role.UserName
  30259. data["fixmedins_code"] = miConfig.Code
  30260. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30261. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30262. if miConfig.MdtrtareaAdmvs == "421300" {
  30263. client := &http.Client{}
  30264. bytesData, _ := json.Marshal(data)
  30265. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30266. resp, _ := client.Do(req)
  30267. defer resp.Body.Close()
  30268. body, ioErr := ioutil.ReadAll(resp.Body)
  30269. if ioErr != nil {
  30270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30272. return
  30273. }
  30274. var respJSON map[string]interface{}
  30275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30278. return
  30279. }
  30280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30281. userJSONBytes, _ := json.Marshal(respJSON)
  30282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30283. utils.ErrorLog("解析失败:%v", err)
  30284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30285. return
  30286. }
  30287. }
  30288. if miConfig.MdtrtareaAdmvs == "420200" {
  30289. client := &http.Client{}
  30290. bytesData, _ := json.Marshal(data)
  30291. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30292. resp, _ := client.Do(req)
  30293. defer resp.Body.Close()
  30294. body, ioErr := ioutil.ReadAll(resp.Body)
  30295. if ioErr != nil {
  30296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30298. return
  30299. }
  30300. var respJSON map[string]interface{}
  30301. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30304. return
  30305. }
  30306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30307. userJSONBytes, _ := json.Marshal(respJSON)
  30308. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30309. utils.ErrorLog("解析失败:%v", err)
  30310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30311. return
  30312. }
  30313. }
  30314. if miConfig.MdtrtareaAdmvs == "421182" {
  30315. client := &http.Client{}
  30316. bytesData, _ := json.Marshal(data)
  30317. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  30318. resp, _ := client.Do(req)
  30319. defer resp.Body.Close()
  30320. body, ioErr := ioutil.ReadAll(resp.Body)
  30321. if ioErr != nil {
  30322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30324. return
  30325. }
  30326. var respJSON map[string]interface{}
  30327. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30330. return
  30331. }
  30332. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30333. userJSONBytes, _ := json.Marshal(respJSON)
  30334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30335. utils.ErrorLog("解析失败:%v", err)
  30336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30337. return
  30338. }
  30339. }
  30340. if res.Infcode == 0 {
  30341. c.ServeSuccessJSON(map[string]interface{}{
  30342. "msg": "发起成功",
  30343. })
  30344. } else {
  30345. c.ServeSuccessJSON(map[string]interface{}{
  30346. "failed_code": -10,
  30347. "msg": res.ErrMsg,
  30348. })
  30349. }
  30350. }
  30351. }
  30352. func (c *HisApiController) Post1608() {
  30353. start_time := c.GetString("start_time")
  30354. end_time := c.GetString("end_time")
  30355. admin_user_id, _ := c.GetInt64("admin_user_id")
  30356. adminUser := c.GetAdminUserInfo()
  30357. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30358. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30359. timeLayout := "2006-01-02"
  30360. loc, _ := time.LoadLocation("Local")
  30361. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30362. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30363. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30364. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30365. fixmedins_setl_cnt := int64(len(orders))
  30366. var medfee_sumamt float64
  30367. var func_smamt float64
  30368. for _, item := range orders {
  30369. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30370. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  30371. }
  30372. times := strings.Split(start_time, "-")
  30373. time_tows := strings.Split(end_time, "-")
  30374. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30375. var res ResultSix
  30376. if config.IsOpen == 1 {
  30377. //var bps []*models.BusinessParamsTwo
  30378. //var bp models.BusinessParamsTwo
  30379. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30380. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  30381. data := make(map[string]interface{})
  30382. data["org_name"] = miConfig.OrgName
  30383. data["doctor"] = role.UserName
  30384. data["func_smamt"] = func_smamt_str
  30385. data["fixmedins_code"] = miConfig.Code
  30386. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30387. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30388. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  30389. data["medfee_sumamt"] = medfee_sumamt_str
  30390. data["start_time"] = times[0] + times[1] + times[2]
  30391. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  30392. if miConfig.MdtrtareaAdmvs == "421300" {
  30393. client := &http.Client{}
  30394. bytesData, _ := json.Marshal(data)
  30395. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30396. resp, _ := client.Do(req)
  30397. defer resp.Body.Close()
  30398. body, ioErr := ioutil.ReadAll(resp.Body)
  30399. if ioErr != nil {
  30400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30402. return
  30403. }
  30404. var respJSON map[string]interface{}
  30405. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30408. return
  30409. }
  30410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30411. userJSONBytes, _ := json.Marshal(respJSON)
  30412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30413. utils.ErrorLog("解析失败:%v", err)
  30414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30415. return
  30416. }
  30417. }
  30418. if miConfig.MdtrtareaAdmvs == "420200" {
  30419. client := &http.Client{}
  30420. bytesData, _ := json.Marshal(data)
  30421. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30422. resp, _ := client.Do(req)
  30423. defer resp.Body.Close()
  30424. body, ioErr := ioutil.ReadAll(resp.Body)
  30425. if ioErr != nil {
  30426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30428. return
  30429. }
  30430. var respJSON map[string]interface{}
  30431. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30434. return
  30435. }
  30436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30437. userJSONBytes, _ := json.Marshal(respJSON)
  30438. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30439. utils.ErrorLog("解析失败:%v", err)
  30440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30441. return
  30442. }
  30443. }
  30444. if miConfig.MdtrtareaAdmvs == "421182" {
  30445. client := &http.Client{}
  30446. bytesData, _ := json.Marshal(data)
  30447. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  30448. resp, _ := client.Do(req)
  30449. defer resp.Body.Close()
  30450. body, ioErr := ioutil.ReadAll(resp.Body)
  30451. if ioErr != nil {
  30452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30454. return
  30455. }
  30456. var respJSON map[string]interface{}
  30457. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30460. return
  30461. }
  30462. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30463. userJSONBytes, _ := json.Marshal(respJSON)
  30464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30465. utils.ErrorLog("解析失败:%v", err)
  30466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30467. return
  30468. }
  30469. }
  30470. if res.Infcode == 0 {
  30471. c.ServeSuccessJSON(map[string]interface{}{
  30472. "msg": "发起成功",
  30473. })
  30474. } else {
  30475. c.ServeSuccessJSON(map[string]interface{}{
  30476. "failed_code": -10,
  30477. "msg": res.ErrMsg,
  30478. })
  30479. }
  30480. }
  30481. }
  30482. // 5.11.1.1【5262】结算信息按时间段查询
  30483. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30484. admin_user_id, _ := c.GetInt64("admin_user_id")
  30485. adminUser := c.GetAdminUserInfo()
  30486. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30487. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30488. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30489. var res Result5262
  30490. if config.IsOpen == 1 {
  30491. if miConfig.MdtrtareaAdmvs == "421300" {
  30492. data := make(map[string]interface{})
  30493. data["bps"] = bp
  30494. data["org_name"] = miConfig.OrgName
  30495. data["doctor"] = role.UserName
  30496. data["fixmedins_code"] = miConfig.Code
  30497. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30498. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30499. data["page"] = strconv.FormatInt(page, 10)
  30500. data["limit"] = strconv.FormatInt(limit, 10)
  30501. fmt.Println(data)
  30502. client := &http.Client{}
  30503. bytesData, _ := json.Marshal(data)
  30504. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30505. resp, _ := client.Do(req)
  30506. defer resp.Body.Close()
  30507. body, ioErr := ioutil.ReadAll(resp.Body)
  30508. if ioErr != nil {
  30509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30511. return
  30512. }
  30513. var respJSON map[string]interface{}
  30514. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30517. return
  30518. }
  30519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30520. userJSONBytes, _ := json.Marshal(respJSON)
  30521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30522. utils.ErrorLog("解析失败:%v", err)
  30523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30524. return
  30525. }
  30526. }
  30527. if miConfig.MdtrtareaAdmvs == "420200" {
  30528. data := make(map[string]interface{})
  30529. data["bps"] = bp
  30530. data["org_name"] = miConfig.OrgName
  30531. data["doctor"] = role.UserName
  30532. data["fixmedins_code"] = miConfig.Code
  30533. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30534. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30535. data["page"] = strconv.FormatInt(page, 10)
  30536. data["limit"] = strconv.FormatInt(limit, 10)
  30537. fmt.Println(data)
  30538. client := &http.Client{}
  30539. bytesData, _ := json.Marshal(data)
  30540. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30541. resp, _ := client.Do(req)
  30542. defer resp.Body.Close()
  30543. body, ioErr := ioutil.ReadAll(resp.Body)
  30544. if ioErr != nil {
  30545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30547. return
  30548. }
  30549. var respJSON map[string]interface{}
  30550. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30553. return
  30554. }
  30555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30556. userJSONBytes, _ := json.Marshal(respJSON)
  30557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30558. utils.ErrorLog("解析失败:%v", err)
  30559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30560. return
  30561. }
  30562. }
  30563. if miConfig.MdtrtareaAdmvs == "421182" {
  30564. data := make(map[string]interface{})
  30565. data["bps"] = bp
  30566. data["org_name"] = miConfig.OrgName
  30567. data["doctor"] = role.UserName
  30568. data["fixmedins_code"] = miConfig.Code
  30569. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30570. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30571. data["page"] = strconv.FormatInt(page, 10)
  30572. data["limit"] = strconv.FormatInt(limit, 10)
  30573. fmt.Println(data)
  30574. client := &http.Client{}
  30575. bytesData, _ := json.Marshal(data)
  30576. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  30577. resp, _ := client.Do(req)
  30578. defer resp.Body.Close()
  30579. body, ioErr := ioutil.ReadAll(resp.Body)
  30580. if ioErr != nil {
  30581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30583. return
  30584. }
  30585. var respJSON map[string]interface{}
  30586. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30589. return
  30590. }
  30591. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30592. userJSONBytes, _ := json.Marshal(respJSON)
  30593. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30594. utils.ErrorLog("解析失败:%v", err)
  30595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30596. return
  30597. }
  30598. }
  30599. if res.Infcode == 0 {
  30600. c.ServeSuccessJSON(map[string]interface{}{
  30601. "order": res.Output.Result,
  30602. "total": res.Output.PageInfo.RecordCounts,
  30603. })
  30604. } else {
  30605. c.ServeSuccessJSON(map[string]interface{}{
  30606. "failed_code": -10,
  30607. "msg": res.ErrMsg,
  30608. })
  30609. }
  30610. }
  30611. }
  30612. // 5.11.1.2【5267】异地结算信息时间段查询
  30613. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30614. admin_user_id, _ := c.GetInt64("admin_user_id")
  30615. adminUser := c.GetAdminUserInfo()
  30616. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30617. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30618. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30619. var res Result5267
  30620. if config.IsOpen == 1 {
  30621. if miConfig.MdtrtareaAdmvs == "421300" {
  30622. data := make(map[string]interface{})
  30623. data["bps"] = bp
  30624. data["org_name"] = miConfig.OrgName
  30625. data["doctor"] = role.UserName
  30626. data["fixmedins_code"] = miConfig.Code
  30627. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30628. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30629. data["page"] = page
  30630. data["limit"] = limit
  30631. fmt.Println(data)
  30632. client := &http.Client{}
  30633. bytesData, _ := json.Marshal(data)
  30634. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30635. resp, _ := client.Do(req)
  30636. defer resp.Body.Close()
  30637. body, ioErr := ioutil.ReadAll(resp.Body)
  30638. if ioErr != nil {
  30639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30641. return
  30642. }
  30643. var respJSON map[string]interface{}
  30644. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30647. return
  30648. }
  30649. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30650. userJSONBytes, _ := json.Marshal(respJSON)
  30651. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30652. utils.ErrorLog("解析失败:%v", err)
  30653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30654. return
  30655. }
  30656. }
  30657. if miConfig.MdtrtareaAdmvs == "420200" {
  30658. data := make(map[string]interface{})
  30659. data["bps"] = bp
  30660. data["org_name"] = miConfig.OrgName
  30661. data["doctor"] = role.UserName
  30662. data["fixmedins_code"] = miConfig.Code
  30663. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30664. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30665. data["page"] = page
  30666. data["limit"] = limit
  30667. fmt.Println(data)
  30668. client := &http.Client{}
  30669. bytesData, _ := json.Marshal(data)
  30670. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30671. resp, _ := client.Do(req)
  30672. defer resp.Body.Close()
  30673. body, ioErr := ioutil.ReadAll(resp.Body)
  30674. if ioErr != nil {
  30675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30677. return
  30678. }
  30679. var respJSON map[string]interface{}
  30680. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30683. return
  30684. }
  30685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30686. userJSONBytes, _ := json.Marshal(respJSON)
  30687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30688. utils.ErrorLog("解析失败:%v", err)
  30689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30690. return
  30691. }
  30692. }
  30693. if miConfig.MdtrtareaAdmvs == "421182" {
  30694. data := make(map[string]interface{})
  30695. data["bps"] = bp
  30696. data["org_name"] = miConfig.OrgName
  30697. data["doctor"] = role.UserName
  30698. data["fixmedins_code"] = miConfig.Code
  30699. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30700. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30701. data["page"] = page
  30702. data["limit"] = limit
  30703. fmt.Println(data)
  30704. client := &http.Client{}
  30705. bytesData, _ := json.Marshal(data)
  30706. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  30707. resp, _ := client.Do(req)
  30708. defer resp.Body.Close()
  30709. body, ioErr := ioutil.ReadAll(resp.Body)
  30710. if ioErr != nil {
  30711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30713. return
  30714. }
  30715. var respJSON map[string]interface{}
  30716. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30719. return
  30720. }
  30721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30722. userJSONBytes, _ := json.Marshal(respJSON)
  30723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30724. utils.ErrorLog("解析失败:%v", err)
  30725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30726. return
  30727. }
  30728. }
  30729. if res.Infcode == 0 {
  30730. c.ServeSuccessJSON(map[string]interface{}{
  30731. "order": res.Output.Result,
  30732. "total": res.Output.PageInfo.RecordCounts,
  30733. })
  30734. } else {
  30735. c.ServeSuccessJSON(map[string]interface{}{
  30736. "failed_code": -10,
  30737. "msg": res.ErrMsg,
  30738. })
  30739. }
  30740. }
  30741. }
  30742. func (c *HisApiController) Post3501() {
  30743. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30744. data := make(map[string]interface{})
  30745. var struct3501s []models.Struct3501
  30746. var struct3501 models.Struct3501
  30747. struct3501.OrgName = miConfig.OrgName
  30748. struct3501.AccessKey = miConfig.AccessKey
  30749. struct3501.RequestUrl = miConfig.Url
  30750. struct3501.SecretKey = miConfig.SecretKey
  30751. struct3501.ManuDate = "2022-08-17"
  30752. struct3501.FixmedinsBchno = ""
  30753. struct3501.ManuLotnum = ""
  30754. struct3501.RxFlag = "0"
  30755. struct3501.ExpyEnd = "2022-08-17"
  30756. struct3501.Invdate = "2022-08-17"
  30757. struct3501.InvCnt = "20.25"
  30758. struct3501.Memo = ""
  30759. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30760. struct3501.FixmedinsHilistId = miConfig.Code
  30761. struct3501.FixmedinsHilistName = miConfig.OrgName
  30762. struct3501s = append(struct3501s, struct3501)
  30763. data["struct_3501s"] = struct3501s
  30764. client := &http.Client{}
  30765. bytesData, _ := json.Marshal(data)
  30766. var req *http.Request
  30767. if miConfig.MdtrtareaAdmvs == "320921" {
  30768. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30769. } else {
  30770. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30771. }
  30772. resp, _ := client.Do(req)
  30773. defer resp.Body.Close()
  30774. body, ioErr := ioutil.ReadAll(resp.Body)
  30775. if ioErr != nil {
  30776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30778. return
  30779. }
  30780. var respJSON map[string]interface{}
  30781. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30784. return
  30785. }
  30786. var res ResultSix
  30787. var resSix10265 ResultSix10265 //1101结果
  30788. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30789. result, _ := json.Marshal(respJSON)
  30790. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30791. utils.ErrorLog("解析失败:%v", err)
  30792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30793. return
  30794. }
  30795. res.InfRefmsgid = resSix10265.InfRefmsgid
  30796. res.Output = resSix10265.Output
  30797. res.ErrMsg = resSix10265.ErrMsg
  30798. res.Cainfo = resSix10265.Cainfo
  30799. res.WarnMsg = resSix10265.WarnMsg
  30800. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30801. res.Infcode = infocode
  30802. if infocode == 0 {
  30803. c.ServeSuccessJSON(map[string]interface{}{
  30804. "msg": "上传成功",
  30805. })
  30806. return
  30807. } else {
  30808. c.ServeSuccessJSON(map[string]interface{}{
  30809. "failed_code": -10,
  30810. "msg": res.ErrMsg,
  30811. })
  30812. return
  30813. }
  30814. }
  30815. func (c *HisApiController) Post3502() {
  30816. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30817. data := make(map[string]interface{})
  30818. var struct3502s []models.Struct3502
  30819. var struct3502 models.Struct3502
  30820. struct3502.OrgName = miConfig.OrgName
  30821. struct3502.AccessKey = miConfig.AccessKey
  30822. struct3502.RequestUrl = miConfig.Url
  30823. struct3502.SecretKey = miConfig.SecretKey
  30824. struct3502.ManuDate = "2022-08-15"
  30825. struct3502.FixmedinsBchno = ""
  30826. struct3502.ManuLotnum = ""
  30827. struct3502.RxFlag = "0"
  30828. struct3502.ExpyEnd = "2022-08-15"
  30829. struct3502.Invdate = "2022-08-15"
  30830. struct3502.InvCnt = "20.25"
  30831. struct3502.Memo = ""
  30832. struct3502.MedListCodg = "XB01ABD056B002020200517"
  30833. struct3502.FixmedinsHilistId = miConfig.Code
  30834. struct3502.FixmedinsHilistName = miConfig.OrgName
  30835. struct3502s = append(struct3502s, struct3502)
  30836. data["struct_3502s"] = struct3502s
  30837. client := &http.Client{}
  30838. bytesData, _ := json.Marshal(data)
  30839. var req *http.Request
  30840. if miConfig.MdtrtareaAdmvs == "320921" {
  30841. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30842. } else {
  30843. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30844. }
  30845. resp, _ := client.Do(req)
  30846. defer resp.Body.Close()
  30847. body, ioErr := ioutil.ReadAll(resp.Body)
  30848. if ioErr != nil {
  30849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30851. return
  30852. }
  30853. var respJSON map[string]interface{}
  30854. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30857. return
  30858. }
  30859. var res ResultSix
  30860. var resSix10265 ResultSix10265 //1101结果
  30861. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30862. result, _ := json.Marshal(respJSON)
  30863. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30864. utils.ErrorLog("解析失败:%v", err)
  30865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30866. return
  30867. }
  30868. res.InfRefmsgid = resSix10265.InfRefmsgid
  30869. res.Output = resSix10265.Output
  30870. res.ErrMsg = resSix10265.ErrMsg
  30871. res.Cainfo = resSix10265.Cainfo
  30872. res.WarnMsg = resSix10265.WarnMsg
  30873. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30874. res.Infcode = infocode
  30875. if infocode == 0 {
  30876. c.ServeSuccessJSON(map[string]interface{}{
  30877. "msg": "上传成功",
  30878. })
  30879. return
  30880. } else {
  30881. c.ServeSuccessJSON(map[string]interface{}{
  30882. "failed_code": -10,
  30883. "msg": res.ErrMsg,
  30884. })
  30885. return
  30886. }
  30887. }
  30888. func (c *HisApiController) Post3503() {
  30889. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30890. data := make(map[string]interface{})
  30891. var struct3501s []models.Struct3501
  30892. var struct3501 models.Struct3501
  30893. struct3501.OrgName = miConfig.OrgName
  30894. struct3501.AccessKey = miConfig.AccessKey
  30895. struct3501.RequestUrl = miConfig.Url
  30896. struct3501.SecretKey = miConfig.SecretKey
  30897. struct3501.ManuDate = "2022-08-15"
  30898. struct3501.FixmedinsBchno = ""
  30899. struct3501.ManuLotnum = ""
  30900. struct3501.RxFlag = "0"
  30901. struct3501.ExpyEnd = "2022-08-15"
  30902. struct3501.Invdate = "2022-08-15"
  30903. struct3501.InvCnt = "20.25"
  30904. struct3501.Memo = ""
  30905. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30906. struct3501.FixmedinsHilistId = miConfig.Code
  30907. struct3501.FixmedinsHilistName = miConfig.OrgName
  30908. struct3501s = append(struct3501s, struct3501)
  30909. data["struct_3501s"] = struct3501s
  30910. client := &http.Client{}
  30911. bytesData, _ := json.Marshal(data)
  30912. var req *http.Request
  30913. if miConfig.MdtrtareaAdmvs == "320921" {
  30914. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30915. } else {
  30916. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30917. }
  30918. resp, _ := client.Do(req)
  30919. defer resp.Body.Close()
  30920. body, ioErr := ioutil.ReadAll(resp.Body)
  30921. if ioErr != nil {
  30922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30924. return
  30925. }
  30926. var respJSON map[string]interface{}
  30927. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30930. return
  30931. }
  30932. var res ResultSix
  30933. var resSix10265 ResultSix10265 //1101结果
  30934. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30935. result, _ := json.Marshal(respJSON)
  30936. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30937. utils.ErrorLog("解析失败:%v", err)
  30938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30939. return
  30940. }
  30941. res.InfRefmsgid = resSix10265.InfRefmsgid
  30942. res.Output = resSix10265.Output
  30943. res.ErrMsg = resSix10265.ErrMsg
  30944. res.Cainfo = resSix10265.Cainfo
  30945. res.WarnMsg = resSix10265.WarnMsg
  30946. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30947. res.Infcode = infocode
  30948. if infocode == 0 {
  30949. c.ServeSuccessJSON(map[string]interface{}{
  30950. "msg": "上传成功",
  30951. })
  30952. return
  30953. } else {
  30954. c.ServeSuccessJSON(map[string]interface{}{
  30955. "failed_code": -10,
  30956. "msg": res.ErrMsg,
  30957. })
  30958. return
  30959. }
  30960. }
  30961. func (c *HisApiController) Post3504() {
  30962. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30963. data := make(map[string]interface{})
  30964. var struct3501s []models.Struct3501
  30965. var struct3501 models.Struct3501
  30966. struct3501.OrgName = miConfig.OrgName
  30967. struct3501.AccessKey = miConfig.AccessKey
  30968. struct3501.RequestUrl = miConfig.Url
  30969. struct3501.SecretKey = miConfig.SecretKey
  30970. struct3501.ManuDate = "2022-08-15"
  30971. struct3501.FixmedinsBchno = ""
  30972. struct3501.ManuLotnum = ""
  30973. struct3501.RxFlag = "0"
  30974. struct3501.ExpyEnd = "2022-08-15"
  30975. struct3501.Invdate = "2022-08-15"
  30976. struct3501.InvCnt = "20.25"
  30977. struct3501.Memo = ""
  30978. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30979. struct3501.FixmedinsHilistId = miConfig.Code
  30980. struct3501.FixmedinsHilistName = miConfig.OrgName
  30981. struct3501s = append(struct3501s, struct3501)
  30982. data["struct_3501s"] = struct3501s
  30983. client := &http.Client{}
  30984. bytesData, _ := json.Marshal(data)
  30985. var req *http.Request
  30986. if miConfig.MdtrtareaAdmvs == "320921" {
  30987. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30988. } else {
  30989. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30990. }
  30991. resp, _ := client.Do(req)
  30992. defer resp.Body.Close()
  30993. body, ioErr := ioutil.ReadAll(resp.Body)
  30994. if ioErr != nil {
  30995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30997. return
  30998. }
  30999. var respJSON map[string]interface{}
  31000. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31003. return
  31004. }
  31005. var res ResultSix
  31006. var resSix10265 ResultSix10265 //1101结果
  31007. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31008. result, _ := json.Marshal(respJSON)
  31009. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31010. utils.ErrorLog("解析失败:%v", err)
  31011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31012. return
  31013. }
  31014. res.InfRefmsgid = resSix10265.InfRefmsgid
  31015. res.Output = resSix10265.Output
  31016. res.ErrMsg = resSix10265.ErrMsg
  31017. res.Cainfo = resSix10265.Cainfo
  31018. res.WarnMsg = resSix10265.WarnMsg
  31019. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31020. res.Infcode = infocode
  31021. if infocode == 0 {
  31022. c.ServeSuccessJSON(map[string]interface{}{
  31023. "msg": "上传成功",
  31024. })
  31025. return
  31026. } else {
  31027. c.ServeSuccessJSON(map[string]interface{}{
  31028. "failed_code": -10,
  31029. "msg": res.ErrMsg,
  31030. })
  31031. return
  31032. }
  31033. }
  31034. func (c *HisApiController) Post3505() {
  31035. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31036. data := make(map[string]interface{})
  31037. var struct3501s []models.Struct3501
  31038. var struct3501 models.Struct3501
  31039. struct3501.OrgName = miConfig.OrgName
  31040. struct3501.AccessKey = miConfig.AccessKey
  31041. struct3501.RequestUrl = miConfig.Url
  31042. struct3501.SecretKey = miConfig.SecretKey
  31043. struct3501.ManuDate = "2022-08-15"
  31044. struct3501.FixmedinsBchno = ""
  31045. struct3501.ManuLotnum = ""
  31046. struct3501.RxFlag = "0"
  31047. struct3501.ExpyEnd = "2022-08-15"
  31048. struct3501.Invdate = "2022-08-15"
  31049. struct3501.InvCnt = "20.25"
  31050. struct3501.Memo = ""
  31051. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31052. struct3501.FixmedinsHilistId = miConfig.Code
  31053. struct3501.FixmedinsHilistName = miConfig.OrgName
  31054. struct3501s = append(struct3501s, struct3501)
  31055. data["struct_3501s"] = struct3501s
  31056. client := &http.Client{}
  31057. bytesData, _ := json.Marshal(data)
  31058. var req *http.Request
  31059. if miConfig.MdtrtareaAdmvs == "320921" {
  31060. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31061. } else {
  31062. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31063. }
  31064. resp, _ := client.Do(req)
  31065. defer resp.Body.Close()
  31066. body, ioErr := ioutil.ReadAll(resp.Body)
  31067. if ioErr != nil {
  31068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31070. return
  31071. }
  31072. var respJSON map[string]interface{}
  31073. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31076. return
  31077. }
  31078. var res ResultSix
  31079. var resSix10265 ResultSix10265 //1101结果
  31080. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31081. result, _ := json.Marshal(respJSON)
  31082. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31083. utils.ErrorLog("解析失败:%v", err)
  31084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31085. return
  31086. }
  31087. res.InfRefmsgid = resSix10265.InfRefmsgid
  31088. res.Output = resSix10265.Output
  31089. res.ErrMsg = resSix10265.ErrMsg
  31090. res.Cainfo = resSix10265.Cainfo
  31091. res.WarnMsg = resSix10265.WarnMsg
  31092. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31093. res.Infcode = infocode
  31094. if infocode == 0 {
  31095. c.ServeSuccessJSON(map[string]interface{}{
  31096. "msg": "上传成功",
  31097. })
  31098. return
  31099. } else {
  31100. c.ServeSuccessJSON(map[string]interface{}{
  31101. "failed_code": -10,
  31102. "msg": res.ErrMsg,
  31103. })
  31104. return
  31105. }
  31106. }
  31107. func (c *HisApiController) Post3506() {
  31108. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31109. data := make(map[string]interface{})
  31110. var struct3501s []models.Struct3501
  31111. var struct3501 models.Struct3501
  31112. struct3501.OrgName = miConfig.OrgName
  31113. struct3501.AccessKey = miConfig.AccessKey
  31114. struct3501.RequestUrl = miConfig.Url
  31115. struct3501.SecretKey = miConfig.SecretKey
  31116. struct3501.ManuDate = "2022-08-15"
  31117. struct3501.FixmedinsBchno = ""
  31118. struct3501.ManuLotnum = ""
  31119. struct3501.RxFlag = "0"
  31120. struct3501.ExpyEnd = "2022-08-15"
  31121. struct3501.Invdate = "2022-08-15"
  31122. struct3501.InvCnt = "20.25"
  31123. struct3501.Memo = ""
  31124. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31125. struct3501.FixmedinsHilistId = miConfig.Code
  31126. struct3501.FixmedinsHilistName = miConfig.OrgName
  31127. struct3501s = append(struct3501s, struct3501)
  31128. data["struct_3501s"] = struct3501s
  31129. client := &http.Client{}
  31130. bytesData, _ := json.Marshal(data)
  31131. var req *http.Request
  31132. if miConfig.MdtrtareaAdmvs == "320921" {
  31133. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31134. } else {
  31135. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31136. }
  31137. resp, _ := client.Do(req)
  31138. defer resp.Body.Close()
  31139. body, ioErr := ioutil.ReadAll(resp.Body)
  31140. if ioErr != nil {
  31141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31143. return
  31144. }
  31145. var respJSON map[string]interface{}
  31146. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31149. return
  31150. }
  31151. var res ResultSix
  31152. var resSix10265 ResultSix10265 //1101结果
  31153. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31154. result, _ := json.Marshal(respJSON)
  31155. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31156. utils.ErrorLog("解析失败:%v", err)
  31157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31158. return
  31159. }
  31160. res.InfRefmsgid = resSix10265.InfRefmsgid
  31161. res.Output = resSix10265.Output
  31162. res.ErrMsg = resSix10265.ErrMsg
  31163. res.Cainfo = resSix10265.Cainfo
  31164. res.WarnMsg = resSix10265.WarnMsg
  31165. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31166. res.Infcode = infocode
  31167. if infocode == 0 {
  31168. c.ServeSuccessJSON(map[string]interface{}{
  31169. "msg": "上传成功",
  31170. })
  31171. return
  31172. } else {
  31173. c.ServeSuccessJSON(map[string]interface{}{
  31174. "failed_code": -10,
  31175. "msg": res.ErrMsg,
  31176. })
  31177. return
  31178. }
  31179. }
  31180. func (c *HisApiController) Post3507() {
  31181. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31182. data := make(map[string]interface{})
  31183. var struct3501s []models.Struct3501
  31184. var struct3501 models.Struct3501
  31185. struct3501.OrgName = miConfig.OrgName
  31186. struct3501.AccessKey = miConfig.AccessKey
  31187. struct3501.RequestUrl = miConfig.Url
  31188. struct3501.SecretKey = miConfig.SecretKey
  31189. struct3501.ManuDate = "2022-08-15"
  31190. struct3501.FixmedinsBchno = ""
  31191. struct3501.ManuLotnum = ""
  31192. struct3501.RxFlag = "0"
  31193. struct3501.ExpyEnd = "2022-08-15"
  31194. struct3501.Invdate = "2022-08-15"
  31195. struct3501.InvCnt = "20.25"
  31196. struct3501.Memo = ""
  31197. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31198. struct3501.FixmedinsHilistId = miConfig.Code
  31199. struct3501.FixmedinsHilistName = miConfig.OrgName
  31200. struct3501s = append(struct3501s, struct3501)
  31201. data["struct_3501s"] = struct3501s
  31202. client := &http.Client{}
  31203. bytesData, _ := json.Marshal(data)
  31204. var req *http.Request
  31205. if miConfig.MdtrtareaAdmvs == "320921" {
  31206. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31207. } else {
  31208. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31209. }
  31210. resp, _ := client.Do(req)
  31211. defer resp.Body.Close()
  31212. body, ioErr := ioutil.ReadAll(resp.Body)
  31213. if ioErr != nil {
  31214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31216. return
  31217. }
  31218. var respJSON map[string]interface{}
  31219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31222. return
  31223. }
  31224. var res ResultSix
  31225. var resSix10265 ResultSix10265 //1101结果
  31226. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31227. result, _ := json.Marshal(respJSON)
  31228. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31229. utils.ErrorLog("解析失败:%v", err)
  31230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31231. return
  31232. }
  31233. res.InfRefmsgid = resSix10265.InfRefmsgid
  31234. res.Output = resSix10265.Output
  31235. res.ErrMsg = resSix10265.ErrMsg
  31236. res.Cainfo = resSix10265.Cainfo
  31237. res.WarnMsg = resSix10265.WarnMsg
  31238. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31239. res.Infcode = infocode
  31240. if infocode == 0 {
  31241. c.ServeSuccessJSON(map[string]interface{}{
  31242. "msg": "上传成功",
  31243. })
  31244. return
  31245. } else {
  31246. c.ServeSuccessJSON(map[string]interface{}{
  31247. "failed_code": -10,
  31248. "msg": res.ErrMsg,
  31249. })
  31250. return
  31251. }
  31252. }
  31253. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31254. // WebSocket服务器地址
  31255. serverURL := "ws://127.0.0.1:8899"
  31256. // 解析WebSocket服务器地址
  31257. u, err := url.Parse(serverURL)
  31258. if err != nil {
  31259. }
  31260. // 建立WebSocket连接
  31261. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31262. if err != nil {
  31263. }
  31264. defer conn.Close()
  31265. input2 := make(map[string]interface{})
  31266. input := make(map[string]interface{})
  31267. inputData := make(map[string]interface{})
  31268. inputData["orgId"] = code
  31269. inputData["businessType"] = "01101"
  31270. inputData["operatorId"] = operator_id
  31271. inputData["operatorName"] = operator_name
  31272. inputData["officeId"] = "001"
  31273. inputData["officeName"] = "血透室"
  31274. inputData["deviceType"] = ""
  31275. input["data"] = inputData
  31276. input["orgId"] = code
  31277. input["transType"] = "ec.query"
  31278. //if md == ""
  31279. if md[:4] == "4403" {
  31280. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31281. } else if md[:4] == "4401" {
  31282. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31283. } else {
  31284. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31285. }
  31286. input2["indata"] = input
  31287. fmt.Println(input2)
  31288. bytesData, _ := json.Marshal(input2)
  31289. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31290. if err != nil {
  31291. fmt.Println(err)
  31292. }
  31293. // 接收消息
  31294. _, receivedMessage, err := conn.ReadMessage()
  31295. if err != nil {
  31296. fmt.Println(err)
  31297. }
  31298. return "", string(receivedMessage)
  31299. }
  31300. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  31301. // WebSocket服务器地址
  31302. serverURL := "ws://127.0.0.1:8899"
  31303. // 解析WebSocket服务器地址
  31304. u, err := url.Parse(serverURL)
  31305. if err != nil {
  31306. }
  31307. // 建立WebSocket连接
  31308. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31309. if err != nil {
  31310. }
  31311. defer conn.Close()
  31312. input2 := make(map[string]interface{})
  31313. input := make(map[string]interface{})
  31314. inputData := make(map[string]interface{})
  31315. inputData["orgId"] = code
  31316. inputData["businessType"] = "01103"
  31317. inputData["operatorId"] = operator_id
  31318. inputData["operatorName"] = operator_name
  31319. inputData["officeId"] = "001"
  31320. inputData["officeName"] = "血透室"
  31321. inputData["deviceType"] = ""
  31322. input["data"] = inputData
  31323. input["orgId"] = code
  31324. input["transType"] = "ec.query"
  31325. //if md ==
  31326. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  31327. input2["indata"] = input
  31328. fmt.Println(input2)
  31329. bytesData, _ := json.Marshal(input2)
  31330. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31331. if err != nil {
  31332. fmt.Println(err)
  31333. }
  31334. // 接收消息
  31335. _, receivedMessage, err := conn.ReadMessage()
  31336. if err != nil {
  31337. fmt.Println(err)
  31338. }
  31339. return "", string(receivedMessage)
  31340. }
  31341. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31342. // WebSocket服务器地址
  31343. serverURL := "ws://127.0.0.1:8899"
  31344. // 解析WebSocket服务器地址
  31345. u, err := url.Parse(serverURL)
  31346. if err != nil {
  31347. }
  31348. // 建立WebSocket连接
  31349. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31350. if err != nil {
  31351. }
  31352. defer conn.Close()
  31353. input2 := make(map[string]interface{})
  31354. input := make(map[string]interface{})
  31355. inputData := make(map[string]interface{})
  31356. inputData["orgId"] = code
  31357. inputData["businessType"] = "01101"
  31358. inputData["operatorId"] = operator_id
  31359. inputData["operatorName"] = operator_name
  31360. inputData["officeId"] = "001"
  31361. inputData["officeName"] = "血透室"
  31362. inputData["deviceType"] = ""
  31363. input["data"] = inputData
  31364. input["orgId"] = code
  31365. input["transType"] = "ec.query"
  31366. //if md == ""
  31367. if md[:4] == "4403" {
  31368. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31369. } else if md[:4] == "4401" {
  31370. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31371. } else {
  31372. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31373. }
  31374. input2["indata"] = input
  31375. fmt.Println(input2)
  31376. bytesData, _ := json.Marshal(input2)
  31377. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31378. if err != nil {
  31379. fmt.Println(err)
  31380. }
  31381. // 接收消息
  31382. _, receivedMessage, err := conn.ReadMessage()
  31383. if err != nil {
  31384. fmt.Println(err)
  31385. }
  31386. return "", string(receivedMessage)
  31387. }
  31388. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  31389. // WebSocket服务器地址
  31390. serverURL := "ws://127.0.0.1:8899"
  31391. // 解析WebSocket服务器地址
  31392. u, err := url.Parse(serverURL)
  31393. if err != nil {
  31394. }
  31395. // 建立WebSocket连接
  31396. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31397. if err != nil {
  31398. }
  31399. defer conn.Close()
  31400. input2 := make(map[string]interface{})
  31401. input := make(map[string]interface{})
  31402. inputData := make(map[string]interface{})
  31403. inputData["orgId"] = code
  31404. inputData["businessType"] = "01301"
  31405. inputData["operatorId"] = operator_id
  31406. inputData["operatorName"] = operator_name
  31407. inputData["officeId"] = "001"
  31408. inputData["officeName"] = "血透室"
  31409. inputData["deviceType"] = ""
  31410. input["data"] = inputData
  31411. input["orgId"] = code
  31412. input["transType"] = "ec.query"
  31413. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31414. input2["indata"] = input
  31415. bytesData, _ := json.Marshal(input2)
  31416. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31417. if err != nil {
  31418. fmt.Println(err)
  31419. }
  31420. // 接收消息
  31421. _, receivedMessage, err := conn.ReadMessage()
  31422. if err != nil {
  31423. fmt.Println(err)
  31424. }
  31425. return "", string(receivedMessage)
  31426. }
  31427. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  31428. newArr = make([]string, 0)
  31429. for i := 0; i < len(arr); i++ {
  31430. repeat := false
  31431. for j := i + 1; j < len(arr); j++ {
  31432. if arr[i] == arr[j] {
  31433. repeat = true
  31434. break
  31435. }
  31436. }
  31437. if !repeat {
  31438. newArr = append(newArr, arr[i])
  31439. }
  31440. }
  31441. return
  31442. }
  31443. func getBirthdateAndAge(idNumber string) (string, int, error) {
  31444. if len(idNumber) != 18 {
  31445. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  31446. }
  31447. // 提取出生日期
  31448. year, err := strconv.Atoi(idNumber[6:10])
  31449. if err != nil {
  31450. return "", 0, err
  31451. }
  31452. month, err := strconv.Atoi(idNumber[10:12])
  31453. if err != nil {
  31454. return "", 0, err
  31455. }
  31456. day, err := strconv.Atoi(idNumber[12:14])
  31457. if err != nil {
  31458. return "", 0, err
  31459. }
  31460. // 格式化生日字符串
  31461. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  31462. birthdateFormatted := birthdate.Format("2006-01-02")
  31463. // 计算年龄
  31464. today := time.Now()
  31465. age := today.Year() - birthdate.Year()
  31466. if today.YearDay() < birthdate.YearDay() {
  31467. age--
  31468. }
  31469. return birthdateFormatted, age, nil
  31470. }