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"
  23. "github.com/go-ole/go-ole/oleutil"
  24. "io"
  25. "io/ioutil"
  26. //"math"
  27. "math/rand"
  28. "net/http"
  29. "net/url"
  30. "os"
  31. "path/filepath"
  32. "regexp"
  33. "strconv"
  34. "strings"
  35. "syscall"
  36. "time"
  37. "unsafe"
  38. )
  39. type HisApiController struct {
  40. controllers.BaseAuthAPIController
  41. }
  42. func HisManagerApiRegistRouters() {
  43. //挂号
  44. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  45. //上传就诊信息-上传明细-结算
  46. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  47. //查询
  48. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  49. //对总账
  50. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  51. //对明细
  52. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  53. //退费,退明细
  54. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  55. //退号
  56. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  57. //退明细
  58. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  59. //上传就诊信息-上传明细-预结算
  60. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  61. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  62. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  63. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  64. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  65. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  66. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  67. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  68. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  69. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  70. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  71. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  72. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  73. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  74. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  75. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  76. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  77. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  78. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  79. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  80. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  81. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  82. beego.Router("/api/check", &HisApiController{}, "get:Check")
  83. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  84. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  85. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  86. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  87. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  88. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  89. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  90. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  91. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  92. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  93. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  94. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  95. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  96. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  97. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  98. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  99. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  100. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  101. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  102. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  103. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  104. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  105. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  109. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  110. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  111. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  112. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  113. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  114. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  115. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  116. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  117. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. }
  159. func (c *HisApiController) FJ3501AND3502() {
  160. ids := c.GetString("ids")
  161. admin_user_id, _ := c.GetInt64("admin_user_id")
  162. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  163. id_arr := strings.Split(ids, ",")
  164. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  165. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  166. //库盘
  167. var errs []string
  168. for _, drug := range drugs {
  169. if drug.IsPc == 0 && drug.IsBg == 0 {
  170. var res2 ResultSix
  171. var res3 ResultSix
  172. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  173. var struct3501 models.Struct3501
  174. struct3501.OrgName = miConfig.OrgName
  175. struct3501.AccessKey = miConfig.AccessKey
  176. struct3501.Opter = roles.UserName
  177. struct3501.RequestUrl = miConfig.Url
  178. struct3501.Url = miConfig.Url
  179. struct3501.AppId = miConfig.Cainfo
  180. struct3501.AppSecret = miConfig.AppSecret
  181. struct3501.Enckey = miConfig.EncKey
  182. struct3501.SignKey = miConfig.SignKey
  183. struct3501.SecretKey = miConfig.SecretKey
  184. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  185. struct3501.FixmedinsHilistId = miConfig.Code
  186. struct3501.FixmedinsHilistName = miConfig.OrgName
  187. struct3501.RxFlag = "0"
  188. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  189. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  190. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  191. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  192. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  193. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  194. struct3501.FixmedinsBchno = number
  195. memo := make(map[string]interface{})
  196. memo["pric"] = drug.Price
  197. bytesData, _ := json.Marshal(memo)
  198. struct3501.Memo = string(bytesData)
  199. result1, result2, _ := service.FJyb3501(struct3501)
  200. saveLog(result1, result2, "3501", "3501")
  201. //saveLog(result, requestLog, "2201", "挂号")
  202. var respJSON2 map[string]interface{}
  203. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  206. return
  207. }
  208. userJSONBytes2, _ := json.Marshal(respJSON2)
  209. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res2.Infcode != -1 {
  215. drug.IsPc = 1
  216. drug.Bchno = number
  217. drug.PcDate = time.Now().Format("2006-01-02")
  218. err := service.SaveW(drug)
  219. if err == nil {
  220. var struct3502 models.Struct3502
  221. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  222. struct3502.FixmedinsHilistId = miConfig.Code
  223. struct3502.FixmedinsHilistName = miConfig.OrgName
  224. struct3502.FixmedinsCode = miConfig.Code
  225. struct3502.RxFlag = "0"
  226. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  227. struct3502.OrgName = miConfig.OrgName
  228. struct3502.Opter = roles.UserName
  229. struct3502.AccessKey = miConfig.AccessKey
  230. struct3502.RequestUrl = miConfig.Url
  231. struct3502.SecretKey = miConfig.SecretKey
  232. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  233. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  234. struct3502.Url = miConfig.Url
  235. struct3502.AppId = miConfig.Cainfo
  236. struct3502.AppSecret = miConfig.AppSecret
  237. struct3502.Enckey = miConfig.EncKey
  238. struct3502.SignKey = miConfig.SignKey
  239. struct3502.SecretKey = miConfig.SecretKey
  240. struct3502.Memo = ""
  241. struct3502.InvChgType = "108"
  242. struct3502.FixmedinsBchno = drug.Bchno
  243. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  244. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  245. result11, result22, _ := service.FJyb3502(struct3502)
  246. saveLog(result11, result22, "3502", "3502")
  247. var respJSON3 map[string]interface{}
  248. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  251. return
  252. }
  253. userJSONBytes3, _ := json.Marshal(respJSON3)
  254. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  255. utils.ErrorLog("解析失败:%v", err)
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. if res3.Infcode == -1 {
  260. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  261. c.ServeSuccessJSON(map[string]interface{}{
  262. "failed_code": -10,
  263. "msg": res3.ErrMsg,
  264. })
  265. } else {
  266. drug.IsBg = 1
  267. service.SaveW(drug)
  268. }
  269. }
  270. } else {
  271. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  272. }
  273. }
  274. //变更
  275. if drug.IsPc == 1 && drug.IsBg == 0 {
  276. var res3 ResultSix
  277. var struct3502 models.Struct3502
  278. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  279. struct3502.FixmedinsHilistId = miConfig.Code
  280. struct3502.FixmedinsHilistName = miConfig.OrgName
  281. struct3502.FixmedinsCode = miConfig.Code
  282. struct3502.Opter = roles.UserName
  283. struct3502.RxFlag = "0"
  284. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  285. struct3502.OrgName = miConfig.OrgName
  286. struct3502.AccessKey = miConfig.AccessKey
  287. struct3502.RequestUrl = miConfig.Url
  288. struct3502.SecretKey = miConfig.SecretKey
  289. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  290. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  291. struct3502.InvChgType = "108"
  292. struct3502.Url = miConfig.Url
  293. struct3502.AppId = miConfig.Cainfo
  294. struct3502.AppSecret = miConfig.AppSecret
  295. struct3502.Enckey = miConfig.EncKey
  296. struct3502.SignKey = miConfig.SignKey
  297. struct3502.SecretKey = miConfig.SecretKey
  298. struct3502.FixmedinsBchno = drug.Bchno
  299. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  300. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  301. result1, result2, _ := service.FJyb3502(struct3502)
  302. saveLog(result1, result2, "3502", "3502")
  303. var respJSON3 map[string]interface{}
  304. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  307. return
  308. }
  309. userJSONBytes3, _ := json.Marshal(respJSON3)
  310. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  311. utils.ErrorLog("解析失败:%v", err)
  312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  313. return
  314. }
  315. if res3.Infcode == -1 {
  316. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  317. } else {
  318. drug.IsBg = 1
  319. //drug.Bchno = number
  320. //drug.PcDate = time.Now().Format("2006-01-02")
  321. service.SaveW(drug)
  322. }
  323. }
  324. }
  325. if len(errs) == 0 {
  326. c.ServeSuccessJSON(map[string]interface{}{
  327. "msg": "盘存变更成功",
  328. })
  329. } else {
  330. c.ServeSuccessJSON(map[string]interface{}{
  331. "failed_code": -10,
  332. "msg": errs,
  333. })
  334. }
  335. }
  336. func (c *HisApiController) DeletePCandBG() {
  337. ids := c.GetString("ids")
  338. id_arr := strings.Split(ids, ",")
  339. admin_user_id, _ := c.GetInt64("admin_user_id")
  340. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  341. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  342. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  343. var err []string
  344. for _, item := range drugs {
  345. if item.IsPc == 1 && item.IsBg == 1 {
  346. var res FJ3507Result
  347. var res2 FJ3507Result
  348. var struct3507 models.Struct3507
  349. struct3507.FixmedinsBchno = item.Bchno
  350. struct3507.InvDataType = "1"
  351. struct3507.Opter = roles.UserName
  352. struct3507.OrgName = miConfig.OrgName
  353. struct3507.AccessKey = miConfig.AccessKey
  354. struct3507.RequestUrl = miConfig.Url
  355. struct3507.FixmedinsCode = miConfig.Code
  356. struct3507.SecretKey = miConfig.SecretKey
  357. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  358. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  359. struct3507.Url = miConfig.Url
  360. struct3507.AppId = miConfig.Cainfo
  361. struct3507.AppSecret = miConfig.AppSecret
  362. struct3507.Enckey = miConfig.EncKey
  363. struct3507.SignKey = miConfig.SignKey
  364. struct3507.SecretKey = miConfig.SecretKey
  365. result, result1, _ := service.FJyb3507(struct3507)
  366. saveLog(result, result1, "3507", "3507")
  367. var respJSON2 map[string]interface{}
  368. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  371. return
  372. }
  373. userJSONBytes2, _ := json.Marshal(respJSON2)
  374. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  375. utils.ErrorLog("解析失败:%v", err)
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  377. return
  378. }
  379. if res.Infcode != -1 {
  380. item.IsPc = 0
  381. err2 := service.SaveW(item)
  382. if err2 == nil {
  383. var struct3507_2 models.Struct3507
  384. struct3507_2.OrgName = miConfig.OrgName
  385. struct3507_2.AccessKey = miConfig.AccessKey
  386. struct3507_2.RequestUrl = miConfig.Url
  387. struct3507_2.Opter = roles.UserName
  388. struct3507_2.FixmedinsCode = miConfig.Code
  389. struct3507_2.SecretKey = miConfig.SecretKey
  390. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  391. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  392. struct3507_2.Url = miConfig.Url
  393. struct3507_2.AppId = miConfig.Cainfo
  394. struct3507_2.AppSecret = miConfig.AppSecret
  395. struct3507_2.Enckey = miConfig.EncKey
  396. struct3507_2.SignKey = miConfig.SignKey
  397. struct3507_2.SecretKey = miConfig.SecretKey
  398. struct3507_2.FixmedinsBchno = item.Bchno
  399. struct3507_2.InvDataType = "2"
  400. result11, result22, _ := service.FJyb3507(struct3507_2)
  401. saveLog(result11, result22, "3507", "3507")
  402. var respJSON3 map[string]interface{}
  403. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  406. return
  407. }
  408. userJSONBytes3, _ := json.Marshal(respJSON3)
  409. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  410. utils.ErrorLog("解析失败:%v", err)
  411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  412. return
  413. }
  414. if res2.Infcode != -1 {
  415. item.IsBg = 0
  416. item.Bchno = ""
  417. item.PcDate = ""
  418. service.SaveW(item)
  419. } else {
  420. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  421. }
  422. }
  423. } else {
  424. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  425. }
  426. }
  427. if item.IsPc == 1 && item.IsBg == 0 {
  428. var res FJ3507Result
  429. var struct3507 models.Struct3507
  430. struct3507.FixmedinsBchno = item.Bchno
  431. struct3507.InvDataType = "2"
  432. struct3507.Opter = roles.UserName
  433. struct3507.FixmedinsCode = miConfig.Code
  434. struct3507.OrgName = miConfig.OrgName
  435. struct3507.AccessKey = miConfig.AccessKey
  436. struct3507.RequestUrl = miConfig.Url
  437. struct3507.SecretKey = miConfig.SecretKey
  438. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  439. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  440. struct3507.Url = miConfig.Url
  441. struct3507.AppId = miConfig.Cainfo
  442. struct3507.AppSecret = miConfig.AppSecret
  443. struct3507.Enckey = miConfig.EncKey
  444. struct3507.SignKey = miConfig.SignKey
  445. struct3507.SecretKey = miConfig.SecretKey
  446. result, result1, _ := service.FJyb3507(struct3507)
  447. saveLog(result, result1, "3507", "3507")
  448. var respJSON3 map[string]interface{}
  449. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  452. return
  453. }
  454. userJSONBytes3, _ := json.Marshal(respJSON3)
  455. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  456. utils.ErrorLog("解析失败:%v", err)
  457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  458. return
  459. }
  460. if res.Infcode != -1 {
  461. item.IsBg = 0
  462. item.Bchno = ""
  463. item.PcDate = ""
  464. service.SaveW(item)
  465. } else {
  466. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  467. }
  468. }
  469. }
  470. if len(err) == 0 {
  471. c.ServeSuccessJSON(map[string]interface{}{
  472. "msg": "删除盘存变更成功",
  473. })
  474. } else {
  475. c.ServeSuccessJSON(map[string]interface{}{
  476. "failed_code": -10,
  477. "msg": err,
  478. })
  479. }
  480. }
  481. func (c *HisApiController) DeleteXSandBG() {
  482. ids := c.GetString("ids")
  483. id_arr := strings.Split(ids, ",")
  484. admin_user_id, _ := c.GetInt64("admin_user_id")
  485. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  486. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  487. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  488. for _, item := range drugs {
  489. if item.IsPc == 1 && item.IsBg == 1 {
  490. var struct3507 models.Struct3507
  491. struct3507.FixmedinsBchno =
  492. struct3507.InvDataType = "1"
  493. struct3507.Opter = roles.UserName
  494. struct3507.OrgName = miConfig.OrgName
  495. struct3507.AccessKey = miConfig.AccessKey
  496. struct3507.RequestUrl = miConfig.Url
  497. struct3507.SecretKey = miConfig.SecretKey
  498. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  499. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  500. struct3507.Url = miConfig.Url
  501. struct3507.AppId = miConfig.Cainfo
  502. struct3507.AppSecret = miConfig.AppSecret
  503. struct3507.Enckey = miConfig.EncKey
  504. struct3507.SignKey = miConfig.SignKey
  505. struct3507.SecretKey = miConfig.SecretKey
  506. struct3507.FixmedinsBchno = ""
  507. struct3507.InvDataType = "1"
  508. service.FJyb3507(struct3507)
  509. var struct3507_2 models.Struct3507
  510. struct3507_2.OrgName = miConfig.OrgName
  511. struct3507_2.AccessKey = miConfig.AccessKey
  512. struct3507_2.RequestUrl = miConfig.Url
  513. struct3507_2.SecretKey = miConfig.SecretKey
  514. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  515. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  516. struct3507_2.FixmedinsBchno = ""
  517. struct3507_2.InvDataType = "2"
  518. struct3507_2.Url = miConfig.Url
  519. struct3507_2.AppId = miConfig.Cainfo
  520. struct3507_2.AppSecret = miConfig.AppSecret
  521. struct3507_2.Enckey = miConfig.EncKey
  522. struct3507_2.SignKey = miConfig.SignKey
  523. struct3507_2.SecretKey = miConfig.SecretKey
  524. struct3507_2.FixmedinsBchno = ""
  525. struct3507_2.InvDataType = "1"
  526. service.FJyb3507(struct3507_2)
  527. }
  528. if item.IsPc == 1 && item.IsBg == 0 {
  529. var struct3507 models.Struct3507
  530. struct3507.OrgName = miConfig.OrgName
  531. struct3507.AccessKey = miConfig.AccessKey
  532. struct3507.RequestUrl = miConfig.Url
  533. struct3507.SecretKey = miConfig.SecretKey
  534. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  535. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  536. struct3507.FixmedinsBchno = ""
  537. struct3507.InvDataType = "1"
  538. service.FJyb3507(struct3507)
  539. }
  540. }
  541. }
  542. func (c *HisApiController) ChangeDrug() {
  543. ids := c.GetString("ids")
  544. id_arr := strings.Split(ids, ",")
  545. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  546. admin_user_id, _ := c.GetInt64("admin_user_id")
  547. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  548. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  549. var err []string
  550. for _, item := range flows {
  551. var res3 ResultSix
  552. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  553. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  554. if prescription.OrderStatus == 2 {
  555. //已经结算
  556. //判断是否已经销售
  557. if item.IsSale == 1 { //是否已经销售,1是 0否
  558. //是否已经变更 1是 0否
  559. if item.IsChange == 0 { //没变更,进行变更操作
  560. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  561. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  562. var respJSON3 map[string]interface{}
  563. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  566. return
  567. }
  568. userJSONBytes3, _ := json.Marshal(respJSON3)
  569. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  570. utils.ErrorLog("解析失败:%v", err)
  571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  572. return
  573. }
  574. if res3.Infcode != -1{
  575. item.IsChange = 1
  576. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  577. service.SaveDF(item)
  578. }else{
  579. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  580. }
  581. }
  582. } else { //没销售,
  583. var res FJ3507Result
  584. //进行商品销售接口
  585. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles)
  586. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  587. var respJSON3 map[string]interface{}
  588. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  591. return
  592. }
  593. userJSONBytes3, _ := json.Marshal(respJSON3)
  594. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  595. utils.ErrorLog("解析失败:%v", err)
  596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  597. return
  598. }
  599. if res.Infcode != -1 {
  600. item.IsSale = 1
  601. item.SaleDate = time.Now().Format("2006-01-02")
  602. err5 := service.SaveDF(item)
  603. if err5 == nil {
  604. if item.IsChange == 0 { //没变更,进行变更操作
  605. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  606. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  607. var respJSON3 map[string]interface{}
  608. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  611. return
  612. }
  613. userJSONBytes3, _ := json.Marshal(respJSON3)
  614. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  615. utils.ErrorLog("解析失败:%v", err)
  616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  617. return
  618. }
  619. if res3.Infcode != -1 {
  620. item.IsChange = 1
  621. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  622. service.SaveDF(item)
  623. } else {
  624. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  625. }
  626. }
  627. }
  628. }else{
  629. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  630. }
  631. }
  632. } else { //还没结算
  633. if item.IsChange == 0 { //没变更,进行变更操作
  634. result, result2 :=ChangeStock(item.Count, item, miConfig, "107", roles)
  635. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  636. var respJSON3 map[string]interface{}
  637. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  640. return
  641. }
  642. userJSONBytes3, _ := json.Marshal(respJSON3)
  643. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  644. utils.ErrorLog("解析失败:%v", err)
  645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  646. return
  647. }
  648. if res3.Infcode != -1{
  649. item.IsChange = 1
  650. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  651. service.SaveDF(item)
  652. }else{
  653. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  654. }
  655. }
  656. }
  657. } else if item.ConsumableType == 7 {
  658. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  659. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  660. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  661. //判断是否已经销售
  662. if item.IsSale == 1 { //是否已经销售,1是 0否
  663. //是否已经变更 1是 0否
  664. if item.IsChange == 0 { //没变更,进行变更操作
  665. result, result2 :=ChangeStock(item.Count, item, miConfig, "107", roles)
  666. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  667. var respJSON3 map[string]interface{}
  668. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. userJSONBytes3, _ := json.Marshal(respJSON3)
  674. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  675. utils.ErrorLog("解析失败:%v", err)
  676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  677. return
  678. }
  679. if res3.Infcode != -1{
  680. item.IsChange = 1
  681. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  682. service.SaveDF(item)
  683. }else{
  684. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  685. }
  686. }
  687. } else { //没销售,
  688. //进行商品销售退货接口
  689. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "",roles)
  690. saveLog(result111,result222,"3506","销售退货")
  691. if item.IsChange == 0 { //没变更,进行变更操作
  692. result, result2 :=ChangeStock(item.Count, item, miConfig, "107", roles)
  693. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  694. var respJSON3 map[string]interface{}
  695. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. userJSONBytes3, _ := json.Marshal(respJSON3)
  701. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  702. utils.ErrorLog("解析失败:%v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. if res3.Infcode != -1{
  707. item.IsChange = 1
  708. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  709. service.SaveDF(item)
  710. }else{
  711. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  712. }
  713. }
  714. }
  715. } else { //还没结算
  716. if item.IsChange == 0 { //没变更,进行变更操作
  717. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  718. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  719. var respJSON3 map[string]interface{}
  720. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  723. return
  724. }
  725. userJSONBytes3, _ := json.Marshal(respJSON3)
  726. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  727. utils.ErrorLog("解析失败:%v", err)
  728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  729. return
  730. }
  731. if res3.Infcode != -1{
  732. item.IsChange = 1
  733. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  734. service.SaveDF(item)
  735. }else{
  736. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  737. }
  738. }
  739. }
  740. } else { //其他方式
  741. if item.IsChange == 0 { //没变更,进行变更操作
  742. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  743. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  744. var respJSON3 map[string]interface{}
  745. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. userJSONBytes3, _ := json.Marshal(respJSON3)
  751. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  752. utils.ErrorLog("解析失败:%v", err)
  753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  754. return
  755. }
  756. if res3.Infcode != -1{
  757. item.IsChange = 1
  758. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  759. service.SaveDF(item)
  760. }else{
  761. err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  762. }
  763. }
  764. }
  765. }
  766. }
  767. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string,string){
  768. var struct3502 models.Struct3502
  769. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  770. struct3502.FixmedinsHilistId = miConfig.Code
  771. struct3502.FixmedinsHilistName = miConfig.OrgName
  772. struct3502.FixmedinsCode = miConfig.Code
  773. struct3502.Opter = role.UserName
  774. struct3502.RxFlag = "0"
  775. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  776. struct3502.OrgName = miConfig.OrgName
  777. struct3502.AccessKey = miConfig.AccessKey
  778. struct3502.RequestUrl = miConfig.Url
  779. struct3502.SecretKey = miConfig.SecretKey
  780. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  781. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  782. struct3502.Url = miConfig.Url
  783. struct3502.AppId = miConfig.Cainfo
  784. struct3502.AppSecret = miConfig.AppSecret
  785. struct3502.Enckey = miConfig.EncKey
  786. struct3502.SignKey = miConfig.SignKey
  787. struct3502.SecretKey = miConfig.SecretKey
  788. struct3502.InvChgType = chgType
  789. struct3502.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
  790. struct3502.Cnt = strconv.FormatInt(count, 10)
  791. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  792. result1, result2, _ := service.FJyb3502(struct3502)
  793. return result1,result2
  794. }
  795. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string, string){
  796. var struct3505 models.Struct3505
  797. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  798. struct3505.FixmedinsHilistId = miConfig.Code
  799. struct3505.FixmedinsHilistName = miConfig.OrgName
  800. struct3505.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
  801. struct3505.FixmedinsCode = miConfig.Code
  802. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  803. struct3505.PrscDrName =roles.UserName
  804. struct3505.PharName = "刘水山"
  805. struct3505.PharPracCertNo = "2015026350260000002611351127"
  806. order := service.GetHisOrderByNumber(pre.BatchNumber)
  807. struct3505.SetlId = order.SetlId
  808. struct3505.MdtrtSn = order.MdtrtId
  809. struct3505.ManuLotnum = drug.Number
  810. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02 15:04:05")
  811. struct3505.ExpyEnd = ""
  812. struct3505.RxFlag = "0"
  813. struct3505.TrdnFlag = "1"
  814. struct3505.RtalDocno = order.Number
  815. struct3505.Url = miConfig.Url
  816. struct3505.AppId = miConfig.Cainfo
  817. struct3505.AppSecret = miConfig.AppSecret
  818. struct3505.Enckey = miConfig.EncKey
  819. struct3505.SignKey = miConfig.SignKey
  820. struct3505.SecretKey = miConfig.SecretKey
  821. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  822. struct3505.SelRetnCnt = strValue
  823. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  824. struct3505.SelRetnOpterName = role.UserName
  825. if order.IsMedicineInsurance == 1 {
  826. struct3505.MdtrtSetlType = "1"
  827. } else {
  828. struct3505.MdtrtSetlType = "2"
  829. }
  830. struct3505.OrgName = miConfig.OrgName
  831. struct3505.AccessKey = miConfig.AccessKey
  832. struct3505.RequestUrl = miConfig.Url
  833. struct3505.SecretKey = miConfig.SecretKey
  834. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  835. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  836. result1, result2, _ := service.FJyb3505(struct3505)
  837. return result1,result2
  838. }
  839. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string,role models.UserAdminRole) (string,string){
  840. var struct3506 models.Struct3506
  841. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  842. struct3506.FixmedinsHilistId = miConfig.Code
  843. struct3506.FixmedinsHilistName = miConfig.OrgName
  844. struct3506.FixmedinsCode = miConfig.Code
  845. struct3506.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
  846. struct3506.Opter = role.UserName
  847. order := service.GetHisOrderByNumber(pre.BatchNumber)
  848. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  849. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  850. struct3506.MdtrtSn = order.MdtrtId
  851. struct3506.ExpyEnd = ""
  852. struct3506.RxFlag = "0"
  853. struct3506.TrdnFlag = "1"
  854. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  855. struct3506.SelRetnCnt = strValue
  856. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  857. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  858. struct3506.SelRetnOpterName = role.UserName
  859. struct3506.OrgName = miConfig.OrgName
  860. struct3506.AccessKey = miConfig.AccessKey
  861. struct3506.RequestUrl = miConfig.Url
  862. struct3506.SecretKey = miConfig.SecretKey
  863. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  864. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  865. struct3506.Url = miConfig.Url
  866. struct3506.AppId = miConfig.Cainfo
  867. struct3506.AppSecret = miConfig.AppSecret
  868. struct3506.Enckey = miConfig.EncKey
  869. struct3506.SignKey = miConfig.SignKey
  870. struct3506.SecretKey = miConfig.SecretKey
  871. result1, result2, _ := service.FJyb3506(struct3506)
  872. return result1,result2
  873. }
  874. func (c *HisApiController) Get1318() {
  875. adminUser := c.GetAdminUserInfo()
  876. admin_user_id, _ := c.GetInt64("admin_user_id")
  877. code := c.GetString("code")
  878. code = ""
  879. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  880. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  881. api := ""
  882. if miConfig.MdtrtareaAdmvs == "320921" {
  883. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  884. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  885. } else {
  886. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  887. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  888. }
  889. resp, requestErr := http.Get(api)
  890. if requestErr != nil {
  891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  892. return
  893. }
  894. body, ioErr := ioutil.ReadAll(resp.Body)
  895. if ioErr != nil {
  896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  898. return
  899. }
  900. var respJSON map[string]interface{}
  901. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  904. return
  905. }
  906. //var res Result2406
  907. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  908. result, _ := json.Marshal(respJSON)
  909. if err := json.Unmarshal([]byte(result), &res); err != nil {
  910. utils.ErrorLog("解析失败:%v", err)
  911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  912. return
  913. }
  914. if res.Infcode == "0" {
  915. c.ServeSuccessJSON(map[string]interface{}{
  916. "result": "",
  917. })
  918. } else {
  919. c.ServeSuccessJSON(map[string]interface{}{
  920. "failed_code": -10,
  921. "msg": res.ErrMsg,
  922. })
  923. */return
  924. //}
  925. }
  926. func (c *HisApiController) Get2503() {
  927. adminUser := c.GetAdminUserInfo()
  928. admin_user_id, _ := c.GetInt64("admin_user_id")
  929. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  930. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  931. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  932. }
  933. func (c *HisApiController) Get2406() {
  934. id, _ := c.GetInt64("id")
  935. record_time := c.GetString("record_time")
  936. his_patient_id, _ := c.GetInt64("his_patient_id")
  937. admin_user_id, _ := c.GetInt64("admin_user_id")
  938. diagnosis_id := c.GetString("diagnosis")
  939. timeLayout := "2006-01-02"
  940. loc, _ := time.LoadLocation("Local")
  941. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  942. if err != nil {
  943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  944. return
  945. }
  946. recordDateTime := theTime.Unix()
  947. adminUser := c.GetAdminUserInfo()
  948. diagnosis_ids := strings.Split(diagnosis_id, ",")
  949. var config []*models.HisXtDiagnoseConfig
  950. for _, item := range diagnosis_ids {
  951. id, _ := strconv.ParseInt(item, 10, 64)
  952. diagnosisConfig, _ := service.FindDiagnoseById(id)
  953. config = append(config, &diagnosisConfig)
  954. }
  955. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  956. fmt.Println(his_patient_id)
  957. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  958. //timestamp := time.Now().Unix()
  959. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  960. var patientPrescription models.HisPrescriptionInfo
  961. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  962. if patientPrescription.ID == 0 {
  963. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  964. }
  965. var res2 Result2406
  966. if miConfig.MdtrtareaAdmvs == "341203" {
  967. data := make(map[string]interface{})
  968. client := &http.Client{}
  969. data["psn_no"] = his.PsnNo
  970. data["mdtrt_id"] = his.Number
  971. data["operator"] = roles.UserName
  972. data["cert_no"] = his.IdCardNo
  973. data["org_name"] = miConfig.OrgName
  974. data["psn_name"] = his.Name
  975. data["ipt_otp_no"] = his.IptOtpNo
  976. data["ipt_psn_sp_flag_type"] = "0901"
  977. data["ipt_psn_sp_flag"] = "1"
  978. data["fixmedins_code"] = miConfig.Code
  979. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  980. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  981. data["url"] = miConfig.Url
  982. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  983. bytesData, _ := json.Marshal(data)
  984. var req *http.Request
  985. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  986. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  987. resp, _ := client.Do(req)
  988. defer resp.Body.Close()
  989. body, ioErr := ioutil.ReadAll(resp.Body)
  990. if ioErr != nil {
  991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  993. return
  994. }
  995. var respJSON map[string]interface{}
  996. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  999. return
  1000. }
  1001. status := respJSON["data"].(map[string]interface{})["status"].(string)
  1002. if status == "0" {
  1003. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  1004. c.ServeSuccessJSON(map[string]interface{}{
  1005. "failed_code": -10,
  1006. "msg": err_msg,
  1007. })
  1008. return
  1009. }
  1010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1011. userJSONBytes, _ := json.Marshal(respJSON)
  1012. fmt.Println("log")
  1013. fmt.Println(string(userJSONBytes))
  1014. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1015. utils.ErrorLog("解析失败:%v", err)
  1016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1017. return
  1018. }
  1019. }
  1020. if res2.Infcode != 0 {
  1021. adminUser := c.GetAdminUserInfo()
  1022. errlog := &models.HisOrderError{
  1023. UserOrgId: adminUser.CurrentOrgId,
  1024. Ctime: time.Now().Unix(),
  1025. Mtime: time.Now().Unix(),
  1026. ErrMsg: res2.ErrMsg,
  1027. Status: 1,
  1028. PatientId: id,
  1029. RecordTime: recordDateTime,
  1030. Stage: 3,
  1031. }
  1032. service.CreateErrMsgLog(errlog)
  1033. c.ServeSuccessJSON(map[string]interface{}{
  1034. "failed_code": -10,
  1035. "msg": res2.ErrMsg,
  1036. })
  1037. return
  1038. } else {
  1039. c.ServeSuccessJSON(map[string]interface{}{
  1040. "msg": "上传成功",
  1041. })
  1042. return
  1043. }
  1044. }
  1045. func (c *HisApiController) Get4105() {
  1046. }
  1047. func (c *HisApiController) Post5302() {
  1048. patient_id, _ := c.GetInt64("id")
  1049. admin_user_id, _ := c.GetInt64("admin_user_id")
  1050. p, _ := service.GetHisPatientById(patient_id)
  1051. adminUser := c.GetAdminUserInfo()
  1052. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1053. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1054. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  1055. }
  1056. func (c *HisApiController) Get4104() {
  1057. }
  1058. type Output struct {
  1059. CertNo string `json:"certno"`
  1060. PsnName string `json:"psn_name"`
  1061. CardNo string `json:"card_no"`
  1062. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1063. CardSN string `json:"card_sn"`
  1064. PsnCertType string `json:"psn_cert_type"`
  1065. MdtrtCertNo string `json:"mdtrt_cert_no"`
  1066. MdtrtCertType string `json:"mdtrt_cert_type"`
  1067. QRCode string `json:"qrCode"`
  1068. EcToken string `json:"ecToken"`
  1069. }
  1070. type AHResponse struct {
  1071. Body AHBody `json:"body"`
  1072. Code int `json:"code"`
  1073. CSBCode int `json:"csbCode"`
  1074. Message string `json:"message"`
  1075. RequestID string `json:"requestId"`
  1076. State struct{} `json:"state"`
  1077. }
  1078. type AHBody struct {
  1079. ErrMsg string `json:"err_msg"`
  1080. InfRefMsgID string `json:"inf_refmsgid"`
  1081. InfCode int `json:"infcode"`
  1082. Output struct {
  1083. Result []struct {
  1084. BasMednFlag string `json:"bas_medn_flag"`
  1085. ChldMedcFlag string `json:"chld_medc_flag"`
  1086. ChrgitmLv string `json:"chrgitm_lv"`
  1087. Cnt float64 `json:"cnt"`
  1088. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1089. DrtReimFlag string `json:"drt_reim_flag"`
  1090. FeedetlSn string `json:"feedetl_sn"`
  1091. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1092. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1093. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1094. ListSpItemFlag string `json:"list_sp_item_flag"`
  1095. LmtUsedFlag string `json:"lmt_used_flag"`
  1096. MedChrgitmType string `json:"med_chrgitm_type"`
  1097. Memo string `json:"memo"`
  1098. OverlmtAmt float64 `json:"overlmt_amt"`
  1099. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1100. Pric float64 `json:"pric"`
  1101. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1102. SelfpayProp float64 `json:"selfpay_prop"`
  1103. } `json:"result"`
  1104. } `json:"output"`
  1105. }
  1106. type Response struct {
  1107. Output Output `json:"output"`
  1108. Infcode int `json:"infcode"`
  1109. InfRefMsgID string `json:"inf_refmsgid"`
  1110. RefMsgTime string `json:"refmsg_time"`
  1111. RespondTime string `json:"respond_time"`
  1112. ErrMsg string `json:"err_msg"`
  1113. WarnMsg string `json:"warn_msg"`
  1114. SignType string `json:"signtype"`
  1115. CAInfo string `json:"cainfo"`
  1116. }
  1117. func (c *HisApiController) Getquerydata() {
  1118. query_type, _ := c.GetInt64("type")
  1119. refd_setl_flag := c.GetString("refd_setl_flag")
  1120. med_type := c.GetString("med_type")
  1121. //admin_user_id,_ := c.GetInt64("admin_user_id")
  1122. cert_no := c.GetString("cert_no")
  1123. psn_no := c.GetString("psn_no")
  1124. start_time := c.GetString("start_time")
  1125. end_time := c.GetString("end_time")
  1126. page, _ := c.GetInt64("page")
  1127. limit, _ := c.GetInt64("limit")
  1128. var bp models.BusinessParams5262
  1129. bp.RefdSetlFlag = refd_setl_flag
  1130. bp.MedType = med_type
  1131. bp.Certno = cert_no
  1132. bp.Psnno = psn_no
  1133. bp.QBegntime = start_time
  1134. bp.QEndtime = end_time
  1135. if query_type == 1 { //本地
  1136. Post5262(c, bp, page, limit)
  1137. } else { //异地
  1138. Post5267(c, bp, page, limit)
  1139. }
  1140. }
  1141. func (c *HisApiController) Drugscheck() {
  1142. admin_user_id, _ := c.GetInt64("admin_user_id")
  1143. adminUser := c.GetAdminUserInfo()
  1144. var queryResult []QueryResult
  1145. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  1146. for _, item := range drugs {
  1147. result := QueryResult{
  1148. ID: item.ID,
  1149. Name: item.DrugName,
  1150. Code: item.MedicalInsuranceNumber,
  1151. List_type_code: "101",
  1152. }
  1153. queryResult = append(queryResult, result)
  1154. }
  1155. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1156. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1157. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1158. for _, item := range queryResult {
  1159. 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)
  1160. }
  1161. }
  1162. func (c *HisApiController) Goodcheck() {
  1163. admin_user_id, _ := c.GetInt64("admin_user_id")
  1164. adminUser := c.GetAdminUserInfo()
  1165. var queryResult []QueryResult
  1166. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  1167. for _, item := range goods {
  1168. result := QueryResult{
  1169. ID: item.ID,
  1170. Name: item.GoodName,
  1171. Code: item.SocialSecurityDirectoryCode,
  1172. List_type_code: "301",
  1173. }
  1174. queryResult = append(queryResult, result)
  1175. }
  1176. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1177. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1178. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1179. for _, item := range queryResult {
  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. //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)
  1182. }
  1183. }
  1184. func (c *HisApiController) Projectcheck() {
  1185. admin_user_id, _ := c.GetInt64("admin_user_id")
  1186. adminUser := c.GetAdminUserInfo()
  1187. var queryResult []QueryResult
  1188. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  1189. for _, item := range projects {
  1190. result := QueryResult{
  1191. ID: item.ID,
  1192. Name: item.ProjectName,
  1193. Code: item.MedicalCode,
  1194. List_type_code: "201",
  1195. }
  1196. queryResult = append(queryResult, result)
  1197. }
  1198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1199. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1200. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1201. for _, item := range queryResult {
  1202. 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)
  1203. }
  1204. }
  1205. //func (c *HisApiController)CancleDia(){
  1206. //
  1207. // id, _ := c.GetInt64("id")
  1208. // record_time := c.GetString("record_time")
  1209. // his_patient_id, _ := c.GetInt64("his_patient_id")
  1210. //
  1211. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1212. //
  1213. // diagnosis_id := c.GetString("diagnosis")
  1214. // sick_type, _ := c.GetInt64("sick_type")
  1215. // reg_type, _ := c.GetInt64("p_type")
  1216. // begin_time := c.GetString("begin_time")
  1217. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  1218. //
  1219. //
  1220. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  1221. //
  1222. // fmt.Println(acct_used_flag)
  1223. //
  1224. //
  1225. // timeLayout := "2006-01-02"
  1226. // loc, _ := time.LoadLocation("Local")
  1227. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1228. // if err != nil {
  1229. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1230. // return
  1231. // }
  1232. // recordDateTime := theTime.Unix()
  1233. // adminUser := c.GetAdminUserInfo()
  1234. //
  1235. //
  1236. //
  1237. //
  1238. //
  1239. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1240. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1241. // var patientPrescription models.HisPrescriptionInfo
  1242. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1243. // if patientPrescription.ID == 0 {
  1244. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1245. // }
  1246. // //if patientPrescription.Do
  1247. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1248. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1249. //
  1250. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1251. //
  1252. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  1253. //
  1254. // var config []*models.HisXtDiagnoseConfig
  1255. // for _, item := range diagnosis_ids {
  1256. // id, _ := strconv.ParseInt(item, 10, 64)
  1257. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  1258. // config = append(config, &diagnosisConfig)
  1259. // }
  1260. //
  1261. // sickConfig, _ := service.FindSickById(sick_type)
  1262. //
  1263. //
  1264. // data := make(map[string]interface{})
  1265. // client := &http.Client{}
  1266. // data["psn_no"] = his.PsnNo
  1267. // data["mdtrt_id"] = his.Number
  1268. // data["doctor"] = roles.UserName
  1269. // data["department"] = department.Name
  1270. // data["org_name"] = miConfig.OrgName
  1271. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  1272. // data["doctor_id"] = doctor_info.DoctorNumber
  1273. // data["new_doctor_name"] = doctor_info.UserName
  1274. // data["fixmedins_code"] = miConfig.Code
  1275. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  1276. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1277. // data["secret_key"] = miConfig.SecretKey
  1278. // data["sick_code"] = sickConfig.CountryCode
  1279. // data["sick_name"] = sickConfig.ClassName
  1280. // data["url"] = miConfig.Url
  1281. // data["ak"] = miConfig.AccessKey
  1282. // data["begin_time"] = begin_time
  1283. // data["cainfo"] = miConfig.Cainfo
  1284. // data["is_vaild"] = "0"
  1285. //
  1286. // data["dept"] = strconv.FormatInt(department.ID, 10)
  1287. // data["config"] = config
  1288. // bytesData, _ := json.Marshal(data)
  1289. //
  1290. // var req *http.Request
  1291. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  1292. // resp, _ := client.Do(req)
  1293. // defer resp.Body.Close()
  1294. // body, ioErr := ioutil.ReadAll(resp.Body)
  1295. // if ioErr != nil {
  1296. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. // return
  1299. // }
  1300. // var respJSON map[string]interface{}
  1301. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1302. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1304. // return
  1305. // }
  1306. //
  1307. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1308. // userJSONBytes, _ := json.Marshal(respJSON)
  1309. // fmt.Println("log")
  1310. // fmt.Println(string(userJSONBytes))
  1311. //
  1312. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  1313. // utils.ErrorLog("解析失败:%v", err)
  1314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1315. // return
  1316. // }
  1317. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  1318. // res2.Output = ressix10265.Output
  1319. // res2.ErrMsg = ressix10265.ErrMsg
  1320. // res2.Cainfo = ressix10265.Cainfo
  1321. // res2.WarnMsg = ressix10265.WarnMsg
  1322. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  1323. // res2.Infcode = infocode
  1324. //
  1325. //}
  1326. func (c *HisApiController) Get4102() {
  1327. order_id, _ := c.GetInt64("order_id")
  1328. admin_user_id, _ := c.GetInt64("admin_user_id")
  1329. stas_type := c.GetString("stas_type")
  1330. order, _ := service.GetHisOrderByIDTwo(order_id)
  1331. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1332. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1333. var pp models.PublicParams
  1334. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1335. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1336. pp.FixmedinsName = miConfig.OrgName
  1337. pp.FixmedinsCode = miConfig.Code
  1338. pp.RequestUrl = miConfig.Url
  1339. pp.Cainfo = miConfig.Cainfo
  1340. pp.SecretKey = miConfig.SecretKey
  1341. pp.AccessKey = miConfig.AccessKey
  1342. pp.OpterName = curRoles.UserName
  1343. if miConfig.MdtrtareaAdmvs == "350500" {
  1344. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1345. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  1346. saveLog(result, request, "4102", "清单确认")
  1347. var dat map[string]interface{}
  1348. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1349. fmt.Println(dat)
  1350. } else {
  1351. fmt.Println(err)
  1352. }
  1353. var empty ResultFourteen
  1354. userJSONBytes, _ := json.Marshal(dat)
  1355. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1356. utils.ErrorLog("解析失败:%v", err)
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1358. return
  1359. }
  1360. if empty.Infcode == 0 {
  1361. c.ServeSuccessJSON(map[string]interface{}{
  1362. "msg": "确认成功",
  1363. })
  1364. return
  1365. }
  1366. } else {
  1367. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1368. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  1369. result3, request3 := service.Jxyb4105(pp)
  1370. saveLog(result, request, "4102", "清单确认")
  1371. saveLog(result2, request2, "4103", "清单确认")
  1372. saveLog(result3, request3, "4105", "清单统计")
  1373. var dat map[string]interface{}
  1374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1375. fmt.Println(dat)
  1376. } else {
  1377. fmt.Println(err)
  1378. }
  1379. var empty ResultFourteen
  1380. userJSONBytes, _ := json.Marshal(dat)
  1381. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1382. utils.ErrorLog("解析失败:%v", err)
  1383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1384. return
  1385. }
  1386. if empty.Infcode == 0 {
  1387. c.ServeSuccessJSON(map[string]interface{}{
  1388. "msg": "确认成功",
  1389. })
  1390. return
  1391. }
  1392. }
  1393. }
  1394. // 对账权限查询
  1395. func (c *HisApiController) Get3260() {
  1396. admin_user_id, _ := c.GetInt64("admin_user_id")
  1397. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1398. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1399. var api string
  1400. var res models.JSResult3260
  1401. if miConfig.MdtrtareaAdmvs == "320921" {
  1402. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1403. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1404. } else {
  1405. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1406. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1407. }
  1408. resp, requestErr := http.Get(api)
  1409. if requestErr != nil {
  1410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1411. return
  1412. }
  1413. body, ioErr := ioutil.ReadAll(resp.Body)
  1414. if ioErr != nil {
  1415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1417. return
  1418. }
  1419. var respJSON map[string]interface{}
  1420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1423. return
  1424. }
  1425. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1426. result, _ := json.Marshal(respJSON)
  1427. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1428. utils.ErrorLog("解析失败:%v", err)
  1429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1430. return
  1431. }
  1432. if res.Infcode == "0" {
  1433. c.ServeSuccessJSON(map[string]interface{}{
  1434. "result": res.Output.Data,
  1435. })
  1436. } else {
  1437. c.ServeSuccessJSON(map[string]interface{}{
  1438. "failed_code": -10,
  1439. "msg": res.ErrMsg,
  1440. })
  1441. return
  1442. }
  1443. }
  1444. func (c *HisApiController) Get3261() {
  1445. admin_user_id, _ := c.GetInt64("admin_user_id")
  1446. //month := c.GetString("month")
  1447. startTime := c.GetString("start_time")
  1448. //endTime, _ := c.GetString("end_time")
  1449. times := strings.Split(startTime, "-")
  1450. stmt_mon := times[0] + times[1]
  1451. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1452. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1453. var api string
  1454. var res models.JSResult3261
  1455. //var res10265 Result5301For10265
  1456. if miConfig.MdtrtareaAdmvs == "320921" {
  1457. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1458. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1459. } else {
  1460. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1461. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1462. }
  1463. resp, requestErr := http.Get(api)
  1464. if requestErr != nil {
  1465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1466. return
  1467. }
  1468. body, ioErr := ioutil.ReadAll(resp.Body)
  1469. if ioErr != nil {
  1470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1472. return
  1473. }
  1474. var respJSON map[string]interface{}
  1475. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1478. return
  1479. }
  1480. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1481. result, _ := json.Marshal(respJSON)
  1482. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1483. utils.ErrorLog("解析失败:%v", err)
  1484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1485. return
  1486. }
  1487. if res.Infcode == "0" {
  1488. c.ServeSuccessJSON(map[string]interface{}{
  1489. "result": res.Output,
  1490. })
  1491. } else {
  1492. c.ServeSuccessJSON(map[string]interface{}{
  1493. "failed_code": -10,
  1494. "msg": res.ErrMsg,
  1495. })
  1496. return
  1497. }
  1498. }
  1499. type TempFun struct {
  1500. FundKey string
  1501. FundCode string
  1502. }
  1503. func (c *HisApiController) Get3262() {
  1504. admin_user_id, _ := c.GetInt64("admin_user_id")
  1505. startTime := c.GetString("start_time")
  1506. endTime := c.GetString("end_time")
  1507. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1508. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1509. //timeLayout := "2006-01-02"
  1510. //loc, _ := time.LoadLocation("Local")
  1511. //var theStartTIme int64
  1512. //if len(startTime) > 0 {
  1513. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1514. // if err != nil {
  1515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1516. // return
  1517. // }
  1518. // theStartTIme = theTime.Unix()
  1519. //}
  1520. //var theEndtTIme int64
  1521. //if len(endTime) > 0 {
  1522. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1523. // if err != nil {
  1524. // utils.ErrorLog(err.Error())
  1525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1526. // return
  1527. // }
  1528. // theEndtTIme = theTime.Unix()
  1529. //}
  1530. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1531. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1532. for _, team := range datas {
  1533. fmt.Println(team.PsnTime)
  1534. for _, team_two := range datas_two {
  1535. fmt.Println(team_two.PsnTime)
  1536. if team.FundKey == team_two.FundKey {
  1537. fmt.Println(team_two.PsnTime)
  1538. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1539. fmt.Println(team.PsnTime)
  1540. }
  1541. }
  1542. }
  1543. fmt.Println("1111")
  1544. fmt.Println(datas)
  1545. fmt.Println("1111")
  1546. var twos []models.FixMonRecDetailFileInTwo
  1547. for _, team := range datas {
  1548. var two models.FixMonRecDetailFileInTwo
  1549. two.MedType = team.MedType
  1550. two.Insutype = team.Insutype
  1551. two.PsnType = team.PsnType
  1552. two.MedType = team.MedType
  1553. two.FixBlngAdmdvs = "999999"
  1554. two.InsuAdmdvs = "555555"
  1555. two.PsnTime = team.PsnTime
  1556. two.PsnCnt = team.PsnCnt
  1557. two.FundKey = team.FundKey
  1558. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1559. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1560. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1561. two.MedfeeSumAmt = ms
  1562. two.InscpAmt = ia
  1563. two.FundPaySumAmt = fps
  1564. twos = append(twos, two)
  1565. }
  1566. //startTime := c.GetString("start_time")
  1567. //endTime, _ := c.GetString("end_time")
  1568. times := strings.Split(startTime, "-")
  1569. stmt_mon := times[0] + times[1]
  1570. var funs []models.FundDetail
  1571. for _, item := range datas {
  1572. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1573. funs = append(funs, fun...)
  1574. }
  1575. var funInfos []models.Fund
  1576. //for _, item := range funs {
  1577. // var rf []models.FundInfo
  1578. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1579. // for _, subitem := range rf {
  1580. // var fund models.Fund
  1581. // fund.FundCode = subitem.FundPayType
  1582. // fund.FundName = subitem.FundPayTypeName
  1583. // fund.FundAmt = subitem.FundPayAmt
  1584. // fund.FundKey = item.FundKey
  1585. // fund.InsuAdmdvs = "555555"
  1586. // fund.FixBlngAdmdvs = "999999"
  1587. // funInfos = append(funInfos, fund)
  1588. // }
  1589. //}
  1590. var tempFuns []TempFun
  1591. for _, funInfo := range funInfos {
  1592. var tempFun TempFun
  1593. tempFun.FundKey = funInfo.FundKey
  1594. tempFun.FundCode = funInfo.FundCode
  1595. tempFuns = append(tempFuns, tempFun)
  1596. }
  1597. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1598. fmt.Println(tempFuns)
  1599. var funInfosTwo []models.Fund
  1600. decimal.DivisionPrecision = 2
  1601. for _, item := range tempFuns {
  1602. var fund models.Fund
  1603. for _, subItem := range funInfos {
  1604. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1605. fund.FundKey = subItem.FundKey
  1606. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1607. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1608. fund.FundName = subItem.FundName
  1609. fund.FundCode = subItem.FundCode
  1610. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1611. }
  1612. }
  1613. funInfosTwo = append(funInfosTwo, fund)
  1614. }
  1615. fmt.Println("funInfosTwo")
  1616. fmt.Println(funInfosTwo)
  1617. var upld_btch string
  1618. var empty models.JSResultEmpty
  1619. data := make(map[string]interface{})
  1620. data["org_name"] = miConfig.OrgName
  1621. data["doctor"] = curRoles.UserName
  1622. data["doctor_name"] = curRoles.UserName
  1623. data["fixmedins_code"] = miConfig.Code
  1624. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1625. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1626. data["secret_key"] = miConfig.SecretKey
  1627. data["url"] = miConfig.Url
  1628. data["ak"] = miConfig.AccessKey
  1629. data["cainfo"] = miConfig.Cainfo
  1630. data["datas"] = twos
  1631. data["fund"] = funInfosTwo
  1632. fmt.Println(twos)
  1633. month := time.Unix(1557042972, 0).Format("1")
  1634. year := time.Now().Format("2006")
  1635. month = time.Now().Format("01")
  1636. day := time.Now().Format("02")
  1637. hour := time.Now().Format("15")
  1638. min := time.Now().Format("04")
  1639. sec := time.Now().Format("05")
  1640. fix_fill_date := year + month + day + hour + min + sec
  1641. data["fix_fill_dept"] = miConfig.OrgName
  1642. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1643. data["fix_fill_psn"] = curRoles.UserName
  1644. data["fix_fill_date"] = fix_fill_date
  1645. data["stmt_loc"] = "2"
  1646. data["setl_mon"] = stmt_mon
  1647. upld_btch = "0"
  1648. data["upld_btch"] = upld_btch
  1649. //fmt.Println(data)
  1650. client := &http.Client{}
  1651. bytesData, _ := json.Marshal(data)
  1652. var req *http.Request
  1653. if miConfig.MdtrtareaAdmvs == "320921" {
  1654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1655. } else {
  1656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1657. }
  1658. resp, _ := client.Do(req)
  1659. defer resp.Body.Close()
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. }
  1665. var respJSON map[string]interface{}
  1666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1669. }
  1670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1671. //fmt.Println(respJSON)
  1672. result, _ := json.Marshal(respJSON)
  1673. //fmt.Println(result)
  1674. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1675. utils.ErrorLog("解析失败:%v", err)
  1676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. }
  1678. if empty.Infcode != "0" {
  1679. c.ServeSuccessJSON(map[string]interface{}{
  1680. "failed_code": -10,
  1681. "msg": empty.ErrMsg,
  1682. })
  1683. return
  1684. } else {
  1685. c.ServeSuccessJSON(map[string]interface{}{
  1686. "msg": "上传成功",
  1687. })
  1688. return
  1689. }
  1690. }
  1691. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1692. newArr = make([]TempFun, 0)
  1693. for i := 0; i < len(arr); i++ {
  1694. repeat := false
  1695. for j := i + 1; j < len(arr); j++ {
  1696. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1697. repeat = true
  1698. break
  1699. }
  1700. }
  1701. if !repeat {
  1702. newArr = append(newArr, arr[i])
  1703. }
  1704. }
  1705. return
  1706. }
  1707. func (c *HisApiController) Get3263() {
  1708. admin_user_id, _ := c.GetInt64("admin_user_id")
  1709. startTime := c.GetString("start_time")
  1710. //endTime, _ := c.GetString("end_time")
  1711. times := strings.Split(startTime, "-")
  1712. setl_mon := times[0] + times[1]
  1713. upld_btch := "0"
  1714. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1715. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1716. var result3263 models.JSResult3263
  1717. data := make(map[string]interface{})
  1718. data["org_name"] = miConfig.OrgName
  1719. data["doctor"] = curRoles.UserName
  1720. data["doctor_name"] = curRoles.UserName
  1721. data["fixmedins_code"] = miConfig.Code
  1722. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1723. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1724. data["secret_key"] = miConfig.SecretKey
  1725. data["url"] = miConfig.Url
  1726. data["ak"] = miConfig.AccessKey
  1727. data["cainfo"] = miConfig.Cainfo
  1728. data["setl_mon"] = setl_mon
  1729. data["stmt_loc"] = "2"
  1730. data["upld_btch"] = upld_btch
  1731. client := &http.Client{}
  1732. bytesData, _ := json.Marshal(data)
  1733. var req *http.Request
  1734. if miConfig.MdtrtareaAdmvs == "320921" {
  1735. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1736. } else {
  1737. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1738. }
  1739. resp, _ := client.Do(req)
  1740. defer resp.Body.Close()
  1741. body, ioErr := ioutil.ReadAll(resp.Body)
  1742. if ioErr != nil {
  1743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1745. }
  1746. var respJSON map[string]interface{}
  1747. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1750. }
  1751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1752. fmt.Println(respJSON)
  1753. result, _ := json.Marshal(respJSON)
  1754. fmt.Println(result)
  1755. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1756. utils.ErrorLog("解析失败:%v", err)
  1757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1758. }
  1759. if result3263.Infcode != "0" {
  1760. c.ServeSuccessJSON(map[string]interface{}{
  1761. "failed_code": -10,
  1762. "msg": result3263.ErrMsg,
  1763. })
  1764. return
  1765. } else {
  1766. c.ServeSuccessJSON(map[string]interface{}{
  1767. "list": result3263.Output,
  1768. })
  1769. return
  1770. }
  1771. }
  1772. func (c *HisApiController) Get3264() {
  1773. admin_user_id, _ := c.GetInt64("admin_user_id")
  1774. startTime := c.GetString("start_time")
  1775. //endTime, _ := c.GetString("end_time")
  1776. times := strings.Split(startTime, "-")
  1777. setl_mon := times[0] + times[1]
  1778. upld_btch := "0"
  1779. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1780. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1781. //solidify_id := []
  1782. var result3263 models.JSResult3263
  1783. data := make(map[string]interface{})
  1784. data["org_name"] = miConfig.OrgName
  1785. data["doctor"] = curRoles.UserName
  1786. data["doctor_name"] = curRoles.UserName
  1787. data["fixmedins_code"] = miConfig.Code
  1788. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1789. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1790. data["secret_key"] = miConfig.SecretKey
  1791. data["url"] = miConfig.Url
  1792. data["ak"] = miConfig.AccessKey
  1793. data["cainfo"] = miConfig.Cainfo
  1794. data["setl_mon"] = setl_mon
  1795. data["stmt_loc"] = "2"
  1796. data["upld_btch"] = upld_btch
  1797. client := &http.Client{}
  1798. bytesData, _ := json.Marshal(data)
  1799. var req3263 *http.Request
  1800. if miConfig.MdtrtareaAdmvs == "320921" {
  1801. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1802. } else {
  1803. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1804. }
  1805. resp, _ := client.Do(req3263)
  1806. defer resp.Body.Close()
  1807. body, ioErr := ioutil.ReadAll(resp.Body)
  1808. if ioErr != nil {
  1809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1811. }
  1812. var respJSON3263 map[string]interface{}
  1813. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1816. }
  1817. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1818. fmt.Println(respJSON3263)
  1819. result, _ := json.Marshal(respJSON3263)
  1820. fmt.Println(result)
  1821. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1822. utils.ErrorLog("解析失败:%v", err)
  1823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1824. }
  1825. var ids []string
  1826. for _, item := range result3263.Output {
  1827. ids = append(ids, item.SolidifyID)
  1828. }
  1829. var empty models.JSResultEmpty
  1830. data2 := make(map[string]interface{})
  1831. data2["org_name"] = miConfig.OrgName
  1832. data2["doctor"] = curRoles.UserName
  1833. data2["doctor_name"] = curRoles.UserName
  1834. data2["fixmedins_code"] = miConfig.Code
  1835. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1836. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1837. data2["secret_key"] = miConfig.SecretKey
  1838. data2["url"] = miConfig.Url
  1839. data2["ak"] = miConfig.AccessKey
  1840. data2["cainfo"] = miConfig.Cainfo
  1841. data2["setl_mon"] = setl_mon
  1842. data2["stmt_loc"] = "2"
  1843. data2["upld_btch"] = upld_btch
  1844. data2["solidify_id"] = ids
  1845. client2 := &http.Client{}
  1846. bytesData2, _ := json.Marshal(data2)
  1847. var req *http.Request
  1848. if miConfig.MdtrtareaAdmvs == "320921" {
  1849. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1850. } else {
  1851. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1852. }
  1853. resp2, _ := client2.Do(req)
  1854. defer resp.Body.Close()
  1855. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1856. if ioErr2 != nil {
  1857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1859. }
  1860. var respJSON map[string]interface{}
  1861. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1864. }
  1865. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1866. fmt.Println(respJSON)
  1867. result2, _ := json.Marshal(respJSON)
  1868. fmt.Println(result2)
  1869. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1870. utils.ErrorLog("解析失败:%v", err)
  1871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1872. }
  1873. if empty.Infcode != "0" {
  1874. c.ServeSuccessJSON(map[string]interface{}{
  1875. "failed_code": -10,
  1876. "msg": empty.ErrMsg,
  1877. })
  1878. return
  1879. } else {
  1880. c.ServeSuccessJSON(map[string]interface{}{
  1881. "msg": "",
  1882. })
  1883. return
  1884. }
  1885. }
  1886. func (c *HisApiController) Get3265() {
  1887. admin_user_id, _ := c.GetInt64("admin_user_id")
  1888. startTime := c.GetString("start_time")
  1889. //endTime, _ := c.GetString("end_time")
  1890. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1891. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1892. times := strings.Split(startTime, "-")
  1893. setl_mon := times[0] + times[1]
  1894. var upld_btch string
  1895. upld_btch = "0"
  1896. //var empty models.JSResultEmpty
  1897. var result3265 models.JSResult3264
  1898. var result3263 models.JSResult3263
  1899. data2 := make(map[string]interface{})
  1900. data2["org_name"] = miConfig.OrgName
  1901. data2["doctor"] = curRoles.UserName
  1902. data2["doctor_name"] = curRoles.UserName
  1903. data2["fixmedins_code"] = miConfig.Code
  1904. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1905. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1906. data2["secret_key"] = miConfig.SecretKey
  1907. data2["url"] = miConfig.Url
  1908. data2["ak"] = miConfig.AccessKey
  1909. data2["cainfo"] = miConfig.Cainfo
  1910. data2["setl_mon"] = setl_mon
  1911. data2["stmt_loc"] = "2"
  1912. data2["upld_btch"] = upld_btch
  1913. client2 := &http.Client{}
  1914. bytesData2, _ := json.Marshal(data2)
  1915. var req3263 *http.Request
  1916. if miConfig.MdtrtareaAdmvs == "320921" {
  1917. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1918. } else {
  1919. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1920. }
  1921. resp2, _ := client2.Do(req3263)
  1922. defer resp2.Body.Close()
  1923. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1924. if ioErr2 != nil {
  1925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. }
  1928. var respJSON3263 map[string]interface{}
  1929. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1932. }
  1933. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1934. fmt.Println(respJSON3263)
  1935. result2, _ := json.Marshal(respJSON3263)
  1936. fmt.Println(result2)
  1937. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1938. utils.ErrorLog("解析失败:%v", err)
  1939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1940. }
  1941. var ids []string
  1942. for _, item := range result3263.Output {
  1943. ids = append(ids, item.SolidifyID)
  1944. }
  1945. data := make(map[string]interface{})
  1946. data["org_name"] = miConfig.OrgName
  1947. data["doctor"] = curRoles.UserName
  1948. data["doctor_name"] = curRoles.UserName
  1949. data["fixmedins_code"] = miConfig.Code
  1950. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1951. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1952. data["secret_key"] = miConfig.SecretKey
  1953. data["url"] = miConfig.Url
  1954. data["ak"] = miConfig.AccessKey
  1955. data["cainfo"] = miConfig.Cainfo
  1956. data["setl_mon"] = setl_mon
  1957. data["solidify_id"] = ids
  1958. month := time.Unix(1557042972, 0).Format("1")
  1959. year := time.Now().Format("2006")
  1960. month = time.Now().Format("01")
  1961. day := time.Now().Format("02")
  1962. hour := time.Now().Format("15")
  1963. min := time.Now().Format("04")
  1964. sec := time.Now().Format("05")
  1965. fix_fill_date := year + month + day + hour + min + sec
  1966. data["fix_fill_dept"] = miConfig.OrgName
  1967. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1968. data["fix_fill_psn"] = curRoles.UserName
  1969. data["fix_fill_date"] = fix_fill_date
  1970. data["stmt_loc"] = "2"
  1971. data["upld_btch"] = upld_btch
  1972. client := &http.Client{}
  1973. bytesData, _ := json.Marshal(data)
  1974. var req *http.Request
  1975. if miConfig.MdtrtareaAdmvs == "320921" {
  1976. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1977. } else {
  1978. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1979. }
  1980. resp, _ := client.Do(req)
  1981. defer resp.Body.Close()
  1982. body, ioErr := ioutil.ReadAll(resp.Body)
  1983. if ioErr != nil {
  1984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1986. }
  1987. var respJSON map[string]interface{}
  1988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1991. }
  1992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1993. fmt.Println(respJSON)
  1994. result, _ := json.Marshal(respJSON)
  1995. fmt.Println(result)
  1996. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1997. utils.ErrorLog("解析失败:%v", err)
  1998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1999. }
  2000. if result3265.Infcode != "0" {
  2001. c.ServeSuccessJSON(map[string]interface{}{
  2002. "failed_code": -10,
  2003. "msg": result3265.ErrMsg,
  2004. })
  2005. return
  2006. } else {
  2007. c.ServeSuccessJSON(map[string]interface{}{
  2008. "info": result3265.Output,
  2009. })
  2010. return
  2011. }
  2012. }
  2013. func (c *HisApiController) Get3266() {
  2014. admin_user_id, _ := c.GetInt64("admin_user_id")
  2015. startTime := c.GetString("start_time")
  2016. //endTime, _ := c.GetString("end_time")
  2017. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2018. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2019. times := strings.Split(startTime, "-")
  2020. stmt_mon := times[0] + times[1]
  2021. var upld_btch string
  2022. //var empty models.JSResultEmpty
  2023. var result3265 models.JSResult3264
  2024. data := make(map[string]interface{})
  2025. data["org_name"] = miConfig.OrgName
  2026. data["doctor"] = curRoles.UserName
  2027. data["doctor_name"] = curRoles.UserName
  2028. data["fixmedins_code"] = miConfig.Code
  2029. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2030. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2031. data["secret_key"] = miConfig.SecretKey
  2032. data["url"] = miConfig.Url
  2033. data["ak"] = miConfig.AccessKey
  2034. data["cainfo"] = miConfig.Cainfo
  2035. data["setl_mon"] = stmt_mon
  2036. month := time.Unix(1557042972, 0).Format("1")
  2037. year := time.Now().Format("2006")
  2038. month = time.Now().Format("01")
  2039. day := time.Now().Format("02")
  2040. hour := time.Now().Format("15")
  2041. min := time.Now().Format("04")
  2042. sec := time.Now().Format("05")
  2043. fix_fill_date := year + month + day + hour + min + sec
  2044. data["fix_fill_dept"] = miConfig.OrgName
  2045. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2046. data["fix_fill_psn"] = curRoles.UserName
  2047. data["fix_fill_date"] = fix_fill_date
  2048. data["stmt_loc"] = "2"
  2049. upld_btch = "0"
  2050. data["upld_btch"] = upld_btch
  2051. client := &http.Client{}
  2052. bytesData, _ := json.Marshal(data)
  2053. var req *http.Request
  2054. if miConfig.MdtrtareaAdmvs == "320921" {
  2055. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  2056. } else {
  2057. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  2058. }
  2059. resp, _ := client.Do(req)
  2060. defer resp.Body.Close()
  2061. body, ioErr := ioutil.ReadAll(resp.Body)
  2062. if ioErr != nil {
  2063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2065. }
  2066. var respJSON map[string]interface{}
  2067. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2070. }
  2071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2072. fmt.Println(respJSON)
  2073. result, _ := json.Marshal(respJSON)
  2074. fmt.Println(result)
  2075. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2076. utils.ErrorLog("解析失败:%v", err)
  2077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2078. }
  2079. if result3265.Infcode != "0" {
  2080. c.ServeSuccessJSON(map[string]interface{}{
  2081. "failed_code": -10,
  2082. "msg": result3265.ErrMsg,
  2083. })
  2084. return
  2085. } else {
  2086. c.ServeSuccessJSON(map[string]interface{}{
  2087. "info": result3265.Output,
  2088. })
  2089. return
  2090. }
  2091. }
  2092. func (c *HisApiController) Get3267() {
  2093. admin_user_id, _ := c.GetInt64("admin_user_id")
  2094. startTime := c.GetString("start_time")
  2095. //endTime, _ := c.GetString("end_time")
  2096. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2097. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2098. times := strings.Split(startTime, "-")
  2099. setl_mon := times[0] + times[1]
  2100. var upld_btch string
  2101. //var empty models.JSResultEmpty
  2102. var result3265 models.JSResult3264
  2103. upld_btch = "0"
  2104. data := make(map[string]interface{})
  2105. data["org_name"] = miConfig.OrgName
  2106. data["doctor"] = curRoles.UserName
  2107. data["doctor_name"] = curRoles.UserName
  2108. data["fixmedins_code"] = miConfig.Code
  2109. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2110. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2111. data["secret_key"] = miConfig.SecretKey
  2112. data["url"] = miConfig.Url
  2113. data["ak"] = miConfig.AccessKey
  2114. data["cainfo"] = miConfig.Cainfo
  2115. data["setl_mon"] = setl_mon
  2116. data["stmt_loc"] = "2"
  2117. data["upld_btch"] = upld_btch
  2118. client := &http.Client{}
  2119. bytesData, _ := json.Marshal(data)
  2120. var req *http.Request
  2121. if miConfig.MdtrtareaAdmvs == "320921" {
  2122. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  2123. } else {
  2124. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  2125. }
  2126. resp, _ := client.Do(req)
  2127. defer resp.Body.Close()
  2128. body, ioErr := ioutil.ReadAll(resp.Body)
  2129. if ioErr != nil {
  2130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2132. }
  2133. var respJSON map[string]interface{}
  2134. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2137. }
  2138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2139. fmt.Println(respJSON)
  2140. result, _ := json.Marshal(respJSON)
  2141. fmt.Println(result)
  2142. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2143. utils.ErrorLog("解析失败:%v", err)
  2144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2145. }
  2146. if result3265.Infcode != "0" {
  2147. c.ServeSuccessJSON(map[string]interface{}{
  2148. "failed_code": -10,
  2149. "msg": result3265.ErrMsg,
  2150. })
  2151. return
  2152. } else {
  2153. c.ServeSuccessJSON(map[string]interface{}{
  2154. "info": result3265.Output.Data,
  2155. })
  2156. return
  2157. }
  2158. }
  2159. func (c *HisApiController) Get3268() {
  2160. admin_user_id, _ := c.GetInt64("admin_user_id")
  2161. startTime := c.GetString("start_time")
  2162. endTime := c.GetString("end_time")
  2163. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2164. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2165. times := strings.Split(startTime, "-")
  2166. setl_mon := times[0] + times[1]
  2167. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2168. var twos []models.FixMonRecDetailFileInTwo
  2169. var funs []models.FundDetail
  2170. for _, item := range datas {
  2171. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  2172. funs = append(funs, fun...)
  2173. }
  2174. var funInfos []models.Fund
  2175. //for _, item := range funs {
  2176. // var rf []models.FundInfo
  2177. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  2178. // for _, subitem := range rf {
  2179. // var fund models.Fund
  2180. // fund.FundCode = subitem.FundPayType
  2181. // fund.FundName = subitem.FundPayTypeName
  2182. // fund.FundAmt = subitem.FundPayAmt
  2183. // fund.FundKey = item.FundKey
  2184. // fund.InsuAdmdvs = "555555"
  2185. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  2186. // funInfos = append(funInfos, fund)
  2187. // }
  2188. //}
  2189. for _, team := range datas {
  2190. var two models.FixMonRecDetailFileInTwo
  2191. two.SetlDate = time.Now().Format("2006-01-02")
  2192. two.MedType = team.MedType
  2193. two.Insutype = team.Insutype
  2194. two.PsnType = team.PsnType
  2195. two.MedType = team.MedType
  2196. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  2197. two.InsuAdmdvs = team.InsuAdmdvs
  2198. two.PsnTime = team.PsnTime
  2199. two.PsnCnt = team.PsnCnt
  2200. two.FundKey = team.FundKey
  2201. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  2202. fps, _ := strconv.ParseFloat(team.Fund, 64)
  2203. ia, _ := strconv.ParseFloat(team.Amt, 64)
  2204. two.MedfeeSumAmt = ms
  2205. two.InscpAmt = ia
  2206. two.FundPaySumAmt = fps
  2207. twos = append(twos, two)
  2208. }
  2209. var upld_btch string
  2210. upld_btch = "0"
  2211. var empty models.JSResultEmpty
  2212. data := make(map[string]interface{})
  2213. data["org_name"] = miConfig.OrgName
  2214. data["doctor"] = curRoles.UserName
  2215. data["doctor_name"] = curRoles.UserName
  2216. data["fixmedins_code"] = miConfig.Code
  2217. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2218. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2219. data["secret_key"] = miConfig.SecretKey
  2220. data["url"] = miConfig.Url
  2221. data["ak"] = miConfig.AccessKey
  2222. data["cainfo"] = miConfig.Cainfo
  2223. data["datas"] = twos
  2224. data["fund"] = funInfos
  2225. data["setl_mon"] = setl_mon
  2226. month := time.Unix(1557042972, 0).Format("1")
  2227. year := time.Now().Format("2006")
  2228. month = time.Now().Format("01")
  2229. day := time.Now().Format("02")
  2230. hour := time.Now().Format("15")
  2231. min := time.Now().Format("04")
  2232. sec := time.Now().Format("05")
  2233. fix_fill_date := year + month + day + hour + min + sec
  2234. data["fix_fill_dept"] = miConfig.OrgName
  2235. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2236. data["fix_fill_psn"] = curRoles.UserName
  2237. data["fix_fill_date"] = fix_fill_date
  2238. data["stmt_loc"] = "2"
  2239. data["upld_btch"] = upld_btch
  2240. client := &http.Client{}
  2241. bytesData, _ := json.Marshal(data)
  2242. var req *http.Request
  2243. if miConfig.MdtrtareaAdmvs == "320921" {
  2244. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2245. } else {
  2246. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2247. }
  2248. resp, _ := client.Do(req)
  2249. defer resp.Body.Close()
  2250. body, ioErr := ioutil.ReadAll(resp.Body)
  2251. if ioErr != nil {
  2252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2254. }
  2255. var respJSON map[string]interface{}
  2256. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2259. }
  2260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2261. fmt.Println(respJSON)
  2262. result, _ := json.Marshal(respJSON)
  2263. fmt.Println(result)
  2264. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  2265. utils.ErrorLog("解析失败:%v", err)
  2266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2267. }
  2268. if empty.Infcode != "0" {
  2269. c.ServeSuccessJSON(map[string]interface{}{
  2270. "failed_code": -10,
  2271. "msg": empty.ErrMsg,
  2272. })
  2273. return
  2274. } else {
  2275. c.ServeSuccessJSON(map[string]interface{}{
  2276. "msg": "上传成功",
  2277. })
  2278. return
  2279. }
  2280. }
  2281. func (c *HisApiController) Get3269() {
  2282. admin_user_id, _ := c.GetInt64("admin_user_id")
  2283. startTime := c.GetString("start_time")
  2284. //endTime, _ := c.GetString("end_time")
  2285. times := strings.Split(startTime, "-")
  2286. setl_mon := times[0] + times[1]
  2287. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2288. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2289. var result3263 models.JSResult3263
  2290. data := make(map[string]interface{})
  2291. data["org_name"] = miConfig.OrgName
  2292. data["doctor"] = curRoles.UserName
  2293. data["doctor_name"] = curRoles.UserName
  2294. data["fixmedins_code"] = miConfig.Code
  2295. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2296. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2297. data["secret_key"] = miConfig.SecretKey
  2298. data["url"] = miConfig.Url
  2299. data["ak"] = miConfig.AccessKey
  2300. data["cainfo"] = miConfig.Cainfo
  2301. data["setl_mon"] = setl_mon
  2302. data["stmt_loc"] = "2"
  2303. client := &http.Client{}
  2304. bytesData, _ := json.Marshal(data)
  2305. var req *http.Request
  2306. if miConfig.MdtrtareaAdmvs == "320921" {
  2307. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  2308. } else {
  2309. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  2310. }
  2311. resp, _ := client.Do(req)
  2312. defer resp.Body.Close()
  2313. body, ioErr := ioutil.ReadAll(resp.Body)
  2314. if ioErr != nil {
  2315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2317. }
  2318. var respJSON map[string]interface{}
  2319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2322. }
  2323. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2324. fmt.Println(respJSON)
  2325. result, _ := json.Marshal(respJSON)
  2326. fmt.Println(result)
  2327. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2328. utils.ErrorLog("解析失败:%v", err)
  2329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2330. }
  2331. if result3263.Infcode != "0" {
  2332. c.ServeSuccessJSON(map[string]interface{}{
  2333. "failed_code": -10,
  2334. "msg": result3263.ErrMsg,
  2335. })
  2336. return
  2337. } else {
  2338. c.ServeSuccessJSON(map[string]interface{}{
  2339. "msg": "上传成功",
  2340. })
  2341. return
  2342. }
  2343. }
  2344. func (c *HisApiController) Get3270() {
  2345. admin_user_id, _ := c.GetInt64("admin_user_id")
  2346. startTime := c.GetString("start_time")
  2347. //endTime, _ := c.GetString("end_time")
  2348. times := strings.Split(startTime, "-")
  2349. setl_mon := times[0] + times[1]
  2350. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2351. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2352. var result3263 models.JSResult3263
  2353. data2 := make(map[string]interface{})
  2354. data2["org_name"] = miConfig.OrgName
  2355. data2["doctor"] = curRoles.UserName
  2356. data2["doctor_name"] = curRoles.UserName
  2357. data2["fixmedins_code"] = miConfig.Code
  2358. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2359. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2360. data2["secret_key"] = miConfig.SecretKey
  2361. data2["url"] = miConfig.Url
  2362. data2["ak"] = miConfig.AccessKey
  2363. data2["cainfo"] = miConfig.Cainfo
  2364. data2["setl_mon"] = setl_mon
  2365. data2["stmt_loc"] = "2"
  2366. client2 := &http.Client{}
  2367. bytesData2, _ := json.Marshal(data2)
  2368. var req3263 *http.Request
  2369. if miConfig.MdtrtareaAdmvs == "320921" {
  2370. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2371. } else {
  2372. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2373. }
  2374. resp2, _ := client2.Do(req3263)
  2375. defer resp2.Body.Close()
  2376. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2377. if ioErr2 != nil {
  2378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. }
  2381. var respJSON3263 map[string]interface{}
  2382. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2385. }
  2386. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2387. fmt.Println(respJSON3263)
  2388. result2, _ := json.Marshal(respJSON3263)
  2389. fmt.Println(result2)
  2390. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2391. utils.ErrorLog("解析失败:%v", err)
  2392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2393. }
  2394. var ids []string
  2395. for _, item := range result3263.Output {
  2396. ids = append(ids, item.SolidifyID)
  2397. }
  2398. var result3264 models.JSResult3264
  2399. data := make(map[string]interface{})
  2400. data["org_name"] = miConfig.OrgName
  2401. data["doctor"] = curRoles.UserName
  2402. data["doctor_name"] = curRoles.UserName
  2403. data["fixmedins_code"] = miConfig.Code
  2404. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2405. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2406. data["secret_key"] = miConfig.SecretKey
  2407. data["url"] = miConfig.Url
  2408. data["ak"] = miConfig.AccessKey
  2409. data["cainfo"] = miConfig.Cainfo
  2410. data["setl_mon"] = setl_mon
  2411. data["stmt_loc"] = "2"
  2412. data["solidify_id"] = ids
  2413. client := &http.Client{}
  2414. bytesData, _ := json.Marshal(data)
  2415. var req *http.Request
  2416. if miConfig.MdtrtareaAdmvs == "320921" {
  2417. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2418. } else {
  2419. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2420. }
  2421. resp, _ := client.Do(req)
  2422. defer resp.Body.Close()
  2423. body, ioErr := ioutil.ReadAll(resp.Body)
  2424. if ioErr != nil {
  2425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2427. }
  2428. var respJSON map[string]interface{}
  2429. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2432. }
  2433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2434. fmt.Println(respJSON)
  2435. result, _ := json.Marshal(respJSON)
  2436. fmt.Println(result)
  2437. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2438. utils.ErrorLog("解析失败:%v", err)
  2439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2440. }
  2441. if result3264.Infcode != "0" {
  2442. c.ServeSuccessJSON(map[string]interface{}{
  2443. "failed_code": -10,
  2444. "msg": result3264.ErrMsg,
  2445. })
  2446. return
  2447. } else {
  2448. c.ServeSuccessJSON(map[string]interface{}{
  2449. "info": result3264.Output,
  2450. })
  2451. return
  2452. }
  2453. }
  2454. func (c *HisApiController) Get3271() {
  2455. admin_user_id, _ := c.GetInt64("admin_user_id")
  2456. startTime := c.GetString("start_time")
  2457. //endTime, _ := c.GetString("end_time")
  2458. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2459. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2460. times := strings.Split(startTime, "-")
  2461. setl_mon := times[0] + times[1]
  2462. //var empty models.JSResultEmpty
  2463. var result3265 models.JSResult3264
  2464. var result3263 models.JSResult3263
  2465. data2 := make(map[string]interface{})
  2466. data2["org_name"] = miConfig.OrgName
  2467. data2["doctor"] = curRoles.UserName
  2468. data2["doctor_name"] = curRoles.UserName
  2469. data2["fixmedins_code"] = miConfig.Code
  2470. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2471. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2472. data2["secret_key"] = miConfig.SecretKey
  2473. data2["url"] = miConfig.Url
  2474. data2["ak"] = miConfig.AccessKey
  2475. data2["cainfo"] = miConfig.Cainfo
  2476. data2["setl_mon"] = setl_mon
  2477. data2["stmt_loc"] = "2"
  2478. client2 := &http.Client{}
  2479. bytesData2, _ := json.Marshal(data2)
  2480. var req3263 *http.Request
  2481. if miConfig.MdtrtareaAdmvs == "320921" {
  2482. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2483. } else {
  2484. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2485. }
  2486. resp2, _ := client2.Do(req3263)
  2487. defer resp2.Body.Close()
  2488. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2489. if ioErr2 != nil {
  2490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2492. }
  2493. var respJSON3263 map[string]interface{}
  2494. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2497. }
  2498. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2499. fmt.Println(respJSON3263)
  2500. result2, _ := json.Marshal(respJSON3263)
  2501. fmt.Println(result2)
  2502. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2503. utils.ErrorLog("解析失败:%v", err)
  2504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2505. }
  2506. var ids []string
  2507. for _, item := range result3263.Output {
  2508. ids = append(ids, item.SolidifyID)
  2509. }
  2510. data := make(map[string]interface{})
  2511. data["org_name"] = miConfig.OrgName
  2512. data["doctor"] = curRoles.UserName
  2513. data["doctor_name"] = curRoles.UserName
  2514. data["fixmedins_code"] = miConfig.Code
  2515. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2516. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2517. data["secret_key"] = miConfig.SecretKey
  2518. data["url"] = miConfig.Url
  2519. data["ak"] = miConfig.AccessKey
  2520. data["cainfo"] = miConfig.Cainfo
  2521. data["setl_mon"] = setl_mon
  2522. data["solidify_id"] = ids
  2523. month := time.Unix(1557042972, 0).Format("1")
  2524. year := time.Now().Format("2006")
  2525. month = time.Now().Format("01")
  2526. day := time.Now().Format("02")
  2527. hour := time.Now().Format("15")
  2528. min := time.Now().Format("04")
  2529. sec := time.Now().Format("05")
  2530. fix_fill_date := year + month + day + hour + min + sec
  2531. data["fix_fill_dept"] = miConfig.OrgName
  2532. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2533. data["fix_fill_psn"] = curRoles.UserName
  2534. data["fix_fill_date"] = fix_fill_date
  2535. data["stmt_loc"] = "2"
  2536. client := &http.Client{}
  2537. bytesData, _ := json.Marshal(data)
  2538. var req *http.Request
  2539. if miConfig.MdtrtareaAdmvs == "320921" {
  2540. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2541. } else {
  2542. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2543. }
  2544. resp, _ := client.Do(req)
  2545. defer resp.Body.Close()
  2546. body, ioErr := ioutil.ReadAll(resp.Body)
  2547. if ioErr != nil {
  2548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2550. }
  2551. var respJSON map[string]interface{}
  2552. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2555. }
  2556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2557. fmt.Println(respJSON)
  2558. result, _ := json.Marshal(respJSON)
  2559. fmt.Println(result)
  2560. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2561. utils.ErrorLog("解析失败:%v", err)
  2562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2563. }
  2564. if result3265.Infcode != "0" {
  2565. c.ServeSuccessJSON(map[string]interface{}{
  2566. "failed_code": -10,
  2567. "msg": result3265.ErrMsg,
  2568. })
  2569. return
  2570. } else {
  2571. c.ServeSuccessJSON(map[string]interface{}{
  2572. "info": result3265.Output.Data,
  2573. })
  2574. return
  2575. }
  2576. }
  2577. func (c *HisApiController) Get3272() {
  2578. admin_user_id, _ := c.GetInt64("admin_user_id")
  2579. startTime := c.GetString("start_time")
  2580. //endTime, _ := c.GetString("end_time")
  2581. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2582. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2583. times := strings.Split(startTime, "-")
  2584. setl_mon := times[0] + times[1]
  2585. var upld_btch string
  2586. //var empty models.JSResultEmpty
  2587. var result3265 models.JSResult3264
  2588. data := make(map[string]interface{})
  2589. data["org_name"] = miConfig.OrgName
  2590. data["doctor"] = curRoles.UserName
  2591. data["doctor_name"] = curRoles.UserName
  2592. data["fixmedins_code"] = miConfig.Code
  2593. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2594. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2595. data["secret_key"] = miConfig.SecretKey
  2596. data["url"] = miConfig.Url
  2597. data["ak"] = miConfig.AccessKey
  2598. data["cainfo"] = miConfig.Cainfo
  2599. data["setl_mon"] = setl_mon
  2600. month := time.Unix(1557042972, 0).Format("1")
  2601. year := time.Now().Format("2006")
  2602. month = time.Now().Format("01")
  2603. day := time.Now().Format("02")
  2604. hour := time.Now().Format("15")
  2605. min := time.Now().Format("04")
  2606. sec := time.Now().Format("05")
  2607. fix_fill_date := year + month + day + hour + min + sec
  2608. data["fix_fill_dept"] = miConfig.OrgName
  2609. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2610. data["fix_fill_psn"] = curRoles.UserName
  2611. data["fix_fill_date"] = fix_fill_date
  2612. data["stmt_loc"] = "2"
  2613. data["upld_btch"] = upld_btch
  2614. client := &http.Client{}
  2615. bytesData, _ := json.Marshal(data)
  2616. var req *http.Request
  2617. if miConfig.MdtrtareaAdmvs == "320921" {
  2618. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2619. } else {
  2620. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2621. }
  2622. resp, _ := client.Do(req)
  2623. defer resp.Body.Close()
  2624. body, ioErr := ioutil.ReadAll(resp.Body)
  2625. if ioErr != nil {
  2626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. }
  2629. var respJSON map[string]interface{}
  2630. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2633. }
  2634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2635. fmt.Println(respJSON)
  2636. result, _ := json.Marshal(respJSON)
  2637. fmt.Println(result)
  2638. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2639. utils.ErrorLog("解析失败:%v", err)
  2640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2641. }
  2642. if result3265.Infcode != "0" {
  2643. c.ServeSuccessJSON(map[string]interface{}{
  2644. "failed_code": -10,
  2645. "msg": result3265.ErrMsg,
  2646. })
  2647. return
  2648. } else {
  2649. c.ServeSuccessJSON(map[string]interface{}{
  2650. "info": result3265.Output,
  2651. })
  2652. return
  2653. }
  2654. }
  2655. func (c *HisApiController) Get3273() {
  2656. admin_user_id, _ := c.GetInt64("admin_user_id")
  2657. startTime := c.GetString("start_time")
  2658. //endTime, _ := c.GetString("end_time")
  2659. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2660. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2661. times := strings.Split(startTime, "-")
  2662. setl_mon := times[0] + times[1]
  2663. var result3265 models.JSResult3264
  2664. data := make(map[string]interface{})
  2665. data["org_name"] = miConfig.OrgName
  2666. data["doctor"] = curRoles.UserName
  2667. data["doctor_name"] = curRoles.UserName
  2668. data["fixmedins_code"] = miConfig.Code
  2669. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2670. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2671. data["secret_key"] = miConfig.SecretKey
  2672. data["url"] = miConfig.Url
  2673. data["ak"] = miConfig.AccessKey
  2674. data["cainfo"] = miConfig.Cainfo
  2675. data["setl_mon"] = setl_mon
  2676. data["stmt_loc"] = "2"
  2677. client := &http.Client{}
  2678. bytesData, _ := json.Marshal(data)
  2679. var req *http.Request
  2680. if miConfig.MdtrtareaAdmvs == "320921" {
  2681. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2682. } else {
  2683. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2684. }
  2685. resp, _ := client.Do(req)
  2686. defer resp.Body.Close()
  2687. body, ioErr := ioutil.ReadAll(resp.Body)
  2688. if ioErr != nil {
  2689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2691. }
  2692. var respJSON map[string]interface{}
  2693. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2696. }
  2697. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2698. fmt.Println(respJSON)
  2699. result, _ := json.Marshal(respJSON)
  2700. fmt.Println(result)
  2701. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2702. utils.ErrorLog("解析失败:%v", err)
  2703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2704. }
  2705. if result3265.Infcode != "0" {
  2706. c.ServeSuccessJSON(map[string]interface{}{
  2707. "failed_code": -10,
  2708. "msg": result3265.ErrMsg,
  2709. })
  2710. return
  2711. } else {
  2712. c.ServeSuccessJSON(map[string]interface{}{
  2713. "info": result3265.Output.Data,
  2714. })
  2715. return
  2716. }
  2717. }
  2718. func (c *HisApiController) Get3274() {
  2719. //if miConfig.MdtrtareaAdmvs == "320921" {
  2720. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2721. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2722. // "&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
  2723. //
  2724. //} else {
  2725. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2726. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2727. // "&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
  2728. //
  2729. //}
  2730. }
  2731. func (c *HisApiController) Get3275() {
  2732. //if miConfig.MdtrtareaAdmvs == "320921" {
  2733. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2734. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2735. // "&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
  2736. //
  2737. //} else {
  2738. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2739. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2740. // "&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
  2741. //
  2742. //}
  2743. }
  2744. func (c *HisApiController) Get3276() {
  2745. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2746. //month := c.GetString("month")
  2747. //
  2748. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2749. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2750. //var api string
  2751. //var res Result5301
  2752. //
  2753. //if miConfig.MdtrtareaAdmvs == "320921" {
  2754. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2755. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2756. //} else {
  2757. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2758. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2759. //}
  2760. //
  2761. //resp, requestErr := http.Get(api)
  2762. //if requestErr != nil {
  2763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2764. // return
  2765. //}
  2766. //
  2767. //body, ioErr := ioutil.ReadAll(resp.Body)
  2768. //if ioErr != nil {
  2769. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2771. // return
  2772. //}
  2773. //var respJSON map[string]interface{}
  2774. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2775. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2777. // return
  2778. //}
  2779. //
  2780. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2781. //result, _ := json.Marshal(respJSON)
  2782. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2783. // utils.ErrorLog("解析失败:%v", err)
  2784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2785. // return
  2786. //}
  2787. }
  2788. func (c *HisApiController) Get3277() {
  2789. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2790. //month := c.GetString("month")
  2791. //
  2792. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2793. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2794. //var api string
  2795. //var res Result5301
  2796. //
  2797. //if miConfig.MdtrtareaAdmvs == "320921" {
  2798. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2799. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2800. //} else {
  2801. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2802. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2803. //}
  2804. //
  2805. //resp, requestErr := http.Get(api)
  2806. //if requestErr != nil {
  2807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2808. // return
  2809. //}
  2810. //
  2811. //body, ioErr := ioutil.ReadAll(resp.Body)
  2812. //if ioErr != nil {
  2813. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2815. // return
  2816. //}
  2817. //var respJSON map[string]interface{}
  2818. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2819. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2820. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2821. // return
  2822. //}
  2823. //
  2824. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2825. //result, _ := json.Marshal(respJSON)
  2826. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2827. // utils.ErrorLog("解析失败:%v", err)
  2828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2829. // return
  2830. //}
  2831. }
  2832. func (c *HisApiController) GetCFYLJG001() {
  2833. admin_user_id, _ := c.GetInt64("admin_user_id")
  2834. patient_id, _ := c.GetInt64("patient_id")
  2835. his_patient_id, _ := c.GetInt64("his_patient_id")
  2836. record_time := c.GetString("record_time")
  2837. admin_user_id = 3626
  2838. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2839. psn, _ := service.GetPsnByPatientId(patient_id)
  2840. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2841. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2842. var cFYLJG001 models.CFYLJG001
  2843. timeLayout := "2006-01-02"
  2844. loc, _ := time.LoadLocation("Local")
  2845. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2846. if err != nil {
  2847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2848. return
  2849. }
  2850. recordDateTime := theTime.Unix()
  2851. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2852. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2853. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2854. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2855. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2856. for _, item := range prescriptions {
  2857. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2858. if his.IdCardType == 1 {
  2859. bas := strings.Split(psn.CardInfo, "|")
  2860. basNumber := bas[1]
  2861. fmt.Println(basNumber)
  2862. card_sn := bas[3]
  2863. card_no := bas[2]
  2864. cFYLJG001.MdtrtCertType = "03"
  2865. cFYLJG001.CardSn = card_sn
  2866. cFYLJG001.MdtrtCertNo = card_no
  2867. cFYLJG001.EcToken = ""
  2868. cFYLJG001.AuthNo = ""
  2869. } else if his.IdCardType == 2 {
  2870. cFYLJG001.MdtrtCertType = "02"
  2871. cFYLJG001.CardSn = ""
  2872. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2873. cFYLJG001.EcToken = ""
  2874. cFYLJG001.AuthNo = ""
  2875. } else if his.IdCardType == 4 {
  2876. cFYLJG001.MdtrtCertType = "01"
  2877. cFYLJG001.CardSn = ""
  2878. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2879. cFYLJG001.EcToken = psn.VerifyNumber
  2880. cFYLJG001.AuthNo = ""
  2881. }
  2882. cFYLJG001.BizTypeCode = "01"
  2883. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2884. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2885. cFYLJG001.RxTypeCode = "1"
  2886. tempTime := time.Unix(item.PreTime, 0)
  2887. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2888. cFYLJG001.PrscTime = timeFormatOne
  2889. var count float64
  2890. if item.Type == 1 {
  2891. for _, sumItem := range item.HisDoctorAdviceInfo {
  2892. count = count + sumItem.PrescribingNumber
  2893. }
  2894. }
  2895. cFYLJG001.RxDrugCnt = count
  2896. cFYLJG001.ValiDays = "5"
  2897. ts := time.Unix(item.PreTime, 0)
  2898. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2899. tempTime3 := time.Unix(record_time2, 0)
  2900. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2901. cFYLJG001.ValiEndTime = timeFormat3
  2902. cFYLJG001.RxCotnFlag = "0"
  2903. for _, subItem := range item.HisDoctorAdviceInfo {
  2904. var drug models.RxDrug
  2905. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2906. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2907. drug.RxItemTypeCode = "11"
  2908. drug.DrugDosform = "乳膏剂" //TODO
  2909. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2910. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2911. }
  2912. drug.MedcWayDscr = subItem.DeliveryWay
  2913. tempTime2 := time.Unix(subItem.StartTime, 0)
  2914. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2915. drug.MedcBegntime = timeFormatTwo
  2916. if subItem.Day > 0 {
  2917. ts := time.Unix(subItem.StartTime, 0)
  2918. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2919. tempTime4 := time.Unix(record_time, 0)
  2920. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2921. drug.MedcEndtime = timeFormat5
  2922. } else {
  2923. tempTime2 := time.Unix(subItem.StartTime, 0)
  2924. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2925. drug.MedcEndtime = timeFormatTwo
  2926. }
  2927. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2928. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2929. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2930. drug.DrugCnt = subItem.PrescribingNumber
  2931. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2932. drug.DrugGenname = subItem.AdviceName
  2933. drug.MedcWayCodg = subItem.DeliveryWay
  2934. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2935. drug.SinDoscnt = subItem.SingleDose
  2936. drug.SinDosunt = subItem.SingleDoseUnit
  2937. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2938. drug.UsedFrquName = subItem.ExecutionFrequency
  2939. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2940. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2941. drug.HospApprFlag = "1"
  2942. cFYLJG001.List = append(cFYLJG001.List, drug)
  2943. }
  2944. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2945. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2946. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2947. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2948. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2949. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2950. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2951. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2952. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2953. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2954. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2955. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2956. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2957. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2958. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2959. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2960. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2961. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2962. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2963. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2964. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2965. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2966. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2967. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2968. tempTime2 := time.Now().Unix()
  2969. tempTime6 := time.Unix(tempTime2, 0)
  2970. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2971. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2972. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2973. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2974. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2975. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2976. //memo := make(map[string]interface{})
  2977. //inputData := make(map[string]interface{}, 0)
  2978. //type MyData struct {
  2979. // Insutype string `json:"insutype"`
  2980. //}
  2981. //
  2982. // data := MyData{
  2983. // Insutype: his.Insutype,
  2984. //}
  2985. //
  2986. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2987. var config []*models.HisXtDiagnoseConfig
  2988. for _, item := range diagnosis_ids {
  2989. id, _ := strconv.ParseInt(item, 10, 64)
  2990. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2991. config = append(config, &diagnosisConfig)
  2992. }
  2993. for index, subitem := range config {
  2994. if index == 0 {
  2995. var dia models.DiseInfo
  2996. dia.DiagType = "1"
  2997. dia.MaindiagFlag = "1"
  2998. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2999. dia.DiagCode = subitem.CountryCode
  3000. dia.DiagName = subitem.ClassName
  3001. dia.DiagDept = "肾内科"
  3002. dia.DiagDrNo = doctor.DoctorNumber
  3003. dia.DiagDrName = doctor.UserName
  3004. tempTime3 := time.Unix(item.PreTime, 0)
  3005. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  3006. dia.DiagTime = timeFormatTwo
  3007. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  3008. } else {
  3009. var dia models.DiseInfo
  3010. dia.DiagType = "1"
  3011. dia.MaindiagFlag = "0"
  3012. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3013. dia.DiagCode = subitem.CountryCode
  3014. dia.DiagName = subitem.ClassName
  3015. dia.DiagDept = "肾内科"
  3016. dia.DiagDrNo = doctor.DoctorNumber
  3017. dia.DiagDrName = doctor.UserName
  3018. tempTime3 := time.Unix(item.PreTime, 0)
  3019. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  3020. dia.DiagTime = timeFormatTwo
  3021. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  3022. }
  3023. }
  3024. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  3025. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  3026. var res ResultCFYLJG001
  3027. var respJSON2 map[string]interface{}
  3028. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3031. return
  3032. }
  3033. userJSONBytes2, _ := json.Marshal(respJSON2)
  3034. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3035. utils.ErrorLog("解析失败:%v", err)
  3036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3037. return
  3038. }
  3039. if res.Infcode == -1 {
  3040. c.ServeSuccessJSON(map[string]interface{}{
  3041. "failed_code": -10,
  3042. "msg": res.ErrMsg,
  3043. })
  3044. return
  3045. } else {
  3046. var flow models.HisPrescriptionFlow
  3047. flow.Ctime = time.Now().Unix()
  3048. flow.SignDigest = ""
  3049. flow.RxTraceCode = res.Output.RxTraceCode
  3050. flow.HiRxno = res.Output.HiRxno
  3051. flow.MID = his.Number
  3052. flow.Status = 1
  3053. flow.DCode = doctor_info.DoctorNumber
  3054. flow.OriginalRxFile = ""
  3055. flow.OriginalValue = ""
  3056. flow.SignCertDn = ""
  3057. flow.UserOrgId = 10454
  3058. flow.SignCertSn = ""
  3059. flow.Mtime = time.Now().Unix()
  3060. service.Createflow(&flow)
  3061. c.ServeSuccessJSON(map[string]interface{}{
  3062. "msg": "上传成功",
  3063. })
  3064. }
  3065. }
  3066. }
  3067. func (c *HisApiController) GetCFYLJG002() {
  3068. admin_user_id, _ := c.GetInt64("admin_user_id")
  3069. his_patient_id, _ := c.GetInt64("his_patient_id")
  3070. record_time := c.GetString("record_time")
  3071. admin_user_id = 3626
  3072. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3073. //id, _ := c.GetInt64("id")
  3074. admin_user_id = 3626
  3075. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3076. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3077. flow, _ := service.Getflowtwo(his.Number)
  3078. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3079. //record_time := c.GetString("record_time")
  3080. patient_id, _ := c.GetInt64("patient_id")
  3081. //patient_id = 23834
  3082. //record_time = "2023-09-18"
  3083. timeLayout := "2006-01-02"
  3084. loc, _ := time.LoadLocation("Local")
  3085. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3086. if err != nil {
  3087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3088. return
  3089. }
  3090. recordDateTime := theTime.Unix()
  3091. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3092. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3093. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3094. dept, _ := service.GetDepartMentDetail(info.Departments)
  3095. inputData := make(map[string]interface{})
  3096. inputData["rxTraceCode"] = flow.RxTraceCode
  3097. inputData["hiRxno"] = flow.HiRxno
  3098. inputData["mdtrtId"] = flow.MID
  3099. inputData["patnName"] = his.PsnName
  3100. inputData["psnCertType"] = his.PsnCertType
  3101. inputData["certno"] = his.Certno
  3102. inputData["fixmedinsName"] = miConfig.OrgName
  3103. inputData["fixmedinsCode"] = miConfig.Code
  3104. inputData["drCode"] = doctor_info.DoctorNumber
  3105. inputData["prscDrName"] = doctor_info.UserName
  3106. inputData["pharDeptName"] = dept.Name
  3107. inputData["pharDeptCode"] = dept.Number
  3108. inputData["pharProfttlCodg"] = dept.Name
  3109. inputData["pharProfttlName"] = ""
  3110. inputData["pharCode"] = "HY440309002107"
  3111. inputData["pharCertType"] = "01"
  3112. inputData["pharCertno"] = "430482199408260023"
  3113. inputData["pharName"] = "彭斯遥"
  3114. inputData["pharPracCertNo"] = ""
  3115. tempTime2 := time.Unix(info.Ctime, 0)
  3116. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3117. inputData["pharChkTime"] = timeFormatTwo
  3118. bytesData, _ := json.Marshal(inputData)
  3119. fmt.Println(string(bytesData))
  3120. encoded := base64.StdEncoding.EncodeToString(bytesData)
  3121. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  3122. if err != nil {
  3123. fmt.Println("Error reading PDF file:", err)
  3124. return
  3125. }
  3126. // 将 PDF 文件内容进行 Base64 编码
  3127. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  3128. fmt.Println(err)
  3129. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  3130. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  3131. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  3132. var res2 Result002
  3133. var respJSON2 map[string]interface{}
  3134. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3137. return
  3138. }
  3139. userJSONBytes2, _ := json.Marshal(respJSON2)
  3140. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3141. utils.ErrorLog("解析失败:%v", err)
  3142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3143. return
  3144. }
  3145. if res2.Infcode == 0 {
  3146. flow.Ctime = time.Now().Unix()
  3147. flow.SignDigest = res2.Output.SignDigest
  3148. flow.RxFile = res2.Output.RxFile
  3149. flow.MID = his.Number
  3150. flow.Status = 1
  3151. flow.DCode = doctor_info.DoctorNumber
  3152. flow.OriginalRxFile = rx_encoded
  3153. flow.OriginalValue = encoded
  3154. flow.SignCertDn = res2.Output.SignCertDn
  3155. flow.SignCertSn = res2.Output.SignCertSn
  3156. flow.Mtime = time.Now().Unix()
  3157. service.Saveflow(flow)
  3158. c.ServeSuccessJSON(map[string]interface{}{
  3159. "msg": "预签名成功",
  3160. })
  3161. } else {
  3162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3163. return
  3164. }
  3165. }
  3166. func (c *HisApiController) GetCFYLJG003() {
  3167. admin_user_id, _ := c.GetInt64("admin_user_id")
  3168. his_patient_id, _ := c.GetInt64("his_patient_id")
  3169. record_time := c.GetString("record_time")
  3170. admin_user_id = 3626
  3171. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3172. //id, _ := c.GetInt64("id")
  3173. admin_user_id = 3626
  3174. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3175. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3176. flow, _ := service.Getflowtwo(his.Number)
  3177. //id = 3
  3178. patient_id, _ := c.GetInt64("patient_id")
  3179. //patient_id = 23834
  3180. //record_time = "2023-09-18"
  3181. timeLayout := "2006-01-02"
  3182. loc, _ := time.LoadLocation("Local")
  3183. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3184. if err != nil {
  3185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3186. return
  3187. }
  3188. recordDateTime := theTime.Unix()
  3189. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3190. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3191. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3192. dept, _ := service.GetDepartMentDetail(info.Departments)
  3193. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  3194. var cFYLJG003 models.CFYLJG003
  3195. cFYLJG003.RxTraceCode = flow.RxTraceCode
  3196. cFYLJG003.HiRxno = flow.HiRxno
  3197. cFYLJG003.MdtrtID = flow.MID
  3198. cFYLJG003.PatnName = his.Name
  3199. cFYLJG003.Certno = his.Certno
  3200. cFYLJG003.FixmedinsName = miConfig.OrgName
  3201. cFYLJG003.FixmedinsCode = miConfig.Code
  3202. cFYLJG003.DrCode = doctor_info.DoctorNumber
  3203. cFYLJG003.PrscDrName = doctor_info.UserName
  3204. cFYLJG003.PharDeptName = dept.Name
  3205. cFYLJG003.PharDeptCode = dept.Number
  3206. cFYLJG003.PharCode = "HY440309002107"
  3207. cFYLJG003.PharCertType = "01"
  3208. cFYLJG003.PharCertno = "430482199408260023"
  3209. cFYLJG003.PharName = "彭斯遥"
  3210. cFYLJG003.PsnCertType = "01"
  3211. cFYLJG003.RxFile = flow.RxFile
  3212. cFYLJG003.SignDigest = flow.SignDigest
  3213. cFYLJG003.FixmedinsCode = miConfig.Code
  3214. cFYLJG003.PsnCertType = "01"
  3215. cFYLJG003.PharProfttlCodg = dept.Name
  3216. //inputData["pharProfttlCodg"] =dept.Name
  3217. tempTime2 := time.Unix(info.Ctime, 0)
  3218. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3219. cFYLJG003.PharChkTime = timeFormatTwo
  3220. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  3221. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  3222. var res ResultCFYLJG003
  3223. var respJSON2 map[string]interface{}
  3224. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3227. return
  3228. }
  3229. userJSONBytes2, _ := json.Marshal(respJSON2)
  3230. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3231. utils.ErrorLog("解析失败:%v", err)
  3232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3233. return
  3234. }
  3235. if res.Infcode == -1 {
  3236. c.ServeSuccessJSON(map[string]interface{}{
  3237. "failed_code": -10,
  3238. "msg": res.ErrMsg,
  3239. })
  3240. return
  3241. } else {
  3242. c.ServeSuccessJSON(map[string]interface{}{
  3243. "info": res.Output,
  3244. })
  3245. }
  3246. }
  3247. func (c *HisApiController) GetCFYLJG004() {
  3248. admin_user_id, _ := c.GetInt64("admin_user_id")
  3249. his_patient_id, _ := c.GetInt64("his_patient_id")
  3250. record_time := c.GetString("record_time")
  3251. admin_user_id = 3626
  3252. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3253. //id, _ := c.GetInt64("id")
  3254. admin_user_id = 3626
  3255. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3256. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3257. flow, _ := service.Getflowtwo(his.Number)
  3258. //id = 3
  3259. patient_id, _ := c.GetInt64("patient_id")
  3260. //patient_id = 23834
  3261. //record_time = "2023-09-18"
  3262. timeLayout := "2006-01-02"
  3263. loc, _ := time.LoadLocation("Local")
  3264. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3265. if err != nil {
  3266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3267. return
  3268. }
  3269. recordDateTime := theTime.Unix()
  3270. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3271. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3272. var cFYLJG004 models.CFYLJG004
  3273. cFYLJG004.HiRxno = flow.HiRxno
  3274. cFYLJG004.FixmedinsCode = miConfig.Code
  3275. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  3276. cFYLJG004.UndoDrCertType = "01"
  3277. cFYLJG004.UndoRea = "撤销处方"
  3278. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  3279. cFYLJG004.UndoDrName = doctor_info.UserName
  3280. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  3281. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  3282. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  3283. var res ResultCFYLJG004
  3284. var respJSON2 map[string]interface{}
  3285. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3288. return
  3289. }
  3290. userJSONBytes2, _ := json.Marshal(respJSON2)
  3291. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3292. utils.ErrorLog("解析失败:%v", err)
  3293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3294. return
  3295. }
  3296. if res.Infcode == -1 {
  3297. c.ServeSuccessJSON(map[string]interface{}{
  3298. "failed_code": -10,
  3299. "msg": res.ErrMsg,
  3300. })
  3301. return
  3302. } else {
  3303. flow.Status = 0
  3304. service.Saveflow(flow)
  3305. c.ServeSuccessJSON(map[string]interface{}{
  3306. "msg": "撤销成功",
  3307. })
  3308. return
  3309. }
  3310. }
  3311. func (c *HisApiController) GetCFYLJG005() {
  3312. admin_user_id, _ := c.GetInt64("admin_user_id")
  3313. his_patient_id, _ := c.GetInt64("his_patient_id")
  3314. //record_time := c.GetString("record_time")
  3315. admin_user_id = 3626
  3316. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3317. //id, _ := c.GetInt64("id")
  3318. admin_user_id = 3626
  3319. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3320. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3321. flow, _ := service.Getflowtwo(his.Number)
  3322. //id = 3
  3323. var cFYLJG005 models.CFYLJG005
  3324. //patient_id, _ := c.GetInt64("patient_id")
  3325. cFYLJG005.HiRxno = flow.HiRxno
  3326. cFYLJG005.MdtrtID = flow.MID
  3327. cFYLJG005.EcToken = ""
  3328. cFYLJG005.PsnName = his.Name
  3329. cFYLJG005.PsnCertType = "01"
  3330. cFYLJG005.Certno = his.IdCardNo
  3331. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  3332. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  3333. var res ResultCFYLJG005
  3334. var respJSON2 map[string]interface{}
  3335. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3338. return
  3339. }
  3340. userJSONBytes2, _ := json.Marshal(respJSON2)
  3341. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3342. utils.ErrorLog("解析失败:%v", err)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. if res.Infcode == -1 {
  3347. c.ServeSuccessJSON(map[string]interface{}{
  3348. "failed_code": -10,
  3349. "msg": res.ErrMsg,
  3350. })
  3351. return
  3352. } else {
  3353. c.ServeSuccessJSON(map[string]interface{}{
  3354. "info": res.Output,
  3355. })
  3356. return
  3357. }
  3358. }
  3359. func (c *HisApiController) GetCFYLJG006() {
  3360. admin_user_id, _ := c.GetInt64("admin_user_id")
  3361. his_patient_id, _ := c.GetInt64("his_patient_id")
  3362. admin_user_id = 3626
  3363. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3364. //id, _ := c.GetInt64("id")
  3365. admin_user_id = 3626
  3366. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3367. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3368. flow, _ := service.Getflowtwo(his.Number)
  3369. //id = 3
  3370. patient_id, _ := c.GetInt64("patient_id")
  3371. var cFYLJG006 models.CFYLJG006
  3372. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3373. cFYLJG006.HiRxno = flow.HiRxno
  3374. cFYLJG006.MdtrtID = flow.MID
  3375. cFYLJG006.PsnName = patient.Name
  3376. cFYLJG006.PsnCertType = "01"
  3377. cFYLJG006.Certno = patient.IdCardNo
  3378. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  3379. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  3380. var res ResultCFYLJG006
  3381. var respJSON2 map[string]interface{}
  3382. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3385. return
  3386. }
  3387. userJSONBytes2, _ := json.Marshal(respJSON2)
  3388. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3389. utils.ErrorLog("解析失败:%v", err)
  3390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3391. return
  3392. }
  3393. if res.Infcode == -1 {
  3394. c.ServeSuccessJSON(map[string]interface{}{
  3395. "failed_code": -10,
  3396. "msg": res.ErrMsg,
  3397. })
  3398. return
  3399. } else {
  3400. c.ServeSuccessJSON(map[string]interface{}{
  3401. "info": res.Output,
  3402. })
  3403. return
  3404. }
  3405. }
  3406. func (c *HisApiController) GetCFYLJG007() {
  3407. admin_user_id, _ := c.GetInt64("admin_user_id")
  3408. his_patient_id, _ := c.GetInt64("his_patient_id")
  3409. admin_user_id = 3626
  3410. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3411. //id, _ := c.GetInt64("id")
  3412. admin_user_id = 3626
  3413. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3414. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3415. flow, _ := service.Getflowtwo(his.Number)
  3416. //id = 3
  3417. patient_id, _ := c.GetInt64("patient_id")
  3418. var cFYLJG007 models.CFYLJG007
  3419. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3420. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3421. cFYLJG007.HiRxno = flow.HiRxno
  3422. cFYLJG007.MdtrtID = flow.MID
  3423. cFYLJG007.PsnNo = his.PsnNo
  3424. cFYLJG007.PsnCertType = "01"
  3425. cFYLJG007.Certno = patient.IdCardNo
  3426. cFYLJG007.PsnName = patient.Name
  3427. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3428. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3429. var res ResultCFYLJG007
  3430. var respJSON2 map[string]interface{}
  3431. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. userJSONBytes2, _ := json.Marshal(respJSON2)
  3437. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3438. utils.ErrorLog("解析失败:%v", err)
  3439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3440. return
  3441. }
  3442. if res.Infcode == -1 {
  3443. c.ServeSuccessJSON(map[string]interface{}{
  3444. "failed_code": -10,
  3445. "msg": res.ErrMsg,
  3446. })
  3447. return
  3448. } else {
  3449. c.ServeSuccessJSON(map[string]interface{}{
  3450. "info": res,
  3451. })
  3452. return
  3453. }
  3454. }
  3455. func (c *HisApiController) GetCFYLJG008() {
  3456. admin_user_id, _ := c.GetInt64("admin_user_id")
  3457. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3458. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3459. var cFYLJG008 models.CFYLJG008
  3460. //id, _ := c.GetInt64("id")
  3461. patient_id, _ := c.GetInt64("patient_id")
  3462. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3463. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3464. //id = 3
  3465. //flow, _ := service.Getflow(id)
  3466. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3467. //
  3468. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3469. //patient_id, _ := c.GetInt64("patient_id")
  3470. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3471. record_time := c.GetString("record_time")
  3472. admin_user_id = 3626
  3473. patient_id = 19424
  3474. //his_patient_id = 263947
  3475. record_time = "2023-08-29"
  3476. timeLayout := "2006-01-02"
  3477. loc, _ := time.LoadLocation("Local")
  3478. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3479. if err != nil {
  3480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3481. return
  3482. }
  3483. recordDateTime := theTime.Unix()
  3484. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3485. cFYLJG008.FixmedinsName = ""
  3486. cFYLJG008.Lat = ""
  3487. cFYLJG008.Lng = ""
  3488. cFYLJG008.OrderType = "1"
  3489. cFYLJG008.PoolareaNo = ""
  3490. cFYLJG008.Lng = ""
  3491. cFYLJG008.PageNum = 1
  3492. cFYLJG008.PageSize = 10
  3493. var MPI models.MedinsProdInvChgDDTO
  3494. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3495. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3496. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3497. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3498. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3499. var res ResultCFYLJG008
  3500. var respJSON2 map[string]interface{}
  3501. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3504. return
  3505. }
  3506. userJSONBytes2, _ := json.Marshal(respJSON2)
  3507. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3508. utils.ErrorLog("解析失败:%v", err)
  3509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3510. return
  3511. }
  3512. if res.Infcode == -1 {
  3513. c.ServeSuccessJSON(map[string]interface{}{
  3514. "failed_code": -10,
  3515. "msg": res.ErrMsg,
  3516. })
  3517. return
  3518. } else {
  3519. c.ServeSuccessJSON(map[string]interface{}{
  3520. "info": res.Output,
  3521. })
  3522. return
  3523. }
  3524. }
  3525. func (c *HisApiController) GetBL4201A() {
  3526. order_id, _ := c.GetInt64("order_id")
  3527. admin_user_id, _ := c.GetInt64("admin_user_id")
  3528. order, _ := service.GetHisOrderByIDTwo(order_id)
  3529. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3530. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3531. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3532. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3533. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3534. department, _ := service.GetDepartMentDetail(his.Departments)
  3535. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3536. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3537. if order.ID == 0 {
  3538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3539. return
  3540. }
  3541. var struct4201A models.Struct4201A
  3542. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3543. for _, items := range order_info {
  3544. memo := make(map[string]interface{})
  3545. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3546. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3547. fsiOPFLD.MedType = "14"
  3548. fsiOPFLD.BkkpSn = items.FeedetlSn
  3549. fsiOPFLD.FixmedinsCode = miConfig.Code
  3550. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3551. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3552. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3553. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3554. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3555. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3556. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3557. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3558. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3559. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3560. fsiOPFLD.BilgDeptName = department.Name
  3561. fsiOPFLD.BilgDeptCodg = department.Number
  3562. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3563. fsiOPFLD.BilgDrName = doctor.UserName
  3564. fsiOPFLD.MedChrgitmType = "09"
  3565. memo["hosp_appr_flag"] = "1"
  3566. memo["invoice_no"] = order.MdtrtId
  3567. memo["memo"] = "自费"
  3568. bytesData, _ := json.Marshal(memo)
  3569. fsiOPFLD.Memo = string(bytesData)
  3570. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3571. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3572. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3573. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3574. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3575. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3576. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3577. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3578. fsiOPFLD.BilgDeptName = department.Name
  3579. fsiOPFLD.BilgDeptCodg = department.Number
  3580. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3581. fsiOPFLD.BilgDrName = doctor.UserName
  3582. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3583. case 0:
  3584. break
  3585. case 1:
  3586. fsiOPFLD.MedChrgitmType = "14"
  3587. break
  3588. case 2:
  3589. fsiOPFLD.MedChrgitmType = "05"
  3590. break
  3591. case 3:
  3592. fsiOPFLD.MedChrgitmType = "03"
  3593. break
  3594. case 4:
  3595. fsiOPFLD.MedChrgitmType = "03"
  3596. break
  3597. case 5:
  3598. fsiOPFLD.MedChrgitmType = "08"
  3599. break
  3600. case 6:
  3601. fsiOPFLD.MedChrgitmType = "14"
  3602. break
  3603. case 7:
  3604. fsiOPFLD.MedChrgitmType = "14"
  3605. break
  3606. case 8:
  3607. fsiOPFLD.MedChrgitmType = "03"
  3608. break
  3609. case 9:
  3610. fsiOPFLD.MedChrgitmType = "14"
  3611. break
  3612. case 10:
  3613. fsiOPFLD.MedChrgitmType = "14"
  3614. break
  3615. case 11:
  3616. fsiOPFLD.MedChrgitmType = "06"
  3617. break
  3618. case 12:
  3619. fsiOPFLD.MedChrgitmType = "12"
  3620. break
  3621. case 13:
  3622. fsiOPFLD.MedChrgitmType = "01"
  3623. break
  3624. case 14:
  3625. fsiOPFLD.MedChrgitmType = "04"
  3626. break
  3627. case 15:
  3628. fsiOPFLD.MedChrgitmType = "14"
  3629. break
  3630. }
  3631. memo["hosp_appr_flag"] = "1"
  3632. memo["invoice_no"] = order.MdtrtId
  3633. memo["memo"] = "自费"
  3634. bytesData, _ := json.Marshal(memo)
  3635. fsiOPFLD.Memo = string(bytesData)
  3636. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3637. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3638. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3639. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3640. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3641. fsiOPFLD.BilgDeptName = department.Name
  3642. fsiOPFLD.BilgDeptCodg = department.Number
  3643. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3644. fsiOPFLD.BilgDrName = doctor.UserName
  3645. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3646. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3647. fsiOPFLD.MedChrgitmType = "08"
  3648. memo["hosp_appr_flag"] = "1"
  3649. memo["invoice_no"] = order.MdtrtId
  3650. memo["memo"] = "自费"
  3651. bytesData, _ := json.Marshal(memo)
  3652. fsiOPFLD.Memo = string(bytesData)
  3653. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3654. }
  3655. }
  3656. }
  3657. for _, items := range order_info_two {
  3658. memo := make(map[string]interface{})
  3659. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3660. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3661. fsiOPFLD.MedType = "14"
  3662. fsiOPFLD.BkkpSn = items.FeedetlSn
  3663. fsiOPFLD.FixmedinsCode = miConfig.Code
  3664. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3665. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3666. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3667. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3668. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3669. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3670. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3671. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3672. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3673. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3674. fsiOPFLD.BilgDeptName = department.Name
  3675. fsiOPFLD.BilgDeptCodg = department.Number
  3676. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3677. fsiOPFLD.BilgDrName = doctor.UserName
  3678. fsiOPFLD.MedChrgitmType = "09"
  3679. memo["hosp_appr_flag"] = "1"
  3680. memo["invoice_no"] = order.MdtrtId
  3681. memo["memo"] = "自费"
  3682. bytesData, _ := json.Marshal(memo)
  3683. fsiOPFLD.Memo = string(bytesData)
  3684. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3685. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3686. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3687. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3688. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3689. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3690. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3691. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3692. fsiOPFLD.BilgDeptName = department.Name
  3693. fsiOPFLD.BilgDeptCodg = department.Number
  3694. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3695. fsiOPFLD.BilgDrName = doctor.UserName
  3696. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3697. case 0:
  3698. break
  3699. case 1:
  3700. fsiOPFLD.MedChrgitmType = "14"
  3701. break
  3702. case 2:
  3703. fsiOPFLD.MedChrgitmType = "05"
  3704. break
  3705. case 3:
  3706. fsiOPFLD.MedChrgitmType = "03"
  3707. break
  3708. case 4:
  3709. fsiOPFLD.MedChrgitmType = "03"
  3710. break
  3711. case 5:
  3712. fsiOPFLD.MedChrgitmType = "08"
  3713. break
  3714. case 6:
  3715. fsiOPFLD.MedChrgitmType = "14"
  3716. break
  3717. case 7:
  3718. fsiOPFLD.MedChrgitmType = "14"
  3719. break
  3720. case 8:
  3721. fsiOPFLD.MedChrgitmType = "03"
  3722. break
  3723. case 9:
  3724. fsiOPFLD.MedChrgitmType = "14"
  3725. break
  3726. case 10:
  3727. fsiOPFLD.MedChrgitmType = "14"
  3728. break
  3729. case 11:
  3730. fsiOPFLD.MedChrgitmType = "06"
  3731. break
  3732. case 12:
  3733. fsiOPFLD.MedChrgitmType = "12"
  3734. break
  3735. case 13:
  3736. fsiOPFLD.MedChrgitmType = "01"
  3737. break
  3738. case 14:
  3739. fsiOPFLD.MedChrgitmType = "04"
  3740. break
  3741. case 15:
  3742. fsiOPFLD.MedChrgitmType = "14"
  3743. break
  3744. }
  3745. memo["hosp_appr_flag"] = "1"
  3746. memo["invoice_no"] = order.MdtrtId
  3747. memo["memo"] = "自费"
  3748. bytesData, _ := json.Marshal(memo)
  3749. fsiOPFLD.Memo = string(bytesData)
  3750. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3751. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3752. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3753. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3754. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3755. fsiOPFLD.BilgDeptName = department.Name
  3756. fsiOPFLD.BilgDeptCodg = department.Number
  3757. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3758. fsiOPFLD.BilgDrName = doctor.UserName
  3759. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3760. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3761. fsiOPFLD.MedChrgitmType = "08"
  3762. memo["hosp_appr_flag"] = "1"
  3763. memo["invoice_no"] = order.MdtrtId
  3764. memo["memo"] = "自费"
  3765. bytesData, _ := json.Marshal(memo)
  3766. fsiOPFLD.Memo = string(bytesData)
  3767. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3768. }
  3769. }
  3770. }
  3771. fmt.Println(fsiOPFLDs)
  3772. struct4201A.Fopfd = fsiOPFLDs
  3773. fmt.Println(struct4201A.Fopfd)
  3774. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3775. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3776. var res2 ResultSix
  3777. var respJSON2 map[string]interface{}
  3778. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3781. return
  3782. }
  3783. userJSONBytes2, _ := json.Marshal(respJSON2)
  3784. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3785. utils.ErrorLog("解析失败:%v", err)
  3786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3787. return
  3788. }
  3789. if res2.Infcode != 0 {
  3790. c.ServeSuccessJSON(map[string]interface{}{
  3791. "failed_code": -10,
  3792. "msg": res2.ErrMsg,
  3793. })
  3794. return
  3795. } else {
  3796. order.IsUploadOrderInfo = 1
  3797. service.UpdateOrder(order)
  3798. c.ServeSuccessJSON(map[string]interface{}{
  3799. "msg": "上传成功",
  3800. })
  3801. }
  3802. }
  3803. func (c *HisApiController) Get2505() {
  3804. admin_user_id, _ := c.GetInt64("admin_user_id")
  3805. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3806. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3807. 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)
  3808. }
  3809. func (c *HisApiController) Get4201A() {
  3810. order_id, _ := c.GetInt64("order_id")
  3811. admin_user_id, _ := c.GetInt64("admin_user_id")
  3812. order, _ := service.GetHisOrderByIDTwo(order_id)
  3813. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3814. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3815. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3816. //order_info = append(order_info, order_info_two...)
  3817. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3819. department, _ := service.GetDepartMentDetail(his.Departments)
  3820. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3821. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3822. if order.ID == 0 {
  3823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3824. return
  3825. }
  3826. var struct4201A models.Struct4201A
  3827. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3828. for _, items := range order_info {
  3829. memo := make(map[string]interface{})
  3830. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3831. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3832. fsiOPFLD.MedType = "14"
  3833. fsiOPFLD.BkkpSn = items.FeedetlSn
  3834. fsiOPFLD.FixmedinsCode = miConfig.Code
  3835. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3836. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3837. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3838. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3839. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3840. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3841. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3842. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3843. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3844. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3845. fsiOPFLD.BilgDeptName = department.Name
  3846. fsiOPFLD.BilgDeptCodg = department.Number
  3847. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3848. fsiOPFLD.BilgDrName = doctor.UserName
  3849. fsiOPFLD.MedChrgitmType = "09"
  3850. memo["hosp_appr_flag"] = "1"
  3851. memo["invoice_no"] = order.MdtrtId
  3852. memo["memo"] = "自费"
  3853. bytesData, _ := json.Marshal(memo)
  3854. fsiOPFLD.Memo = string(bytesData)
  3855. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3856. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3857. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3858. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3859. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3860. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3861. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3862. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3863. fsiOPFLD.BilgDeptName = department.Name
  3864. fsiOPFLD.BilgDeptCodg = department.Number
  3865. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3866. fsiOPFLD.BilgDrName = doctor.UserName
  3867. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3868. case 0:
  3869. break
  3870. case 1:
  3871. fsiOPFLD.MedChrgitmType = "14"
  3872. break
  3873. case 2:
  3874. fsiOPFLD.MedChrgitmType = "05"
  3875. break
  3876. case 3:
  3877. fsiOPFLD.MedChrgitmType = "03"
  3878. break
  3879. case 4:
  3880. fsiOPFLD.MedChrgitmType = "03"
  3881. break
  3882. case 5:
  3883. fsiOPFLD.MedChrgitmType = "08"
  3884. break
  3885. case 6:
  3886. fsiOPFLD.MedChrgitmType = "14"
  3887. break
  3888. case 7:
  3889. fsiOPFLD.MedChrgitmType = "14"
  3890. break
  3891. case 8:
  3892. fsiOPFLD.MedChrgitmType = "03"
  3893. break
  3894. case 9:
  3895. fsiOPFLD.MedChrgitmType = "14"
  3896. break
  3897. case 10:
  3898. fsiOPFLD.MedChrgitmType = "14"
  3899. break
  3900. case 11:
  3901. fsiOPFLD.MedChrgitmType = "06"
  3902. break
  3903. case 12:
  3904. fsiOPFLD.MedChrgitmType = "12"
  3905. break
  3906. case 13:
  3907. fsiOPFLD.MedChrgitmType = "01"
  3908. break
  3909. case 14:
  3910. fsiOPFLD.MedChrgitmType = "04"
  3911. break
  3912. case 15:
  3913. fsiOPFLD.MedChrgitmType = "14"
  3914. break
  3915. }
  3916. memo["hosp_appr_flag"] = "1"
  3917. memo["invoice_no"] = order.MdtrtId
  3918. memo["memo"] = "自费"
  3919. bytesData, _ := json.Marshal(memo)
  3920. fsiOPFLD.Memo = string(bytesData)
  3921. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3922. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3923. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3924. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3925. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3926. fsiOPFLD.BilgDeptName = department.Name
  3927. fsiOPFLD.BilgDeptCodg = department.Number
  3928. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3929. fsiOPFLD.BilgDrName = doctor.UserName
  3930. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3931. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3932. fsiOPFLD.MedChrgitmType = "08"
  3933. memo["hosp_appr_flag"] = "1"
  3934. memo["invoice_no"] = order.MdtrtId
  3935. memo["memo"] = "自费"
  3936. bytesData, _ := json.Marshal(memo)
  3937. fsiOPFLD.Memo = string(bytesData)
  3938. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3939. }
  3940. }
  3941. }
  3942. for _, items := range order_info_two {
  3943. memo := make(map[string]interface{})
  3944. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3945. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3946. fsiOPFLD.MedType = "14"
  3947. fsiOPFLD.BkkpSn = items.FeedetlSn
  3948. fsiOPFLD.FixmedinsCode = miConfig.Code
  3949. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3950. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3951. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3952. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3953. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3954. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3955. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3956. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3957. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3958. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3959. fsiOPFLD.BilgDeptName = department.Name
  3960. fsiOPFLD.BilgDeptCodg = department.Number
  3961. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3962. fsiOPFLD.BilgDrName = doctor.UserName
  3963. fsiOPFLD.MedChrgitmType = "09"
  3964. memo["hosp_appr_flag"] = "1"
  3965. memo["invoice_no"] = order.MdtrtId
  3966. memo["memo"] = "自费"
  3967. bytesData, _ := json.Marshal(memo)
  3968. fsiOPFLD.Memo = string(bytesData)
  3969. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3970. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3971. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3972. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3973. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3974. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3975. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3976. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3977. fsiOPFLD.BilgDeptName = department.Name
  3978. fsiOPFLD.BilgDeptCodg = department.Number
  3979. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3980. fsiOPFLD.BilgDrName = doctor.UserName
  3981. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3982. case 0:
  3983. break
  3984. case 1:
  3985. fsiOPFLD.MedChrgitmType = "14"
  3986. break
  3987. case 2:
  3988. fsiOPFLD.MedChrgitmType = "05"
  3989. break
  3990. case 3:
  3991. fsiOPFLD.MedChrgitmType = "03"
  3992. break
  3993. case 4:
  3994. fsiOPFLD.MedChrgitmType = "03"
  3995. break
  3996. case 5:
  3997. fsiOPFLD.MedChrgitmType = "08"
  3998. break
  3999. case 6:
  4000. fsiOPFLD.MedChrgitmType = "14"
  4001. break
  4002. case 7:
  4003. fsiOPFLD.MedChrgitmType = "14"
  4004. break
  4005. case 8:
  4006. fsiOPFLD.MedChrgitmType = "03"
  4007. break
  4008. case 9:
  4009. fsiOPFLD.MedChrgitmType = "14"
  4010. break
  4011. case 10:
  4012. fsiOPFLD.MedChrgitmType = "14"
  4013. break
  4014. case 11:
  4015. fsiOPFLD.MedChrgitmType = "06"
  4016. break
  4017. case 12:
  4018. fsiOPFLD.MedChrgitmType = "12"
  4019. break
  4020. case 13:
  4021. fsiOPFLD.MedChrgitmType = "01"
  4022. break
  4023. case 14:
  4024. fsiOPFLD.MedChrgitmType = "04"
  4025. break
  4026. case 15:
  4027. fsiOPFLD.MedChrgitmType = "14"
  4028. break
  4029. }
  4030. memo["hosp_appr_flag"] = "1"
  4031. memo["invoice_no"] = order.MdtrtId
  4032. memo["memo"] = "自费"
  4033. bytesData, _ := json.Marshal(memo)
  4034. fsiOPFLD.Memo = string(bytesData)
  4035. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4036. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4037. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4038. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4039. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4040. fsiOPFLD.BilgDeptName = department.Name
  4041. fsiOPFLD.BilgDeptCodg = department.Number
  4042. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4043. fsiOPFLD.BilgDrName = doctor.UserName
  4044. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4045. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4046. fsiOPFLD.MedChrgitmType = "08"
  4047. memo["hosp_appr_flag"] = "1"
  4048. memo["invoice_no"] = order.MdtrtId
  4049. memo["memo"] = "自费"
  4050. bytesData, _ := json.Marshal(memo)
  4051. fsiOPFLD.Memo = string(bytesData)
  4052. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4053. }
  4054. }
  4055. }
  4056. fmt.Println(fsiOPFLDs)
  4057. struct4201A.Fopfd = fsiOPFLDs
  4058. fmt.Println(struct4201A.Fopfd)
  4059. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  4060. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  4061. var res2 ResultSix
  4062. var respJSON2 map[string]interface{}
  4063. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4066. return
  4067. }
  4068. userJSONBytes2, _ := json.Marshal(respJSON2)
  4069. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4070. utils.ErrorLog("解析失败:%v", err)
  4071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4072. return
  4073. }
  4074. if res2.Infcode != 0 {
  4075. c.ServeSuccessJSON(map[string]interface{}{
  4076. "failed_code": -10,
  4077. "msg": res2.ErrMsg,
  4078. })
  4079. return
  4080. } else {
  4081. order.IsUploadOrderInfo = 1
  4082. service.UpdateOrder(order)
  4083. c.ServeSuccessJSON(map[string]interface{}{
  4084. "msg": "上传成功",
  4085. })
  4086. }
  4087. }
  4088. func (c *HisApiController) Get4202() {
  4089. order_id, _ := c.GetInt64("order_id")
  4090. admin_user_id, _ := c.GetInt64("admin_user_id")
  4091. order, _ := service.GetHisOrderByIDTwo(order_id)
  4092. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4093. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4094. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4095. if order.ID == 0 {
  4096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4097. return
  4098. }
  4099. var struct4202 models.Struct4202
  4100. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4101. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4102. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4103. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4104. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4105. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4106. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  4107. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  4108. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4109. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4110. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4111. var config []*models.HisXtDiagnoseConfig
  4112. for _, item := range diagnosis_ids {
  4113. id, _ := strconv.ParseInt(item, 10, 64)
  4114. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4115. config = append(config, &diagnosisConfig)
  4116. }
  4117. var tempDiaginfos []models.OwnPayPatnDiagListD
  4118. for index, item := range config {
  4119. if index == 0 {
  4120. var tempDiaginfo models.OwnPayPatnDiagListD
  4121. tempDiaginfo.InoutDiagType = "1"
  4122. tempDiaginfo.DiagCode = item.CountryCode
  4123. tempDiaginfo.DiagName = item.CountryContentName
  4124. tempDiaginfo.DiagType = "1"
  4125. tempDiaginfo.DiagSrtNo = "1"
  4126. tempDiaginfo.MaindiagFlag = "1"
  4127. tempDiaginfo.ValiFlag = "1"
  4128. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4129. } else {
  4130. var tempDiaginfo models.OwnPayPatnDiagListD
  4131. tempDiaginfo.DiagCode = item.CountryCode
  4132. tempDiaginfo.DiagName = item.CountryContentName
  4133. tempDiaginfo.DiagType = "2"
  4134. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4135. tempDiaginfo.MaindiagFlag = "0"
  4136. tempDiaginfo.ValiFlag = "1"
  4137. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4138. }
  4139. }
  4140. struct4202.ODiagListD = tempDiaginfos
  4141. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  4142. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  4143. var res2 ResultSix
  4144. var respJSON2 map[string]interface{}
  4145. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4148. return
  4149. }
  4150. userJSONBytes2, _ := json.Marshal(respJSON2)
  4151. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4152. utils.ErrorLog("解析失败:%v", err)
  4153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4154. return
  4155. }
  4156. if res2.Infcode != 0 {
  4157. c.ServeSuccessJSON(map[string]interface{}{
  4158. "failed_code": -10,
  4159. "msg": res2.ErrMsg,
  4160. })
  4161. return
  4162. } else {
  4163. order.IsUploadDiagnose = 1
  4164. service.UpdateOrder(order)
  4165. c.ServeSuccessJSON(map[string]interface{}{
  4166. "msg": "上传成功",
  4167. })
  4168. }
  4169. }
  4170. func (c *HisApiController) Get4203() {
  4171. admin_user_id, _ := c.GetInt64("admin_user_id")
  4172. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4173. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4174. order_id, _ := c.GetInt64("order_id")
  4175. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4176. number := ""
  4177. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4178. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4179. if his.ID == 0 {
  4180. number = hospital.Number
  4181. } else {
  4182. number = his.Number
  4183. }
  4184. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  4185. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  4186. var res2 ResultSix
  4187. var respJSON2 map[string]interface{}
  4188. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4191. return
  4192. }
  4193. userJSONBytes2, _ := json.Marshal(respJSON2)
  4194. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4195. utils.ErrorLog("解析失败:%v", err)
  4196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4197. return
  4198. }
  4199. if res2.Infcode != 0 {
  4200. c.ServeSuccessJSON(map[string]interface{}{
  4201. "failed_code": -10,
  4202. "msg": res2.ErrMsg,
  4203. })
  4204. return
  4205. } else {
  4206. order.IsUploadSuccess = 1
  4207. service.UpdateOrderTwo(order)
  4208. c.ServeSuccessJSON(map[string]interface{}{
  4209. "msg": "上传成功",
  4210. })
  4211. }
  4212. }
  4213. func (c *HisApiController) Get4205() {
  4214. order_id, _ := c.GetInt64("order_id")
  4215. admin_user_id, _ := c.GetInt64("admin_user_id")
  4216. fapiao_code := c.GetString("fapiao_code")
  4217. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4218. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4219. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4220. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4221. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  4222. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4223. //order_info = append(order_info, order_info_two...)
  4224. department, _ := service.GetDepartMentDetail(his.Departments)
  4225. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4226. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4227. if order.ID == 0 {
  4228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4229. return
  4230. }
  4231. var struct4201A models.Struct4201A
  4232. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4233. for _, items := range order_info {
  4234. memo := make(map[string]interface{})
  4235. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4236. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4237. fsiOPFLD.MedType = pre.MedType
  4238. fsiOPFLD.FixmedinsCode = miConfig.Code
  4239. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4240. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4241. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4242. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4243. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4244. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4245. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4246. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  4247. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4248. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4249. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4250. fsiOPFLD.BilgDeptName = department.Name
  4251. fsiOPFLD.BilgDeptCodg = department.Number
  4252. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4253. fsiOPFLD.BilgDrName = doctor.UserName
  4254. fsiOPFLD.MedChrgitmType = "09"
  4255. memo["hosp_appr_flag"] = "1"
  4256. memo["invoice_no"] = fapiao_code
  4257. memo["memo"] = "自费"
  4258. bytesData, _ := json.Marshal(memo)
  4259. fsiOPFLD.Memo = string(bytesData)
  4260. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4261. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4262. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4263. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4264. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4265. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4266. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4267. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4268. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4269. fsiOPFLD.BilgDeptName = department.Name
  4270. fsiOPFLD.BilgDeptCodg = department.Number
  4271. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4272. fsiOPFLD.BilgDrName = doctor.UserName
  4273. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4274. case 0:
  4275. break
  4276. case 1:
  4277. fsiOPFLD.MedChrgitmType = "14"
  4278. break
  4279. case 2:
  4280. fsiOPFLD.MedChrgitmType = "05"
  4281. break
  4282. case 3:
  4283. fsiOPFLD.MedChrgitmType = "03"
  4284. break
  4285. case 4:
  4286. fsiOPFLD.MedChrgitmType = "03"
  4287. break
  4288. case 5:
  4289. fsiOPFLD.MedChrgitmType = "08"
  4290. break
  4291. case 6:
  4292. fsiOPFLD.MedChrgitmType = "14"
  4293. break
  4294. case 7:
  4295. fsiOPFLD.MedChrgitmType = "14"
  4296. break
  4297. case 8:
  4298. fsiOPFLD.MedChrgitmType = "03"
  4299. break
  4300. case 9:
  4301. fsiOPFLD.MedChrgitmType = "14"
  4302. break
  4303. case 10:
  4304. fsiOPFLD.MedChrgitmType = "14"
  4305. break
  4306. case 11:
  4307. fsiOPFLD.MedChrgitmType = "06"
  4308. break
  4309. case 12:
  4310. fsiOPFLD.MedChrgitmType = "12"
  4311. break
  4312. case 13:
  4313. fsiOPFLD.MedChrgitmType = "01"
  4314. break
  4315. case 14:
  4316. fsiOPFLD.MedChrgitmType = "04"
  4317. break
  4318. case 15:
  4319. fsiOPFLD.MedChrgitmType = "14"
  4320. break
  4321. }
  4322. memo["hosp_appr_flag"] = "1"
  4323. memo["invoice_no"] = fapiao_code
  4324. memo["memo"] = "自费"
  4325. bytesData, _ := json.Marshal(memo)
  4326. fsiOPFLD.Memo = string(bytesData)
  4327. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4328. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4329. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4330. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4331. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4332. fsiOPFLD.BilgDeptName = department.Name
  4333. fsiOPFLD.BilgDeptCodg = department.Number
  4334. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4335. fsiOPFLD.BilgDrName = doctor.UserName
  4336. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4337. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4338. fsiOPFLD.MedChrgitmType = "08"
  4339. memo["hosp_appr_flag"] = "1"
  4340. memo["invoice_no"] = fapiao_code
  4341. memo["memo"] = "自费"
  4342. bytesData, _ := json.Marshal(memo)
  4343. fsiOPFLD.Memo = string(bytesData)
  4344. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4345. }
  4346. }
  4347. }
  4348. for _, items := range order_info_two {
  4349. memo := make(map[string]interface{})
  4350. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4351. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4352. fsiOPFLD.MedType = pre.MedType
  4353. fsiOPFLD.BkkpSn = items.FeedetlSn
  4354. fsiOPFLD.FixmedinsCode = miConfig.Code
  4355. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4356. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4357. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4358. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4359. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4360. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4361. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4362. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4363. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4364. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4365. fsiOPFLD.BilgDeptName = department.Name
  4366. fsiOPFLD.BilgDeptCodg = department.Number
  4367. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4368. fsiOPFLD.BilgDrName = doctor.UserName
  4369. fsiOPFLD.MedChrgitmType = "09"
  4370. memo["hosp_appr_flag"] = "1"
  4371. memo["invoice_no"] = fapiao_code
  4372. memo["memo"] = "自费"
  4373. bytesData, _ := json.Marshal(memo)
  4374. fsiOPFLD.Memo = string(bytesData)
  4375. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4376. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4377. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4378. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4379. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4380. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4381. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4382. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4383. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4384. fsiOPFLD.BilgDeptName = department.Name
  4385. fsiOPFLD.BilgDeptCodg = department.Number
  4386. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4387. fsiOPFLD.BilgDrName = doctor.UserName
  4388. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4389. case 0:
  4390. break
  4391. case 1:
  4392. fsiOPFLD.MedChrgitmType = "14"
  4393. break
  4394. case 2:
  4395. fsiOPFLD.MedChrgitmType = "05"
  4396. break
  4397. case 3:
  4398. fsiOPFLD.MedChrgitmType = "03"
  4399. break
  4400. case 4:
  4401. fsiOPFLD.MedChrgitmType = "03"
  4402. break
  4403. case 5:
  4404. fsiOPFLD.MedChrgitmType = "08"
  4405. break
  4406. case 6:
  4407. fsiOPFLD.MedChrgitmType = "14"
  4408. break
  4409. case 7:
  4410. fsiOPFLD.MedChrgitmType = "14"
  4411. break
  4412. case 8:
  4413. fsiOPFLD.MedChrgitmType = "03"
  4414. break
  4415. case 9:
  4416. fsiOPFLD.MedChrgitmType = "14"
  4417. break
  4418. case 10:
  4419. fsiOPFLD.MedChrgitmType = "14"
  4420. break
  4421. case 11:
  4422. fsiOPFLD.MedChrgitmType = "06"
  4423. break
  4424. case 12:
  4425. fsiOPFLD.MedChrgitmType = "12"
  4426. break
  4427. case 13:
  4428. fsiOPFLD.MedChrgitmType = "01"
  4429. break
  4430. case 14:
  4431. fsiOPFLD.MedChrgitmType = "04"
  4432. break
  4433. case 15:
  4434. fsiOPFLD.MedChrgitmType = "14"
  4435. break
  4436. }
  4437. memo["hosp_appr_flag"] = "1"
  4438. memo["invoice_no"] = fapiao_code
  4439. memo["memo"] = "自费"
  4440. bytesData, _ := json.Marshal(memo)
  4441. fsiOPFLD.Memo = string(bytesData)
  4442. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4443. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4444. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4445. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4446. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4447. fsiOPFLD.BilgDeptName = department.Name
  4448. fsiOPFLD.BilgDeptCodg = department.Number
  4449. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4450. fsiOPFLD.BilgDrName = doctor.UserName
  4451. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4452. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4453. fsiOPFLD.MedChrgitmType = "08"
  4454. memo["hosp_appr_flag"] = "1"
  4455. memo["invoice_no"] = fapiao_code
  4456. memo["memo"] = "自费"
  4457. bytesData, _ := json.Marshal(memo)
  4458. fsiOPFLD.Memo = string(bytesData)
  4459. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4460. }
  4461. }
  4462. }
  4463. fmt.Println(fsiOPFLDs)
  4464. struct4201A.Fopfd = fsiOPFLDs
  4465. fmt.Println(struct4201A.Fopfd)
  4466. var struct4202 models.Struct4202
  4467. timeLayout := "2006-01-02 15:04:05"
  4468. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4469. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4470. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4471. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4472. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4473. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4474. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4475. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4476. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4477. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4478. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4479. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4480. var config []*models.HisXtDiagnoseConfig
  4481. for _, item := range diagnosis_ids {
  4482. id, _ := strconv.ParseInt(item, 10, 64)
  4483. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4484. config = append(config, &diagnosisConfig)
  4485. }
  4486. var tempDiaginfos []models.OwnPayPatnDiagListD
  4487. for index, item := range config {
  4488. if index == 0 {
  4489. var tempDiaginfo models.OwnPayPatnDiagListD
  4490. tempDiaginfo.InoutDiagType = "1"
  4491. tempDiaginfo.DiagCode = item.CountryCode
  4492. tempDiaginfo.DiagName = item.CountryContentName
  4493. tempDiaginfo.DiagType = "1"
  4494. tempDiaginfo.DiagSrtNo = "1"
  4495. tempDiaginfo.MaindiagFlag = "1"
  4496. tempDiaginfo.ValiFlag = "1"
  4497. tempDiaginfo.DiagDrName = doctor.UserName
  4498. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4499. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4500. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4501. } else {
  4502. var tempDiaginfo models.OwnPayPatnDiagListD
  4503. tempDiaginfo.DiagCode = item.CountryCode
  4504. tempDiaginfo.DiagName = item.CountryContentName
  4505. tempDiaginfo.DiagType = "2"
  4506. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4507. tempDiaginfo.MaindiagFlag = "0"
  4508. tempDiaginfo.ValiFlag = "1"
  4509. tempDiaginfo.DiagDrName = doctor.UserName
  4510. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4511. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4512. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4513. }
  4514. }
  4515. struct4202.ODiagListD = tempDiaginfos
  4516. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4517. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4518. var res2 ResultSix
  4519. var respJSON2 map[string]interface{}
  4520. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4523. return
  4524. }
  4525. userJSONBytes2, _ := json.Marshal(respJSON2)
  4526. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4527. utils.ErrorLog("解析失败:%v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. if res2.Infcode != 0 {
  4532. c.ServeSuccessJSON(map[string]interface{}{
  4533. "failed_code": -10,
  4534. "msg": res2.ErrMsg,
  4535. })
  4536. return
  4537. } else {
  4538. order.IsUploadDiagnose = 1
  4539. order.IsUploadOrderInfo = 1
  4540. service.UpdateOrderTwo(order)
  4541. c.ServeSuccessJSON(map[string]interface{}{
  4542. "msg": "上传成功",
  4543. })
  4544. }
  4545. }
  4546. func (c *HisApiController) Get4207() {
  4547. admin_user_id, _ := c.GetInt64("admin_user_id")
  4548. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4549. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4550. order_id, _ := c.GetInt64("order_id")
  4551. order, _ := service.GetHisOrderByIDTwo(order_id)
  4552. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4553. var struct4207 models.Struct4207
  4554. struct4207.PageNum = "1"
  4555. struct4207.PageSize = "1000"
  4556. struct4207.FixmedinsCode = miConfig.Code
  4557. struct4207.FixmedinsMdtrtID = order.Number
  4558. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4559. saveLog(result, requestLog, "4207", "查询")
  4560. var res2 ResultSix
  4561. var respJSON2 map[string]interface{}
  4562. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4565. return
  4566. }
  4567. userJSONBytes2, _ := json.Marshal(respJSON2)
  4568. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4569. utils.ErrorLog("解析失败:%v", err)
  4570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. return
  4572. }
  4573. if res2.Infcode != 0 {
  4574. c.ServeSuccessJSON(map[string]interface{}{
  4575. "failed_code": -10,
  4576. "msg": res2.ErrMsg,
  4577. })
  4578. return
  4579. } else {
  4580. c.ServeSuccessJSON(map[string]interface{}{
  4581. "msg": "查询成功",
  4582. })
  4583. }
  4584. }
  4585. func (c *HisApiController) Get4208() {
  4586. admin_user_id, _ := c.GetInt64("admin_user_id")
  4587. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4588. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4589. order_id, _ := c.GetInt64("order_id")
  4590. order, _ := service.GetHisOrderByIDTwo(order_id)
  4591. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4592. var struct4208 models.Struct4208
  4593. struct4208.PageNum = "1"
  4594. struct4208.PageSize = "1000"
  4595. struct4208.PsnCertType = "01"
  4596. struct4208.Certno = his.Certno
  4597. struct4208.MedType = order.MedType
  4598. struct4208.PsnName = his.Name
  4599. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4600. saveLog(result, requestLog, "4208", "查询")
  4601. var res2 ResultSix
  4602. var respJSON2 map[string]interface{}
  4603. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4606. return
  4607. }
  4608. userJSONBytes2, _ := json.Marshal(respJSON2)
  4609. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4610. utils.ErrorLog("解析失败:%v", err)
  4611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4612. return
  4613. }
  4614. if res2.Infcode != 0 {
  4615. c.ServeSuccessJSON(map[string]interface{}{
  4616. "failed_code": -10,
  4617. "msg": res2.ErrMsg,
  4618. })
  4619. return
  4620. } else {
  4621. c.ServeSuccessJSON(map[string]interface{}{
  4622. "msg": "查询成功",
  4623. })
  4624. }
  4625. }
  4626. func (c *HisApiController) Get4209() {
  4627. admin_user_id, _ := c.GetInt64("admin_user_id")
  4628. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4629. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4630. order_id, _ := c.GetInt64("order_id")
  4631. order, _ := service.GetHisOrderByIDTwo(order_id)
  4632. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4633. var struct4209 models.Struct4209
  4634. struct4209.FixmedinsMdtrtID = order.Number
  4635. struct4209.FixmedinsCode = miConfig.Code
  4636. struct4209.PageSize = "1000"
  4637. struct4209.PageNum = "1"
  4638. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4639. saveLog(result, requestLog, "4209", "查询")
  4640. var res2 ResultSix
  4641. var respJSON2 map[string]interface{}
  4642. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4645. return
  4646. }
  4647. userJSONBytes2, _ := json.Marshal(respJSON2)
  4648. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4649. utils.ErrorLog("解析失败:%v", err)
  4650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4651. return
  4652. }
  4653. if res2.Infcode != 0 {
  4654. c.ServeSuccessJSON(map[string]interface{}{
  4655. "failed_code": -10,
  4656. "msg": res2.ErrMsg,
  4657. })
  4658. return
  4659. } else {
  4660. c.ServeSuccessJSON(map[string]interface{}{
  4661. "msg": "查询成功",
  4662. })
  4663. }
  4664. }
  4665. type Result3101 struct {
  4666. Infcode string `json:"infcode"`
  4667. InfRefmsgid string `json:"inf_refmsgid"`
  4668. RefmsgTime string `json:"refmsg_time"`
  4669. RespondTime string `json:"respond_time"`
  4670. Enctype string `json:"enctype"`
  4671. Signtype string `json:"signtype"`
  4672. ErrMsg string `json:"err_msg"`
  4673. Output struct {
  4674. Result []struct {
  4675. JudgeResultDetailDtos []struct {
  4676. VolaItemType string `json:"vola_item_type"`
  4677. MdtrtID string `json:"mdtrt_id"`
  4678. JrdID string `json:"jrd_id"`
  4679. PatnID string `json:"patn_id"`
  4680. RxID string `json:"rx_id"`
  4681. VolaAmt interface{} `json:"vola_amt"`
  4682. } `json:"judge_result_detail_dtos"`
  4683. RuleID string `json:"rule_id"`
  4684. VolaEvid string `json:"vola_evid"`
  4685. MdtrtID string `json:"mdtrt_id"`
  4686. RuleName string `json:"rule_name"`
  4687. VolaAmtStas string `json:"vola_amt_stas"`
  4688. JrID string `json:"jr_id"`
  4689. PatnID string `json:"patn_id"`
  4690. SevDeg string `json:"sev_deg"`
  4691. VolaAmt float64 `json:"vola_amt"`
  4692. VolaBhvrType string `json:"vola_bhvr_type"`
  4693. VolaCont string `json:"vola_cont"`
  4694. } `json:"result"`
  4695. } `json:"output"`
  4696. }
  4697. type Resultgd3101 struct {
  4698. Infcode int64 `json:"infcode"`
  4699. InfRefmsgid string `json:"inf_refmsgid"`
  4700. RefmsgTime string `json:"refmsg_time"`
  4701. RespondTime string `json:"respond_time"`
  4702. Enctype string `json:"enctype"`
  4703. Signtype string `json:"signtype"`
  4704. ErrMsg string `json:"err_msg"`
  4705. Output struct {
  4706. Result []struct {
  4707. JudgeResultDetailDtos []struct {
  4708. VolaItemType string `json:"vola_item_type"`
  4709. MdtrtID string `json:"mdtrt_id"`
  4710. JrdID string `json:"jrd_id"`
  4711. PatnID string `json:"patn_id"`
  4712. RxID string `json:"rx_id"`
  4713. VolaAmt interface{} `json:"vola_amt"`
  4714. } `json:"judge_result_detail_dtos"`
  4715. RuleID string `json:"rule_id"`
  4716. VolaEvid string `json:"vola_evid"`
  4717. MdtrtID string `json:"mdtrt_id"`
  4718. RuleName string `json:"rule_name"`
  4719. VolaAmtStas string `json:"vola_amt_stas"`
  4720. JrID string `json:"jr_id"`
  4721. PatnID string `json:"patn_id"`
  4722. SevDeg string `json:"sev_deg"`
  4723. VolaAmt float64 `json:"vola_amt"`
  4724. VolaBhvrType string `json:"vola_bhvr_type"`
  4725. VolaCont string `json:"vola_cont"`
  4726. } `json:"result"`
  4727. } `json:"output"`
  4728. }
  4729. func (c *HisApiController) ReadEleToken() {
  4730. admin_user_id, _ := c.GetInt64("admin_user_id")
  4731. his_patient_id, _ := c.GetInt64("his_patient_id")
  4732. adminUser := c.GetAdminUserInfo()
  4733. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4734. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4735. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4736. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4737. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4738. if len(tokens) > 0 {
  4739. c.ServeSuccessJSON(map[string]interface{}{
  4740. "msg": "读取成功",
  4741. })
  4742. } else {
  4743. c.ServeSuccessJSON(map[string]interface{}{
  4744. "failed_code": -10,
  4745. "msg": "读取失败",
  4746. })
  4747. }
  4748. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4749. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4750. if len(tokens) > 0 {
  4751. c.ServeSuccessJSON(map[string]interface{}{
  4752. "msg": "读取成功",
  4753. })
  4754. } else {
  4755. c.ServeSuccessJSON(map[string]interface{}{
  4756. "failed_code": -10,
  4757. "msg": "读取失败",
  4758. })
  4759. }
  4760. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4761. var api string
  4762. 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 +
  4763. "&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"
  4764. resp, requestErr := http.Get(api)
  4765. if requestErr != nil {
  4766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4767. }
  4768. body, ioErr := ioutil.ReadAll(resp.Body)
  4769. if ioErr != nil {
  4770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4772. }
  4773. var respJSON map[string]interface{}
  4774. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4777. return
  4778. }
  4779. var status string
  4780. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4781. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4782. var token string
  4783. var res ResultTwo //1101结果
  4784. var res10265 ResultTwo10265 //1101结果
  4785. if status == "0" { //读卡成功
  4786. var card_info string //卡信息
  4787. var busi_card_info string
  4788. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4789. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4790. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4791. fmt.Println(card_info)
  4792. fmt.Println(busi_card_info)
  4793. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4794. result, _ := json.Marshal(respJSON)
  4795. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4796. utils.ErrorLog("解析失败:%v", err)
  4797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4798. return
  4799. }
  4800. res.ErrMsg = res10265.ErrMsg
  4801. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4802. res.Infcode = infocode
  4803. res.Output = res10265.Output
  4804. res.InfRefmsgid = res10265.InfRefmsgid
  4805. if res.Infcode == 0 {
  4806. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4807. if err == gorm.ErrRecordNotFound {
  4808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4809. return
  4810. } else if err != nil {
  4811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4812. return
  4813. } else {
  4814. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4815. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4816. infoStr := string(Iinfos)
  4817. idetinfoStr := string(Idetinfos)
  4818. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4819. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4820. psn := &models.HisPsn{
  4821. PsnNo: res.Output.Baseinfo.PsnNo,
  4822. PatientId: patient.ID,
  4823. Certno: res.Output.Baseinfo.Certno,
  4824. Gend: res.Output.Baseinfo.Gend,
  4825. Naty: res.Output.Baseinfo.Naty,
  4826. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4827. PsnName: res.Output.Baseinfo.PsnName,
  4828. Age: float64(age),
  4829. Brdy: b,
  4830. Idetinfo: idetinfoStr,
  4831. Insuinfo: infoStr,
  4832. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4833. CardInfo: card_info,
  4834. VerifyNumber: token,
  4835. IdCardType: 4,
  4836. }
  4837. var rf []*ResultFive
  4838. json.Unmarshal([]byte(infoStr), &rf)
  4839. var insutypes []*ResultFive
  4840. var insutype string
  4841. var is390 int = 0
  4842. var is310 int = 0
  4843. for _, item := range rf {
  4844. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4845. insutypes = append(insutypes, item)
  4846. }
  4847. }
  4848. if len(insutypes) == 1 {
  4849. insutype = insutypes[0].Insutype
  4850. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4851. } else {
  4852. for _, i := range insutypes {
  4853. if i.Insutype == "390" {
  4854. is390 = 1
  4855. }
  4856. if i.Insutype == "310" {
  4857. is310 = 1
  4858. }
  4859. }
  4860. }
  4861. if is390 == 1 {
  4862. insutype = "390"
  4863. }
  4864. if is310 == 1 {
  4865. insutype = "310"
  4866. }
  4867. if len(insutypes) == 0 {
  4868. insutype = "310"
  4869. }
  4870. service.CreateHisPsn(psn)
  4871. c.ServeSuccessJSON(map[string]interface{}{
  4872. "patient": patient,
  4873. "number": token,
  4874. "insutype": insutype,
  4875. })
  4876. }
  4877. } else {
  4878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4879. return
  4880. }
  4881. } else { //读卡失败
  4882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4883. return
  4884. }
  4885. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4886. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4887. if len(errMsg) == 0 {
  4888. type ELeData struct {
  4889. Data struct {
  4890. IdNo string `json:"idNo"`
  4891. IdType string `json:"idType"`
  4892. UserName string `json:"userName"`
  4893. EcToken string `json:"ecToken"`
  4894. InsuOrg string `json:"insuOrg"`
  4895. Gender string `json:"gender"`
  4896. Birthday string `json:"birthday"`
  4897. Nationality string `json:"nationality"`
  4898. Email string `json:"email"`
  4899. Extra string `json:"extra"`
  4900. } `json:"data"`
  4901. Code int `json:"code"`
  4902. Message string `json:"message"`
  4903. }
  4904. var ele ELeData
  4905. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4906. if err != nil {
  4907. utils.ErrorLog("解析失败:%v", err)
  4908. }
  4909. token := ele.Data.EcToken
  4910. if len(token) > 0 {
  4911. psn := &models.HisPsn{
  4912. PsnNo: his.PsnNo,
  4913. Age: 0,
  4914. PatientId: his.PatientId,
  4915. Certno: his.Certno,
  4916. Brdy: his.Brdy,
  4917. Gend: his.Gend,
  4918. Naty: his.Naty,
  4919. PsnCertType: his.PsnCertType,
  4920. PsnName: his.PsnName,
  4921. Idetinfo: his.Idetinfo,
  4922. Insuinfo: his.Iinfo,
  4923. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4924. CardInfo: outPutInfo,
  4925. VerifyNumber: token,
  4926. }
  4927. service.CreateHisPsn(psn)
  4928. }
  4929. if len(token) > 0 {
  4930. c.ServeSuccessJSON(map[string]interface{}{
  4931. "msg": "读取成功",
  4932. })
  4933. } else {
  4934. c.ServeSuccessJSON(map[string]interface{}{
  4935. "failed_code": -10,
  4936. "msg": "读取失败",
  4937. })
  4938. }
  4939. }
  4940. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4941. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4942. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4943. type ELeData struct {
  4944. Data struct {
  4945. IdNo string `json:"idNo"`
  4946. IdType string `json:"idType"`
  4947. UserName string `json:"userName"`
  4948. EcToken string `json:"ecToken"`
  4949. InsuOrg string `json:"insuOrg"`
  4950. Gender string `json:"gender"`
  4951. Birthday string `json:"birthday"`
  4952. Nationality string `json:"nationality"`
  4953. Email string `json:"email"`
  4954. Extra string `json:"extra"`
  4955. } `json:"data"`
  4956. Code int `json:"code"`
  4957. Message string `json:"message"`
  4958. }
  4959. var ele ELeData
  4960. err := json.Unmarshal([]byte(result), &ele)
  4961. if err != nil {
  4962. utils.ErrorLog("解析失败:%v", err)
  4963. }
  4964. token := ele.Data.EcToken
  4965. token = Remove0000(token)
  4966. fmt.Println(ele.Data.UserName)
  4967. 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)
  4968. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4969. var res ResultTwo
  4970. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4971. utils.ErrorLog("解析失败:%v", err)
  4972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4973. return
  4974. }
  4975. if res.Infcode == 0 {
  4976. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4977. if err == gorm.ErrRecordNotFound {
  4978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4979. return
  4980. } else if err != nil {
  4981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4982. return
  4983. } else {
  4984. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4985. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4986. infoStr := string(Iinfos)
  4987. idetinfoStr := string(Idetinfos)
  4988. psn := &models.HisPsn{
  4989. PsnNo: res.Output.Baseinfo.PsnNo,
  4990. PatientId: patient.ID,
  4991. Certno: res.Output.Baseinfo.Certno,
  4992. Gend: res.Output.Baseinfo.Gend,
  4993. Naty: res.Output.Baseinfo.Naty,
  4994. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4995. PsnName: res.Output.Baseinfo.PsnName,
  4996. Idetinfo: idetinfoStr,
  4997. Insuinfo: infoStr,
  4998. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4999. CardInfo: "",
  5000. VerifyNumber: token,
  5001. }
  5002. service.CreateHisPsn(psn)
  5003. c.ServeSuccessJSON(map[string]interface{}{
  5004. "patient": patient,
  5005. "number": token,
  5006. })
  5007. }
  5008. } else {
  5009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5010. return
  5011. }
  5012. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5013. idNo := c.GetString("idNo")
  5014. userName := c.GetString("userName")
  5015. ecToken := c.GetString("ecToken")
  5016. insuOrg := c.GetString("insuOrg")
  5017. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  5018. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5019. var res ResultTwo
  5020. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5021. utils.ErrorLog("解析失败:%v", err)
  5022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5023. return
  5024. }
  5025. if res.Infcode == 0 {
  5026. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5027. if err == gorm.ErrRecordNotFound {
  5028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5029. return
  5030. } else if err != nil {
  5031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5032. return
  5033. } else {
  5034. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5035. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5036. infoStr := string(Iinfos)
  5037. idetinfoStr := string(Idetinfos)
  5038. psn := &models.HisPsn{
  5039. PsnNo: res.Output.Baseinfo.PsnNo,
  5040. PatientId: patient.ID,
  5041. Certno: res.Output.Baseinfo.Certno,
  5042. Gend: res.Output.Baseinfo.Gend,
  5043. Naty: res.Output.Baseinfo.Naty,
  5044. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5045. PsnName: res.Output.Baseinfo.PsnName,
  5046. Idetinfo: idetinfoStr,
  5047. Insuinfo: infoStr,
  5048. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5049. CardInfo: "",
  5050. VerifyNumber: ecToken,
  5051. InsuplcAdmdvs: insuOrg,
  5052. }
  5053. service.CreateHisPsn(psn)
  5054. c.ServeSuccessJSON(map[string]interface{}{
  5055. "patient": patient,
  5056. "number": ecToken,
  5057. })
  5058. }
  5059. } else {
  5060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5061. return
  5062. }
  5063. } else if miConfig.MdtrtareaAdmvs == "450721" {
  5064. res := c.GetoleInfo()
  5065. if res.Infcode == 0 {
  5066. var result string
  5067. if res.Output.MdtrtCertType == "01" {
  5068. 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)
  5069. } else if res.Output.MdtrtCertType == "02" {
  5070. 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)
  5071. } else if res.Output.MdtrtCertType == "03" {
  5072. 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)
  5073. }
  5074. var dat map[string]interface{}
  5075. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5076. fmt.Println(dat)
  5077. } else {
  5078. fmt.Println(err)
  5079. }
  5080. userJSONBytes, _ := json.Marshal(dat)
  5081. var res2 ResultTwo
  5082. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5083. utils.ErrorLog("解析失败:%v", err)
  5084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5085. return
  5086. }
  5087. if res2.Infcode == 0 {
  5088. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  5089. if err == gorm.ErrRecordNotFound {
  5090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5091. return
  5092. } else if err != nil {
  5093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5094. return
  5095. } else {
  5096. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  5097. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  5098. infoStr := string(Iinfos)
  5099. idetinfoStr := string(Idetinfos)
  5100. var rf []*ResultFive
  5101. json.Unmarshal([]byte(infoStr), &rf)
  5102. var insutypes []*ResultFive
  5103. var insutype string
  5104. var is390 int = 0
  5105. var is310 int = 0
  5106. //var insuplc_admdvs string
  5107. for _, item := range rf {
  5108. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5109. insutypes = append(insutypes, item)
  5110. }
  5111. }
  5112. if len(insutypes) == 1 {
  5113. insutype = insutypes[0].Insutype
  5114. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5115. } else {
  5116. for _, i := range insutypes {
  5117. if i.Insutype == "390" {
  5118. is390 = 1
  5119. }
  5120. if i.Insutype == "310" {
  5121. is310 = 1
  5122. }
  5123. }
  5124. }
  5125. if is390 == 1 {
  5126. insutype = "390"
  5127. }
  5128. if is310 == 1 {
  5129. insutype = "310"
  5130. }
  5131. if len(insutypes) == 0 {
  5132. insutype = "310"
  5133. }
  5134. psn := &models.HisPsn{
  5135. PsnNo: res2.Output.Baseinfo.PsnNo,
  5136. PatientId: patient.ID,
  5137. Certno: res2.Output.Baseinfo.Certno,
  5138. Gend: res2.Output.Baseinfo.Gend,
  5139. Naty: res2.Output.Baseinfo.Naty,
  5140. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  5141. PsnName: res2.Output.Baseinfo.PsnName,
  5142. Idetinfo: idetinfoStr,
  5143. Insuinfo: infoStr,
  5144. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5145. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  5146. VerifyNumber: res.Output.EcToken,
  5147. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  5148. }
  5149. service.CreateHisPsn(psn)
  5150. c.ServeSuccessJSON(map[string]interface{}{
  5151. "patient": patient,
  5152. "number": res.Output.CardNo,
  5153. "insutype": insutype,
  5154. })
  5155. }
  5156. } else {
  5157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5158. return
  5159. }
  5160. } else {
  5161. c.ServeSuccessJSON(map[string]interface{}{
  5162. "failed_code": -10,
  5163. "msg": res.ErrMsg,
  5164. })
  5165. }
  5166. } else {
  5167. //if initFlag == 0 {
  5168. // c.TestGetBasBaseInit()
  5169. //}
  5170. //token := c.GetEleBaseInfo()
  5171. //token = Remove0000(token)
  5172. type ELeData struct {
  5173. Code string `json:"code"`
  5174. Data struct {
  5175. Aac002 string `json:"aac002"`
  5176. Aaz500 string `json:"aaz500"`
  5177. ActCardNo string `json:"actCardNo"`
  5178. Bab520 string `json:"bab520"`
  5179. Bkz543 string `json:"bkz543"`
  5180. BusinessType string `json:"businessType"`
  5181. CertfCodg string `json:"certfCodg"`
  5182. EcIndexNo string `json:"ecIndexNo"`
  5183. EcToken string `json:"ecToken"`
  5184. ID0000 string `json:"id0000"`
  5185. IDNo string `json:"idNo"`
  5186. IDType string `json:"idType"`
  5187. Idcode string `json:"idcode"`
  5188. IdentityToken string `json:"identity_token"`
  5189. InsuOrg string `json:"insuOrg"`
  5190. OfficeID string `json:"officeId"`
  5191. OfficeName string `json:"officeName"`
  5192. OperatorID string `json:"operatorId"`
  5193. OperatorName string `json:"operatorName"`
  5194. OrgID string `json:"orgId"`
  5195. UserName string `json:"userName"`
  5196. } `json:"data"`
  5197. Infno interface{} `json:"infno"`
  5198. Message string `json:"message"`
  5199. OrgID string `json:"orgId"`
  5200. TransType string `json:"transType"`
  5201. }
  5202. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  5203. fmt.Println(result)
  5204. outPutInfo := Remove0000(result)
  5205. fmt.Println(outPutInfo)
  5206. var ele ELeData
  5207. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5208. if err != nil {
  5209. utils.ErrorLog("解析失败:%v", err)
  5210. }
  5211. token := ele.Data.EcToken
  5212. var result2 string
  5213. var requestLog2 string
  5214. if len(token) > 0 {
  5215. if strings.Contains(ele.Data.IDNo, "HKG") {
  5216. 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)
  5217. } else {
  5218. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5219. }
  5220. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5221. var res ResultTwo
  5222. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5223. utils.ErrorLog("解析失败:%v", err)
  5224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5225. return
  5226. }
  5227. if res.Infcode == 0 {
  5228. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5229. if err == gorm.ErrRecordNotFound {
  5230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5231. return
  5232. } else if err != nil {
  5233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5234. return
  5235. } else {
  5236. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5237. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5238. infoStr := string(Iinfos)
  5239. idetinfoStr := string(Idetinfos)
  5240. psn := &models.HisPsn{
  5241. PsnNo: res.Output.Baseinfo.PsnNo,
  5242. PatientId: patient.ID,
  5243. Certno: res.Output.Baseinfo.Certno,
  5244. Gend: res.Output.Baseinfo.Gend,
  5245. Naty: res.Output.Baseinfo.Naty,
  5246. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5247. PsnName: res.Output.Baseinfo.PsnName,
  5248. Idetinfo: idetinfoStr,
  5249. Insuinfo: infoStr,
  5250. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5251. CardInfo: "",
  5252. VerifyNumber: token,
  5253. }
  5254. service.CreateHisPsn(psn)
  5255. c.ServeSuccessJSON(map[string]interface{}{
  5256. "msg": "读取成功",
  5257. })
  5258. }
  5259. } else {
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5261. return
  5262. }
  5263. } else {
  5264. c.ServeSuccessJSON(map[string]interface{}{
  5265. "failed_code": -10,
  5266. "msg": "读取失败",
  5267. })
  5268. }
  5269. }
  5270. }
  5271. func (c *HisApiController) ReadEleFace() {
  5272. admin_user_id, _ := c.GetInt64("admin_user_id")
  5273. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5274. adminUser := c.GetAdminUserInfo()
  5275. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5276. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5277. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5278. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5279. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  5280. if len(tokens) > 0 {
  5281. c.ServeSuccessJSON(map[string]interface{}{
  5282. "msg": "读取成功",
  5283. })
  5284. } else {
  5285. c.ServeSuccessJSON(map[string]interface{}{
  5286. "failed_code": -10,
  5287. "msg": "读取失败",
  5288. })
  5289. }
  5290. }
  5291. }
  5292. func (c *HisApiController) Get9001() {
  5293. adminUser := c.GetAdminUserInfo()
  5294. admin_user_id, _ := c.GetInt64("admin_user_id")
  5295. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5296. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5297. if miConfig.MdtrtareaAdmvs == "350500" {
  5298. service.GetFjAuthorizationInfo(miConfig.Code)
  5299. } else if miConfig.MdtrtareaAdmvs == "131023" {
  5300. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  5301. var dat map[string]interface{}
  5302. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5303. fmt.Println(dat)
  5304. } else {
  5305. fmt.Println(err)
  5306. }
  5307. userJSONBytes, _ := json.Marshal(dat)
  5308. var res models.Result9001
  5309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5310. utils.ErrorLog("解析失败:%v", err)
  5311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5312. return
  5313. }
  5314. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5315. fmt.Println(miConfig.SecretKey)
  5316. var res models.Result9001Two
  5317. 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 +
  5318. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  5319. resp, requestErr := http.Get(api)
  5320. if requestErr != nil {
  5321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5322. return
  5323. }
  5324. body, ioErr := ioutil.ReadAll(resp.Body)
  5325. if ioErr != nil {
  5326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5328. return
  5329. }
  5330. var respJSON map[string]interface{}
  5331. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5334. return
  5335. }
  5336. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5337. if status == "0" {
  5338. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5339. c.ServeSuccessJSON(map[string]interface{}{
  5340. "failed_code": -10,
  5341. "msg": err_msg,
  5342. })
  5343. return
  5344. }
  5345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5346. result, _ := json.Marshal(respJSON)
  5347. fmt.Println("log")
  5348. fmt.Println(string(result))
  5349. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5350. utils.ErrorLog("解析失败:%v", err)
  5351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5352. return
  5353. }
  5354. if res.Infcode == 0 {
  5355. sign := models.HisSignIn{
  5356. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5357. SignNo: res.Output.Signinoutb.SignNo,
  5358. SignTime: "",
  5359. Ctime: time.Now().Unix(),
  5360. Mtime: time.Now().Unix(),
  5361. Status: 1,
  5362. InputLog: "",
  5363. OutputLog: "",
  5364. FixmedinsCode: miConfig.Code,
  5365. }
  5366. err := service.CreateSignIn(&sign)
  5367. if err == nil {
  5368. c.ServeSuccessJSON(map[string]interface{}{
  5369. "msg": "签到成功",
  5370. })
  5371. }
  5372. } else {
  5373. c.ServeSuccessJSON(map[string]interface{}{
  5374. "failed_code": -10,
  5375. "msg": res.ErrMsg,
  5376. })
  5377. return
  5378. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5379. //return
  5380. }
  5381. } else {
  5382. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5383. var dat map[string]interface{}
  5384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5385. fmt.Println(dat)
  5386. } else {
  5387. fmt.Println(err)
  5388. }
  5389. userJSONBytes, _ := json.Marshal(dat)
  5390. var res models.Result9001
  5391. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5392. utils.ErrorLog("解析失败:%v", err)
  5393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5394. return
  5395. }
  5396. if res.Infcode == 0 {
  5397. sign := models.HisSignIn{
  5398. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5399. SignNo: res.Output.Signinoutb.SignNo,
  5400. SignTime: res.Output.Signinoutb.SignTime,
  5401. Ctime: time.Now().Unix(),
  5402. Mtime: time.Now().Unix(),
  5403. Status: 1,
  5404. InputLog: "",
  5405. OutputLog: "",
  5406. FixmedinsCode: miConfig.Code,
  5407. }
  5408. err := service.CreateSignIn(&sign)
  5409. if err == nil {
  5410. c.ServeSuccessJSON(map[string]interface{}{
  5411. "msg": "签到成功",
  5412. })
  5413. }
  5414. }
  5415. }
  5416. }
  5417. 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) {
  5418. var res Result3101
  5419. adminUser := c.GetAdminUserInfo()
  5420. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5421. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5422. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5423. //record_time := c.GetString("record_time")
  5424. //trig_scen := c.GetString("trig_scen")
  5425. timeLayout := "2006-01-02"
  5426. loc, _ := time.LoadLocation("Local")
  5427. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5428. if err != nil {
  5429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5430. return res
  5431. }
  5432. recordDateTime := theTime.Unix()
  5433. var patientPrescription models.HisPrescriptionInfo
  5434. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5435. //if patientPrescription.ID == 0 {
  5436. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5437. //}
  5438. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5439. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5440. //
  5441. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5442. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5443. var pp models.PublicParams
  5444. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5445. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5446. pp.FixmedinsName = miConfig.OrgName
  5447. pp.FixmedinsCode = miConfig.Code
  5448. pp.RequestUrl = miConfig.Url
  5449. pp.Cainfo = miConfig.Cainfo
  5450. pp.SecretKey = miConfig.SecretKey
  5451. pp.AccessKey = miConfig.AccessKey
  5452. pp.OpterName = roles.UserName
  5453. var config []*models.HisXtDiagnoseConfig
  5454. for _, item := range diagnosis_ids {
  5455. id, _ := strconv.ParseInt(item, 10, 64)
  5456. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5457. config = append(config, &diagnosisConfig)
  5458. }
  5459. var pd models.PatientDtos
  5460. pd.PatnID = his.PsnNo
  5461. pd.PatnName = his.Name
  5462. pd.Gend = his.Gend
  5463. pd.Brdy = his.Brdy
  5464. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5465. pd.CurrMdtrtID = his.Number
  5466. var fed models.FsiEncounterDtos
  5467. fed.MdtrtID = his.Number
  5468. fed.MedinsID = miConfig.Code
  5469. fed.MedinsName = miConfig.OrgName
  5470. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5471. fed.MedMdtrtType = "1"
  5472. fed.MedinsType = "1"
  5473. fed.MedinsLv = "11"
  5474. tm := time.Unix(his.RecordDate, 0)
  5475. s_tm := tm.Format("2006-01-02 15:04:05")
  5476. fed.AdmDate = s_tm
  5477. fed.DscgDate = s_tm
  5478. fed.DscgMainDiseCodg = config[0].CountryCode
  5479. fed.DscgMainDiseName = config[0].CountryContentName
  5480. //诊断信息
  5481. var fdds []*models.FsiDiagnoseDtos
  5482. for index, item := range config {
  5483. if index == 0 {
  5484. var fdd models.FsiDiagnoseDtos
  5485. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5486. fdd.InoutDiseType = "1"
  5487. fdd.MaindiseFlag = "1"
  5488. fdd.DiseDate = s_tm
  5489. fdd.DiasSrtNo = "1"
  5490. fdd.DiseName = item.CountryContentName
  5491. fdd.DiseCodg = item.CountryCode
  5492. fdds = append(fdds, &fdd)
  5493. } else {
  5494. var fdd models.FsiDiagnoseDtos
  5495. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5496. fdd.InoutDiseType = "1"
  5497. fdd.MaindiseFlag = "1"
  5498. fdd.DiseDate = s_tm
  5499. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5500. fdd.DiseName = item.CountryContentName
  5501. fdd.DiseCodg = item.CountryCode
  5502. fdds = append(fdds, &fdd)
  5503. }
  5504. }
  5505. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5506. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5507. fed.AdmDeptName = department.Name
  5508. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5509. fed.DscgDeptName = department.Name
  5510. fed.MedMdtrtType = "1"
  5511. fed.MedType = "11"
  5512. //if his.Insutype == "390" {
  5513. // fed.MedType = "1402"
  5514. //} else {
  5515. // fed.MedType = "9933"
  5516. //}
  5517. var orders []*models.FsiOrderDtos
  5518. if trig_scen == "2" {
  5519. //处方医嘱信息
  5520. for _, item := range prescriptions {
  5521. for _, subItem := range item.HisDoctorAdviceInfo {
  5522. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5523. var order models.FsiOrderDtos
  5524. order.RxID = strconv.FormatInt(item.ID, 10)
  5525. order.Rxno = strconv.FormatInt(item.ID, 10)
  5526. order.LongDrordFlag = "0"
  5527. order.HilistType = "1"
  5528. order.ChrgType = "1"
  5529. order.DrordBhvr = "-"
  5530. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5531. order.HosplistName = subItem.BaseDrugLib.DrugName
  5532. order.HilistLv = "1"
  5533. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5534. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5535. order.HosplistName = subItem.BaseDrugLib.DrugName
  5536. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5537. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5538. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5539. order.OwnpayAmt = ""
  5540. order.SelfpayAmt = ""
  5541. order.Spec = ""
  5542. order.SpecUnt = ""
  5543. order.DrordBegnDate = s_tm
  5544. order.DrordStopDate = ""
  5545. order.DrordDrCodg = doctor_info.DoctorNumber
  5546. order.DrordDeptName = department.Name
  5547. order.DrordDeptCodg = department.Number
  5548. order.DrordDrName = doctor_info.UserName
  5549. order.DrordDrProfttl = "234"
  5550. order.CurrDrordFlag = "1"
  5551. orders = append(orders, &order)
  5552. }
  5553. }
  5554. for _, subItem := range item.HisPrescriptionProject {
  5555. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5556. var order models.FsiOrderDtos
  5557. order.RxID = strconv.FormatInt(item.ID, 10)
  5558. order.Rxno = strconv.FormatInt(item.ID, 10)
  5559. order.LongDrordFlag = "0"
  5560. order.HilistType = "1"
  5561. order.ChrgType = "1"
  5562. order.DrordBhvr = "-"
  5563. order.HilistCode = subItem.HisProject.MedicalCode
  5564. order.HosplistName = subItem.HisProject.ProjectName
  5565. order.HilistLv = "1"
  5566. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5567. order.HosplistCode = subItem.HisProject.MedicalCode
  5568. order.HosplistName = subItem.HisProject.ProjectName
  5569. order.Cnt = subItem.Count
  5570. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5571. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5572. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5573. order.OwnpayAmt = ""
  5574. order.SelfpayAmt = ""
  5575. order.Spec = ""
  5576. order.SpecUnt = ""
  5577. order.DrordBegnDate = s_tm
  5578. order.DrordStopDate = ""
  5579. order.DrordDrCodg = doctor_info.DoctorNumber
  5580. order.DrordDeptName = department.Name
  5581. order.DrordDeptCodg = department.Number
  5582. order.DrordDrName = doctor_info.UserName
  5583. order.DrordDrProfttl = "234"
  5584. order.CurrDrordFlag = "1"
  5585. orders = append(orders, &order)
  5586. }
  5587. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5588. var order models.FsiOrderDtos
  5589. order.RxID = strconv.FormatInt(item.ID, 10)
  5590. order.Rxno = strconv.FormatInt(item.ID, 10)
  5591. order.LongDrordFlag = "0"
  5592. order.HilistType = "1"
  5593. order.ChrgType = "1"
  5594. order.DrordBhvr = "-"
  5595. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5596. order.HosplistName = subItem.GoodInfo.GoodName
  5597. order.HilistLv = "1"
  5598. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5599. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5600. order.HosplistName = subItem.GoodInfo.GoodName
  5601. order.Cnt = subItem.Count
  5602. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5603. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5604. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5605. order.OwnpayAmt = ""
  5606. order.SelfpayAmt = ""
  5607. order.Spec = ""
  5608. order.SpecUnt = ""
  5609. order.DrordBegnDate = s_tm
  5610. order.DrordStopDate = ""
  5611. order.DrordDrCodg = doctor_info.DoctorNumber
  5612. order.DrordDeptName = department.Name
  5613. order.DrordDeptCodg = department.Number
  5614. order.DrordDrName = doctor_info.UserName
  5615. order.DrordDrProfttl = "234"
  5616. order.CurrDrordFlag = "1"
  5617. orders = append(orders, &order)
  5618. }
  5619. }
  5620. }
  5621. //处方医嘱信息
  5622. }
  5623. fed.MatnStas = "0"
  5624. fed.MedfeeSumamt = "0"
  5625. fed.OwnpayAmt = "0"
  5626. fed.SelfpayAmt = "0"
  5627. fed.AcctPayamt = "0"
  5628. fed.MaAmt = "0"
  5629. fed.HifpPayamt = "0"
  5630. fed.SetlTotlnum = "1"
  5631. fed.Insutype = his.Insutype
  5632. fed.ReimFlag = "0"
  5633. fed.OutSetlFlag = "0"
  5634. var fopd []*models.FsiOperationDtosData
  5635. data := make(map[string]interface{})
  5636. data["fed"] = fed
  5637. data["fdd"] = fdds
  5638. data["fod"] = orders
  5639. data["pd"] = pd
  5640. data["pp"] = pp
  5641. data["fopd"] = fopd
  5642. data["trig_scen"] = trig_scen
  5643. fmt.Println(data)
  5644. fmt.Println(fed)
  5645. fmt.Println(fdds)
  5646. fmt.Println(orders)
  5647. fmt.Println(pd)
  5648. fmt.Println(pp)
  5649. fmt.Println(fopd)
  5650. client := &http.Client{}
  5651. bytesData, _ := json.Marshal(data)
  5652. var req *http.Request
  5653. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5654. if miConfig.MdtrtareaAdmvs == "320921" {
  5655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5656. } else {
  5657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5658. }
  5659. resp, _ := client.Do(req)
  5660. defer resp.Body.Close()
  5661. body, ioErr := ioutil.ReadAll(resp.Body)
  5662. if ioErr != nil {
  5663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5665. return res
  5666. }
  5667. var respJSON map[string]interface{}
  5668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5671. return res
  5672. }
  5673. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5674. fmt.Println(respJSON)
  5675. result, _ := json.Marshal(respJSON)
  5676. fmt.Println(result)
  5677. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5678. utils.ErrorLog("解析失败:%v", err)
  5679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5680. return res
  5681. }
  5682. return res
  5683. } else {
  5684. //if miConfig.MdtrtareaAdmvs == "441202" {
  5685. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5686. saveLog(output, input, "3101", "事前")
  5687. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5688. utils.ErrorLog("解析失败:%v", err)
  5689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5690. return
  5691. }
  5692. return res
  5693. //}
  5694. }
  5695. }
  5696. 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) {
  5697. adminUser := c.GetAdminUserInfo()
  5698. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5699. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5700. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5701. //record_time := c.GetString("record_time")
  5702. //trig_scen := c.GetString("trig_scen")
  5703. timeLayout := "2006-01-02"
  5704. loc, _ := time.LoadLocation("Local")
  5705. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5706. if err != nil {
  5707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5708. return res
  5709. }
  5710. recordDateTime := theTime.Unix()
  5711. var patientPrescription models.HisPrescriptionInfo
  5712. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5713. if patientPrescription.ID == 0 {
  5714. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5715. }
  5716. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5717. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5718. //
  5719. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5720. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5721. var pp models.PublicParams
  5722. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5723. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5724. pp.FixmedinsName = miConfig.OrgName
  5725. pp.FixmedinsCode = miConfig.Code
  5726. pp.RequestUrl = miConfig.Url
  5727. pp.Cainfo = miConfig.Cainfo
  5728. pp.SecretKey = miConfig.SecretKey
  5729. pp.AccessKey = miConfig.AccessKey
  5730. pp.OpterName = roles.UserName
  5731. var config []*models.HisXtDiagnoseConfig
  5732. for _, item := range diagnosis_ids {
  5733. id, _ := strconv.ParseInt(item, 10, 64)
  5734. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5735. config = append(config, &diagnosisConfig)
  5736. }
  5737. var pd models.PatientDtos
  5738. pd.PatnID = his.PsnNo
  5739. pd.PatnName = his.Name
  5740. pd.Gend = his.Gend
  5741. pd.Brdy = his.Brdy
  5742. pd.Poolarea = his.InsuplcAdmdvs
  5743. pd.CurrMdtrtID = his.Number
  5744. var fed models.FsiEncounterDtos
  5745. fed.MdtrtID = his.Number
  5746. fed.MedinsID = miConfig.Code
  5747. fed.MedinsName = miConfig.OrgName
  5748. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5749. fed.MedMdtrtType = "1"
  5750. fed.MedinsType = "1"
  5751. fed.MedinsLv = "11"
  5752. tm := time.Unix(his.RecordDate, 0)
  5753. s_tm := tm.Format("2006-01-02 15:04:05")
  5754. fed.AdmDate = s_tm
  5755. fed.DscgDate = s_tm
  5756. fed.DscgMainDiseCodg = config[0].CountryCode
  5757. fed.DscgMainDiseName = config[0].CountryContentName
  5758. //诊断信息
  5759. var fdds []*models.FsiDiagnoseDtos
  5760. for index, item := range config {
  5761. if index == 0 {
  5762. var fdd models.FsiDiagnoseDtos
  5763. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5764. fdd.InoutDiseType = "1"
  5765. fdd.MaindiseFlag = "1"
  5766. fdd.DiseDate = s_tm
  5767. fdd.DiasSrtNo = "1"
  5768. fdd.DiseName = item.CountryContentName
  5769. fdd.DiseCodg = item.CountryCode
  5770. fdds = append(fdds, &fdd)
  5771. } else {
  5772. var fdd models.FsiDiagnoseDtos
  5773. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5774. fdd.InoutDiseType = "1"
  5775. fdd.MaindiseFlag = "1"
  5776. fdd.DiseDate = s_tm
  5777. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5778. fdd.DiseName = item.CountryContentName
  5779. fdd.DiseCodg = item.CountryCode
  5780. fdds = append(fdds, &fdd)
  5781. }
  5782. }
  5783. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5784. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5785. fed.AdmDeptName = department.Name
  5786. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5787. fed.DscgDeptName = department.Name
  5788. fed.MedMdtrtType = "1"
  5789. fed.MedType = "11"
  5790. //if his.Insutype == "390" {
  5791. // fed.MedType = "1402"
  5792. //} else {
  5793. // fed.MedType = "9933"
  5794. //}
  5795. var orders []*models.FsiOrderDtos
  5796. if trig_scen == "2" {
  5797. //处方医嘱信息
  5798. for _, item := range prescriptions {
  5799. for _, subItem := range item.HisDoctorAdviceInfo {
  5800. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5801. var order models.FsiOrderDtos
  5802. order.RxID = strconv.FormatInt(item.ID, 10)
  5803. order.Rxno = strconv.FormatInt(item.ID, 10)
  5804. order.LongDrordFlag = "0"
  5805. order.HilistType = "1"
  5806. order.ChrgType = "1"
  5807. order.DrordBhvr = "-"
  5808. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5809. order.HosplistName = subItem.BaseDrugLib.DrugName
  5810. order.HilistLv = "1"
  5811. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5812. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5813. order.HosplistName = subItem.BaseDrugLib.DrugName
  5814. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5815. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5816. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5817. order.OwnpayAmt = ""
  5818. order.SelfpayAmt = ""
  5819. order.Spec = ""
  5820. order.SpecUnt = ""
  5821. order.DrordBegnDate = s_tm
  5822. order.DrordStopDate = ""
  5823. order.DrordDrCodg = doctor_info.DoctorNumber
  5824. order.DrordDeptName = department.Name
  5825. order.DrordDeptCodg = department.Number
  5826. order.DrordDrName = doctor_info.UserName
  5827. order.DrordDrProfttl = "234"
  5828. order.CurrDrordFlag = "1"
  5829. orders = append(orders, &order)
  5830. }
  5831. }
  5832. for _, subItem := range item.HisPrescriptionProject {
  5833. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5834. var order models.FsiOrderDtos
  5835. order.RxID = strconv.FormatInt(item.ID, 10)
  5836. order.Rxno = strconv.FormatInt(item.ID, 10)
  5837. order.LongDrordFlag = "0"
  5838. order.HilistType = "1"
  5839. order.ChrgType = "1"
  5840. order.DrordBhvr = "-"
  5841. order.HilistCode = subItem.HisProject.MedicalCode
  5842. order.HosplistName = subItem.HisProject.ProjectName
  5843. order.HilistLv = "1"
  5844. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5845. order.HosplistCode = subItem.HisProject.MedicalCode
  5846. order.HosplistName = subItem.HisProject.ProjectName
  5847. order.Cnt = subItem.Count
  5848. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5849. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5850. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5851. order.OwnpayAmt = ""
  5852. order.SelfpayAmt = ""
  5853. order.Spec = ""
  5854. order.SpecUnt = ""
  5855. order.DrordBegnDate = s_tm
  5856. order.DrordStopDate = ""
  5857. order.DrordDrCodg = doctor_info.DoctorNumber
  5858. order.DrordDeptName = department.Name
  5859. order.DrordDeptCodg = department.Number
  5860. order.DrordDrName = doctor_info.UserName
  5861. order.DrordDrProfttl = "234"
  5862. order.CurrDrordFlag = "1"
  5863. orders = append(orders, &order)
  5864. }
  5865. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5866. var order models.FsiOrderDtos
  5867. order.RxID = strconv.FormatInt(item.ID, 10)
  5868. order.Rxno = strconv.FormatInt(item.ID, 10)
  5869. order.LongDrordFlag = "0"
  5870. order.HilistType = "1"
  5871. order.ChrgType = "1"
  5872. order.DrordBhvr = "-"
  5873. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5874. order.HosplistName = subItem.GoodInfo.GoodName
  5875. order.HilistLv = "1"
  5876. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5877. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5878. order.HosplistName = subItem.GoodInfo.GoodName
  5879. order.Cnt = subItem.Count
  5880. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5881. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5882. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5883. order.OwnpayAmt = ""
  5884. order.SelfpayAmt = ""
  5885. order.Spec = ""
  5886. order.SpecUnt = ""
  5887. order.DrordBegnDate = s_tm
  5888. order.DrordStopDate = ""
  5889. order.DrordDrCodg = doctor_info.DoctorNumber
  5890. order.DrordDeptName = department.Name
  5891. order.DrordDeptCodg = department.Number
  5892. order.DrordDrName = doctor_info.UserName
  5893. order.DrordDrProfttl = "234"
  5894. order.CurrDrordFlag = "1"
  5895. orders = append(orders, &order)
  5896. }
  5897. }
  5898. }
  5899. //处方医嘱信息
  5900. }
  5901. fed.MatnStas = "0"
  5902. fed.MedfeeSumamt = "0"
  5903. fed.OwnpayAmt = "0"
  5904. fed.SelfpayAmt = "0"
  5905. fed.AcctPayamt = "0"
  5906. fed.MaAmt = "0"
  5907. fed.HifpPayamt = "0"
  5908. fed.SetlTotlnum = "1"
  5909. fed.Insutype = his.Insutype
  5910. fed.ReimFlag = "0"
  5911. fed.OutSetlFlag = "0"
  5912. var fopd []*models.FsiOperationDtosData
  5913. data := make(map[string]interface{})
  5914. data["fed"] = fed
  5915. data["fdd"] = fdds
  5916. data["fod"] = orders
  5917. data["pd"] = pd
  5918. data["pp"] = pp
  5919. data["fopd"] = fopd
  5920. data["trig_scen"] = trig_scen
  5921. fmt.Println(data)
  5922. fmt.Println(fed)
  5923. fmt.Println(fdds)
  5924. fmt.Println(orders)
  5925. fmt.Println(pd)
  5926. fmt.Println(pp)
  5927. fmt.Println(fopd)
  5928. client := &http.Client{}
  5929. bytesData, _ := json.Marshal(data)
  5930. var req *http.Request
  5931. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5932. if miConfig.MdtrtareaAdmvs == "320921" {
  5933. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5934. } else {
  5935. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5936. }
  5937. resp, _ := client.Do(req)
  5938. defer resp.Body.Close()
  5939. body, ioErr := ioutil.ReadAll(resp.Body)
  5940. if ioErr != nil {
  5941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5943. return res
  5944. }
  5945. var respJSON map[string]interface{}
  5946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5949. return res
  5950. }
  5951. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5952. fmt.Println(respJSON)
  5953. result, _ := json.Marshal(respJSON)
  5954. fmt.Println(result)
  5955. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5956. utils.ErrorLog("解析失败:%v", err)
  5957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5958. return res
  5959. }
  5960. return res
  5961. } else {
  5962. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5963. saveLog(output, input, "3101", "事前")
  5964. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5965. utils.ErrorLog("解析失败:%v", err)
  5966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5967. return
  5968. }
  5969. return res
  5970. }
  5971. return res
  5972. }
  5973. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5974. ////patient_id, _ := c.GetInt64("patient_id")
  5975. //order_id, _ := c.GetInt64("order_id")
  5976. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5977. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5978. //trig_scen := c.GetString("trig_scen")
  5979. adminUser := c.GetAdminUserInfo()
  5980. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5981. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5982. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5983. record_time := c.GetString("record_time")
  5984. order, _ := service.GetHisOrderByID(order_id)
  5985. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5986. timeLayout := "2006-01-02"
  5987. loc, _ := time.LoadLocation("Local")
  5988. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5989. if err != nil {
  5990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5991. return
  5992. }
  5993. recordDateTime := theTime.Unix()
  5994. var patientPrescription models.HisPrescriptionInfo
  5995. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5996. if patientPrescription.ID == 0 {
  5997. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5998. }
  5999. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6000. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6001. //
  6002. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6003. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6004. var pp models.PublicParams
  6005. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6006. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6007. pp.FixmedinsName = miConfig.OrgName
  6008. pp.FixmedinsCode = miConfig.Code
  6009. pp.RequestUrl = miConfig.Url
  6010. pp.Cainfo = miConfig.Cainfo
  6011. pp.SecretKey = miConfig.SecretKey
  6012. pp.AccessKey = miConfig.AccessKey
  6013. pp.OpterName = roles.UserName
  6014. var config []*models.HisXtDiagnoseConfig
  6015. for _, item := range diagnosis_ids {
  6016. id, _ := strconv.ParseInt(item, 10, 64)
  6017. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6018. config = append(config, &diagnosisConfig)
  6019. }
  6020. var pd models.PatientDtos
  6021. pd.PatnID = his.PsnNo
  6022. pd.PatnName = his.Name
  6023. pd.Gend = his.Gend
  6024. pd.Brdy = psn_info.Brdy
  6025. pd.Poolarea = his.InsuplcAdmdvs
  6026. pd.CurrMdtrtID = his.Number
  6027. var fed models.FsiEncounterDtos
  6028. fed.MdtrtID = his.Number
  6029. fed.MedinsID = miConfig.Code
  6030. fed.MedinsName = miConfig.OrgName
  6031. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6032. fed.MedMdtrtType = "1"
  6033. fed.MedinsType = "1"
  6034. fed.MedinsLv = "11"
  6035. tm := time.Unix(his.RecordDate, 0)
  6036. s_tm := tm.Format("2006-01-02 15:04:05")
  6037. fed.AdmDate = s_tm
  6038. fed.DscgDate = s_tm
  6039. fed.DscgMainDiseCodg = config[0].CountryCode
  6040. fed.DscgMainDiseName = config[0].CountryContentName
  6041. //诊断信息
  6042. var fdds []*models.FsiDiagnoseDtos
  6043. for index, item := range config {
  6044. if index == 0 {
  6045. var fdd models.FsiDiagnoseDtos
  6046. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6047. fdd.InoutDiseType = "1"
  6048. fdd.MaindiseFlag = "1"
  6049. fdd.DiseDate = s_tm
  6050. fdd.DiasSrtNo = "1"
  6051. fdd.DiseName = item.CountryContentName
  6052. fdd.DiseCodg = item.CountryCode
  6053. fdds = append(fdds, &fdd)
  6054. } else {
  6055. var fdd models.FsiDiagnoseDtos
  6056. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6057. fdd.InoutDiseType = "1"
  6058. fdd.MaindiseFlag = "1"
  6059. fdd.DiseDate = s_tm
  6060. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6061. fdd.DiseName = item.CountryContentName
  6062. fdd.DiseCodg = item.CountryCode
  6063. fdds = append(fdds, &fdd)
  6064. }
  6065. }
  6066. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6067. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6068. fed.AdmDeptName = department.Name
  6069. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6070. fed.DscgDeptName = department.Name
  6071. fed.MedType = order.MedType
  6072. //处方医嘱信息
  6073. var orders []*models.FsiOrderDtos
  6074. //for _, item := range prescriptions {
  6075. // for _, subItem := range item.HisDoctorAdviceInfo {
  6076. // var order models.FsiOrderDtos
  6077. // order.RxID = strconv.FormatInt(item.ID, 10)
  6078. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6079. // order.LongDrordFlag = "0"
  6080. // order.HilistType = "1"
  6081. // order.ChrgType = "1"
  6082. // order.DrordBhvr = "-"
  6083. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6084. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6085. // order.HilistLv = "1"
  6086. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6087. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6088. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6089. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6090. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6091. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6092. // order.OwnpayAmt = ""
  6093. // order.SelfpayAmt = ""
  6094. // order.Spec = ""
  6095. // order.SpecUnt = ""
  6096. // order.DrordBegnDate = s_tm
  6097. // order.DrordStopDate = ""
  6098. // order.DrordDrCodg = "1"
  6099. // order.DrordDeptName = department.Name
  6100. // order.DrordDrCodg = "1"
  6101. // order.DrordDrName = doctor_info.UserName
  6102. // order.DrordDrProfttl = ""
  6103. // order.CurrDrordFlag = "1"
  6104. // orders = append(orders, &order)
  6105. // }
  6106. // for _, subItem := range item.HisPrescriptionProject {
  6107. // if subItem.Type == 2 {
  6108. // var order models.FsiOrderDtos
  6109. // order.RxID = strconv.FormatInt(item.ID, 10)
  6110. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6111. // order.LongDrordFlag = "0"
  6112. // order.HilistType = "1"
  6113. // order.ChrgType = "1"
  6114. // order.DrordBhvr = "-"
  6115. // order.HilistCode = subItem.HisProject.MedicalCode
  6116. // order.HosplistName = subItem.HisProject.ProjectName
  6117. // order.HilistLv = "1"
  6118. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6119. // order.HosplistCode = subItem.HisProject.MedicalCode
  6120. // order.HosplistName = subItem.HisProject.ProjectName
  6121. // order.Cnt = subItem.Count
  6122. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6123. //
  6124. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6125. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6126. // order.OwnpayAmt = ""
  6127. // order.SelfpayAmt = ""
  6128. // order.Spec = ""
  6129. // order.SpecUnt = ""
  6130. // order.DrordBegnDate = s_tm
  6131. // order.DrordStopDate = ""
  6132. // order.DrordDrCodg = "1"
  6133. // order.DrordDeptName = department.Name
  6134. // order.DrordDrCodg = "1"
  6135. // order.DrordDrName = doctor_info.UserName
  6136. // order.DrordDrProfttl = ""
  6137. // order.CurrDrordFlag = "1"
  6138. // orders = append(orders, &order)
  6139. //
  6140. // }
  6141. // if subItem.Type == 3 {
  6142. //
  6143. // var order models.FsiOrderDtos
  6144. // order.RxID = strconv.FormatInt(item.ID, 10)
  6145. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6146. // order.LongDrordFlag = "0"
  6147. // order.HilistType = "1"
  6148. // order.ChrgType = "1"
  6149. // order.DrordBhvr = "-"
  6150. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6151. // order.HosplistName = subItem.GoodInfo.GoodName
  6152. // order.HilistLv = "1"
  6153. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6154. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6155. // order.HosplistName = subItem.GoodInfo.GoodName
  6156. // order.Cnt = subItem.Count
  6157. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6158. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6159. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6160. // order.OwnpayAmt = ""
  6161. // order.SelfpayAmt = ""
  6162. // order.Spec = ""
  6163. // order.SpecUnt = ""
  6164. // order.DrordBegnDate = s_tm
  6165. // order.DrordStopDate = ""
  6166. // order.DrordDrCodg = "1"
  6167. // order.DrordDeptName = department.Name
  6168. // order.DrordDrCodg = "1"
  6169. // order.DrordDrName = doctor_info.UserName
  6170. // order.DrordDrProfttl = ""
  6171. // order.CurrDrordFlag = "1"
  6172. // orders = append(orders, &order)
  6173. //
  6174. // }
  6175. // }
  6176. //}
  6177. for _, item := range prescriptions {
  6178. for _, subItem := range item.HisDoctorAdviceInfo {
  6179. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6180. var order models.FsiOrderDtos
  6181. order.RxID = strconv.FormatInt(item.ID, 10)
  6182. order.Rxno = strconv.FormatInt(item.ID, 10)
  6183. order.LongDrordFlag = "0"
  6184. order.HilistType = "1"
  6185. order.ChrgType = "1"
  6186. order.DrordBhvr = "-"
  6187. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6188. order.HosplistName = subItem.BaseDrugLib.DrugName
  6189. order.HilistLv = "1"
  6190. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6191. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6192. order.HosplistName = subItem.BaseDrugLib.DrugName
  6193. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6194. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6195. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6196. order.OwnpayAmt = ""
  6197. order.SelfpayAmt = ""
  6198. order.Spec = ""
  6199. order.SpecUnt = ""
  6200. order.DrordBegnDate = s_tm
  6201. order.DrordStopDate = ""
  6202. order.DrordDrCodg = doctor_info.DoctorNumber
  6203. order.DrordDeptName = department.Name
  6204. order.DrordDeptCodg = department.Number
  6205. order.DrordDrName = doctor_info.UserName
  6206. order.DrordDrProfttl = "234"
  6207. order.CurrDrordFlag = "1"
  6208. orders = append(orders, &order)
  6209. }
  6210. }
  6211. for _, subItem := range item.HisPrescriptionProject {
  6212. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6213. var order models.FsiOrderDtos
  6214. order.RxID = strconv.FormatInt(item.ID, 10)
  6215. order.Rxno = strconv.FormatInt(item.ID, 10)
  6216. order.LongDrordFlag = "0"
  6217. order.HilistType = "1"
  6218. order.ChrgType = "1"
  6219. order.DrordBhvr = "-"
  6220. order.HilistCode = subItem.HisProject.MedicalCode
  6221. order.HosplistName = subItem.HisProject.ProjectName
  6222. order.HilistLv = "1"
  6223. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6224. order.HosplistCode = subItem.HisProject.MedicalCode
  6225. order.HosplistName = subItem.HisProject.ProjectName
  6226. order.Cnt = subItem.Count
  6227. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6228. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6229. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6230. order.OwnpayAmt = ""
  6231. order.SelfpayAmt = ""
  6232. order.Spec = ""
  6233. order.SpecUnt = ""
  6234. order.DrordBegnDate = s_tm
  6235. order.DrordStopDate = ""
  6236. order.DrordDrCodg = doctor_info.DoctorNumber
  6237. order.DrordDeptName = department.Name
  6238. order.DrordDeptCodg = department.Number
  6239. order.DrordDrName = doctor_info.UserName
  6240. order.DrordDrProfttl = "234"
  6241. order.CurrDrordFlag = "1"
  6242. orders = append(orders, &order)
  6243. }
  6244. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6245. var order models.FsiOrderDtos
  6246. order.RxID = strconv.FormatInt(item.ID, 10)
  6247. order.Rxno = strconv.FormatInt(item.ID, 10)
  6248. order.LongDrordFlag = "0"
  6249. order.HilistType = "1"
  6250. order.ChrgType = "1"
  6251. order.DrordBhvr = "0"
  6252. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6253. order.HosplistName = subItem.GoodInfo.GoodName
  6254. order.HilistLv = "1"
  6255. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6256. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6257. order.HosplistName = subItem.GoodInfo.GoodName
  6258. order.Cnt = subItem.Count
  6259. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6260. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6261. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6262. order.OwnpayAmt = ""
  6263. order.SelfpayAmt = ""
  6264. order.Spec = ""
  6265. order.SpecUnt = ""
  6266. order.DrordBegnDate = s_tm
  6267. order.DrordStopDate = ""
  6268. order.DrordDrCodg = doctor_info.DoctorNumber
  6269. order.DrordDeptName = department.Name
  6270. order.DrordDeptCodg = department.Number
  6271. order.DrordDrName = doctor_info.UserName
  6272. order.DrordDrProfttl = "234"
  6273. order.CurrDrordFlag = "1"
  6274. orders = append(orders, &order)
  6275. }
  6276. }
  6277. }
  6278. //处方医嘱信息
  6279. fed.MatnStas = "0"
  6280. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6281. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6282. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6283. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6284. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6285. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6286. fed.SetlTotlnum = "1"
  6287. fed.Insutype = his.Insutype
  6288. fed.ReimFlag = "0"
  6289. fed.OutSetlFlag = "0"
  6290. var fopd []*models.FsiOperationDtosData
  6291. data := make(map[string]interface{})
  6292. data["fed"] = fed
  6293. data["fdd"] = fdds
  6294. data["fod"] = orders
  6295. data["pd"] = pd
  6296. data["pp"] = pp
  6297. data["fopd"] = fopd
  6298. data["trig_scen"] = trig_scen
  6299. client := &http.Client{}
  6300. bytesData, _ := json.Marshal(data)
  6301. var req *http.Request
  6302. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6303. if miConfig.MdtrtareaAdmvs == "320921" {
  6304. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6305. } else {
  6306. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6307. }
  6308. resp, _ := client.Do(req)
  6309. defer resp.Body.Close()
  6310. body, ioErr := ioutil.ReadAll(resp.Body)
  6311. if ioErr != nil {
  6312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6314. return res
  6315. }
  6316. var respJSON map[string]interface{}
  6317. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6320. return res
  6321. }
  6322. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6323. result, _ := json.Marshal(respJSON)
  6324. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6325. utils.ErrorLog("解析失败:%v", err)
  6326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6327. return res
  6328. }
  6329. return res
  6330. } else {
  6331. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6332. saveLog(output, input, "3102", "事中")
  6333. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6334. utils.ErrorLog("解析失败:%v", err)
  6335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6336. return
  6337. }
  6338. return res
  6339. }
  6340. return res
  6341. }
  6342. 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) {
  6343. var res Resultgd3101
  6344. adminUser := c.GetAdminUserInfo()
  6345. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6346. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6347. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6348. //record_time := c.GetString("record_time")
  6349. //trig_scen := c.GetString("trig_scen")
  6350. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6351. timeLayout := "2006-01-02"
  6352. loc, _ := time.LoadLocation("Local")
  6353. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6354. if err != nil {
  6355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6356. return res
  6357. }
  6358. recordDateTime := theTime.Unix()
  6359. var patientPrescription models.HisPrescriptionInfo
  6360. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6361. //if patientPrescription.ID == 0 {
  6362. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6363. //}
  6364. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6365. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6366. //
  6367. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6368. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6369. var pp models.PublicParams
  6370. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6371. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6372. pp.FixmedinsName = miConfig.OrgName
  6373. pp.FixmedinsCode = miConfig.Code
  6374. pp.RequestUrl = miConfig.Url
  6375. pp.Cainfo = miConfig.Cainfo
  6376. pp.SecretKey = miConfig.SecretKey
  6377. pp.AccessKey = miConfig.AccessKey
  6378. pp.OpterName = roles.UserName
  6379. var config []*models.HisXtDiagnoseConfig
  6380. for _, item := range diagnosis_ids {
  6381. id, _ := strconv.ParseInt(item, 10, 64)
  6382. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6383. config = append(config, &diagnosisConfig)
  6384. }
  6385. var pd models.PatientDtos
  6386. pd.PatnID = his.PsnNo
  6387. pd.PatnName = his.Name
  6388. pd.Gend = his.Gend
  6389. pd.Brdy = psn_info.Brdy
  6390. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6391. pd.CurrMdtrtID = his.Number
  6392. var fed models.FsiEncounterDtos
  6393. fed.MdtrtID = his.Number
  6394. fed.MedinsID = miConfig.Code
  6395. fed.MedinsName = miConfig.OrgName
  6396. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6397. fed.MedMdtrtType = "1"
  6398. fed.MedinsType = "1"
  6399. fed.MedinsLv = "11"
  6400. tm := time.Unix(his.RecordDate, 0)
  6401. s_tm := tm.Format("2006-01-02 15:04:05")
  6402. fed.AdmDate = s_tm
  6403. fed.DscgDate = s_tm
  6404. fed.DscgMainDiseCodg = config[0].CountryCode
  6405. fed.DscgMainDiseName = config[0].CountryContentName
  6406. //诊断信息
  6407. var fdds []*models.FsiDiagnoseDtos
  6408. for index, item := range config {
  6409. if index == 0 {
  6410. var fdd models.FsiDiagnoseDtos
  6411. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6412. fdd.InoutDiseType = "1"
  6413. fdd.MaindiseFlag = "1"
  6414. fdd.DiseDate = s_tm
  6415. fdd.DiasSrtNo = "1"
  6416. fdd.DiseName = item.CountryContentName
  6417. fdd.DiseCodg = item.CountryCode
  6418. fdds = append(fdds, &fdd)
  6419. } else {
  6420. var fdd models.FsiDiagnoseDtos
  6421. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6422. fdd.InoutDiseType = "1"
  6423. fdd.MaindiseFlag = "1"
  6424. fdd.DiseDate = s_tm
  6425. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6426. fdd.DiseName = item.CountryContentName
  6427. fdd.DiseCodg = item.CountryCode
  6428. fdds = append(fdds, &fdd)
  6429. }
  6430. }
  6431. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6432. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6433. fed.AdmDeptName = department.Name
  6434. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6435. fed.DscgDeptName = department.Name
  6436. fed.MedMdtrtType = "1"
  6437. fed.MedType = "11"
  6438. //if his.Insutype == "390" {
  6439. // fed.MedType = "1402"
  6440. //} else {
  6441. // fed.MedType = "9933"
  6442. //}
  6443. var orders []*models.FsiOrderDtos
  6444. if trig_scen == "2" {
  6445. //处方医嘱信息
  6446. for _, item := range prescriptions {
  6447. for _, subItem := range item.HisDoctorAdviceInfo {
  6448. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6449. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6450. var order models.FsiOrderDtos
  6451. order.RxID = strconv.FormatInt(item.ID, 10)
  6452. order.Rxno = strconv.FormatInt(item.ID, 10)
  6453. order.LongDrordFlag = "0"
  6454. order.HilistType = "1"
  6455. order.ChrgType = "1"
  6456. order.DrordBhvr = "0"
  6457. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6458. order.HosplistName = subItem.BaseDrugLib.DrugName
  6459. order.HilistLv = "1"
  6460. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6461. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6462. order.HosplistName = subItem.BaseDrugLib.DrugName
  6463. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6464. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6465. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6466. order.OwnpayAmt = ""
  6467. order.SelfpayAmt = ""
  6468. order.Spec = spec
  6469. order.SpecUnt = subItem.PrescribingNumberUnit
  6470. order.DrordBegnDate = s_tm
  6471. order.DrordStopDate = ""
  6472. order.DrordDrCodg = doctor_info.DoctorNumber
  6473. order.DrordDeptName = department.Name
  6474. order.DrordDeptCodg = department.Number
  6475. order.DrordDrName = doctor_info.UserName
  6476. order.DrordDrProfttl = "234"
  6477. order.CurrDrordFlag = "1"
  6478. orders = append(orders, &order)
  6479. }
  6480. }
  6481. for _, subItem := range item.HisPrescriptionProject {
  6482. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6483. var order models.FsiOrderDtos
  6484. order.RxID = strconv.FormatInt(item.ID, 10)
  6485. order.Rxno = strconv.FormatInt(item.ID, 10)
  6486. order.LongDrordFlag = "0"
  6487. order.HilistType = "1"
  6488. order.ChrgType = "1"
  6489. order.DrordBhvr = "0"
  6490. order.HilistCode = subItem.HisProject.MedicalCode
  6491. order.HosplistName = subItem.HisProject.ProjectName
  6492. order.HilistLv = "1"
  6493. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6494. order.HosplistCode = subItem.HisProject.MedicalCode
  6495. order.HosplistName = subItem.HisProject.ProjectName
  6496. order.Cnt = subItem.Count
  6497. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6498. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6499. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6500. order.OwnpayAmt = ""
  6501. order.SelfpayAmt = ""
  6502. order.Spec = subItem.Unit
  6503. order.SpecUnt = subItem.Unit
  6504. order.DrordBegnDate = s_tm
  6505. order.DrordStopDate = ""
  6506. order.DrordDrCodg = doctor_info.DoctorNumber
  6507. order.DrordDeptName = department.Name
  6508. order.DrordDeptCodg = department.Number
  6509. order.DrordDrName = doctor_info.UserName
  6510. order.DrordDrProfttl = "234"
  6511. order.CurrDrordFlag = "1"
  6512. orders = append(orders, &order)
  6513. }
  6514. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6515. var order models.FsiOrderDtos
  6516. order.RxID = strconv.FormatInt(item.ID, 10)
  6517. order.Rxno = strconv.FormatInt(item.ID, 10)
  6518. order.LongDrordFlag = "0"
  6519. order.HilistType = "1"
  6520. order.ChrgType = "1"
  6521. order.DrordBhvr = "0"
  6522. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6523. order.HosplistName = subItem.GoodInfo.GoodName
  6524. order.HilistLv = "1"
  6525. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6526. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6527. order.HosplistName = subItem.GoodInfo.GoodName
  6528. order.Cnt = subItem.Count
  6529. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6530. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6531. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6532. order.OwnpayAmt = ""
  6533. order.SelfpayAmt = ""
  6534. order.Spec = subItem.GoodInfo.SpecificationName
  6535. order.SpecUnt = subItem.Unit
  6536. order.DrordBegnDate = s_tm
  6537. order.DrordStopDate = ""
  6538. order.DrordDrCodg = doctor_info.DoctorNumber
  6539. order.DrordDeptName = department.Name
  6540. order.DrordDeptCodg = department.Number
  6541. order.DrordDrName = doctor_info.UserName
  6542. order.DrordDrProfttl = "234"
  6543. order.CurrDrordFlag = "1"
  6544. orders = append(orders, &order)
  6545. }
  6546. }
  6547. }
  6548. //处方医嘱信息
  6549. }
  6550. fed.MatnStas = "0"
  6551. fed.MedfeeSumamt = "0"
  6552. fed.OwnpayAmt = "0"
  6553. fed.SelfpayAmt = "0"
  6554. fed.AcctPayamt = "0"
  6555. fed.MaAmt = "0"
  6556. fed.HifpPayamt = "0"
  6557. fed.SetlTotlnum = "1"
  6558. fed.Insutype = his.Insutype
  6559. fed.ReimFlag = "0"
  6560. fed.OutSetlFlag = "0"
  6561. var fopd []*models.FsiOperationDtosData
  6562. data := make(map[string]interface{})
  6563. data["fed"] = fed
  6564. data["fdd"] = fdds
  6565. data["fod"] = orders
  6566. data["pd"] = pd
  6567. data["pp"] = pp
  6568. data["fopd"] = fopd
  6569. data["trig_scen"] = trig_scen
  6570. fmt.Println(data)
  6571. fmt.Println(fed)
  6572. fmt.Println(fdds)
  6573. fmt.Println(orders)
  6574. fmt.Println(pd)
  6575. fmt.Println(pp)
  6576. fmt.Println(fopd)
  6577. client := &http.Client{}
  6578. bytesData, _ := json.Marshal(data)
  6579. var req *http.Request
  6580. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6581. if miConfig.MdtrtareaAdmvs == "320921" {
  6582. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6583. } else {
  6584. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6585. }
  6586. resp, _ := client.Do(req)
  6587. defer resp.Body.Close()
  6588. body, ioErr := ioutil.ReadAll(resp.Body)
  6589. if ioErr != nil {
  6590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6592. return res
  6593. }
  6594. var respJSON map[string]interface{}
  6595. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6598. return res
  6599. }
  6600. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6601. fmt.Println(respJSON)
  6602. result, _ := json.Marshal(respJSON)
  6603. fmt.Println(result)
  6604. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6605. utils.ErrorLog("解析失败:%v", err)
  6606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6607. return res
  6608. }
  6609. return res
  6610. } else {
  6611. //if miConfig.MdtrtareaAdmvs == "441202" {
  6612. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6613. saveLog(output, input, "3101", "事前")
  6614. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6615. utils.ErrorLog("解析失败:%v", err)
  6616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6617. return
  6618. }
  6619. return res
  6620. //}
  6621. }
  6622. }
  6623. 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) {
  6624. adminUser := c.GetAdminUserInfo()
  6625. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6626. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6627. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6628. //record_time := c.GetString("record_time")
  6629. //trig_scen := c.GetString("trig_scen")
  6630. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6631. timeLayout := "2006-01-02"
  6632. loc, _ := time.LoadLocation("Local")
  6633. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6634. if err != nil {
  6635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6636. return res
  6637. }
  6638. recordDateTime := theTime.Unix()
  6639. var patientPrescription models.HisPrescriptionInfo
  6640. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6641. if patientPrescription.ID == 0 {
  6642. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6643. }
  6644. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6645. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6646. //
  6647. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6648. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6649. var pp models.PublicParams
  6650. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6651. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6652. pp.FixmedinsName = miConfig.OrgName
  6653. pp.FixmedinsCode = miConfig.Code
  6654. pp.RequestUrl = miConfig.Url
  6655. pp.Cainfo = miConfig.Cainfo
  6656. pp.SecretKey = miConfig.SecretKey
  6657. pp.AccessKey = miConfig.AccessKey
  6658. pp.OpterName = roles.UserName
  6659. var config []*models.HisXtDiagnoseConfig
  6660. for _, item := range diagnosis_ids {
  6661. id, _ := strconv.ParseInt(item, 10, 64)
  6662. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6663. config = append(config, &diagnosisConfig)
  6664. }
  6665. var pd models.PatientDtos
  6666. pd.PatnID = his.PsnNo
  6667. pd.PatnName = his.Name
  6668. pd.Gend = his.Gend
  6669. pd.Brdy = psn_info.Brdy
  6670. pd.Poolarea = his.InsuplcAdmdvs
  6671. pd.CurrMdtrtID = his.Number
  6672. var fed models.FsiEncounterDtos
  6673. fed.MdtrtID = his.Number
  6674. fed.MedinsID = miConfig.Code
  6675. fed.MedinsName = miConfig.OrgName
  6676. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6677. fed.MedMdtrtType = "1"
  6678. fed.MedinsType = "1"
  6679. fed.MedinsLv = "11"
  6680. tm := time.Unix(his.RecordDate, 0)
  6681. s_tm := tm.Format("2006-01-02 15:04:05")
  6682. fed.AdmDate = s_tm
  6683. fed.DscgDate = s_tm
  6684. fed.DscgMainDiseCodg = config[0].CountryCode
  6685. fed.DscgMainDiseName = config[0].CountryContentName
  6686. //诊断信息
  6687. var fdds []*models.FsiDiagnoseDtos
  6688. for index, item := range config {
  6689. if index == 0 {
  6690. var fdd models.FsiDiagnoseDtos
  6691. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6692. fdd.InoutDiseType = "1"
  6693. fdd.MaindiseFlag = "1"
  6694. fdd.DiseDate = s_tm
  6695. fdd.DiasSrtNo = "1"
  6696. fdd.DiseName = item.CountryContentName
  6697. fdd.DiseCodg = item.CountryCode
  6698. fdds = append(fdds, &fdd)
  6699. } else {
  6700. var fdd models.FsiDiagnoseDtos
  6701. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6702. fdd.InoutDiseType = "1"
  6703. fdd.MaindiseFlag = "1"
  6704. fdd.DiseDate = s_tm
  6705. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6706. fdd.DiseName = item.CountryContentName
  6707. fdd.DiseCodg = item.CountryCode
  6708. fdds = append(fdds, &fdd)
  6709. }
  6710. }
  6711. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6712. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6713. fed.AdmDeptName = department.Name
  6714. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6715. fed.DscgDeptName = department.Name
  6716. fed.MedMdtrtType = "1"
  6717. fed.MedType = "11"
  6718. //if his.Insutype == "390" {
  6719. // fed.MedType = "1402"
  6720. //} else {
  6721. // fed.MedType = "9933"
  6722. //}
  6723. var orders []*models.FsiOrderDtos
  6724. if trig_scen == "2" {
  6725. //处方医嘱信息
  6726. for _, item := range prescriptions {
  6727. for _, subItem := range item.HisDoctorAdviceInfo {
  6728. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6729. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6730. var order models.FsiOrderDtos
  6731. order.RxID = strconv.FormatInt(item.ID, 10)
  6732. order.Rxno = strconv.FormatInt(item.ID, 10)
  6733. order.LongDrordFlag = "0"
  6734. order.HilistType = "1"
  6735. order.ChrgType = "1"
  6736. order.DrordBhvr = "0"
  6737. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6738. order.HosplistName = subItem.BaseDrugLib.DrugName
  6739. order.HilistLv = "1"
  6740. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6741. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6742. order.HosplistName = subItem.BaseDrugLib.DrugName
  6743. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6744. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6745. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6746. order.OwnpayAmt = ""
  6747. order.SelfpayAmt = ""
  6748. order.Spec = spec
  6749. order.SpecUnt = subItem.PrescribingNumberUnit
  6750. order.DrordBegnDate = s_tm
  6751. order.DrordStopDate = ""
  6752. order.DrordDrCodg = doctor_info.DoctorNumber
  6753. order.DrordDeptName = department.Name
  6754. order.DrordDeptCodg = department.Number
  6755. order.DrordDrName = doctor_info.UserName
  6756. order.DrordDrProfttl = "234"
  6757. order.CurrDrordFlag = "1"
  6758. orders = append(orders, &order)
  6759. }
  6760. }
  6761. for _, subItem := range item.HisPrescriptionProject {
  6762. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6763. var order models.FsiOrderDtos
  6764. order.RxID = strconv.FormatInt(item.ID, 10)
  6765. order.Rxno = strconv.FormatInt(item.ID, 10)
  6766. order.LongDrordFlag = "0"
  6767. order.HilistType = "1"
  6768. order.ChrgType = "1"
  6769. order.DrordBhvr = "0"
  6770. order.HilistCode = subItem.HisProject.MedicalCode
  6771. order.HosplistName = subItem.HisProject.ProjectName
  6772. order.HilistLv = "1"
  6773. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6774. order.HosplistCode = subItem.HisProject.MedicalCode
  6775. order.HosplistName = subItem.HisProject.ProjectName
  6776. order.Cnt = subItem.Count
  6777. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6778. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6779. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6780. order.OwnpayAmt = ""
  6781. order.SelfpayAmt = ""
  6782. order.Spec = subItem.Unit
  6783. order.SpecUnt = subItem.Unit
  6784. order.DrordBegnDate = s_tm
  6785. order.DrordStopDate = ""
  6786. order.DrordDrCodg = doctor_info.DoctorNumber
  6787. order.DrordDeptName = department.Name
  6788. order.DrordDeptCodg = department.Number
  6789. order.DrordDrName = doctor_info.UserName
  6790. order.DrordDrProfttl = "234"
  6791. order.CurrDrordFlag = "1"
  6792. orders = append(orders, &order)
  6793. }
  6794. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6795. var order models.FsiOrderDtos
  6796. order.RxID = strconv.FormatInt(item.ID, 10)
  6797. order.Rxno = strconv.FormatInt(item.ID, 10)
  6798. order.LongDrordFlag = "0"
  6799. order.HilistType = "1"
  6800. order.ChrgType = "1"
  6801. order.DrordBhvr = "0"
  6802. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6803. order.HosplistName = subItem.GoodInfo.GoodName
  6804. order.HilistLv = "1"
  6805. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6806. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6807. order.HosplistName = subItem.GoodInfo.GoodName
  6808. order.Cnt = subItem.Count
  6809. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6810. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6811. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6812. order.OwnpayAmt = ""
  6813. order.SelfpayAmt = ""
  6814. order.Spec = subItem.GoodInfo.SpecificationName
  6815. order.SpecUnt = subItem.Unit
  6816. order.DrordBegnDate = s_tm
  6817. order.DrordStopDate = ""
  6818. order.DrordDrCodg = doctor_info.DoctorNumber
  6819. order.DrordDeptName = department.Name
  6820. order.DrordDeptCodg = department.Number
  6821. order.DrordDrName = doctor_info.UserName
  6822. order.DrordDrProfttl = "234"
  6823. order.CurrDrordFlag = "1"
  6824. orders = append(orders, &order)
  6825. }
  6826. }
  6827. }
  6828. //处方医嘱信息
  6829. }
  6830. fed.MatnStas = "0"
  6831. fed.MedfeeSumamt = "0"
  6832. fed.OwnpayAmt = "0"
  6833. fed.SelfpayAmt = "0"
  6834. fed.AcctPayamt = "0"
  6835. fed.MaAmt = "0"
  6836. fed.HifpPayamt = "0"
  6837. fed.SetlTotlnum = "1"
  6838. fed.Insutype = his.Insutype
  6839. fed.ReimFlag = "0"
  6840. fed.OutSetlFlag = "0"
  6841. var fopd []*models.FsiOperationDtosData
  6842. data := make(map[string]interface{})
  6843. data["fed"] = fed
  6844. data["fdd"] = fdds
  6845. data["fod"] = orders
  6846. data["pd"] = pd
  6847. data["pp"] = pp
  6848. data["fopd"] = fopd
  6849. data["trig_scen"] = trig_scen
  6850. fmt.Println(data)
  6851. fmt.Println(fed)
  6852. fmt.Println(fdds)
  6853. fmt.Println(orders)
  6854. fmt.Println(pd)
  6855. fmt.Println(pp)
  6856. fmt.Println(fopd)
  6857. client := &http.Client{}
  6858. bytesData, _ := json.Marshal(data)
  6859. var req *http.Request
  6860. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6861. if miConfig.MdtrtareaAdmvs == "320921" {
  6862. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6863. } else {
  6864. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6865. }
  6866. resp, _ := client.Do(req)
  6867. defer resp.Body.Close()
  6868. body, ioErr := ioutil.ReadAll(resp.Body)
  6869. if ioErr != nil {
  6870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6872. return res
  6873. }
  6874. var respJSON map[string]interface{}
  6875. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6878. return res
  6879. }
  6880. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6881. fmt.Println(respJSON)
  6882. result, _ := json.Marshal(respJSON)
  6883. fmt.Println(result)
  6884. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6885. utils.ErrorLog("解析失败:%v", err)
  6886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6887. return res
  6888. }
  6889. return res
  6890. } else {
  6891. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6892. saveLog(output, input, "3101", "事前")
  6893. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6894. utils.ErrorLog("解析失败:%v", err)
  6895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6896. return
  6897. }
  6898. return res
  6899. }
  6900. return res
  6901. }
  6902. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6903. ////patient_id, _ := c.GetInt64("patient_id")
  6904. //order_id, _ := c.GetInt64("order_id")
  6905. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6906. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6907. //trig_scen := c.GetString("trig_scen")
  6908. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6909. utils.ErrorLog("解析失败:%v", psn_info)
  6910. adminUser := c.GetAdminUserInfo()
  6911. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6912. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6913. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6914. record_time := c.GetString("record_time")
  6915. order, _ := service.GetHisOrderByID(order_id)
  6916. timeLayout := "2006-01-02"
  6917. loc, _ := time.LoadLocation("Local")
  6918. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6919. if err != nil {
  6920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6921. return
  6922. }
  6923. recordDateTime := theTime.Unix()
  6924. var patientPrescription models.HisPrescriptionInfo
  6925. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6926. if patientPrescription.ID == 0 {
  6927. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6928. }
  6929. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6930. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6931. //
  6932. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6933. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6934. var pp models.PublicParams
  6935. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6936. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6937. pp.FixmedinsName = miConfig.OrgName
  6938. pp.FixmedinsCode = miConfig.Code
  6939. pp.RequestUrl = miConfig.Url
  6940. pp.Cainfo = miConfig.Cainfo
  6941. pp.SecretKey = miConfig.SecretKey
  6942. pp.AccessKey = miConfig.AccessKey
  6943. pp.OpterName = roles.UserName
  6944. var config []*models.HisXtDiagnoseConfig
  6945. for _, item := range diagnosis_ids {
  6946. id, _ := strconv.ParseInt(item, 10, 64)
  6947. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6948. config = append(config, &diagnosisConfig)
  6949. }
  6950. var pd models.PatientDtos
  6951. pd.PatnID = his.PsnNo
  6952. pd.PatnName = his.Name
  6953. pd.Gend = his.Gend
  6954. pd.Brdy = psn_info.Brdy
  6955. pd.Poolarea = his.InsuplcAdmdvs
  6956. pd.CurrMdtrtID = his.Number
  6957. var fed models.FsiEncounterDtos
  6958. fed.MdtrtID = his.Number
  6959. fed.MedinsID = miConfig.Code
  6960. fed.MedinsName = miConfig.OrgName
  6961. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6962. fed.MedMdtrtType = "1"
  6963. fed.MedinsType = "1"
  6964. fed.MedinsLv = "11"
  6965. tm := time.Unix(his.RecordDate, 0)
  6966. s_tm := tm.Format("2006-01-02 15:04:05")
  6967. fed.AdmDate = s_tm
  6968. fed.DscgDate = s_tm
  6969. fed.DscgMainDiseCodg = config[0].CountryCode
  6970. fed.DscgMainDiseName = config[0].CountryContentName
  6971. //诊断信息
  6972. var fdds []*models.FsiDiagnoseDtos
  6973. for index, item := range config {
  6974. if index == 0 {
  6975. var fdd models.FsiDiagnoseDtos
  6976. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6977. fdd.InoutDiseType = "1"
  6978. fdd.MaindiseFlag = "1"
  6979. fdd.DiseDate = s_tm
  6980. fdd.DiasSrtNo = "1"
  6981. fdd.DiseName = item.CountryContentName
  6982. fdd.DiseCodg = item.CountryCode
  6983. fdds = append(fdds, &fdd)
  6984. } else {
  6985. var fdd models.FsiDiagnoseDtos
  6986. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6987. fdd.InoutDiseType = "1"
  6988. fdd.MaindiseFlag = "1"
  6989. fdd.DiseDate = s_tm
  6990. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6991. fdd.DiseName = item.CountryContentName
  6992. fdd.DiseCodg = item.CountryCode
  6993. fdds = append(fdds, &fdd)
  6994. }
  6995. }
  6996. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6997. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6998. fed.AdmDeptName = department.Name
  6999. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  7000. fed.DscgDeptName = department.Name
  7001. fed.MedType = order.MedType
  7002. //处方医嘱信息
  7003. var orders []*models.FsiOrderDtos
  7004. //for _, item := range prescriptions {
  7005. // for _, subItem := range item.HisDoctorAdviceInfo {
  7006. // var order models.FsiOrderDtos
  7007. // order.RxID = strconv.FormatInt(item.ID, 10)
  7008. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7009. // order.LongDrordFlag = "0"
  7010. // order.HilistType = "1"
  7011. // order.ChrgType = "1"
  7012. // order.DrordBhvr = "-"
  7013. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7014. // order.HosplistName = subItem.BaseDrugLib.DrugName
  7015. // order.HilistLv = "1"
  7016. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7017. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7018. // order.HosplistName = subItem.BaseDrugLib.DrugName
  7019. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  7020. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7021. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  7022. // order.OwnpayAmt = ""
  7023. // order.SelfpayAmt = ""
  7024. // order.Spec = ""
  7025. // order.SpecUnt = ""
  7026. // order.DrordBegnDate = s_tm
  7027. // order.DrordStopDate = ""
  7028. // order.DrordDrCodg = "1"
  7029. // order.DrordDeptName = department.Name
  7030. // order.DrordDrCodg = "1"
  7031. // order.DrordDrName = doctor_info.UserName
  7032. // order.DrordDrProfttl = ""
  7033. // order.CurrDrordFlag = "1"
  7034. // orders = append(orders, &order)
  7035. // }
  7036. // for _, subItem := range item.HisPrescriptionProject {
  7037. // if subItem.Type == 2 {
  7038. // var order models.FsiOrderDtos
  7039. // order.RxID = strconv.FormatInt(item.ID, 10)
  7040. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7041. // order.LongDrordFlag = "0"
  7042. // order.HilistType = "1"
  7043. // order.ChrgType = "1"
  7044. // order.DrordBhvr = "-"
  7045. // order.HilistCode = subItem.HisProject.MedicalCode
  7046. // order.HosplistName = subItem.HisProject.ProjectName
  7047. // order.HilistLv = "1"
  7048. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7049. // order.HosplistCode = subItem.HisProject.MedicalCode
  7050. // order.HosplistName = subItem.HisProject.ProjectName
  7051. // order.Cnt = subItem.Count
  7052. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7053. //
  7054. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7055. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  7056. // order.OwnpayAmt = ""
  7057. // order.SelfpayAmt = ""
  7058. // order.Spec = ""
  7059. // order.SpecUnt = ""
  7060. // order.DrordBegnDate = s_tm
  7061. // order.DrordStopDate = ""
  7062. // order.DrordDrCodg = "1"
  7063. // order.DrordDeptName = department.Name
  7064. // order.DrordDrCodg = "1"
  7065. // order.DrordDrName = doctor_info.UserName
  7066. // order.DrordDrProfttl = ""
  7067. // order.CurrDrordFlag = "1"
  7068. // orders = append(orders, &order)
  7069. //
  7070. // }
  7071. // if subItem.Type == 3 {
  7072. //
  7073. // var order models.FsiOrderDtos
  7074. // order.RxID = strconv.FormatInt(item.ID, 10)
  7075. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7076. // order.LongDrordFlag = "0"
  7077. // order.HilistType = "1"
  7078. // order.ChrgType = "1"
  7079. // order.DrordBhvr = "-"
  7080. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7081. // order.HosplistName = subItem.GoodInfo.GoodName
  7082. // order.HilistLv = "1"
  7083. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7084. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7085. // order.HosplistName = subItem.GoodInfo.GoodName
  7086. // order.Cnt = subItem.Count
  7087. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7088. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7089. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  7090. // order.OwnpayAmt = ""
  7091. // order.SelfpayAmt = ""
  7092. // order.Spec = ""
  7093. // order.SpecUnt = ""
  7094. // order.DrordBegnDate = s_tm
  7095. // order.DrordStopDate = ""
  7096. // order.DrordDrCodg = "1"
  7097. // order.DrordDeptName = department.Name
  7098. // order.DrordDrCodg = "1"
  7099. // order.DrordDrName = doctor_info.UserName
  7100. // order.DrordDrProfttl = ""
  7101. // order.CurrDrordFlag = "1"
  7102. // orders = append(orders, &order)
  7103. //
  7104. // }
  7105. // }
  7106. //}
  7107. for _, item := range prescriptions {
  7108. for _, subItem := range item.HisDoctorAdviceInfo {
  7109. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7110. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7111. var order models.FsiOrderDtos
  7112. order.RxID = strconv.FormatInt(item.ID, 10)
  7113. order.Rxno = strconv.FormatInt(item.ID, 10)
  7114. order.LongDrordFlag = "0"
  7115. order.HilistType = "1"
  7116. order.ChrgType = "1"
  7117. order.DrordBhvr = "0"
  7118. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7119. order.HosplistName = subItem.BaseDrugLib.DrugName
  7120. order.HilistLv = "1"
  7121. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7122. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7123. order.HosplistName = subItem.BaseDrugLib.DrugName
  7124. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7125. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7126. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  7127. order.OwnpayAmt = ""
  7128. order.SelfpayAmt = ""
  7129. order.Spec = spec
  7130. order.SpecUnt = subItem.PrescribingNumberUnit
  7131. order.DrordBegnDate = s_tm
  7132. order.DrordStopDate = ""
  7133. order.DrordDrCodg = doctor_info.DoctorNumber
  7134. order.DrordDeptName = department.Name
  7135. order.DrordDeptCodg = department.Number
  7136. order.DrordDrName = doctor_info.UserName
  7137. order.DrordDrProfttl = "234"
  7138. order.CurrDrordFlag = "1"
  7139. orders = append(orders, &order)
  7140. }
  7141. }
  7142. for _, subItem := range item.HisPrescriptionProject {
  7143. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  7144. var order models.FsiOrderDtos
  7145. order.RxID = strconv.FormatInt(item.ID, 10)
  7146. order.Rxno = strconv.FormatInt(item.ID, 10)
  7147. order.LongDrordFlag = "0"
  7148. order.HilistType = "1"
  7149. order.ChrgType = "1"
  7150. order.DrordBhvr = "0"
  7151. order.HilistCode = subItem.HisProject.MedicalCode
  7152. order.HosplistName = subItem.HisProject.ProjectName
  7153. order.HilistLv = "1"
  7154. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7155. order.HosplistCode = subItem.HisProject.MedicalCode
  7156. order.HosplistName = subItem.HisProject.ProjectName
  7157. order.Cnt = subItem.Count
  7158. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7159. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7160. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7161. order.OwnpayAmt = ""
  7162. order.SelfpayAmt = ""
  7163. order.Spec = subItem.Unit
  7164. order.SpecUnt = subItem.Unit
  7165. order.DrordBegnDate = s_tm
  7166. order.DrordStopDate = ""
  7167. order.DrordDrCodg = doctor_info.DoctorNumber
  7168. order.DrordDeptName = department.Name
  7169. order.DrordDeptCodg = department.Number
  7170. order.DrordDrName = doctor_info.UserName
  7171. order.DrordDrProfttl = "234"
  7172. order.CurrDrordFlag = "1"
  7173. orders = append(orders, &order)
  7174. }
  7175. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7176. var order models.FsiOrderDtos
  7177. order.RxID = strconv.FormatInt(item.ID, 10)
  7178. order.Rxno = strconv.FormatInt(item.ID, 10)
  7179. order.LongDrordFlag = "0"
  7180. order.HilistType = "1"
  7181. order.ChrgType = "1"
  7182. order.DrordBhvr = "0"
  7183. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7184. order.HosplistName = subItem.GoodInfo.GoodName
  7185. order.HilistLv = "1"
  7186. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7187. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7188. order.HosplistName = subItem.GoodInfo.GoodName
  7189. order.Cnt = subItem.Count
  7190. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7191. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7192. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7193. order.OwnpayAmt = ""
  7194. order.SelfpayAmt = ""
  7195. order.Spec = subItem.GoodInfo.SpecificationName
  7196. order.SpecUnt = subItem.Unit
  7197. order.DrordBegnDate = s_tm
  7198. order.DrordStopDate = ""
  7199. order.DrordDrCodg = doctor_info.DoctorNumber
  7200. order.DrordDeptName = department.Name
  7201. order.DrordDeptCodg = department.Number
  7202. order.DrordDrName = doctor_info.UserName
  7203. order.DrordDrProfttl = "234"
  7204. order.CurrDrordFlag = "1"
  7205. orders = append(orders, &order)
  7206. }
  7207. }
  7208. }
  7209. //处方医嘱信息
  7210. fed.MatnStas = "0"
  7211. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7212. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  7213. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  7214. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  7215. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  7216. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  7217. fed.SetlTotlnum = "1"
  7218. fed.Insutype = his.Insutype
  7219. fed.ReimFlag = "0"
  7220. fed.OutSetlFlag = "0"
  7221. var fopd []*models.FsiOperationDtosData
  7222. data := make(map[string]interface{})
  7223. data["fed"] = fed
  7224. data["fdd"] = fdds
  7225. data["fod"] = orders
  7226. data["pd"] = pd
  7227. data["pp"] = pp
  7228. data["fopd"] = fopd
  7229. data["trig_scen"] = trig_scen
  7230. client := &http.Client{}
  7231. bytesData, _ := json.Marshal(data)
  7232. var req *http.Request
  7233. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7234. if miConfig.MdtrtareaAdmvs == "320921" {
  7235. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7236. } else {
  7237. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7238. }
  7239. resp, _ := client.Do(req)
  7240. defer resp.Body.Close()
  7241. body, ioErr := ioutil.ReadAll(resp.Body)
  7242. if ioErr != nil {
  7243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7245. return res
  7246. }
  7247. var respJSON map[string]interface{}
  7248. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7251. return res
  7252. }
  7253. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7254. result, _ := json.Marshal(respJSON)
  7255. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7256. utils.ErrorLog("解析失败:%v", err)
  7257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7258. return res
  7259. }
  7260. return res
  7261. } else {
  7262. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7263. saveLog(output, input, "3102", "事中")
  7264. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7265. utils.ErrorLog("解析失败:%v", err)
  7266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7267. return
  7268. }
  7269. return res
  7270. }
  7271. return res
  7272. }
  7273. func (c *HisApiController) Check() {
  7274. psn_no := c.GetString("psn_no")
  7275. in := c.GetString("in")
  7276. mt := c.GetString("mt")
  7277. baseParams := models.BaseParams{
  7278. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  7279. FixmedinsCode: "H15049901371",
  7280. InsuplcAdmdvs: "150499",
  7281. MdtrtareaAdmvs: "150499",
  7282. OrgName: "赤峰费森血液透析中心",
  7283. Doctor: "1111",
  7284. }
  7285. service.Gdyb2001(baseParams, psn_no, in, mt)
  7286. }
  7287. func (c *HisApiController) GetPsnNcdsInfo() {
  7288. admin_user_id, _ := c.GetInt64("admin_user_id")
  7289. patient_id, _ := c.GetInt64("patient_id")
  7290. //id, _ := c.GetInt64("id")
  7291. adminUser := c.GetAdminUserInfo()
  7292. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7293. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7294. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7295. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7296. //psn_record, _ := service.GetP(id)
  7297. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7298. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  7299. //
  7300. //if psn_record.ID == 0 {
  7301. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7302. // return
  7303. //}
  7304. var res Result5301
  7305. var res10265 Result5301For10265
  7306. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7307. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7308. var api string
  7309. if miConfig.MdtrtareaAdmvs == "320921" {
  7310. 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 +
  7311. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7312. } else {
  7313. 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 +
  7314. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7315. }
  7316. resp, requestErr := http.Get(api)
  7317. if requestErr != nil {
  7318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7319. return
  7320. }
  7321. body, ioErr := ioutil.ReadAll(resp.Body)
  7322. if ioErr != nil {
  7323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7325. return
  7326. }
  7327. var respJSON map[string]interface{}
  7328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7331. return
  7332. }
  7333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7334. result, _ := json.Marshal(respJSON)
  7335. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7336. utils.ErrorLog("解析失败:%v", err)
  7337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7338. return
  7339. }
  7340. res.ErrMsg = res10265.ErrMsg
  7341. res.Output = res10265.Output
  7342. res.InfRefmsgid = res10265.InfRefmsgid
  7343. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7344. res.Infcode = infocode
  7345. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7346. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7347. var api string
  7348. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7349. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7350. resp, requestErr := http.Get(api)
  7351. if requestErr != nil {
  7352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7353. return
  7354. }
  7355. body, ioErr := ioutil.ReadAll(resp.Body)
  7356. if ioErr != nil {
  7357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7359. return
  7360. }
  7361. var respJSON map[string]interface{}
  7362. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7365. return
  7366. }
  7367. status := respJSON["data"].(map[string]interface{})["status"].(string)
  7368. if status == "0" {
  7369. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  7370. c.ServeSuccessJSON(map[string]interface{}{
  7371. "failed_code": -10,
  7372. "msg": err_msg,
  7373. })
  7374. return
  7375. }
  7376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7377. result, _ := json.Marshal(respJSON)
  7378. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7379. utils.ErrorLog("解析失败:%v", err)
  7380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7381. return
  7382. }
  7383. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7384. p, _ := service.GetHisPatientById(patient_id)
  7385. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7386. var dat map[string]interface{}
  7387. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7388. fmt.Println(dat)
  7389. } else {
  7390. fmt.Println(err)
  7391. }
  7392. userJSONBytes, _ := json.Marshal(dat)
  7393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7394. utils.ErrorLog("解析失败:%v", err)
  7395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7396. return
  7397. }
  7398. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7399. p, _ := service.GetHisPatientById(patient_id)
  7400. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7401. var dat map[string]interface{}
  7402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7403. fmt.Println(dat)
  7404. } else {
  7405. fmt.Println(err)
  7406. }
  7407. userJSONBytes, _ := json.Marshal(dat)
  7408. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7409. utils.ErrorLog("解析失败:%v", err)
  7410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7411. return
  7412. }
  7413. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7414. p, _ := service.GetHisPatientById(patient_id)
  7415. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7416. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7417. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7418. resp, requestErr := http.Get(api)
  7419. if requestErr != nil {
  7420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7421. return
  7422. }
  7423. body, ioErr := ioutil.ReadAll(resp.Body)
  7424. if ioErr != nil {
  7425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7427. return
  7428. }
  7429. var respJSON map[string]interface{}
  7430. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7433. return
  7434. }
  7435. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7436. result, _ := json.Marshal(respJSON)
  7437. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7438. utils.ErrorLog("解析失败:%v", err)
  7439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7440. return
  7441. }
  7442. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7443. p, _ := service.GetHisPatientById(patient_id)
  7444. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  7445. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7446. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7447. resp, requestErr := http.Get(api)
  7448. if requestErr != nil {
  7449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7450. return
  7451. }
  7452. body, ioErr := ioutil.ReadAll(resp.Body)
  7453. if ioErr != nil {
  7454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7456. return
  7457. }
  7458. var respJSON map[string]interface{}
  7459. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7462. return
  7463. }
  7464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7465. result, _ := json.Marshal(respJSON)
  7466. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7467. utils.ErrorLog("解析失败:%v", err)
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7469. return
  7470. }
  7471. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7472. p, _ := service.GetHisPatientById(patient_id)
  7473. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7474. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7475. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7476. resp, requestErr := http.Get(api)
  7477. if requestErr != nil {
  7478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7479. return
  7480. }
  7481. body, ioErr := ioutil.ReadAll(resp.Body)
  7482. if ioErr != nil {
  7483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7485. return
  7486. }
  7487. var respJSON map[string]interface{}
  7488. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7491. return
  7492. }
  7493. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7494. result, _ := json.Marshal(respJSON)
  7495. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7496. utils.ErrorLog("解析失败:%v", err)
  7497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7498. return
  7499. }
  7500. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7501. p, _ := service.GetHisPatientById(patient_id)
  7502. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7503. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7504. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7505. resp, requestErr := http.Get(api)
  7506. if requestErr != nil {
  7507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7508. return
  7509. }
  7510. body, ioErr := ioutil.ReadAll(resp.Body)
  7511. if ioErr != nil {
  7512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7514. return
  7515. }
  7516. var respJSON map[string]interface{}
  7517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7520. return
  7521. }
  7522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7523. result, _ := json.Marshal(respJSON)
  7524. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7525. utils.ErrorLog("解析失败:%v", err)
  7526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7527. return
  7528. }
  7529. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7530. p, _ := service.GetHisPatientById(patient_id)
  7531. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7532. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7533. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7534. resp, requestErr := http.Get(api)
  7535. if requestErr != nil {
  7536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7537. return
  7538. }
  7539. body, ioErr := ioutil.ReadAll(resp.Body)
  7540. if ioErr != nil {
  7541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7543. return
  7544. }
  7545. var respJSON map[string]interface{}
  7546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7549. return
  7550. }
  7551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7552. result, _ := json.Marshal(respJSON)
  7553. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7554. utils.ErrorLog("解析失败:%v", err)
  7555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7556. return
  7557. }
  7558. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7559. p, _ := service.GetHisPatientById(patient_id)
  7560. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7561. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7562. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7563. resp, requestErr := http.Get(api)
  7564. if requestErr != nil {
  7565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7566. return
  7567. }
  7568. body, ioErr := ioutil.ReadAll(resp.Body)
  7569. if ioErr != nil {
  7570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7572. return
  7573. }
  7574. var respJSON map[string]interface{}
  7575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7578. return
  7579. }
  7580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7581. result, _ := json.Marshal(respJSON)
  7582. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7583. utils.ErrorLog("解析失败:%v", err)
  7584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7585. return
  7586. }
  7587. } else {
  7588. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7589. var dat map[string]interface{}
  7590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7591. fmt.Println(dat)
  7592. } else {
  7593. fmt.Println(err)
  7594. }
  7595. userJSONBytes, _ := json.Marshal(dat)
  7596. if miConfig.Code == "H15049901371" {
  7597. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7598. utils.ErrorLog("解析失败:%v", err)
  7599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7600. return
  7601. }
  7602. res.InfRefmsgid = res10265.InfRefmsgid
  7603. res.Output = res10265.Output
  7604. res.ErrMsg = res10265.ErrMsg
  7605. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7606. res.Infcode = infocode
  7607. } else {
  7608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7609. utils.ErrorLog("解析失败:%v", err)
  7610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7611. return
  7612. }
  7613. }
  7614. }
  7615. if res.Infcode == 0 {
  7616. c.ServeSuccessJSON(map[string]interface{}{
  7617. "result": res.Output.Result,
  7618. })
  7619. }
  7620. }
  7621. func (c *HisApiController) CheckInsutype() {
  7622. his_patient_id, _ := c.GetInt64("his_patient_id")
  7623. admin_user_id, _ := c.GetInt64("admin_user_id")
  7624. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7625. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7626. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7627. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7628. var dat map[string]interface{}
  7629. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7630. fmt.Println(dat)
  7631. } else {
  7632. fmt.Println(err)
  7633. }
  7634. userJSONBytes, _ := json.Marshal(dat)
  7635. var res Result90100
  7636. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7637. utils.ErrorLog("解析失败:%v", err)
  7638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7639. return
  7640. }
  7641. if res.Infcode != 0 {
  7642. c.ServeSuccessJSON(map[string]interface{}{
  7643. "failed_code": -10,
  7644. "msg": res.ErrMsg,
  7645. })
  7646. return
  7647. } else {
  7648. fmt.Println(res)
  7649. }
  7650. }
  7651. func (c *HisApiController) CheckCardPWD() {
  7652. card_pwd := c.GetString("card_pwd")
  7653. his_patient_id, _ := c.GetInt64("his_patient_id")
  7654. admin_user_id, _ := c.GetInt64("admin_user_id")
  7655. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7656. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7657. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7658. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7659. bas := strings.Split(psn.CardInfo, "|")
  7660. basNumber := bas[2]
  7661. if psn.InsuplcAdmdvs[:4] == "4403" {
  7662. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7663. var dat map[string]interface{}
  7664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7665. fmt.Println(dat)
  7666. } else {
  7667. fmt.Println(err)
  7668. }
  7669. userJSONBytes, _ := json.Marshal(dat)
  7670. var res Result90991
  7671. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7672. utils.ErrorLog("解析失败:%v", err)
  7673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7674. return
  7675. }
  7676. if res.Infcode != 0 {
  7677. c.ServeSuccessJSON(map[string]interface{}{
  7678. "failed_code": -10,
  7679. "msg": res.ErrMsg,
  7680. })
  7681. return
  7682. } else {
  7683. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7684. var msg string
  7685. switch res.Output.Result.CardStat {
  7686. case "00":
  7687. msg = "未激活"
  7688. break
  7689. case "10":
  7690. msg = "激活"
  7691. break
  7692. case "20":
  7693. msg = "窗口挂失"
  7694. break
  7695. case "21":
  7696. msg = "电话挂失"
  7697. break
  7698. case "22":
  7699. msg = "单位网上申报挂失"
  7700. break
  7701. case "23":
  7702. msg = "保健办挂失"
  7703. break
  7704. case "24":
  7705. msg = "个人网上挂失"
  7706. break
  7707. case "25":
  7708. msg = "网上服务大厅挂失"
  7709. break
  7710. case "30":
  7711. msg = "注销"
  7712. break
  7713. case "40":
  7714. msg = "回收"
  7715. break
  7716. case "99":
  7717. msg = "制卡中(无效卡)"
  7718. break
  7719. }
  7720. c.ServeSuccessJSON(map[string]interface{}{
  7721. "failed_code": -10,
  7722. "msg": msg,
  7723. })
  7724. return
  7725. } else {
  7726. c.ServeSuccessJSON(map[string]interface{}{
  7727. "msg": "校验成功",
  7728. })
  7729. return
  7730. }
  7731. }
  7732. } else {
  7733. c.ServeSuccessJSON(map[string]interface{}{
  7734. "msg": "校验成功",
  7735. })
  7736. return
  7737. }
  7738. }
  7739. func (c *HisApiController) CheckCardPWDTwo() {
  7740. //card_pwd := c.GetString("card_pwd")
  7741. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7742. admin_user_id, _ := c.GetInt64("admin_user_id")
  7743. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7744. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7745. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7746. var dat map[string]interface{}
  7747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7748. fmt.Println(dat)
  7749. } else {
  7750. fmt.Println(err)
  7751. }
  7752. userJSONBytes, _ := json.Marshal(dat)
  7753. var res Result90991
  7754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7755. utils.ErrorLog("解析失败:%v", err)
  7756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7757. return
  7758. }
  7759. if res.Infcode != 0 {
  7760. c.ServeSuccessJSON(map[string]interface{}{
  7761. "failed_code": -10,
  7762. "msg": res.ErrMsg,
  7763. })
  7764. return
  7765. } else {
  7766. if res.Output.Result.SscnoCheckStat == "0" {
  7767. var msg string
  7768. switch res.Output.Result.CardStat {
  7769. case "00":
  7770. msg = "未激活"
  7771. break
  7772. case "10":
  7773. msg = "激活"
  7774. break
  7775. case "20":
  7776. msg = "窗口挂失"
  7777. break
  7778. case "21":
  7779. msg = "电话挂失"
  7780. break
  7781. case "22":
  7782. msg = "单位网上申报挂失"
  7783. break
  7784. case "23":
  7785. msg = "保健办挂失"
  7786. break
  7787. case "24":
  7788. msg = "个人网上挂失"
  7789. break
  7790. case "25":
  7791. msg = "网上服务大厅挂失"
  7792. break
  7793. case "30":
  7794. msg = "注销"
  7795. break
  7796. case "40":
  7797. msg = "回收"
  7798. break
  7799. case "99":
  7800. msg = "制卡中(无效卡)"
  7801. break
  7802. }
  7803. c.ServeSuccessJSON(map[string]interface{}{
  7804. "failed_code": -10,
  7805. "msg": msg,
  7806. })
  7807. return
  7808. } else {
  7809. c.ServeSuccessJSON(map[string]interface{}{
  7810. "msg": "校验成功",
  7811. })
  7812. return
  7813. }
  7814. }
  7815. }
  7816. type ELeCertData struct {
  7817. Data struct {
  7818. Extra string `json:"extra"`
  7819. IDNo string `json:"idNo"`
  7820. IDType string `json:"idType"`
  7821. EcToken string `json:"ecToken"`
  7822. InsuOrg string `json:"insuOrg"`
  7823. UserName string `json:"userName"`
  7824. EcIndexNo string `json:"ecIndexNo"`
  7825. Gender string `json:"gender"`
  7826. Birthday string `json:"birthday"`
  7827. Nationality string `json:"nationality"`
  7828. Email string `json:"email"`
  7829. } `json:"OutData"`
  7830. }
  7831. func (c *HisApiController) ReadCard() {
  7832. id_card_type, _ := c.GetInt64("id_card_type")
  7833. admin_user_id, _ := c.GetInt64("admin_user_id")
  7834. certificates, _ := c.GetInt64("certificates")
  7835. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7836. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7837. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7838. switch id_card_type {
  7839. case 1:
  7840. if miConfig.MdtrtareaAdmvs == "421300" {
  7841. var res ResultTwo
  7842. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7843. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7844. "&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)
  7845. resp, requestErr := http.Get(api)
  7846. if requestErr != nil {
  7847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7848. return
  7849. }
  7850. body, ioErr := ioutil.ReadAll(resp.Body)
  7851. if ioErr != nil {
  7852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7854. return
  7855. }
  7856. var respJSON map[string]interface{}
  7857. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7860. return
  7861. }
  7862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7863. result, _ := json.Marshal(respJSON)
  7864. fmt.Println("log")
  7865. fmt.Println(string(result))
  7866. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7867. utils.ErrorLog("解析失败:%v", err)
  7868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7869. return
  7870. }
  7871. if res.Infcode == 0 {
  7872. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7873. if err == gorm.ErrRecordNotFound {
  7874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7875. return
  7876. } else if err != nil {
  7877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7878. return
  7879. } else {
  7880. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7881. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7882. infoStr := string(Iinfos)
  7883. idetinfoStr := string(Idetinfos)
  7884. var rf []*ResultFive
  7885. json.Unmarshal([]byte(infoStr), &rf)
  7886. var insutypes []*ResultFive
  7887. var insutype string
  7888. var is390 int = 0
  7889. var is310 int = 0
  7890. for _, item := range rf {
  7891. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7892. insutypes = append(insutypes, item)
  7893. }
  7894. }
  7895. if len(insutypes) == 1 {
  7896. insutype = insutypes[0].Insutype
  7897. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7898. } else {
  7899. for _, i := range insutypes {
  7900. if i.Insutype == "390" {
  7901. is390 = 1
  7902. }
  7903. if i.Insutype == "310" {
  7904. is310 = 1
  7905. }
  7906. }
  7907. }
  7908. if is390 == 1 {
  7909. insutype = "390"
  7910. }
  7911. if is310 == 1 {
  7912. insutype = "310"
  7913. }
  7914. if len(insutypes) == 0 {
  7915. insutype = "390"
  7916. }
  7917. var insuplc_admdvs string
  7918. for _, item := range rf {
  7919. if item.Insutype == insutype {
  7920. insuplc_admdvs = item.InsuplcAdmdvs
  7921. }
  7922. }
  7923. if strings.Contains(insuplc_admdvs, "4213") {
  7924. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7925. }
  7926. psn := &models.HisPsn{
  7927. PsnNo: res.Output.Baseinfo.PsnNo,
  7928. PatientId: patient.ID,
  7929. Certno: res.Output.Baseinfo.Certno,
  7930. Gend: res.Output.Baseinfo.Gend,
  7931. Naty: res.Output.Baseinfo.Naty,
  7932. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7933. PsnName: res.Output.Baseinfo.PsnName,
  7934. Idetinfo: idetinfoStr,
  7935. Insuinfo: infoStr,
  7936. InsuplcAdmdvs: insuplc_admdvs,
  7937. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7938. }
  7939. service.CreateHisPsn(psn)
  7940. c.ServeSuccessJSON(map[string]interface{}{
  7941. "patient": patient,
  7942. "number": res.Output.Baseinfo.Certno,
  7943. })
  7944. }
  7945. } else {
  7946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7947. return
  7948. }
  7949. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7950. var res ResultTwo
  7951. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7952. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7953. "&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)
  7954. resp, requestErr := http.Get(api)
  7955. if requestErr != nil {
  7956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7957. return
  7958. }
  7959. body, ioErr := ioutil.ReadAll(resp.Body)
  7960. if ioErr != nil {
  7961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7963. return
  7964. }
  7965. var respJSON map[string]interface{}
  7966. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7969. return
  7970. }
  7971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7972. result, _ := json.Marshal(respJSON)
  7973. fmt.Println("log")
  7974. fmt.Println(string(result))
  7975. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7976. utils.ErrorLog("解析失败:%v", err)
  7977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7978. return
  7979. }
  7980. if res.Infcode == 0 {
  7981. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7982. if err == gorm.ErrRecordNotFound {
  7983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7984. return
  7985. } else if err != nil {
  7986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7987. return
  7988. } else {
  7989. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7990. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7991. infoStr := string(Iinfos)
  7992. idetinfoStr := string(Idetinfos)
  7993. psn := &models.HisPsn{
  7994. PsnNo: res.Output.Baseinfo.PsnNo,
  7995. PatientId: patient.ID,
  7996. Certno: res.Output.Baseinfo.Certno,
  7997. Gend: res.Output.Baseinfo.Gend,
  7998. Naty: res.Output.Baseinfo.Naty,
  7999. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8000. PsnName: res.Output.Baseinfo.PsnName,
  8001. Idetinfo: idetinfoStr,
  8002. Insuinfo: infoStr,
  8003. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8004. }
  8005. service.CreateHisPsn(psn)
  8006. var rf []*ResultFive
  8007. json.Unmarshal([]byte(infoStr), &rf)
  8008. var insutypes []*ResultFive
  8009. var insutype string
  8010. var is390 int = 0
  8011. var is310 int = 0
  8012. for _, item := range rf {
  8013. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8014. insutypes = append(insutypes, item)
  8015. }
  8016. }
  8017. if len(insutypes) == 1 {
  8018. insutype = insutypes[0].Insutype
  8019. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8020. } else {
  8021. for _, i := range insutypes {
  8022. if i.Insutype == "390" {
  8023. is390 = 1
  8024. }
  8025. if i.Insutype == "310" {
  8026. is310 = 1
  8027. }
  8028. }
  8029. }
  8030. if is390 == 1 {
  8031. insutype = "390"
  8032. }
  8033. if is310 == 1 {
  8034. insutype = "310"
  8035. }
  8036. if len(insutypes) == 0 {
  8037. insutype = "310"
  8038. }
  8039. c.ServeSuccessJSON(map[string]interface{}{
  8040. "patient": patient,
  8041. "number": res.Output.Baseinfo.Certno,
  8042. "insutype": insutype,
  8043. })
  8044. }
  8045. } else {
  8046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8047. return
  8048. }
  8049. } else if miConfig.MdtrtareaAdmvs == "420902" {
  8050. var res ResultTwo
  8051. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  8052. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8053. "&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)
  8054. resp, requestErr := http.Get(api)
  8055. if requestErr != nil {
  8056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8057. return
  8058. }
  8059. body, ioErr := ioutil.ReadAll(resp.Body)
  8060. if ioErr != nil {
  8061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8063. return
  8064. }
  8065. var respJSON map[string]interface{}
  8066. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8069. return
  8070. }
  8071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8072. result, _ := json.Marshal(respJSON)
  8073. fmt.Println("log")
  8074. fmt.Println(string(result))
  8075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8076. utils.ErrorLog("解析失败:%v", err)
  8077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8078. return
  8079. }
  8080. if res.Infcode == 0 {
  8081. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8082. if err == gorm.ErrRecordNotFound {
  8083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8084. return
  8085. } else if err != nil {
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8087. return
  8088. } else {
  8089. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8090. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8091. infoStr := string(Iinfos)
  8092. idetinfoStr := string(Idetinfos)
  8093. var rf []*ResultFive
  8094. json.Unmarshal([]byte(infoStr), &rf)
  8095. var insutypes []*ResultFive
  8096. var insutype string
  8097. var is390 int = 0
  8098. var is310 int = 0
  8099. for _, item := range rf {
  8100. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8101. insutypes = append(insutypes, item)
  8102. }
  8103. }
  8104. if len(insutypes) == 1 {
  8105. insutype = insutypes[0].Insutype
  8106. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8107. } else {
  8108. for _, i := range insutypes {
  8109. if i.Insutype == "390" {
  8110. is390 = 1
  8111. }
  8112. if i.Insutype == "310" {
  8113. is310 = 1
  8114. }
  8115. }
  8116. }
  8117. if is390 == 1 {
  8118. insutype = "390"
  8119. }
  8120. if is310 == 1 {
  8121. insutype = "310"
  8122. }
  8123. if len(insutypes) == 0 {
  8124. insutype = "390"
  8125. }
  8126. var insuplc_admdvs string
  8127. for _, item := range rf {
  8128. if item.Insutype == insutype {
  8129. insuplc_admdvs = item.InsuplcAdmdvs
  8130. }
  8131. }
  8132. psn := &models.HisPsn{
  8133. PsnNo: res.Output.Baseinfo.PsnNo,
  8134. PatientId: patient.ID,
  8135. Certno: res.Output.Baseinfo.Certno,
  8136. Gend: res.Output.Baseinfo.Gend,
  8137. Naty: res.Output.Baseinfo.Naty,
  8138. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8139. PsnName: res.Output.Baseinfo.PsnName,
  8140. Idetinfo: idetinfoStr,
  8141. Insuinfo: infoStr,
  8142. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8143. InsuplcAdmdvs: insuplc_admdvs,
  8144. }
  8145. service.CreateHisPsn(psn)
  8146. for _, item := range rf {
  8147. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8148. insutypes = append(insutypes, item)
  8149. }
  8150. }
  8151. if len(insutypes) == 1 {
  8152. insutype = insutypes[0].Insutype
  8153. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8154. } else {
  8155. for _, i := range insutypes {
  8156. if i.Insutype == "390" {
  8157. is390 = 1
  8158. }
  8159. if i.Insutype == "310" {
  8160. is310 = 1
  8161. }
  8162. }
  8163. }
  8164. if is390 == 1 {
  8165. insutype = "390"
  8166. }
  8167. if is310 == 1 {
  8168. insutype = "310"
  8169. }
  8170. if len(insutypes) == 0 {
  8171. insutype = "310"
  8172. }
  8173. c.ServeSuccessJSON(map[string]interface{}{
  8174. "patient": patient,
  8175. "number": res.Output.Baseinfo.Certno,
  8176. "insutype": insutype,
  8177. })
  8178. }
  8179. } else {
  8180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8181. return
  8182. }
  8183. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8184. var res ResultTwo
  8185. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  8186. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8187. "&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)
  8188. resp, requestErr := http.Get(api)
  8189. if requestErr != nil {
  8190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8191. return
  8192. }
  8193. body, ioErr := ioutil.ReadAll(resp.Body)
  8194. if ioErr != nil {
  8195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. return
  8198. }
  8199. var respJSON map[string]interface{}
  8200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8203. return
  8204. }
  8205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8206. result, _ := json.Marshal(respJSON)
  8207. fmt.Println("log")
  8208. fmt.Println(string(result))
  8209. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8210. utils.ErrorLog("解析失败:%v", err)
  8211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8212. return
  8213. }
  8214. if res.Infcode == 0 {
  8215. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8216. if err == gorm.ErrRecordNotFound {
  8217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8218. return
  8219. } else if err != nil {
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8221. return
  8222. } else {
  8223. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8224. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8225. infoStr := string(Iinfos)
  8226. idetinfoStr := string(Idetinfos)
  8227. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8228. psn := &models.HisPsn{
  8229. PsnNo: res.Output.Baseinfo.PsnNo,
  8230. PatientId: patient.ID,
  8231. Certno: res.Output.Baseinfo.Certno,
  8232. Brdy: b,
  8233. Age: float64(age),
  8234. Gend: res.Output.Baseinfo.Gend,
  8235. Naty: res.Output.Baseinfo.Naty,
  8236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8237. PsnName: res.Output.Baseinfo.PsnName,
  8238. Idetinfo: idetinfoStr,
  8239. Insuinfo: infoStr,
  8240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8241. }
  8242. service.CreateHisPsn(psn)
  8243. var rf []*ResultFive
  8244. json.Unmarshal([]byte(infoStr), &rf)
  8245. var insutypes []*ResultFive
  8246. var insutype string
  8247. var is390 int = 0
  8248. var is310 int = 0
  8249. for _, item := range rf {
  8250. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8251. insutypes = append(insutypes, item)
  8252. }
  8253. }
  8254. if len(insutypes) == 1 {
  8255. insutype = insutypes[0].Insutype
  8256. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8257. } else {
  8258. for _, i := range insutypes {
  8259. if i.Insutype == "390" {
  8260. is390 = 1
  8261. }
  8262. if i.Insutype == "310" {
  8263. is310 = 1
  8264. }
  8265. }
  8266. }
  8267. if is390 == 1 {
  8268. insutype = "390"
  8269. }
  8270. if is310 == 1 {
  8271. insutype = "310"
  8272. }
  8273. if len(insutypes) == 0 {
  8274. insutype = "310"
  8275. }
  8276. c.ServeSuccessJSON(map[string]interface{}{
  8277. "patient": patient,
  8278. "number": res.Output.Baseinfo.Certno,
  8279. "insutype": insutype,
  8280. })
  8281. }
  8282. } else {
  8283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8284. return
  8285. }
  8286. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8287. var api string
  8288. if miConfig.MdtrtareaAdmvs == "320921" {
  8289. 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 +
  8290. "&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
  8291. fmt.Println(api)
  8292. } else {
  8293. 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 +
  8294. "&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)
  8295. }
  8296. resp, requestErr := http.Get(api)
  8297. if requestErr != nil {
  8298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8299. return
  8300. }
  8301. body, ioErr := ioutil.ReadAll(resp.Body)
  8302. if ioErr != nil {
  8303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. var respJSON map[string]interface{}
  8308. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8311. return
  8312. }
  8313. var status string
  8314. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8315. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8316. //console.log()
  8317. fmt.Println("type===")
  8318. fmt.Println(card_type)
  8319. var token string
  8320. var res ResultTwo //1101结果
  8321. var res10265 ResultTwo10265 //1101结果
  8322. var card_info string //卡信息
  8323. var busi_card_info string
  8324. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8325. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8326. if status == "0" { //读卡成功
  8327. if card_type == "1" {
  8328. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8329. result, _ := json.Marshal(respJSON)
  8330. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8331. utils.ErrorLog("解析失败:%v", err)
  8332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8333. return
  8334. }
  8335. res.ErrMsg = res10265.ErrMsg
  8336. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8337. res.Infcode = infocode
  8338. res.Output = res10265.Output
  8339. res.InfRefmsgid = res10265.InfRefmsgid
  8340. } else {
  8341. //var card_info string //卡信息
  8342. //var busi_card_info string
  8343. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8344. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8345. //fmt.Println(card_info)
  8346. //fmt.Println(busi_card_info)
  8347. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8348. result, _ := json.Marshal(respJSON)
  8349. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8350. utils.ErrorLog("解析失败:%v", err)
  8351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8352. return
  8353. }
  8354. res.ErrMsg = res10265.ErrMsg
  8355. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8356. res.Infcode = infocode
  8357. res.Output = res10265.Output
  8358. res.InfRefmsgid = res10265.InfRefmsgid
  8359. }
  8360. if res.Infcode == 0 {
  8361. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8362. if err == gorm.ErrRecordNotFound {
  8363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8364. return
  8365. } else if err != nil {
  8366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8367. return
  8368. } else {
  8369. if card_type == "1" {
  8370. bas := strings.Split(card_info, "|")
  8371. basNumber := bas[2]
  8372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8373. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8374. infoStr := string(Iinfos)
  8375. idetinfoStr := string(Idetinfos)
  8376. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8377. psn := &models.HisPsn{
  8378. PsnNo: res.Output.Baseinfo.PsnNo,
  8379. PatientId: patient.ID,
  8380. Certno: res.Output.Baseinfo.Certno,
  8381. Brdy: b,
  8382. Age: float64(age),
  8383. Gend: res.Output.Baseinfo.Gend,
  8384. Naty: res.Output.Baseinfo.Naty,
  8385. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8386. PsnName: res.Output.Baseinfo.PsnName,
  8387. Idetinfo: idetinfoStr,
  8388. Insuinfo: infoStr,
  8389. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8390. CardInfo: card_info,
  8391. VerifyNumber: busi_card_info,
  8392. }
  8393. service.CreateHisPsn(psn)
  8394. var rf []*ResultFive
  8395. json.Unmarshal([]byte(infoStr), &rf)
  8396. var insutypes []*ResultFive
  8397. var insutype string
  8398. var is390 int = 0
  8399. var is310 int = 0
  8400. for _, item := range rf {
  8401. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8402. insutypes = append(insutypes, item)
  8403. }
  8404. }
  8405. if len(insutypes) == 1 {
  8406. insutype = insutypes[0].Insutype
  8407. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8408. } else {
  8409. for _, i := range insutypes {
  8410. if i.Insutype == "390" {
  8411. is390 = 1
  8412. }
  8413. if i.Insutype == "310" {
  8414. is310 = 1
  8415. }
  8416. }
  8417. }
  8418. if is390 == 1 {
  8419. insutype = "390"
  8420. }
  8421. if is310 == 1 {
  8422. insutype = "310"
  8423. }
  8424. if len(insutypes) == 0 {
  8425. insutype = "310"
  8426. }
  8427. c.ServeSuccessJSON(map[string]interface{}{
  8428. "patient": patient,
  8429. "number": basNumber,
  8430. "insutype": insutype,
  8431. })
  8432. } else {
  8433. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8434. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8435. infoStr := string(Iinfos)
  8436. idetinfoStr := string(Idetinfos)
  8437. psn := &models.HisPsn{
  8438. PsnNo: res.Output.Baseinfo.PsnNo,
  8439. PatientId: patient.ID,
  8440. Certno: res.Output.Baseinfo.Certno,
  8441. Gend: res.Output.Baseinfo.Gend,
  8442. Naty: res.Output.Baseinfo.Naty,
  8443. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8444. PsnName: res.Output.Baseinfo.PsnName,
  8445. Idetinfo: idetinfoStr,
  8446. Insuinfo: infoStr,
  8447. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8448. CardInfo: card_info,
  8449. VerifyNumber: token,
  8450. }
  8451. service.CreateHisPsn(psn)
  8452. c.ServeSuccessJSON(map[string]interface{}{
  8453. "patient": patient,
  8454. "number": token,
  8455. })
  8456. }
  8457. }
  8458. } else {
  8459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8460. return
  8461. }
  8462. } else { //读卡失败
  8463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8464. return
  8465. }
  8466. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8467. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  8468. cardnum = DeleteExtraSpaceTwo(cardnum)
  8469. cardCode = DeleteExtraSpaceTwo(cardCode)
  8470. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  8471. name = DeleteExtraSpaceTwo(name)
  8472. errmsg = DeleteExtraSpaceTwo(errmsg)
  8473. cardnum = Remove0000(cardnum)
  8474. cardCode = Remove0000(cardCode)
  8475. id_card_no = Remove0000(id_card_no)
  8476. name = Remove0000(name)
  8477. errmsg = Remove0000(errmsg)
  8478. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  8479. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  8480. //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)
  8481. //fmt.Println(result2)
  8482. //fmt.Println(requestLog2)
  8483. //fmt.Println(errMsgLog2)
  8484. 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)
  8485. saveLog(result, requestLog, "1101", "获取人员信息")
  8486. fmt.Println(errMsgLog)
  8487. if len(errMsgLog) > 0 {
  8488. } else {
  8489. var dat map[string]interface{}
  8490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8491. fmt.Println(dat)
  8492. } else {
  8493. fmt.Println(err)
  8494. }
  8495. userJSONBytes, _ := json.Marshal(dat)
  8496. var res ResultTwo
  8497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8498. utils.ErrorLog("解析失败:%v", err)
  8499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8500. return
  8501. }
  8502. res.ErrMsg = errMsgLog
  8503. if res.Infcode == 0 {
  8504. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8505. if err == gorm.ErrRecordNotFound {
  8506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8507. return
  8508. } else if err != nil {
  8509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8510. return
  8511. } else {
  8512. fmt.Println(res)
  8513. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8514. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8515. infoStr := string(Iinfos)
  8516. idetinfoStr := string(Idetinfos)
  8517. var rf []*ResultFive
  8518. json.Unmarshal([]byte(infoStr), &rf)
  8519. var insutypes []*ResultFive
  8520. var insutype string
  8521. var is390 int = 0
  8522. var is310 int = 0
  8523. for _, item := range rf {
  8524. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8525. insutypes = append(insutypes, item)
  8526. }
  8527. }
  8528. if len(insutypes) == 1 {
  8529. insutype = insutypes[0].Insutype
  8530. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8531. } else {
  8532. for _, i := range insutypes {
  8533. if i.Insutype == "390" {
  8534. is390 = 1
  8535. }
  8536. if i.Insutype == "310" {
  8537. is310 = 1
  8538. }
  8539. }
  8540. }
  8541. if is390 == 1 {
  8542. insutype = "390"
  8543. }
  8544. if is310 == 1 {
  8545. insutype = "310"
  8546. }
  8547. if len(insutypes) == 0 {
  8548. insutype = "390"
  8549. }
  8550. var insuplc_admdvs string
  8551. for _, item := range rf {
  8552. if item.Insutype == insutype {
  8553. insuplc_admdvs = item.InsuplcAdmdvs
  8554. }
  8555. }
  8556. psn := &models.HisPsn{
  8557. PsnNo: res.Output.Baseinfo.PsnNo,
  8558. PatientId: patient.ID,
  8559. Certno: res.Output.Baseinfo.Certno,
  8560. Gend: res.Output.Baseinfo.Gend,
  8561. Naty: res.Output.Baseinfo.Naty,
  8562. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8563. PsnName: res.Output.Baseinfo.PsnName,
  8564. Idetinfo: idetinfoStr,
  8565. Insuinfo: infoStr,
  8566. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8567. CardInfo: basStr,
  8568. VerifyNumber: "",
  8569. InsuplcAdmdvs: insuplc_admdvs,
  8570. }
  8571. service.CreateHisPsn(psn)
  8572. c.ServeSuccessJSON(map[string]interface{}{
  8573. "patient": patient,
  8574. "number": cardnum,
  8575. "insutype": insutype,
  8576. })
  8577. }
  8578. } else {
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8580. return
  8581. }
  8582. }
  8583. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8584. fmt.Println(initFlag)
  8585. fmt.Println("initFlag")
  8586. if initFlag == 0 {
  8587. c.TestGetJiangXiBasBaseInit()
  8588. }
  8589. basStr := c.GetBasBaseInfo()
  8590. if len(basStr) == 0 {
  8591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8592. return
  8593. }
  8594. fmt.Println(basStr)
  8595. bas := strings.Split(basStr, "|")
  8596. basNumber := bas[1]
  8597. fmt.Println(basNumber)
  8598. card_sn := bas[3]
  8599. fmt.Println(card_sn)
  8600. 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, "")
  8601. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8602. var dat map[string]interface{}
  8603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8604. fmt.Println(dat)
  8605. } else {
  8606. fmt.Println(err)
  8607. }
  8608. userJSONBytes, _ := json.Marshal(dat)
  8609. var res ResultTwo
  8610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8611. utils.ErrorLog("解析失败:%v", err)
  8612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8613. return
  8614. }
  8615. if res.Infcode == 0 {
  8616. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8617. if err == gorm.ErrRecordNotFound {
  8618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8619. return
  8620. } else if err != nil {
  8621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8622. return
  8623. } else {
  8624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8626. infoStr := string(Iinfos)
  8627. idetinfoStr := string(Idetinfos)
  8628. var rf []*ResultFive
  8629. json.Unmarshal([]byte(infoStr), &rf)
  8630. var insutypes []*ResultFive
  8631. var insutype string
  8632. var is390 int = 0
  8633. var is310 int = 0
  8634. var insuplc_admdvs string
  8635. for _, item := range rf {
  8636. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8637. insutypes = append(insutypes, item)
  8638. }
  8639. }
  8640. if len(insutypes) == 1 {
  8641. insutype = insutypes[0].Insutype
  8642. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8643. } else {
  8644. for _, i := range insutypes {
  8645. if i.Insutype == "390" {
  8646. is390 = 1
  8647. }
  8648. if i.Insutype == "310" {
  8649. is310 = 1
  8650. }
  8651. }
  8652. }
  8653. if is390 == 1 {
  8654. insutype = "390"
  8655. }
  8656. if is310 == 1 {
  8657. insutype = "310"
  8658. }
  8659. if len(insutypes) == 0 {
  8660. insutype = "310"
  8661. }
  8662. for _, item := range rf {
  8663. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8664. insuplc_admdvs = item.InsuplcAdmdvs
  8665. }
  8666. }
  8667. psn := &models.HisPsn{
  8668. PsnNo: res.Output.Baseinfo.PsnNo,
  8669. PatientId: patient.ID,
  8670. Certno: res.Output.Baseinfo.Certno,
  8671. Gend: res.Output.Baseinfo.Gend,
  8672. Naty: res.Output.Baseinfo.Naty,
  8673. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8674. PsnName: res.Output.Baseinfo.PsnName,
  8675. Idetinfo: idetinfoStr,
  8676. Insuinfo: infoStr,
  8677. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8678. CardInfo: basStr,
  8679. InsuplcAdmdvs: insuplc_admdvs,
  8680. VerifyNumber: "",
  8681. }
  8682. service.CreateHisPsn(psn)
  8683. c.ServeSuccessJSON(map[string]interface{}{
  8684. "patient": patient,
  8685. "number": basNumber,
  8686. "insutype": insutype,
  8687. })
  8688. }
  8689. } else {
  8690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8691. return
  8692. }
  8693. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8694. fmt.Println(initFlag)
  8695. fmt.Println("initFlag")
  8696. if initFlag == 0 {
  8697. c.TestGetHnBasBaseInit()
  8698. }
  8699. basStr := c.GetBasBaseInfo()
  8700. if len(basStr) == 0 {
  8701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8702. return
  8703. }
  8704. fmt.Println(basStr)
  8705. bas := strings.Split(basStr, "|")
  8706. basNumber := bas[1]
  8707. fmt.Println(basNumber)
  8708. card_sn := bas[3]
  8709. card_no := bas[2]
  8710. fmt.Println(card_sn)
  8711. name := bas[4]
  8712. name = ConvertToString(name, "gbk", "utf-8")
  8713. 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)
  8714. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8715. var dat map[string]interface{}
  8716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8717. fmt.Println(dat)
  8718. } else {
  8719. fmt.Println(err)
  8720. }
  8721. userJSONBytes, _ := json.Marshal(dat)
  8722. var res ResultTwo
  8723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8724. utils.ErrorLog("解析失败:%v", err)
  8725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8726. return
  8727. }
  8728. if res.Infcode == 0 {
  8729. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8730. if err == gorm.ErrRecordNotFound {
  8731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8732. return
  8733. } else if err != nil {
  8734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8735. return
  8736. } else {
  8737. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8738. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8739. infoStr := string(Iinfos)
  8740. idetinfoStr := string(Idetinfos)
  8741. psn := &models.HisPsn{
  8742. PsnNo: res.Output.Baseinfo.PsnNo,
  8743. PatientId: patient.ID,
  8744. Certno: res.Output.Baseinfo.Certno,
  8745. Gend: res.Output.Baseinfo.Gend,
  8746. Naty: res.Output.Baseinfo.Naty,
  8747. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8748. PsnName: res.Output.Baseinfo.PsnName,
  8749. Idetinfo: idetinfoStr,
  8750. Insuinfo: infoStr,
  8751. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8752. CardInfo: basStr,
  8753. VerifyNumber: "",
  8754. }
  8755. service.CreateHisPsn(psn)
  8756. var rf []*ResultFive
  8757. json.Unmarshal([]byte(infoStr), &rf)
  8758. var insutypes []*ResultFive
  8759. var insutype string
  8760. var is390 int = 0
  8761. var is310 int = 0
  8762. for _, item := range rf {
  8763. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8764. insutypes = append(insutypes, item)
  8765. }
  8766. }
  8767. if len(insutypes) == 1 {
  8768. insutype = insutypes[0].Insutype
  8769. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8770. } else {
  8771. for _, i := range insutypes {
  8772. if i.Insutype == "390" {
  8773. is390 = 1
  8774. }
  8775. if i.Insutype == "310" {
  8776. is310 = 1
  8777. }
  8778. }
  8779. }
  8780. if is390 == 1 {
  8781. insutype = "390"
  8782. }
  8783. if is310 == 1 {
  8784. insutype = "310"
  8785. }
  8786. if len(insutypes) == 0 {
  8787. insutype = "310"
  8788. }
  8789. c.ServeSuccessJSON(map[string]interface{}{
  8790. "patient": patient,
  8791. "number": basNumber,
  8792. "insutype": insutype,
  8793. })
  8794. }
  8795. } else {
  8796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8797. return
  8798. }
  8799. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8800. var api string
  8801. 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 +
  8802. "&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
  8803. fmt.Println(api)
  8804. resp, requestErr := http.Get(api)
  8805. if requestErr != nil {
  8806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8807. return
  8808. }
  8809. body, ioErr := ioutil.ReadAll(resp.Body)
  8810. if ioErr != nil {
  8811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8813. return
  8814. }
  8815. var respJSON map[string]interface{}
  8816. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8819. return
  8820. }
  8821. var res ResultTwo //1101结果
  8822. var res10265 ResultTwo10265 //1101结果
  8823. var card_info string //卡信息
  8824. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8825. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8826. result, _ := json.Marshal(respJSON)
  8827. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8828. utils.ErrorLog("解析失败:%v", err)
  8829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8830. return
  8831. }
  8832. res.ErrMsg = res10265.ErrMsg
  8833. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8834. res.Infcode = infocode
  8835. res.Output = res10265.Output
  8836. res.InfRefmsgid = res10265.InfRefmsgid
  8837. if res.Infcode == 0 {
  8838. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8839. if err == gorm.ErrRecordNotFound {
  8840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8841. return
  8842. } else if err != nil {
  8843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8844. return
  8845. } else {
  8846. bas := strings.Split(card_info, "|")
  8847. basNumber := bas[2]
  8848. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8849. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8850. infoStr := string(Iinfos)
  8851. idetinfoStr := string(Idetinfos)
  8852. psn := &models.HisPsn{
  8853. PsnNo: res.Output.Baseinfo.PsnNo,
  8854. PatientId: patient.ID,
  8855. Certno: res.Output.Baseinfo.Certno,
  8856. Gend: res.Output.Baseinfo.Gend,
  8857. Naty: res.Output.Baseinfo.Naty,
  8858. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8859. PsnName: res.Output.Baseinfo.PsnName,
  8860. Idetinfo: idetinfoStr,
  8861. Insuinfo: infoStr,
  8862. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8863. CardInfo: card_info,
  8864. VerifyNumber: token,
  8865. }
  8866. service.CreateHisPsn(psn)
  8867. var rf []*ResultFive
  8868. json.Unmarshal([]byte(infoStr), &rf)
  8869. var insutypes []*ResultFive
  8870. var insutype string
  8871. var is390 int = 0
  8872. var is310 int = 0
  8873. for _, item := range rf {
  8874. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8875. insutypes = append(insutypes, item)
  8876. }
  8877. }
  8878. if len(insutypes) == 1 {
  8879. insutype = insutypes[0].Insutype
  8880. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8881. } else {
  8882. for _, i := range insutypes {
  8883. if i.Insutype == "390" {
  8884. is390 = 1
  8885. }
  8886. if i.Insutype == "310" {
  8887. is310 = 1
  8888. }
  8889. }
  8890. }
  8891. if is390 == 1 {
  8892. insutype = "390"
  8893. }
  8894. if is310 == 1 {
  8895. insutype = "310"
  8896. }
  8897. if len(insutypes) == 0 {
  8898. insutype = "310"
  8899. }
  8900. c.ServeSuccessJSON(map[string]interface{}{
  8901. "patient": patient,
  8902. "number": basNumber,
  8903. "insutype": insutype,
  8904. })
  8905. }
  8906. } else {
  8907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8908. return
  8909. }
  8910. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8911. res := c.GetoleInfo()
  8912. if res.Infcode == 0 {
  8913. var result string
  8914. if res.Output.MdtrtCertType == "01" {
  8915. 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)
  8916. } else if res.Output.MdtrtCertType == "02" {
  8917. 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)
  8918. } else if res.Output.MdtrtCertType == "03" {
  8919. 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)
  8920. }
  8921. var dat map[string]interface{}
  8922. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8923. fmt.Println(dat)
  8924. } else {
  8925. fmt.Println(err)
  8926. }
  8927. userJSONBytes, _ := json.Marshal(dat)
  8928. var res2 ResultTwo
  8929. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8930. utils.ErrorLog("解析失败:%v", err)
  8931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8932. return
  8933. }
  8934. if res2.Infcode == 0 {
  8935. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8936. if err == gorm.ErrRecordNotFound {
  8937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8938. return
  8939. } else if err != nil {
  8940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8941. return
  8942. } else {
  8943. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8944. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8945. infoStr := string(Iinfos)
  8946. idetinfoStr := string(Idetinfos)
  8947. var rf []*ResultFive
  8948. json.Unmarshal([]byte(infoStr), &rf)
  8949. var insutypes []*ResultFive
  8950. var insutype string
  8951. var is390 int = 0
  8952. var is310 int = 0
  8953. //var insuplc_admdvs string
  8954. for _, item := range rf {
  8955. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8956. insutypes = append(insutypes, item)
  8957. }
  8958. }
  8959. if len(insutypes) == 1 {
  8960. insutype = insutypes[0].Insutype
  8961. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8962. } else {
  8963. for _, i := range insutypes {
  8964. if i.Insutype == "390" {
  8965. is390 = 1
  8966. }
  8967. if i.Insutype == "310" {
  8968. is310 = 1
  8969. }
  8970. }
  8971. }
  8972. if is390 == 1 {
  8973. insutype = "390"
  8974. }
  8975. if is310 == 1 {
  8976. insutype = "310"
  8977. }
  8978. if len(insutypes) == 0 {
  8979. insutype = "310"
  8980. }
  8981. psn := &models.HisPsn{
  8982. PsnNo: res2.Output.Baseinfo.PsnNo,
  8983. PatientId: patient.ID,
  8984. Certno: res2.Output.Baseinfo.Certno,
  8985. Gend: res2.Output.Baseinfo.Gend,
  8986. Naty: res2.Output.Baseinfo.Naty,
  8987. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8988. PsnName: res2.Output.Baseinfo.PsnName,
  8989. Idetinfo: idetinfoStr,
  8990. Insuinfo: infoStr,
  8991. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8992. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8993. VerifyNumber: res.Output.EcToken,
  8994. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8995. }
  8996. if res.Output.MdtrtCertType == "01" {
  8997. psn.VerifyNumber = res.Output.EcToken
  8998. //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)
  8999. } else if res.Output.MdtrtCertType == "02" {
  9000. psn.VerifyNumber = res.Output.MdtrtCertNo
  9001. //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)
  9002. } else if res.Output.MdtrtCertType == "03" {
  9003. psn.VerifyNumber = res.Output.MdtrtCertNo
  9004. //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)
  9005. }
  9006. var balc float64
  9007. for _, item := range rf {
  9008. if item.Insutype == insutype {
  9009. balc = item.Balc
  9010. }
  9011. }
  9012. service.CreateHisPsn(psn)
  9013. c.ServeSuccessJSON(map[string]interface{}{
  9014. "patient": patient,
  9015. "number": res.Output.CardNo,
  9016. "insutype": insutype,
  9017. "blac": balc,
  9018. "desc": idetinfoStr,
  9019. })
  9020. }
  9021. } else {
  9022. c.ServeSuccessJSON(map[string]interface{}{
  9023. "failed_code": -10,
  9024. "msg": res2.ErrMsg,
  9025. })
  9026. }
  9027. } else {
  9028. c.ServeSuccessJSON(map[string]interface{}{
  9029. "failed_code": -10,
  9030. "msg": res.ErrMsg,
  9031. })
  9032. }
  9033. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9034. var api string
  9035. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9036. "&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
  9037. fmt.Println(api)
  9038. resp, requestErr := http.Get(api)
  9039. if requestErr != nil {
  9040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9041. return
  9042. }
  9043. body, ioErr := ioutil.ReadAll(resp.Body)
  9044. if ioErr != nil {
  9045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9047. return
  9048. }
  9049. var respJSON map[string]interface{}
  9050. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9053. return
  9054. }
  9055. var status string
  9056. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9057. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9058. //console.log()
  9059. fmt.Println("type===")
  9060. fmt.Println(card_type)
  9061. var token string
  9062. var res ResultTwo //1101结果
  9063. //var res10265 ResultTwoesultTwo10265 //1101结果
  9064. var card_info string //卡信息
  9065. var busi_card_info string
  9066. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9067. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9068. if status == "0" { //读卡成功
  9069. if card_type == "1" {
  9070. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9071. result, _ := json.Marshal(respJSON)
  9072. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9073. utils.ErrorLog("解析失败:%v", err)
  9074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9075. return
  9076. }
  9077. } else {
  9078. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9079. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9080. result, _ := json.Marshal(respJSON)
  9081. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9082. utils.ErrorLog("解析失败:%v", err)
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9084. return
  9085. }
  9086. }
  9087. if res.Infcode == 0 {
  9088. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9089. if err == gorm.ErrRecordNotFound {
  9090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9091. return
  9092. } else if err != nil {
  9093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9094. return
  9095. } else {
  9096. if card_type == "1" {
  9097. bas := strings.Split(card_info, "|")
  9098. basNumber := bas[2]
  9099. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9100. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9101. infoStr := string(Iinfos)
  9102. idetinfoStr := string(Idetinfos)
  9103. psn := &models.HisPsn{
  9104. PsnNo: res.Output.Baseinfo.PsnNo,
  9105. PatientId: patient.ID,
  9106. Certno: res.Output.Baseinfo.Certno,
  9107. Gend: res.Output.Baseinfo.Gend,
  9108. Naty: res.Output.Baseinfo.Naty,
  9109. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9110. PsnName: res.Output.Baseinfo.PsnName,
  9111. Idetinfo: idetinfoStr,
  9112. Insuinfo: infoStr,
  9113. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9114. CardInfo: card_info,
  9115. VerifyNumber: busi_card_info,
  9116. }
  9117. service.CreateHisPsn(psn)
  9118. var rf []*ResultFive
  9119. json.Unmarshal([]byte(infoStr), &rf)
  9120. var insutypes []*ResultFive
  9121. var insutype string
  9122. var is390 int = 0
  9123. var is310 int = 0
  9124. for _, item := range rf {
  9125. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9126. insutypes = append(insutypes, item)
  9127. }
  9128. }
  9129. if len(insutypes) == 1 {
  9130. insutype = insutypes[0].Insutype
  9131. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9132. } else {
  9133. for _, i := range insutypes {
  9134. if i.Insutype == "390" {
  9135. is390 = 1
  9136. }
  9137. if i.Insutype == "310" {
  9138. is310 = 1
  9139. }
  9140. }
  9141. }
  9142. if is390 == 1 {
  9143. insutype = "390"
  9144. }
  9145. if is310 == 1 {
  9146. insutype = "310"
  9147. }
  9148. if len(insutypes) == 0 {
  9149. insutype = "310"
  9150. }
  9151. c.ServeSuccessJSON(map[string]interface{}{
  9152. "patient": patient,
  9153. "number": basNumber,
  9154. "insutype": insutype,
  9155. })
  9156. } else {
  9157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9159. infoStr := string(Iinfos)
  9160. idetinfoStr := string(Idetinfos)
  9161. psn := &models.HisPsn{
  9162. PsnNo: res.Output.Baseinfo.PsnNo,
  9163. PatientId: patient.ID,
  9164. Certno: res.Output.Baseinfo.Certno,
  9165. Gend: res.Output.Baseinfo.Gend,
  9166. Naty: res.Output.Baseinfo.Naty,
  9167. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9168. PsnName: res.Output.Baseinfo.PsnName,
  9169. Idetinfo: idetinfoStr,
  9170. Insuinfo: infoStr,
  9171. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9172. CardInfo: card_info,
  9173. VerifyNumber: token,
  9174. }
  9175. service.CreateHisPsn(psn)
  9176. c.ServeSuccessJSON(map[string]interface{}{
  9177. "patient": patient,
  9178. "number": token,
  9179. })
  9180. }
  9181. }
  9182. } else {
  9183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9184. return
  9185. }
  9186. } else { //读卡失败
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9188. return
  9189. }
  9190. } else {
  9191. if initFlag == 0 {
  9192. c.TestGetBasBaseInit()
  9193. }
  9194. basStr := c.GetBasBaseInfo()
  9195. if len(basStr) == 0 {
  9196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9197. return
  9198. }
  9199. fmt.Println(basStr)
  9200. bas := strings.Split(basStr, "|")
  9201. basNumber := bas[1]
  9202. fmt.Println(basNumber)
  9203. card_sn := bas[3]
  9204. fmt.Println(card_sn)
  9205. cardNumber := bas[2]
  9206. fmt.Println(cardNumber)
  9207. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  9208. var result string
  9209. if bas[0][:2] == "44" {
  9210. 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)
  9211. } else {
  9212. 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)
  9213. }
  9214. var dat map[string]interface{}
  9215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9216. fmt.Println(dat)
  9217. } else {
  9218. fmt.Println(err)
  9219. }
  9220. userJSONBytes, _ := json.Marshal(dat)
  9221. var res ResultTwo
  9222. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9223. utils.ErrorLog("解析失败:%v", err)
  9224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9225. return
  9226. }
  9227. if res.Infcode == 0 {
  9228. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9229. if err == gorm.ErrRecordNotFound {
  9230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9231. return
  9232. } else if err != nil {
  9233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9234. return
  9235. } else {
  9236. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9237. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9238. infoStr := string(Iinfos)
  9239. idetinfoStr := string(Idetinfos)
  9240. var rf []*ResultFive
  9241. json.Unmarshal([]byte(infoStr), &rf)
  9242. var insutypes []*ResultFive
  9243. var insutype string
  9244. var is390 int = 0
  9245. var is310 int = 0
  9246. var insuplc_admdvs string
  9247. for _, item := range rf {
  9248. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9249. insutypes = append(insutypes, item)
  9250. }
  9251. }
  9252. if len(insutypes) == 1 {
  9253. insutype = insutypes[0].Insutype
  9254. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9255. } else {
  9256. for _, i := range insutypes {
  9257. if i.Insutype == "390" {
  9258. is390 = 1
  9259. }
  9260. if i.Insutype == "310" {
  9261. is310 = 1
  9262. }
  9263. }
  9264. }
  9265. if is390 == 1 {
  9266. insutype = "390"
  9267. }
  9268. if is310 == 1 {
  9269. insutype = "310"
  9270. }
  9271. if len(insutypes) == 0 {
  9272. insutype = "310"
  9273. }
  9274. for _, item := range rf {
  9275. if item.Insutype == insutype {
  9276. insuplc_admdvs = item.InsuplcAdmdvs
  9277. }
  9278. }
  9279. psn := &models.HisPsn{
  9280. PsnNo: res.Output.Baseinfo.PsnNo,
  9281. PatientId: patient.ID,
  9282. Certno: res.Output.Baseinfo.Certno,
  9283. Gend: res.Output.Baseinfo.Gend,
  9284. Naty: res.Output.Baseinfo.Naty,
  9285. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9286. PsnName: res.Output.Baseinfo.PsnName,
  9287. Idetinfo: idetinfoStr,
  9288. Insuinfo: infoStr,
  9289. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9290. CardInfo: basStr,
  9291. VerifyNumber: "",
  9292. InsuplcAdmdvs: insuplc_admdvs,
  9293. }
  9294. service.CreateHisPsn(psn)
  9295. c.ServeSuccessJSON(map[string]interface{}{
  9296. "patient": patient,
  9297. "number": basNumber,
  9298. })
  9299. }
  9300. } else {
  9301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9302. return
  9303. }
  9304. break
  9305. }
  9306. case 2:
  9307. if miConfig.MdtrtareaAdmvs == "430800" {
  9308. if initFlag == 0 {
  9309. c.TestGetHnBasBaseInit()
  9310. }
  9311. SFZStr := c.GetSFZBaseInfo()
  9312. if len(SFZStr) == 0 {
  9313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9314. return
  9315. }
  9316. fmt.Println(SFZStr)
  9317. id_card_str := strings.Split(SFZStr, "^")
  9318. card_no := id_card_str[0]
  9319. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9320. //name := id_card_str[1]
  9321. //name = ConvertToString(name, "gbk", "utf-8")
  9322. 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)
  9323. var dat map[string]interface{}
  9324. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9325. fmt.Println(dat)
  9326. } else {
  9327. fmt.Println(err)
  9328. }
  9329. userJSONBytes, _ := json.Marshal(dat)
  9330. var res ResultTwo
  9331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9332. utils.ErrorLog("解析失败:%v", err)
  9333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9334. return
  9335. }
  9336. if res.Infcode == 0 {
  9337. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9338. if err == gorm.ErrRecordNotFound {
  9339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9340. return
  9341. } else if err != nil {
  9342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9343. return
  9344. } else {
  9345. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9346. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9347. infoStr := string(Iinfos)
  9348. idetinfoStr := string(Idetinfos)
  9349. var rf []*ResultFive
  9350. json.Unmarshal([]byte(infoStr), &rf)
  9351. var insutypes []*ResultFive
  9352. var insutype string
  9353. var is390 int = 0
  9354. var is310 int = 0
  9355. for _, item := range rf {
  9356. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9357. insutypes = append(insutypes, item)
  9358. }
  9359. }
  9360. if len(insutypes) == 1 {
  9361. insutype = insutypes[0].Insutype
  9362. } else {
  9363. for _, i := range insutypes {
  9364. if i.Insutype == "390" {
  9365. is390 = 1
  9366. }
  9367. if i.Insutype == "310" {
  9368. is310 = 1
  9369. }
  9370. }
  9371. }
  9372. if is390 == 1 {
  9373. insutype = "390"
  9374. }
  9375. if is310 == 1 {
  9376. insutype = "310"
  9377. }
  9378. if len(insutypes) == 0 {
  9379. insutype = "310"
  9380. }
  9381. var InsuplcAdmdvs string
  9382. for _, item := range rf {
  9383. if item.Insutype == insutype {
  9384. InsuplcAdmdvs = item.InsuplcAdmdvs
  9385. }
  9386. }
  9387. psn := &models.HisPsn{
  9388. PsnNo: res.Output.Baseinfo.PsnNo,
  9389. PatientId: patient.ID,
  9390. Certno: res.Output.Baseinfo.Certno,
  9391. Gend: res.Output.Baseinfo.Gend,
  9392. Naty: res.Output.Baseinfo.Naty,
  9393. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9394. PsnName: res.Output.Baseinfo.PsnName,
  9395. Idetinfo: idetinfoStr,
  9396. Insuinfo: infoStr,
  9397. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9398. CardInfo: SFZStr,
  9399. VerifyNumber: "",
  9400. InsuplcAdmdvs: InsuplcAdmdvs,
  9401. }
  9402. service.CreateHisPsn(psn)
  9403. c.ServeSuccessJSON(map[string]interface{}{
  9404. "patient": patient,
  9405. "number": card_no,
  9406. "insutype": insutype,
  9407. })
  9408. }
  9409. } else {
  9410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9411. return
  9412. }
  9413. } else if miConfig.MdtrtareaAdmvs == "420200" {
  9414. var res ResultTwo
  9415. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  9416. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9417. "&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)
  9418. resp, requestErr := http.Get(api)
  9419. if requestErr != nil {
  9420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9421. return
  9422. }
  9423. body, ioErr := ioutil.ReadAll(resp.Body)
  9424. if ioErr != nil {
  9425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9427. return
  9428. }
  9429. var respJSON map[string]interface{}
  9430. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9433. return
  9434. }
  9435. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9436. result, _ := json.Marshal(respJSON)
  9437. fmt.Println("log")
  9438. fmt.Println(string(result))
  9439. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9440. utils.ErrorLog("解析失败:%v", err)
  9441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9442. return
  9443. }
  9444. if res.Infcode == 0 {
  9445. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9446. if err == gorm.ErrRecordNotFound {
  9447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9448. return
  9449. } else if err != nil {
  9450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9451. return
  9452. } else {
  9453. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9454. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9455. infoStr := string(Iinfos)
  9456. idetinfoStr := string(Idetinfos)
  9457. psn := &models.HisPsn{
  9458. PsnNo: res.Output.Baseinfo.PsnNo,
  9459. PatientId: patient.ID,
  9460. Certno: res.Output.Baseinfo.Certno,
  9461. Gend: res.Output.Baseinfo.Gend,
  9462. Naty: res.Output.Baseinfo.Naty,
  9463. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9464. PsnName: res.Output.Baseinfo.PsnName,
  9465. Idetinfo: idetinfoStr,
  9466. Insuinfo: infoStr,
  9467. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9468. }
  9469. service.CreateHisPsn(psn)
  9470. c.ServeSuccessJSON(map[string]interface{}{
  9471. "patient": patient,
  9472. "number": res.Output.Baseinfo.Certno,
  9473. })
  9474. }
  9475. } else {
  9476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9477. return
  9478. }
  9479. } else if miConfig.MdtrtareaAdmvs == "421182" {
  9480. var res ResultTwo
  9481. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9482. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9483. "&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)
  9484. resp, requestErr := http.Get(api)
  9485. if requestErr != nil {
  9486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9487. return
  9488. }
  9489. body, ioErr := ioutil.ReadAll(resp.Body)
  9490. if ioErr != nil {
  9491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9493. return
  9494. }
  9495. var respJSON map[string]interface{}
  9496. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9499. return
  9500. }
  9501. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9502. result, _ := json.Marshal(respJSON)
  9503. fmt.Println("log")
  9504. fmt.Println(string(result))
  9505. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9506. utils.ErrorLog("解析失败:%v", err)
  9507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9508. return
  9509. }
  9510. if res.Infcode == 0 {
  9511. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9512. if err == gorm.ErrRecordNotFound {
  9513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9514. return
  9515. } else if err != nil {
  9516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9517. return
  9518. } else {
  9519. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9520. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9521. infoStr := string(Iinfos)
  9522. idetinfoStr := string(Idetinfos)
  9523. psn := &models.HisPsn{
  9524. PsnNo: res.Output.Baseinfo.PsnNo,
  9525. PatientId: patient.ID,
  9526. Certno: res.Output.Baseinfo.Certno,
  9527. Gend: res.Output.Baseinfo.Gend,
  9528. Naty: res.Output.Baseinfo.Naty,
  9529. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9530. PsnName: res.Output.Baseinfo.PsnName,
  9531. Idetinfo: idetinfoStr,
  9532. Insuinfo: infoStr,
  9533. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9534. }
  9535. service.CreateHisPsn(psn)
  9536. c.ServeSuccessJSON(map[string]interface{}{
  9537. "patient": patient,
  9538. "number": res.Output.Baseinfo.Certno,
  9539. })
  9540. }
  9541. } else {
  9542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9543. return
  9544. }
  9545. } else if miConfig.MdtrtareaAdmvs == "420902" {
  9546. var res ResultTwo
  9547. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9548. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9549. "&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)
  9550. resp, requestErr := http.Get(api)
  9551. if requestErr != nil {
  9552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9553. return
  9554. }
  9555. body, ioErr := ioutil.ReadAll(resp.Body)
  9556. if ioErr != nil {
  9557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9559. return
  9560. }
  9561. var respJSON map[string]interface{}
  9562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9565. return
  9566. }
  9567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9568. result, _ := json.Marshal(respJSON)
  9569. fmt.Println("log")
  9570. fmt.Println(string(result))
  9571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9572. utils.ErrorLog("解析失败:%v", err)
  9573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9574. return
  9575. }
  9576. if res.Infcode == 0 {
  9577. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9578. if err == gorm.ErrRecordNotFound {
  9579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9580. return
  9581. } else if err != nil {
  9582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9583. return
  9584. } else {
  9585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9586. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9587. infoStr := string(Iinfos)
  9588. idetinfoStr := string(Idetinfos)
  9589. var rf []*ResultFive
  9590. json.Unmarshal([]byte(infoStr), &rf)
  9591. var insutypes []*ResultFive
  9592. var insutype string
  9593. var is390 int = 0
  9594. var is310 int = 0
  9595. for _, item := range rf {
  9596. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9597. insutypes = append(insutypes, item)
  9598. }
  9599. }
  9600. if len(insutypes) == 1 {
  9601. insutype = insutypes[0].Insutype
  9602. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9603. } else {
  9604. for _, i := range insutypes {
  9605. if i.Insutype == "390" {
  9606. is390 = 1
  9607. }
  9608. if i.Insutype == "310" {
  9609. is310 = 1
  9610. }
  9611. }
  9612. }
  9613. if is390 == 1 {
  9614. insutype = "390"
  9615. }
  9616. if is310 == 1 {
  9617. insutype = "310"
  9618. }
  9619. if len(insutypes) == 0 {
  9620. insutype = "390"
  9621. }
  9622. var insuplc_admdvs string
  9623. for _, item := range rf {
  9624. if item.Insutype == insutype {
  9625. insuplc_admdvs = item.InsuplcAdmdvs
  9626. }
  9627. }
  9628. psn := &models.HisPsn{
  9629. PsnNo: res.Output.Baseinfo.PsnNo,
  9630. PatientId: patient.ID,
  9631. Certno: res.Output.Baseinfo.Certno,
  9632. Gend: res.Output.Baseinfo.Gend,
  9633. Naty: res.Output.Baseinfo.Naty,
  9634. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9635. PsnName: res.Output.Baseinfo.PsnName,
  9636. Idetinfo: idetinfoStr,
  9637. Insuinfo: infoStr,
  9638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9639. InsuplcAdmdvs: insuplc_admdvs,
  9640. }
  9641. service.CreateHisPsn(psn)
  9642. c.ServeSuccessJSON(map[string]interface{}{
  9643. "patient": patient,
  9644. "number": res.Output.Baseinfo.Certno,
  9645. })
  9646. }
  9647. } else {
  9648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9649. return
  9650. }
  9651. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9652. res := c.GetoleInfo()
  9653. if res.Infcode == 0 {
  9654. var result string
  9655. if res.Output.MdtrtCertType == "01" {
  9656. 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)
  9657. } else if res.Output.MdtrtCertType == "02" {
  9658. 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)
  9659. } else if res.Output.MdtrtCertType == "03" {
  9660. 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)
  9661. }
  9662. var dat map[string]interface{}
  9663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9664. fmt.Println(dat)
  9665. } else {
  9666. fmt.Println(err)
  9667. }
  9668. userJSONBytes, _ := json.Marshal(dat)
  9669. var res2 ResultTwo
  9670. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9671. utils.ErrorLog("解析失败:%v", err)
  9672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9673. return
  9674. }
  9675. if res2.Infcode == 0 {
  9676. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9677. if err == gorm.ErrRecordNotFound {
  9678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9679. return
  9680. } else if err != nil {
  9681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9682. return
  9683. } else {
  9684. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9685. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9686. infoStr := string(Iinfos)
  9687. idetinfoStr := string(Idetinfos)
  9688. var rf []*ResultFive
  9689. json.Unmarshal([]byte(infoStr), &rf)
  9690. var insutypes []*ResultFive
  9691. var insutype string
  9692. var is390 int = 0
  9693. var is310 int = 0
  9694. //var insuplc_admdvs string
  9695. for _, item := range rf {
  9696. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9697. insutypes = append(insutypes, item)
  9698. }
  9699. }
  9700. if len(insutypes) == 1 {
  9701. insutype = insutypes[0].Insutype
  9702. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9703. } else {
  9704. for _, i := range insutypes {
  9705. if i.Insutype == "390" {
  9706. is390 = 1
  9707. }
  9708. if i.Insutype == "310" {
  9709. is310 = 1
  9710. }
  9711. }
  9712. }
  9713. if is390 == 1 {
  9714. insutype = "390"
  9715. }
  9716. if is310 == 1 {
  9717. insutype = "310"
  9718. }
  9719. if len(insutypes) == 0 {
  9720. insutype = "310"
  9721. }
  9722. psn := &models.HisPsn{
  9723. PsnNo: res2.Output.Baseinfo.PsnNo,
  9724. PatientId: patient.ID,
  9725. //Brdy: res2.Output.Baseinfo.Brdy,
  9726. Certno: res2.Output.Baseinfo.Certno,
  9727. Gend: res2.Output.Baseinfo.Gend,
  9728. Naty: res2.Output.Baseinfo.Naty,
  9729. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9730. PsnName: res2.Output.Baseinfo.PsnName,
  9731. Idetinfo: idetinfoStr,
  9732. Insuinfo: infoStr,
  9733. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9734. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9735. VerifyNumber: res.Output.EcToken,
  9736. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9737. }
  9738. service.CreateHisPsn(psn)
  9739. var balc float64
  9740. for _, item := range rf {
  9741. if item.Insutype == insutype {
  9742. balc = item.Balc
  9743. }
  9744. }
  9745. c.ServeSuccessJSON(map[string]interface{}{
  9746. "patient": patient,
  9747. "number": res.Output.CardNo,
  9748. "insutype": insutype,
  9749. "blac": balc,
  9750. "desc": idetinfoStr,
  9751. })
  9752. }
  9753. } else {
  9754. c.ServeSuccessJSON(map[string]interface{}{
  9755. "failed_code": -10,
  9756. "msg": res2.ErrMsg,
  9757. })
  9758. }
  9759. } else {
  9760. c.ServeSuccessJSON(map[string]interface{}{
  9761. "failed_code": -10,
  9762. "msg": res.ErrMsg,
  9763. })
  9764. }
  9765. } else {
  9766. SFZStr := c.GetSFZBaseInfo()
  9767. id_card_str := strings.Split(SFZStr, "^")
  9768. id_card_number := id_card_str[0]
  9769. card_sn := ""
  9770. 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)
  9771. var dat map[string]interface{}
  9772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9773. fmt.Println(dat)
  9774. } else {
  9775. fmt.Println(err)
  9776. }
  9777. userJSONBytes, _ := json.Marshal(dat)
  9778. var res ResultTwo
  9779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9780. utils.ErrorLog("解析失败:%v", err)
  9781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9782. return
  9783. }
  9784. if res.Infcode == 0 {
  9785. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9786. if err == gorm.ErrRecordNotFound {
  9787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9788. return
  9789. } else if err != nil {
  9790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9791. return
  9792. } else {
  9793. c.ServeSuccessJSON(map[string]interface{}{
  9794. "patient": patient,
  9795. "number": id_card_number,
  9796. })
  9797. }
  9798. } else {
  9799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9800. return
  9801. }
  9802. }
  9803. break
  9804. case 3:
  9805. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9806. var api string
  9807. if miConfig.MdtrtareaAdmvs == "320921" {
  9808. 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 +
  9809. "&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
  9810. fmt.Println(api)
  9811. } else {
  9812. 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 +
  9813. "&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)
  9814. }
  9815. resp, requestErr := http.Get(api)
  9816. if requestErr != nil {
  9817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9818. return
  9819. }
  9820. body, ioErr := ioutil.ReadAll(resp.Body)
  9821. if ioErr != nil {
  9822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9824. return
  9825. }
  9826. var respJSON map[string]interface{}
  9827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9830. return
  9831. }
  9832. var status string
  9833. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9834. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9835. var token string
  9836. var res ResultTwo //1101结果
  9837. var res10265 ResultTwo10265 //1101结果
  9838. var card_info string //卡信息
  9839. var busi_card_info string
  9840. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9841. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9842. if status == "0" { //读卡成功
  9843. if card_type == "1" {
  9844. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9845. result, _ := json.Marshal(respJSON)
  9846. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9847. utils.ErrorLog("解析失败:%v", err)
  9848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9849. return
  9850. }
  9851. res.ErrMsg = res10265.ErrMsg
  9852. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9853. res.Infcode = infocode
  9854. res.Output = res10265.Output
  9855. res.InfRefmsgid = res10265.InfRefmsgid
  9856. } else {
  9857. //var card_info string //卡信息
  9858. //var busi_card_info string
  9859. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9860. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9861. //fmt.Println(card_info)
  9862. //fmt.Println(busi_card_info)
  9863. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9864. result, _ := json.Marshal(respJSON)
  9865. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9866. utils.ErrorLog("解析失败:%v", err)
  9867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9868. return
  9869. }
  9870. res.ErrMsg = res10265.ErrMsg
  9871. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9872. res.Infcode = infocode
  9873. res.Output = res10265.Output
  9874. res.InfRefmsgid = res10265.InfRefmsgid
  9875. }
  9876. if res.Infcode == 0 {
  9877. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9878. if err == gorm.ErrRecordNotFound {
  9879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9880. return
  9881. } else if err != nil {
  9882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9883. return
  9884. } else {
  9885. if card_type == "1" {
  9886. bas := strings.Split(card_info, "|")
  9887. basNumber := bas[2]
  9888. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9889. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9890. infoStr := string(Iinfos)
  9891. idetinfoStr := string(Idetinfos)
  9892. psn := &models.HisPsn{
  9893. PsnNo: res.Output.Baseinfo.PsnNo,
  9894. PatientId: patient.ID,
  9895. Certno: res.Output.Baseinfo.Certno,
  9896. //Brdy: res.Output.Baseinfo.Brdy,
  9897. Gend: res.Output.Baseinfo.Gend,
  9898. Naty: res.Output.Baseinfo.Naty,
  9899. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9900. PsnName: res.Output.Baseinfo.PsnName,
  9901. Idetinfo: idetinfoStr,
  9902. Insuinfo: infoStr,
  9903. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9904. CardInfo: card_info,
  9905. VerifyNumber: busi_card_info,
  9906. }
  9907. service.CreateHisPsn(psn)
  9908. c.ServeSuccessJSON(map[string]interface{}{
  9909. "patient": patient,
  9910. "number": basNumber,
  9911. })
  9912. } else {
  9913. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9914. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9915. infoStr := string(Iinfos)
  9916. idetinfoStr := string(Idetinfos)
  9917. psn := &models.HisPsn{
  9918. PsnNo: res.Output.Baseinfo.PsnNo,
  9919. PatientId: patient.ID,
  9920. Certno: res.Output.Baseinfo.Certno,
  9921. Gend: res.Output.Baseinfo.Gend,
  9922. Naty: res.Output.Baseinfo.Naty,
  9923. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9924. PsnName: res.Output.Baseinfo.PsnName,
  9925. Idetinfo: idetinfoStr,
  9926. Insuinfo: infoStr,
  9927. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9928. CardInfo: card_info,
  9929. VerifyNumber: token,
  9930. }
  9931. service.CreateHisPsn(psn)
  9932. var rf []*ResultFive
  9933. json.Unmarshal([]byte(infoStr), &rf)
  9934. var insutypes []*ResultFive
  9935. var insutype string
  9936. var is390 int = 0
  9937. var is310 int = 0
  9938. for _, item := range rf {
  9939. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9940. insutypes = append(insutypes, item)
  9941. }
  9942. }
  9943. if len(insutypes) == 1 {
  9944. insutype = insutypes[0].Insutype
  9945. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9946. } else {
  9947. for _, i := range insutypes {
  9948. if i.Insutype == "390" {
  9949. is390 = 1
  9950. }
  9951. if i.Insutype == "310" {
  9952. is310 = 1
  9953. }
  9954. }
  9955. }
  9956. if is390 == 1 {
  9957. insutype = "390"
  9958. }
  9959. if is310 == 1 {
  9960. insutype = "310"
  9961. }
  9962. if len(insutypes) == 0 {
  9963. insutype = "310"
  9964. }
  9965. c.ServeSuccessJSON(map[string]interface{}{
  9966. "patient": patient,
  9967. "number": token,
  9968. "insutype": insutype,
  9969. })
  9970. }
  9971. }
  9972. } else {
  9973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9974. return
  9975. }
  9976. } else { //读卡失败
  9977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9978. return
  9979. }
  9980. }
  9981. break
  9982. case 4:
  9983. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9984. var api string
  9985. if miConfig.MdtrtareaAdmvs == "320921" {
  9986. 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 +
  9987. "&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
  9988. fmt.Println(api)
  9989. } else {
  9990. 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 +
  9991. "&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)
  9992. }
  9993. resp, requestErr := http.Get(api)
  9994. if requestErr != nil {
  9995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9996. return
  9997. }
  9998. body, ioErr := ioutil.ReadAll(resp.Body)
  9999. if ioErr != nil {
  10000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10002. return
  10003. }
  10004. var respJSON map[string]interface{}
  10005. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10008. return
  10009. }
  10010. var status string
  10011. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10012. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10013. var token string
  10014. var res ResultTwo //1101结果
  10015. var res10265 ResultTwo10265 //1101结果
  10016. if status == "0" { //读卡成功
  10017. var card_info string //卡信息
  10018. var busi_card_info string
  10019. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10020. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10021. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10022. fmt.Println(card_info)
  10023. fmt.Println(busi_card_info)
  10024. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10025. result, _ := json.Marshal(respJSON)
  10026. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10027. utils.ErrorLog("解析失败:%v", err)
  10028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10029. return
  10030. }
  10031. res.ErrMsg = res10265.ErrMsg
  10032. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10033. res.Infcode = infocode
  10034. res.Output = res10265.Output
  10035. res.InfRefmsgid = res10265.InfRefmsgid
  10036. if res.Infcode == 0 {
  10037. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10038. if err == gorm.ErrRecordNotFound {
  10039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10040. return
  10041. } else if err != nil {
  10042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10043. return
  10044. } else {
  10045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10047. infoStr := string(Iinfos)
  10048. idetinfoStr := string(Idetinfos)
  10049. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10050. psn := &models.HisPsn{
  10051. PsnNo: res.Output.Baseinfo.PsnNo,
  10052. PatientId: patient.ID,
  10053. Certno: res.Output.Baseinfo.Certno,
  10054. Brdy: b,
  10055. Age: float64(age),
  10056. //Brdy: res.Output.Baseinfo.Brdy,
  10057. Gend: res.Output.Baseinfo.Gend,
  10058. Naty: res.Output.Baseinfo.Naty,
  10059. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10060. PsnName: res.Output.Baseinfo.PsnName,
  10061. Idetinfo: idetinfoStr,
  10062. Insuinfo: infoStr,
  10063. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10064. CardInfo: card_info,
  10065. VerifyNumber: token,
  10066. }
  10067. var rf []*ResultFive
  10068. json.Unmarshal([]byte(infoStr), &rf)
  10069. var insutypes []*ResultFive
  10070. var insutype string
  10071. var is390 int = 0
  10072. var is310 int = 0
  10073. for _, item := range rf {
  10074. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10075. insutypes = append(insutypes, item)
  10076. }
  10077. }
  10078. if len(insutypes) == 1 {
  10079. insutype = insutypes[0].Insutype
  10080. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10081. } else {
  10082. for _, i := range insutypes {
  10083. if i.Insutype == "390" {
  10084. is390 = 1
  10085. }
  10086. if i.Insutype == "310" {
  10087. is310 = 1
  10088. }
  10089. }
  10090. }
  10091. if is390 == 1 {
  10092. insutype = "390"
  10093. }
  10094. if is310 == 1 {
  10095. insutype = "310"
  10096. }
  10097. if len(insutypes) == 0 {
  10098. insutype = "310"
  10099. }
  10100. service.CreateHisPsn(psn)
  10101. c.ServeSuccessJSON(map[string]interface{}{
  10102. "patient": patient,
  10103. "number": token,
  10104. "insutype": insutype,
  10105. })
  10106. }
  10107. } else {
  10108. c.ServeSuccessJSON(map[string]interface{}{
  10109. "failed_code": -10,
  10110. "msg": res.ErrMsg,
  10111. })
  10112. }
  10113. } else { //读卡失败
  10114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10115. return
  10116. }
  10117. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10118. var api string
  10119. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10120. "&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
  10121. resp, requestErr := http.Get(api)
  10122. if requestErr != nil {
  10123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10124. return
  10125. }
  10126. body, ioErr := ioutil.ReadAll(resp.Body)
  10127. if ioErr != nil {
  10128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10130. return
  10131. }
  10132. var respJSON map[string]interface{}
  10133. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10136. return
  10137. }
  10138. var status string
  10139. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10140. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10141. var token string
  10142. var res ResultTwo //1101结果
  10143. if status == "1" { //读卡成功
  10144. var card_info string //卡信息
  10145. var busi_card_info string
  10146. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10147. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10148. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10149. fmt.Println(card_info)
  10150. fmt.Println(busi_card_info)
  10151. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10152. result, _ := json.Marshal(respJSON)
  10153. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10154. utils.ErrorLog("解析失败:%v", err)
  10155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10156. return
  10157. }
  10158. if res.Infcode == 0 {
  10159. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10160. if err == gorm.ErrRecordNotFound {
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10162. return
  10163. } else if err != nil {
  10164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10165. return
  10166. } else {
  10167. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10168. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10169. infoStr := string(Iinfos)
  10170. idetinfoStr := string(Idetinfos)
  10171. psn := &models.HisPsn{
  10172. PsnNo: res.Output.Baseinfo.PsnNo,
  10173. PatientId: patient.ID,
  10174. Certno: res.Output.Baseinfo.Certno,
  10175. Gend: res.Output.Baseinfo.Gend,
  10176. Naty: res.Output.Baseinfo.Naty,
  10177. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10178. PsnName: res.Output.Baseinfo.PsnName,
  10179. Idetinfo: idetinfoStr,
  10180. Insuinfo: infoStr,
  10181. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10182. CardInfo: card_info,
  10183. VerifyNumber: token,
  10184. }
  10185. var rf []*ResultFive
  10186. json.Unmarshal([]byte(infoStr), &rf)
  10187. var insutypes []*ResultFive
  10188. var insutype string
  10189. var is390 int = 0
  10190. var is310 int = 0
  10191. for _, item := range rf {
  10192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10193. insutypes = append(insutypes, item)
  10194. }
  10195. }
  10196. if len(insutypes) == 1 {
  10197. insutype = insutypes[0].Insutype
  10198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10199. } else {
  10200. for _, i := range insutypes {
  10201. if i.Insutype == "390" {
  10202. is390 = 1
  10203. }
  10204. if i.Insutype == "310" {
  10205. is310 = 1
  10206. }
  10207. }
  10208. }
  10209. if is390 == 1 {
  10210. insutype = "390"
  10211. }
  10212. if is310 == 1 {
  10213. insutype = "310"
  10214. }
  10215. if len(insutypes) == 0 {
  10216. insutype = "310"
  10217. }
  10218. service.CreateHisPsn(psn)
  10219. c.ServeSuccessJSON(map[string]interface{}{
  10220. "patient": patient,
  10221. "number": token,
  10222. "insutype": insutype,
  10223. })
  10224. }
  10225. } else {
  10226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10227. return
  10228. }
  10229. } else { //读卡失败
  10230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10231. return
  10232. }
  10233. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10234. idNo := c.GetString("idNo")
  10235. userName := c.GetString("userName")
  10236. ecToken := c.GetString("ecToken")
  10237. insuOrg := c.GetString("insuOrg")
  10238. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10239. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10240. var res ResultTwo
  10241. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10242. utils.ErrorLog("解析失败:%v", err)
  10243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10244. return
  10245. }
  10246. if res.Infcode == 0 {
  10247. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10248. if err == gorm.ErrRecordNotFound {
  10249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10250. return
  10251. } else if err != nil {
  10252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10253. return
  10254. } else {
  10255. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10256. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10257. infoStr := string(Iinfos)
  10258. idetinfoStr := string(Idetinfos)
  10259. psn := &models.HisPsn{
  10260. PsnNo: res.Output.Baseinfo.PsnNo,
  10261. PatientId: patient.ID,
  10262. Certno: res.Output.Baseinfo.Certno,
  10263. Gend: res.Output.Baseinfo.Gend,
  10264. Naty: res.Output.Baseinfo.Naty,
  10265. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10266. PsnName: res.Output.Baseinfo.PsnName,
  10267. Idetinfo: idetinfoStr,
  10268. Insuinfo: infoStr,
  10269. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10270. CardInfo: "",
  10271. Stage: "1",
  10272. VerifyNumber: ecToken,
  10273. InsuplcAdmdvs: insuOrg,
  10274. }
  10275. service.CreateHisPsn(psn)
  10276. var rf []*ResultFive
  10277. json.Unmarshal([]byte(infoStr), &rf)
  10278. var insutypes []*ResultFive
  10279. var insutype string
  10280. var is390 int = 0
  10281. var is310 int = 0
  10282. for _, item := range rf {
  10283. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10284. insutypes = append(insutypes, item)
  10285. }
  10286. }
  10287. if len(insutypes) == 1 {
  10288. insutype = insutypes[0].Insutype
  10289. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10290. } else {
  10291. for _, i := range insutypes {
  10292. if i.Insutype == "390" {
  10293. is390 = 1
  10294. }
  10295. if i.Insutype == "310" {
  10296. is310 = 1
  10297. }
  10298. }
  10299. }
  10300. if is390 == 1 {
  10301. insutype = "390"
  10302. }
  10303. if is310 == 1 {
  10304. insutype = "310"
  10305. }
  10306. if len(insutypes) == 0 {
  10307. insutype = "310"
  10308. }
  10309. c.ServeSuccessJSON(map[string]interface{}{
  10310. "patient": patient,
  10311. "number": ecToken,
  10312. "insutype": insutype,
  10313. })
  10314. }
  10315. } else {
  10316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10317. return
  10318. }
  10319. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10320. //if initFlag == 0 {
  10321. //c.TestGetJiangXiBasBaseInit()
  10322. //}
  10323. //if initEleFlag == 0 {
  10324. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10325. //}
  10326. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  10327. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  10328. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10329. type ELeData struct {
  10330. Data struct {
  10331. IdNo string `json:"idNo"`
  10332. IdType string `json:"idType"`
  10333. UserName string `json:"userName"`
  10334. EcToken string `json:"ecToken"`
  10335. InsuOrg string `json:"insuOrg"`
  10336. Gender string `json:"gender"`
  10337. Birthday string `json:"birthday"`
  10338. Nationality string `json:"nationality"`
  10339. Email string `json:"email"`
  10340. Extra string `json:"extra"`
  10341. } `json:"data"`
  10342. Code int `json:"code"`
  10343. Message string `json:"message"`
  10344. }
  10345. var ele ELeData
  10346. err := json.Unmarshal([]byte(result), &ele)
  10347. if err != nil {
  10348. utils.ErrorLog("解析失败:%v", err)
  10349. }
  10350. token := ele.Data.EcToken
  10351. token = Remove0000(token)
  10352. 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)
  10353. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10354. var res ResultTwo
  10355. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10356. utils.ErrorLog("解析失败:%v", err)
  10357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10358. return
  10359. }
  10360. if res.Infcode == 0 {
  10361. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10362. if err == gorm.ErrRecordNotFound {
  10363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10364. return
  10365. } else if err != nil {
  10366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10367. return
  10368. } else {
  10369. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10370. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10371. infoStr := string(Iinfos)
  10372. idetinfoStr := string(Idetinfos)
  10373. psn := &models.HisPsn{
  10374. PsnNo: res.Output.Baseinfo.PsnNo,
  10375. PatientId: patient.ID,
  10376. Certno: res.Output.Baseinfo.Certno,
  10377. Gend: res.Output.Baseinfo.Gend,
  10378. Naty: res.Output.Baseinfo.Naty,
  10379. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10380. PsnName: res.Output.Baseinfo.PsnName,
  10381. Idetinfo: idetinfoStr,
  10382. Insuinfo: infoStr,
  10383. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10384. CardInfo: "",
  10385. VerifyNumber: token,
  10386. }
  10387. service.CreateHisPsn(psn)
  10388. var rf []*ResultFive
  10389. json.Unmarshal([]byte(infoStr), &rf)
  10390. var insutypes []*ResultFive
  10391. var insutype string
  10392. var is390 int = 0
  10393. var is310 int = 0
  10394. for _, item := range rf {
  10395. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10396. insutypes = append(insutypes, item)
  10397. }
  10398. }
  10399. if len(insutypes) == 1 {
  10400. insutype = insutypes[0].Insutype
  10401. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10402. } else {
  10403. for _, i := range insutypes {
  10404. if i.Insutype == "390" {
  10405. is390 = 1
  10406. }
  10407. if i.Insutype == "310" {
  10408. is310 = 1
  10409. }
  10410. }
  10411. }
  10412. if is390 == 1 {
  10413. insutype = "390"
  10414. }
  10415. if is310 == 1 {
  10416. insutype = "310"
  10417. }
  10418. if len(insutypes) == 0 {
  10419. insutype = "310"
  10420. }
  10421. c.ServeSuccessJSON(map[string]interface{}{
  10422. "patient": patient,
  10423. "number": token,
  10424. "insutype": insutype,
  10425. })
  10426. }
  10427. } else {
  10428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10429. return
  10430. }
  10431. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10432. //if initFlag == 0 {
  10433. c.TestGetJiangXiBasBaseInit()
  10434. //}
  10435. //if initEleFlag == 0 {
  10436. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10437. //}
  10438. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10439. type ELeData struct {
  10440. Data struct {
  10441. IdNo string `json:"idNo"`
  10442. IdType string `json:"idType"`
  10443. UserName string `json:"userName"`
  10444. EcToken string `json:"ecToken"`
  10445. InsuOrg string `json:"insuOrg"`
  10446. Gender string `json:"gender"`
  10447. Birthday string `json:"birthday"`
  10448. Nationality string `json:"nationality"`
  10449. Email string `json:"email"`
  10450. Extra string `json:"extra"`
  10451. } `json:"data"`
  10452. Code int `json:"code"`
  10453. Message string `json:"message"`
  10454. }
  10455. var ele ELeData
  10456. err := json.Unmarshal([]byte(json_result), &ele)
  10457. if err != nil {
  10458. utils.ErrorLog("解析失败:%v", err)
  10459. }
  10460. token := ele.Data.EcToken
  10461. token = Remove0000(token)
  10462. 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)
  10463. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10464. var res ResultTwo
  10465. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10466. utils.ErrorLog("解析失败:%v", err)
  10467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10468. return
  10469. }
  10470. if res.Infcode == 0 {
  10471. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10472. if err == gorm.ErrRecordNotFound {
  10473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10474. return
  10475. } else if err != nil {
  10476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10477. return
  10478. } else {
  10479. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10480. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10481. infoStr := string(Iinfos)
  10482. idetinfoStr := string(Idetinfos)
  10483. psn := &models.HisPsn{
  10484. PsnNo: res.Output.Baseinfo.PsnNo,
  10485. PatientId: patient.ID,
  10486. Certno: res.Output.Baseinfo.Certno,
  10487. Gend: res.Output.Baseinfo.Gend,
  10488. Naty: res.Output.Baseinfo.Naty,
  10489. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10490. PsnName: res.Output.Baseinfo.PsnName,
  10491. Idetinfo: idetinfoStr,
  10492. Insuinfo: infoStr,
  10493. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10494. CardInfo: "",
  10495. VerifyNumber: token,
  10496. }
  10497. service.CreateHisPsn(psn)
  10498. var rf []*ResultFive
  10499. json.Unmarshal([]byte(infoStr), &rf)
  10500. var insutypes []*ResultFive
  10501. var insutype string
  10502. var is390 int = 0
  10503. var is310 int = 0
  10504. for _, item := range rf {
  10505. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10506. insutypes = append(insutypes, item)
  10507. }
  10508. }
  10509. if len(insutypes) == 1 {
  10510. insutype = insutypes[0].Insutype
  10511. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10512. } else {
  10513. for _, i := range insutypes {
  10514. if i.Insutype == "390" {
  10515. is390 = 1
  10516. }
  10517. if i.Insutype == "310" {
  10518. is310 = 1
  10519. }
  10520. }
  10521. }
  10522. if is390 == 1 {
  10523. insutype = "390"
  10524. }
  10525. if is310 == 1 {
  10526. insutype = "310"
  10527. }
  10528. if len(insutypes) == 0 {
  10529. insutype = "310"
  10530. }
  10531. c.ServeSuccessJSON(map[string]interface{}{
  10532. "patient": patient,
  10533. "number": token,
  10534. "insutype": insutype,
  10535. })
  10536. }
  10537. } else {
  10538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10539. return
  10540. }
  10541. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10542. type ELeData struct {
  10543. Code string `json:"code"`
  10544. Data struct {
  10545. Aac002 string `json:"aac002"`
  10546. Aaz500 string `json:"aaz500"`
  10547. ActCardNo string `json:"actCardNo"`
  10548. Bab520 string `json:"bab520"`
  10549. Bkz543 string `json:"bkz543"`
  10550. BusinessType string `json:"businessType"`
  10551. CertfCodg string `json:"certfCodg"`
  10552. EcIndexNo string `json:"ecIndexNo"`
  10553. EcToken string `json:"ecToken"`
  10554. ID0000 string `json:"id0000"`
  10555. IDNo string `json:"idNo"`
  10556. IDType string `json:"idType"`
  10557. Idcode string `json:"idcode"`
  10558. IdentityToken string `json:"identity_token"`
  10559. InsuOrg string `json:"insuOrg"`
  10560. OfficeID string `json:"officeId"`
  10561. OfficeName string `json:"officeName"`
  10562. OperatorID string `json:"operatorId"`
  10563. OperatorName string `json:"operatorName"`
  10564. OrgID string `json:"orgId"`
  10565. UserName string `json:"userName"`
  10566. } `json:"data"`
  10567. Infno interface{} `json:"infno"`
  10568. Message string `json:"message"`
  10569. OrgID string `json:"orgId"`
  10570. TransType string `json:"transType"`
  10571. }
  10572. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  10573. outPutInfo = Remove0000(outPutInfo)
  10574. if len(outPutInfo) > 0 {
  10575. var ele ELeData
  10576. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10577. if err != nil {
  10578. utils.ErrorLog("解析失败:%v", err)
  10579. }
  10580. token := ele.Data.EcToken
  10581. fmt.Println(inputInfo)
  10582. fmt.Println(outPutInfo)
  10583. 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)
  10584. saveLog(result, requestLog, "1101", "获取人员信息")
  10585. var dat map[string]interface{}
  10586. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10587. fmt.Println(dat)
  10588. } else {
  10589. fmt.Println(err)
  10590. }
  10591. userJSONBytes, _ := json.Marshal(dat)
  10592. var res ResultTwo
  10593. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10594. utils.ErrorLog("解析失败:%v", err)
  10595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10596. return
  10597. }
  10598. res.ErrMsg = errMsgLog
  10599. if res.Infcode == 0 {
  10600. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10601. if err == gorm.ErrRecordNotFound {
  10602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10603. return
  10604. } else if err != nil {
  10605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10606. return
  10607. } else {
  10608. fmt.Println(res)
  10609. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10610. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10611. infoStr := string(Iinfos)
  10612. idetinfoStr := string(Idetinfos)
  10613. psn := &models.HisPsn{
  10614. PsnNo: res.Output.Baseinfo.PsnNo,
  10615. PatientId: patient.ID,
  10616. Certno: res.Output.Baseinfo.Certno,
  10617. Gend: res.Output.Baseinfo.Gend,
  10618. Naty: res.Output.Baseinfo.Naty,
  10619. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10620. PsnName: res.Output.Baseinfo.PsnName,
  10621. Idetinfo: idetinfoStr,
  10622. Insuinfo: infoStr,
  10623. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10624. CardInfo: outPutInfo,
  10625. VerifyNumber: token,
  10626. InsuplcAdmdvs: ele.Data.InsuOrg,
  10627. }
  10628. service.CreateHisPsn(psn)
  10629. var rf []*ResultFive
  10630. json.Unmarshal([]byte(infoStr), &rf)
  10631. var insutypes []*ResultFive
  10632. var insutype string
  10633. var is390 int = 0
  10634. var is310 int = 0
  10635. for _, item := range rf {
  10636. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10637. insutypes = append(insutypes, item)
  10638. }
  10639. }
  10640. if len(insutypes) == 1 {
  10641. insutype = insutypes[0].Insutype
  10642. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10643. } else {
  10644. for _, i := range insutypes {
  10645. if i.Insutype == "390" {
  10646. is390 = 1
  10647. }
  10648. if i.Insutype == "310" {
  10649. is310 = 1
  10650. }
  10651. }
  10652. }
  10653. if is390 == 1 {
  10654. insutype = "390"
  10655. }
  10656. if is310 == 1 {
  10657. insutype = "310"
  10658. }
  10659. if len(insutypes) == 0 {
  10660. insutype = "310"
  10661. }
  10662. c.ServeSuccessJSON(map[string]interface{}{
  10663. "patient": patient,
  10664. "number": token,
  10665. "insutype": insutype,
  10666. })
  10667. }
  10668. } else {
  10669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10670. return
  10671. }
  10672. }
  10673. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10674. var api string
  10675. 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 +
  10676. "&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
  10677. resp, requestErr := http.Get(api)
  10678. if requestErr != nil {
  10679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10680. return
  10681. }
  10682. body, ioErr := ioutil.ReadAll(resp.Body)
  10683. if ioErr != nil {
  10684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10686. return
  10687. }
  10688. var respJSON map[string]interface{}
  10689. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10692. return
  10693. }
  10694. var status string
  10695. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10696. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10697. var token string
  10698. var res ResultTwo //1101结果
  10699. var res10265 ResultTwo10265 //1101结果
  10700. if status == "0" { //读卡成功
  10701. var card_info string //卡信息
  10702. var busi_card_info string
  10703. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10704. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10705. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10706. fmt.Println(card_info)
  10707. fmt.Println(busi_card_info)
  10708. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10709. result, _ := json.Marshal(respJSON)
  10710. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10711. utils.ErrorLog("解析失败:%v", err)
  10712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10713. return
  10714. }
  10715. res.ErrMsg = res10265.ErrMsg
  10716. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10717. res.Infcode = infocode
  10718. res.Output = res10265.Output
  10719. res.InfRefmsgid = res10265.InfRefmsgid
  10720. if res.Infcode == 0 {
  10721. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10722. if err == gorm.ErrRecordNotFound {
  10723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10724. return
  10725. } else if err != nil {
  10726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10727. return
  10728. } else {
  10729. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10730. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10731. infoStr := string(Iinfos)
  10732. idetinfoStr := string(Idetinfos)
  10733. psn := &models.HisPsn{
  10734. PsnNo: res.Output.Baseinfo.PsnNo,
  10735. PatientId: patient.ID,
  10736. Certno: res.Output.Baseinfo.Certno,
  10737. Gend: res.Output.Baseinfo.Gend,
  10738. Naty: res.Output.Baseinfo.Naty,
  10739. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10740. PsnName: res.Output.Baseinfo.PsnName,
  10741. Idetinfo: idetinfoStr,
  10742. Insuinfo: infoStr,
  10743. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10744. CardInfo: card_info,
  10745. VerifyNumber: token,
  10746. }
  10747. var rf []*ResultFive
  10748. json.Unmarshal([]byte(infoStr), &rf)
  10749. var insutypes []*ResultFive
  10750. var insutype string
  10751. var is390 int = 0
  10752. var is310 int = 0
  10753. for _, item := range rf {
  10754. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10755. insutypes = append(insutypes, item)
  10756. }
  10757. }
  10758. if len(insutypes) == 1 {
  10759. insutype = insutypes[0].Insutype
  10760. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10761. } else {
  10762. for _, i := range insutypes {
  10763. if i.Insutype == "390" {
  10764. is390 = 1
  10765. }
  10766. if i.Insutype == "310" {
  10767. is310 = 1
  10768. }
  10769. }
  10770. }
  10771. if is390 == 1 {
  10772. insutype = "390"
  10773. }
  10774. if is310 == 1 {
  10775. insutype = "310"
  10776. }
  10777. if len(insutypes) == 0 {
  10778. insutype = "310"
  10779. }
  10780. service.CreateHisPsn(psn)
  10781. c.ServeSuccessJSON(map[string]interface{}{
  10782. "patient": patient,
  10783. "number": token,
  10784. "insutype": insutype,
  10785. })
  10786. }
  10787. } else {
  10788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10789. return
  10790. }
  10791. } else { //读卡失败
  10792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10793. return
  10794. }
  10795. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10796. res := c.GetoleInfo()
  10797. if res.Infcode == 0 {
  10798. var result string
  10799. if res.Output.MdtrtCertType == "01" {
  10800. 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)
  10801. } else if res.Output.MdtrtCertType == "02" {
  10802. 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)
  10803. } else if res.Output.MdtrtCertType == "03" {
  10804. 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)
  10805. }
  10806. var dat map[string]interface{}
  10807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10808. fmt.Println(dat)
  10809. } else {
  10810. fmt.Println(err)
  10811. }
  10812. userJSONBytes, _ := json.Marshal(dat)
  10813. var res2 ResultTwo
  10814. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10815. utils.ErrorLog("解析失败:%v", err)
  10816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10817. return
  10818. }
  10819. if res2.Infcode == 0 {
  10820. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10821. if err == gorm.ErrRecordNotFound {
  10822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10823. return
  10824. } else if err != nil {
  10825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10826. return
  10827. } else {
  10828. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10829. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10830. infoStr := string(Iinfos)
  10831. idetinfoStr := string(Idetinfos)
  10832. var rf []*ResultFive
  10833. json.Unmarshal([]byte(infoStr), &rf)
  10834. var insutypes []*ResultFive
  10835. var insutype string
  10836. var is390 int = 0
  10837. var is310 int = 0
  10838. //var insuplc_admdvs string
  10839. for _, item := range rf {
  10840. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10841. insutypes = append(insutypes, item)
  10842. }
  10843. }
  10844. if len(insutypes) == 1 {
  10845. insutype = insutypes[0].Insutype
  10846. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10847. } else {
  10848. for _, i := range insutypes {
  10849. if i.Insutype == "390" {
  10850. is390 = 1
  10851. }
  10852. if i.Insutype == "310" {
  10853. is310 = 1
  10854. }
  10855. }
  10856. }
  10857. if is390 == 1 {
  10858. insutype = "390"
  10859. }
  10860. if is310 == 1 {
  10861. insutype = "310"
  10862. }
  10863. if len(insutypes) == 0 {
  10864. insutype = "310"
  10865. }
  10866. psn := &models.HisPsn{
  10867. PsnNo: res2.Output.Baseinfo.PsnNo,
  10868. PatientId: patient.ID,
  10869. Certno: res2.Output.Baseinfo.Certno,
  10870. Gend: res2.Output.Baseinfo.Gend,
  10871. Naty: res2.Output.Baseinfo.Naty,
  10872. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10873. PsnName: res2.Output.Baseinfo.PsnName,
  10874. Idetinfo: idetinfoStr,
  10875. Insuinfo: infoStr,
  10876. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10877. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10878. VerifyNumber: res.Output.EcToken,
  10879. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10880. }
  10881. if res.Output.MdtrtCertType == "01" {
  10882. psn.VerifyNumber = res.Output.EcToken
  10883. //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)
  10884. } else if res.Output.MdtrtCertType == "02" {
  10885. psn.VerifyNumber = res.Output.CardNo
  10886. //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)
  10887. } else if res.Output.MdtrtCertType == "03" {
  10888. psn.VerifyNumber = res.Output.MdtrtCertNo
  10889. //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)
  10890. }
  10891. service.CreateHisPsn(psn)
  10892. var balc float64
  10893. for _, item := range rf {
  10894. if item.Insutype == insutype {
  10895. balc = item.Balc
  10896. }
  10897. }
  10898. c.ServeSuccessJSON(map[string]interface{}{
  10899. "patient": patient,
  10900. "number": res.Output.CardNo,
  10901. "insutype": insutype,
  10902. "blac": balc,
  10903. "desc": idetinfoStr,
  10904. })
  10905. }
  10906. } else {
  10907. c.ServeSuccessJSON(map[string]interface{}{
  10908. "failed_code": -10,
  10909. "msg": res2.ErrMsg,
  10910. })
  10911. }
  10912. } else {
  10913. c.ServeSuccessJSON(map[string]interface{}{
  10914. "failed_code": -10,
  10915. "msg": res.ErrMsg,
  10916. })
  10917. }
  10918. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10919. var res ResultTwo
  10920. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10921. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10922. "&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)
  10923. resp, requestErr := http.Get(api)
  10924. if requestErr != nil {
  10925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10926. return
  10927. }
  10928. body, ioErr := ioutil.ReadAll(resp.Body)
  10929. if ioErr != nil {
  10930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10932. return
  10933. }
  10934. var respJSON map[string]interface{}
  10935. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10938. return
  10939. }
  10940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10941. result, _ := json.Marshal(respJSON)
  10942. fmt.Println("log")
  10943. fmt.Println(string(result))
  10944. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10945. utils.ErrorLog("解析失败:%v", err)
  10946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10947. return
  10948. }
  10949. if res.Infcode == 0 {
  10950. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10951. if err == gorm.ErrRecordNotFound {
  10952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10953. return
  10954. } else if err != nil {
  10955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10956. return
  10957. } else {
  10958. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10959. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10960. infoStr := string(Iinfos)
  10961. idetinfoStr := string(Idetinfos)
  10962. var rf []*ResultFive
  10963. json.Unmarshal([]byte(infoStr), &rf)
  10964. var insutypes []*ResultFive
  10965. var insutype string
  10966. var is390 int = 0
  10967. var is310 int = 0
  10968. for _, item := range rf {
  10969. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10970. insutypes = append(insutypes, item)
  10971. }
  10972. }
  10973. if len(insutypes) == 1 {
  10974. insutype = insutypes[0].Insutype
  10975. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10976. } else {
  10977. for _, i := range insutypes {
  10978. if i.Insutype == "390" {
  10979. is390 = 1
  10980. }
  10981. if i.Insutype == "310" {
  10982. is310 = 1
  10983. }
  10984. }
  10985. }
  10986. if is390 == 1 {
  10987. insutype = "390"
  10988. }
  10989. if is310 == 1 {
  10990. insutype = "310"
  10991. }
  10992. if len(insutypes) == 0 {
  10993. insutype = "390"
  10994. }
  10995. var insuplc_admdvs string
  10996. for _, item := range rf {
  10997. if item.Insutype == insutype {
  10998. insuplc_admdvs = item.InsuplcAdmdvs
  10999. }
  11000. }
  11001. psn := &models.HisPsn{
  11002. PsnNo: res.Output.Baseinfo.PsnNo,
  11003. PatientId: patient.ID,
  11004. Certno: res.Output.Baseinfo.Certno,
  11005. Gend: res.Output.Baseinfo.Gend,
  11006. Naty: res.Output.Baseinfo.Naty,
  11007. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11008. PsnName: res.Output.Baseinfo.PsnName,
  11009. Idetinfo: idetinfoStr,
  11010. Insuinfo: infoStr,
  11011. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11012. InsuplcAdmdvs: insuplc_admdvs,
  11013. }
  11014. service.CreateHisPsn(psn)
  11015. c.ServeSuccessJSON(map[string]interface{}{
  11016. "patient": patient,
  11017. "number": res.Output.Baseinfo.Certno,
  11018. })
  11019. }
  11020. } else {
  11021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11022. return
  11023. }
  11024. } else {
  11025. type ELeData struct {
  11026. Code string `json:"code"`
  11027. Data struct {
  11028. Aac002 string `json:"aac002"`
  11029. Aaz500 string `json:"aaz500"`
  11030. ActCardNo string `json:"actCardNo"`
  11031. Bab520 string `json:"bab520"`
  11032. Bkz543 string `json:"bkz543"`
  11033. BusinessType string `json:"businessType"`
  11034. CertfCodg string `json:"certfCodg"`
  11035. EcIndexNo string `json:"ecIndexNo"`
  11036. EcToken string `json:"ecToken"`
  11037. ID0000 string `json:"id0000"`
  11038. IDNo string `json:"idNo"`
  11039. IDType string `json:"idType"`
  11040. Idcode string `json:"idcode"`
  11041. IdentityToken string `json:"identity_token"`
  11042. InsuOrg string `json:"insuOrg"`
  11043. OfficeID string `json:"officeId"`
  11044. OfficeName string `json:"officeName"`
  11045. OperatorID string `json:"operatorId"`
  11046. OperatorName string `json:"operatorName"`
  11047. OrgID string `json:"orgId"`
  11048. UserName string `json:"userName"`
  11049. } `json:"data"`
  11050. Infno interface{} `json:"infno"`
  11051. Message string `json:"message"`
  11052. OrgID string `json:"orgId"`
  11053. TransType string `json:"transType"`
  11054. }
  11055. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  11056. fmt.Println(result)
  11057. outPutInfo := Remove0000(result)
  11058. fmt.Println(outPutInfo)
  11059. if len(outPutInfo) > 0 {
  11060. var ele ELeData
  11061. err := json.Unmarshal([]byte(outPutInfo), &ele)
  11062. if err != nil {
  11063. utils.ErrorLog("解析失败:%v", err)
  11064. }
  11065. token := ele.Data.EcToken
  11066. fmt.Println(outPutInfo)
  11067. 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)
  11068. saveLog(result, requestLog, "1101", "获取人员信息")
  11069. var dat map[string]interface{}
  11070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11071. fmt.Println(dat)
  11072. } else {
  11073. fmt.Println(err)
  11074. }
  11075. userJSONBytes, _ := json.Marshal(dat)
  11076. var res ResultTwo
  11077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11078. utils.ErrorLog("解析失败:%v", err)
  11079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11080. return
  11081. }
  11082. if res.Infcode == 0 {
  11083. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  11084. if err == gorm.ErrRecordNotFound {
  11085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11086. return
  11087. } else if err != nil {
  11088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11089. return
  11090. } else {
  11091. fmt.Println(res)
  11092. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11093. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11094. infoStr := string(Iinfos)
  11095. idetinfoStr := string(Idetinfos)
  11096. psn := &models.HisPsn{
  11097. PsnNo: res.Output.Baseinfo.PsnNo,
  11098. PatientId: patient.ID,
  11099. Certno: res.Output.Baseinfo.Certno,
  11100. Gend: res.Output.Baseinfo.Gend,
  11101. Naty: res.Output.Baseinfo.Naty,
  11102. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11103. PsnName: res.Output.Baseinfo.PsnName,
  11104. Idetinfo: idetinfoStr,
  11105. Insuinfo: infoStr,
  11106. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11107. CardInfo: outPutInfo,
  11108. VerifyNumber: token,
  11109. InsuplcAdmdvs: ele.Data.InsuOrg,
  11110. }
  11111. service.CreateHisPsn(psn)
  11112. var rf []*ResultFive
  11113. json.Unmarshal([]byte(infoStr), &rf)
  11114. var insutypes []*ResultFive
  11115. var insutype string
  11116. var is390 int = 0
  11117. var is310 int = 0
  11118. for _, item := range rf {
  11119. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11120. insutypes = append(insutypes, item)
  11121. }
  11122. }
  11123. if len(insutypes) == 1 {
  11124. insutype = insutypes[0].Insutype
  11125. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11126. } else {
  11127. for _, i := range insutypes {
  11128. if i.Insutype == "390" {
  11129. is390 = 1
  11130. }
  11131. if i.Insutype == "310" {
  11132. is310 = 1
  11133. }
  11134. }
  11135. }
  11136. if is390 == 1 {
  11137. insutype = "390"
  11138. }
  11139. if is310 == 1 {
  11140. insutype = "310"
  11141. }
  11142. if len(insutypes) == 0 {
  11143. insutype = "310"
  11144. }
  11145. c.ServeSuccessJSON(map[string]interface{}{
  11146. "patient": patient,
  11147. "number": token,
  11148. "insutype": insutype,
  11149. })
  11150. }
  11151. } else {
  11152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11153. return
  11154. }
  11155. }
  11156. //fmt.Println(result)
  11157. //
  11158. //if initFlag == 0 {
  11159. // c.TestGetBasBaseInit()
  11160. //}
  11161. //token := c.GetEleBaseInfo()
  11162. //
  11163. //token = Remove0000(token)
  11164. //
  11165. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  11166. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  11167. ////
  11168. //var res ResultTwo
  11169. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11170. // utils.ErrorLog("解析失败:%v", err)
  11171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11172. // return
  11173. //}
  11174. //
  11175. //if res.Infcode == 0 {
  11176. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11177. // if err == gorm.ErrRecordNotFound {
  11178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11179. // return
  11180. // } else if err != nil {
  11181. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11182. // return
  11183. //
  11184. // } else {
  11185. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11186. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11187. // infoStr := string(Iinfos)
  11188. // idetinfoStr := string(Idetinfos)
  11189. //
  11190. //
  11191. //
  11192. //
  11193. // var rf []*ResultFive
  11194. // json.Unmarshal([]byte(infoStr), &rf)
  11195. //
  11196. // var insutypes []*ResultFive
  11197. // var insutype string
  11198. // var is390 int = 0
  11199. // var is310 int = 0
  11200. // var insuplc_admdvs string
  11201. //
  11202. // for _, item := range rf {
  11203. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11204. // insutypes = append(insutypes, item)
  11205. // }
  11206. // }
  11207. //
  11208. // if len(insutypes) == 1 {
  11209. // insutype = insutypes[0].Insutype
  11210. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11211. // } else {
  11212. // for _, i := range insutypes {
  11213. // if i.Insutype == "390" {
  11214. // is390 = 1
  11215. // }
  11216. //
  11217. // if i.Insutype == "310" {
  11218. // is310 = 1
  11219. // }
  11220. // }
  11221. // }
  11222. // if is390 == 1 {
  11223. // insutype = "390"
  11224. // }
  11225. //
  11226. // if is310 == 1 {
  11227. // insutype = "310"
  11228. // }
  11229. // if len(insutypes) == 0 {
  11230. // insutype = "310"
  11231. // }
  11232. // for _, item := range rf {
  11233. // if item.Insutype == insutype {
  11234. // insuplc_admdvs = item.InsuplcAdmdvs
  11235. // }
  11236. // }
  11237. // psn := &models.HisPsn{
  11238. // PsnNo: res.Output.Baseinfo.PsnNo,
  11239. // Age: res.Output.Baseinfo.Age,
  11240. // PatientId: patient.ID,
  11241. // Certno: res.Output.Baseinfo.Certno,
  11242. // Brdy: res.Output.Baseinfo.Brdy,
  11243. // Gend: res.Output.Baseinfo.Gend,
  11244. // Naty: res.Output.Baseinfo.Naty,
  11245. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  11246. // PsnName: res.Output.Baseinfo.PsnName,
  11247. // Idetinfo: idetinfoStr,
  11248. // Insuinfo: infoStr,
  11249. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11250. // CardInfo: "",
  11251. // VerifyNumber: token,
  11252. // InsuplcAdmdvs: insuplc_admdvs,
  11253. // }
  11254. // service.CreateHisPsn(psn)
  11255. //
  11256. // c.ServeSuccessJSON(map[string]interface{}{
  11257. // "patient": patient,
  11258. // "number": token,
  11259. // })
  11260. // }
  11261. //} else {
  11262. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11263. // return
  11264. //}
  11265. }
  11266. break
  11267. case 5:
  11268. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11269. var api string
  11270. if miConfig.MdtrtareaAdmvs == "320921" {
  11271. 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 +
  11272. "&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
  11273. fmt.Println(api)
  11274. } else {
  11275. 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 +
  11276. "&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)
  11277. }
  11278. resp, requestErr := http.Get(api)
  11279. if requestErr != nil {
  11280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11281. return
  11282. }
  11283. body, ioErr := ioutil.ReadAll(resp.Body)
  11284. if ioErr != nil {
  11285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11287. return
  11288. }
  11289. var respJSON map[string]interface{}
  11290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11293. return
  11294. }
  11295. var status string
  11296. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11297. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11298. var token string
  11299. var res ResultTwo //1101结果
  11300. var res10265 ResultTwo10265 //1101结果
  11301. if status == "0" { //读卡成功
  11302. var card_info string //卡信息
  11303. //var busi_card_info string
  11304. var auth_info string
  11305. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11306. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11307. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11308. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  11309. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11310. result, _ := json.Marshal(respJSON)
  11311. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11312. utils.ErrorLog("解析失败:%v", err)
  11313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11314. return
  11315. }
  11316. res.ErrMsg = res10265.ErrMsg
  11317. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11318. res.Infcode = infocode
  11319. res.Output = res10265.Output
  11320. res.InfRefmsgid = res10265.InfRefmsgid
  11321. if res.Infcode == 0 {
  11322. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11323. if err == gorm.ErrRecordNotFound {
  11324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11325. return
  11326. } else if err != nil {
  11327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11328. return
  11329. } else {
  11330. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11331. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11332. infoStr := string(Iinfos)
  11333. idetinfoStr := string(Idetinfos)
  11334. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  11335. psn := &models.HisPsn{
  11336. PsnNo: res.Output.Baseinfo.PsnNo,
  11337. PatientId: patient.ID,
  11338. Certno: res.Output.Baseinfo.Certno,
  11339. Gend: res.Output.Baseinfo.Gend,
  11340. Brdy: b,
  11341. Age: float64(age),
  11342. Naty: res.Output.Baseinfo.Naty,
  11343. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11344. PsnName: res.Output.Baseinfo.PsnName,
  11345. Idetinfo: idetinfoStr,
  11346. Insuinfo: infoStr,
  11347. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11348. CardInfo: card_info,
  11349. VerifyNumber: token,
  11350. AuthInfo: auth_info,
  11351. }
  11352. var rf []*ResultFive
  11353. json.Unmarshal([]byte(infoStr), &rf)
  11354. var insutypes []*ResultFive
  11355. var insutype string
  11356. var is390 int = 0
  11357. var is310 int = 0
  11358. for _, item := range rf {
  11359. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11360. insutypes = append(insutypes, item)
  11361. }
  11362. }
  11363. if len(insutypes) == 1 {
  11364. insutype = insutypes[0].Insutype
  11365. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11366. } else {
  11367. for _, i := range insutypes {
  11368. if i.Insutype == "390" {
  11369. is390 = 1
  11370. }
  11371. if i.Insutype == "310" {
  11372. is310 = 1
  11373. }
  11374. }
  11375. }
  11376. if is390 == 1 {
  11377. insutype = "390"
  11378. }
  11379. if is310 == 1 {
  11380. insutype = "310"
  11381. }
  11382. if len(insutypes) == 0 {
  11383. insutype = "310"
  11384. }
  11385. service.CreateHisPsn(psn)
  11386. c.ServeSuccessJSON(map[string]interface{}{
  11387. "patient": patient,
  11388. "number": token,
  11389. "insutype": insutype,
  11390. })
  11391. }
  11392. } else {
  11393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11394. return
  11395. }
  11396. } else { //读卡失败
  11397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11398. return
  11399. }
  11400. }
  11401. break
  11402. }
  11403. }
  11404. var initFlag int64 = 0
  11405. var initEleFlag int64 = 0
  11406. func (c *HisApiController) TestGetBasBaseInit() {
  11407. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11408. Iinit := DllDef.MustFindProc("Init")
  11409. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11410. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  11411. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  11412. if ret != 0 {
  11413. fmt.Println("SSCard的报错原因:", err)
  11414. fmt.Println("SSCard的运算结果为:", ret)
  11415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11416. return
  11417. }
  11418. result := int(ret)
  11419. fmt.Println("SSCard的运算结果为1:", result)
  11420. initFlag = 1
  11421. return
  11422. }
  11423. func (c *HisApiController) HandleJiangXiReadCard() {
  11424. fmt.Println("~~~~~~")
  11425. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11426. admin_user_id, _ := c.GetInt64("admin_user_id")
  11427. id_card_type, _ := c.GetInt64("id_card_type")
  11428. //certificates, _ := c.GetInt64("certificates")
  11429. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11430. if initFlag == 0 {
  11431. c.TestGetJiangXiBasBaseInit()
  11432. }
  11433. basStr := c.GetBasBaseInfo()
  11434. if len(basStr) == 0 {
  11435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11436. return
  11437. }
  11438. fmt.Println(basStr)
  11439. bas := strings.Split(basStr, "|")
  11440. basNumber := bas[1]
  11441. fmt.Println(basNumber)
  11442. card_sn := bas[3]
  11443. fmt.Println(card_sn)
  11444. 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, "")
  11445. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11446. var dat map[string]interface{}
  11447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11448. fmt.Println(dat)
  11449. } else {
  11450. fmt.Println(err)
  11451. }
  11452. userJSONBytes, _ := json.Marshal(dat)
  11453. var res ResultTwo
  11454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11455. utils.ErrorLog("解析失败:%v", err)
  11456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11457. return
  11458. }
  11459. if res.Infcode == 0 {
  11460. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11461. if err == gorm.ErrRecordNotFound {
  11462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11463. return
  11464. } else if err != nil {
  11465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11466. return
  11467. } else {
  11468. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11469. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11470. infoStr := string(Iinfos)
  11471. idetinfoStr := string(Idetinfos)
  11472. psn := &models.HisPsn{
  11473. PsnNo: res.Output.Baseinfo.PsnNo,
  11474. PatientId: patient.ID,
  11475. Certno: res.Output.Baseinfo.Certno,
  11476. Gend: res.Output.Baseinfo.Gend,
  11477. Naty: res.Output.Baseinfo.Naty,
  11478. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11479. PsnName: res.Output.Baseinfo.PsnName,
  11480. Idetinfo: idetinfoStr,
  11481. Insuinfo: infoStr,
  11482. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11483. CardInfo: basStr,
  11484. VerifyNumber: "",
  11485. }
  11486. service.CreateHisPsn(psn)
  11487. c.ServeSuccessJSON(map[string]interface{}{
  11488. "patient": patient,
  11489. "number": basNumber,
  11490. })
  11491. }
  11492. } else {
  11493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11494. return
  11495. }
  11496. }
  11497. func (c *HisApiController) TestGetHnBasBaseInit() {
  11498. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11499. Iinit := DllDef.MustFindProc("Init")
  11500. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11501. //http://10.77.211.236/CSB/hsa-fsi-1303
  11502. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  11503. if ret != 0 {
  11504. fmt.Println("SSCard的报错原因:", err)
  11505. fmt.Println("SSCard的运算结果为:", ret)
  11506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11507. return
  11508. }
  11509. result := int(ret)
  11510. fmt.Println("SSCard的运算结果为1:", result)
  11511. initFlag = 1
  11512. return
  11513. }
  11514. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  11515. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11516. Iinit := DllDef.MustFindProc("Init")
  11517. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11518. //http://10.77.211.236/CSB/hsa-fsi-1303
  11519. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  11520. if ret != 0 {
  11521. fmt.Println("SSCard的报错原因:", err)
  11522. fmt.Println("SSCard的运算结果为:", ret)
  11523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11524. return
  11525. }
  11526. result := int(ret)
  11527. fmt.Println("SSCard的运算结果为1:", result)
  11528. initFlag = 1
  11529. return
  11530. }
  11531. func (c *HisApiController) GetSFZBaseInfo() string {
  11532. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11533. readCard := DllDef.MustFindProc("ReadSFZ")
  11534. if readCard == nil {
  11535. fmt.Println("readcard is nil")
  11536. readCard = DllDef.MustFindProc("ReadSFZ")
  11537. }
  11538. str := make([]byte, 8096)
  11539. str1 := make([]byte, 8096)
  11540. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  11541. fmt.Println(r)
  11542. return Remove0000(string(str))
  11543. }
  11544. func (c *HisApiController) GetEleBaseInfo() string {
  11545. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11546. readCard := DllDef.MustFindProc("GetQRBase")
  11547. fmt.Println(readCard)
  11548. if readCard == nil {
  11549. fmt.Println("readcard is nil")
  11550. readCard = DllDef.MustFindProc("GetQRBase")
  11551. }
  11552. str := make([]byte, 1024)
  11553. str1 := make([]byte, 1024)
  11554. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11555. fmt.Println(ret2)
  11556. fmt.Println(string(str1))
  11557. fmt.Println(string(str))
  11558. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11559. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11560. if ret2 != 0 {
  11561. return ""
  11562. }
  11563. return string(str)
  11564. }
  11565. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11566. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11567. readCard := DllDef.MustFindProc("NationEcTrans")
  11568. fmt.Println(readCard)
  11569. fmt.Println("!!!!!")
  11570. pBusiCardInfo := make([]byte, 2048)
  11571. input := make(map[string]interface{})
  11572. inputData := make(map[string]interface{})
  11573. inputData["orgId"] = code
  11574. inputData["businessType"] = "01101"
  11575. inputData["operatorId"] = "1"
  11576. inputData["operatorName"] = "admin"
  11577. inputData["officeId"] = "001"
  11578. inputData["officeName"] = "血透室"
  11579. inputData["deviceType"] = ""
  11580. input["data"] = inputData
  11581. input["orgId"] = code
  11582. input["transType"] = "ec.query"
  11583. bytesData, _ := json.Marshal(input)
  11584. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11585. fmt.Println(ret2)
  11586. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11587. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11588. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  11589. }
  11590. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11591. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11592. readCard := DllDef.MustFindProc("NationEcTrans")
  11593. fmt.Println(readCard)
  11594. fmt.Println("!!!!!")
  11595. pBusiCardInfo := make([]byte, 2048)
  11596. input := make(map[string]interface{})
  11597. inputData := make(map[string]interface{})
  11598. inputData["orgId"] = code
  11599. inputData["businessType"] = "01101"
  11600. inputData["operatorId"] = "9"
  11601. inputData["operatorName"] = "admin"
  11602. inputData["officeId"] = "001"
  11603. inputData["officeName"] = "血透室"
  11604. inputData["deviceType"] = ""
  11605. input["data"] = inputData
  11606. input["orgId"] = code
  11607. input["transType"] = "ec.query"
  11608. bytesData, _ := json.Marshal(input)
  11609. 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])))
  11610. fmt.Println(ret2)
  11611. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11612. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11613. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11614. }
  11615. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  11616. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11617. readCard := DllDef.MustFindProc("NationEcTrans")
  11618. fmt.Println(readCard)
  11619. fmt.Println("!!!!!")
  11620. pBusiCardInfo := make([]byte, 2048)
  11621. input := make(map[string]interface{})
  11622. inputData := make(map[string]interface{})
  11623. inputData["orgId"] = code
  11624. inputData["businessType"] = "01301"
  11625. inputData["operatorId"] = "9"
  11626. inputData["operatorName"] = "admin"
  11627. inputData["officeId"] = "001"
  11628. inputData["officeName"] = "血透室"
  11629. inputData["deviceType"] = ""
  11630. input["data"] = inputData
  11631. input["orgId"] = code
  11632. input["transType"] = "ec.query"
  11633. bytesData, _ := json.Marshal(input)
  11634. 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])))
  11635. fmt.Println(ret2)
  11636. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11637. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11638. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11639. }
  11640. func GetJxEleBaseInfo(org_id int64) string {
  11641. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11642. readCard := DllDef.MustFindProc("NationEcTrans")
  11643. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11644. if readCard == nil {
  11645. fmt.Println("readcard is nil")
  11646. readCard = DllDef.MustFindProc("NationEcTrans")
  11647. }
  11648. str1 := make([]byte, 1024)
  11649. data := make(map[string]interface{})
  11650. inputData := make(map[string]interface{})
  11651. inputData["orgId"] = miConfig.Code
  11652. inputData["businessType"] = "01101"
  11653. inputData["operatorId"] = "test001"
  11654. inputData["operatorName"] = "cn"
  11655. inputData["officeId"] = "32760"
  11656. inputData["officeName"] = "waike"
  11657. inputData["deviceType"] = ""
  11658. data["data"] = inputData
  11659. data["transType"] = "ec.query"
  11660. data["extra "] = ""
  11661. data["orgId"] = miConfig.Code
  11662. bytesData, _ := json.Marshal(data)
  11663. //bytesData, _ := json.Marshal(data)
  11664. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11665. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11666. fmt.Println(ret2)
  11667. fmt.Println(string(str1))
  11668. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11669. if ret2 != 0 {
  11670. return ""
  11671. }
  11672. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11673. }
  11674. func GetJxEleBaseInitInfo(org_id int64) string {
  11675. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11676. readCard := DllDef.MustFindProc("NationEcTrans")
  11677. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11678. if readCard == nil {
  11679. fmt.Println("readcard is nil")
  11680. readCard = DllDef.MustFindProc("NationEcTrans")
  11681. }
  11682. str1 := make([]byte, 2048)
  11683. data := make(map[string]interface{})
  11684. inputData := make(map[string]interface{})
  11685. inputData["orgId"] = miConfig.Code
  11686. inputData["businessType"] = "01101"
  11687. inputData["operatorId"] = "1"
  11688. inputData["operatorName"] = "huangchuang"
  11689. inputData["officeId"] = "101"
  11690. inputData["officeName"] = "xuetou"
  11691. inputData["deviceType"] = ""
  11692. data["data"] = inputData
  11693. data["transType"] = "ec.query"
  11694. data["orgId"] = miConfig.Code
  11695. bytesData, _ := json.Marshal(data)
  11696. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11697. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11698. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  11699. fmt.Println(ret2)
  11700. fmt.Println(string(str1))
  11701. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11702. if ret2 != 0 {
  11703. return ""
  11704. }
  11705. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  11706. initEleFlag = 1
  11707. }
  11708. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11709. }
  11710. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  11711. // // 构建命令
  11712. // cmd := exec.Command("python", "b.py")
  11713. //
  11714. // // 执行命令并等待完成
  11715. // output, err := cmd.CombinedOutput()
  11716. // if err != nil {
  11717. // fmt.Println("Error executing Python script:", err)
  11718. // return
  11719. // }
  11720. //
  11721. // // 打印Python脚本的输出
  11722. // fmt.Println(string(output))
  11723. //}
  11724. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  11725. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  11726. readCard := DllDef.MustFindProc("gxyb_call")
  11727. if readCard == nil {
  11728. fmt.Println("readcard is nil")
  11729. readCard = DllDef.MustFindProc("gxyb_call")
  11730. }
  11731. str := make([]byte, 1024)
  11732. str1 := make([]byte, 1024)
  11733. //data := make(map[string]interface{})
  11734. currentTime := time.Now()
  11735. // 格式化时间为 "YYYYMMDDHH24MISS"
  11736. formattedTime := currentTime.Format("20060102150405")
  11737. inputData := make(map[string]interface{})
  11738. inputData2 := make(map[string]interface{})
  11739. inputData["transNo"] = "1401"
  11740. inputData["transType"] = "passwordCheck"
  11741. inputData["timestamp"] = formattedTime
  11742. inputData2["fixmedinsCode"] = code
  11743. inputData2["psnNo"] = ""
  11744. inputData["data"] = inputData2
  11745. jsonBytes, err := json.Marshal(inputData)
  11746. if err != nil {
  11747. fmt.Println("Error encoding map to JSON:", err)
  11748. }
  11749. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11750. fmt.Println(string(str1))
  11751. fmt.Println(string(str))
  11752. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11753. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11754. if ret2 != 0 {
  11755. return ""
  11756. }
  11757. return string(str)
  11758. }
  11759. func (c *HisApiController) GetoleInfo() Response {
  11760. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11761. defer ole.CoUninitialize()
  11762. // Replace with the ProgID or CLSID of your COM object
  11763. progID := "YinHai.XJ.Actual.Interface.New"
  11764. // Create COM object
  11765. unknown, err := oleutil.CreateObject(progID)
  11766. if err != nil {
  11767. fmt.Println("Unable to create COM object:", err)
  11768. }
  11769. defer unknown.Release()
  11770. // Query for the IDispatch interface
  11771. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11772. if err != nil {
  11773. fmt.Println("Unable to get IDispatch interface:", err)
  11774. }
  11775. defer dispatch.Release()
  11776. // Prepare parameters
  11777. transNo := "1401"
  11778. transType := "passwordCheck"
  11779. timestamp := time.Now().Unix()
  11780. fixmedinsCode := "H45072101171"
  11781. psnNo := ""
  11782. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11783. result2 := ""
  11784. // Call COM object's method using the IDispatch interface
  11785. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11786. fmt.Println(resulr)
  11787. fmt.Println(result2)
  11788. if err != nil {
  11789. fmt.Println("调用COM对象方法失败:", err)
  11790. }
  11791. var response Response
  11792. err2 := json.Unmarshal([]byte(result2), &response)
  11793. if err2 != nil {
  11794. fmt.Println("解析JSON失败:", err)
  11795. }
  11796. return response
  11797. }
  11798. func (c *HisApiController) GetBasBaseInfo() string {
  11799. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11800. readCard := DllDef.MustFindProc("ReadCardBas")
  11801. if readCard == nil {
  11802. fmt.Println("readcard is nil")
  11803. readCard = DllDef.MustFindProc("ReadCardBas")
  11804. }
  11805. str := make([]byte, 1024)
  11806. str1 := make([]byte, 1024)
  11807. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11808. fmt.Println(string(str1))
  11809. fmt.Println(string(str))
  11810. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11811. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11812. if ret2 != 0 {
  11813. return ""
  11814. }
  11815. return string(str)
  11816. }
  11817. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11818. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11819. readCard := DllDef.MustFindProc("read_cardinfo")
  11820. if readCard == nil {
  11821. fmt.Println("readcard is nil")
  11822. readCard = DllDef.MustFindProc("read_cardinfo")
  11823. }
  11824. str := make([]byte, 1024) //卡号
  11825. str1 := make([]byte, 1024) //卡识别码
  11826. str2 := make([]byte, 1024) //身份证号
  11827. str3 := make([]byte, 1024) //姓名
  11828. str4 := make([]byte, 1024) //错误信息
  11829. 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])))
  11830. fmt.Println(string(str1))
  11831. fmt.Println(string(str))
  11832. fmt.Println(string(str2))
  11833. fmt.Println(string(str3))
  11834. fmt.Println(string(str4))
  11835. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11836. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11837. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11838. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11839. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11840. if ret2 != 0 {
  11841. return "", "", "", "", ""
  11842. }
  11843. return string(str), string(str1), string(str2), string(str3), string(str4)
  11844. }
  11845. type CustomFundPay struct {
  11846. FundPayType string `json:"fund_pay_type"`
  11847. FundPayamt float64 `json:"fund_payamt"`
  11848. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11849. }
  11850. //func (c *HisApiController) GetBatchSettleList() {
  11851. // start_time_str := c.GetString("start_time")
  11852. // //end_time_str := c.GetString("end_time")
  11853. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11854. //
  11855. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11856. //
  11857. // for _, item := range orders {
  11858. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11859. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11860. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11861. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11862. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11863. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11864. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11865. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11866. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11867. //
  11868. // if order.ID == 0 {
  11869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11870. // return
  11871. // }
  11872. //
  11873. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11874. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11875. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11876. // //fmt.Println(count)
  11877. // //var zero string
  11878. // //number := count + 1
  11879. // //if number >= 1000 {
  11880. // // zero = "0000" + strconv.FormatInt(number, 10)
  11881. // //} else if number >= 10000 {
  11882. // // zero = "000" + strconv.FormatInt(number, 10)
  11883. // //} else if number >= 100000 {
  11884. // // zero = "00" + strconv.FormatInt(number, 10)
  11885. // //} else if number >= 1000000 {
  11886. // // zero = "0" + strconv.FormatInt(number, 10)
  11887. // //} else {
  11888. // // zero = strconv.FormatInt(number, 10)
  11889. // //}
  11890. // //fmt.Println(zero)
  11891. //
  11892. // struct4101 := service.Struct4101{
  11893. // PsnNo: order.PsnNo,
  11894. // MdtrtId: order.MdtrtId,
  11895. // SetlId: order.SetlId,
  11896. // PsnName: order.PsnName,
  11897. // Gend: order.Gend,
  11898. // Brdy: his.Brdy,
  11899. // Age: his.Age,
  11900. // Naty: order.Naty,
  11901. // PatnCertType: "01",
  11902. // Certno: order.Certno,
  11903. // Prfs: "90",
  11904. // ConerName: roles[0].UserName,
  11905. // PatnRlts: "99",
  11906. // ConerAddr: miConfig.OrgName,
  11907. // ConerTel: admin.Mobile,
  11908. // HiType: order.Insutype,
  11909. // Insuplc: miConfig.InsuplcAdmdvs,
  11910. // MaindiagFlag: "1",
  11911. // BillCode: order.SetlId,
  11912. // BillNo: order.SetlId,
  11913. // BizSn: order.Number,
  11914. // PsnSelfPay: order.PsnPartAmt,
  11915. // PsnOwnPay: order.PsnPartAmt,
  11916. // AcctPay: order.AcctPay,
  11917. // PsnCashpay: order.PsnCashPay,
  11918. // HiPaymtd: "1",
  11919. // Hsorg: miConfig.InsuplcAdmdvs,
  11920. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11921. // MedinsFillPsn: curRoles.UserName,
  11922. // MedinsFillDept: miConfig.OrgName,
  11923. // IptMedType: "2",
  11924. // }
  11925. // struct4101.SetlBegnDate = order.SetlTime
  11926. // struct4101.SetlEndDate = order.SetlTime
  11927. // time_arr := strings.Split(order.SetlTime, " ")
  11928. // struct4101.AdmTime = time_arr[0]
  11929. // struct4101.AdmEndTime = time_arr[0]
  11930. //
  11931. // var rf []CustomFundPay
  11932. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11933. //
  11934. // var tempFunPays []service.CustomStruct
  11935. // for _, item := range rf {
  11936. // var tempFunPay service.CustomStruct
  11937. // tempFunPay.FundPayamt = item.FundPayamt
  11938. // tempFunPay.FundPayType = item.FundPayType
  11939. // tempFunPays = append(tempFunPays, tempFunPay)
  11940. // }
  11941. // struct4101.CustomStruct = tempFunPays
  11942. //
  11943. // var tempDiaginfos []service.DiaginfoStructTwo
  11944. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11945. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11946. //
  11947. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11948. // var config []*models.HisXtDiagnoseConfig
  11949. // for _, item := range diagnosis_ids {
  11950. // id, _ := strconv.ParseInt(item, 10, 64)
  11951. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11952. // config = append(config, &diagnosisConfig)
  11953. // }
  11954. //
  11955. // for index, item := range config {
  11956. // if index == 0 {
  11957. // var tempDiaginfo service.DiaginfoStructTwo
  11958. // tempDiaginfo.DiagCode = item.CountryCode
  11959. // tempDiaginfo.DiagName = item.CountryContentName
  11960. // tempDiaginfo.DiagType = "1"
  11961. // tempDiaginfo.MaindiagFlag = "1"
  11962. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11963. // } else {
  11964. // var tempDiaginfo service.DiaginfoStructTwo
  11965. // tempDiaginfo.DiagCode = item.CountryCode
  11966. // tempDiaginfo.DiagName = item.CountryContentName
  11967. // tempDiaginfo.DiagType = "1"
  11968. // tempDiaginfo.MaindiagFlag = "0"
  11969. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11970. // }
  11971. // }
  11972. // struct4101.Diseinfo = tempDiaginfos
  11973. //
  11974. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11975. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11976. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11977. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11978. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11979. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11980. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11981. //
  11982. // var iteminfo service.IteminfoStruct
  11983. //
  11984. // var bedCostTotal float64 = 0 //床位总费
  11985. // var bedCostSelfTotal float64 = 0 //床位自费
  11986. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11987. //
  11988. // var operationCostTotal float64 = 0 //手术费
  11989. // var operationCostSelfTotal float64 = 0 //手术费
  11990. // var operationCostPartSelfTotal float64 = 0 //手术费
  11991. //
  11992. // var otherCostTotal float64 = 0 //其他费用
  11993. // var otherCostSelfTotal float64 = 0 //其他费用
  11994. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11995. //
  11996. // var materialCostTotal float64 = 0 //材料费
  11997. // var materialCostSelfTotal float64 = 0 //材料费
  11998. // var materialCostPartSelfTotal float64 = 0 //材料费
  11999. //
  12000. // var westernMedicineCostTotal float64 = 0 //西药费
  12001. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  12002. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12003. //
  12004. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12005. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12006. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12007. //
  12008. // var checkCostTotal float64 = 0 //检查费
  12009. // var checkCostSelfTotal float64 = 0 //检查费
  12010. // var checkCostPartSelfTotal float64 = 0 //检查费
  12011. //
  12012. // var laboratoryCostTotal float64 = 0 //化验费
  12013. // var laboratoryCostSelfTotal float64 = 0 //化验费
  12014. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12015. //
  12016. // var treatCostTotal float64 = 0 //治疗费用
  12017. // var treatCostSelfTotal float64 = 0 //治疗费用
  12018. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  12019. //
  12020. // decimal.DivisionPrecision = 2
  12021. //
  12022. // var bed_fulamt_ownpay_amt float64 = 0
  12023. // var operation_fulamt_ownpay_amt float64 = 0
  12024. // var other_fulamt_ownpay_amt float64 = 0
  12025. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  12026. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12027. // var check_fulamt_ownpay_amt float64 = 0
  12028. // var material_fulamt_ownpay_amt float64 = 0
  12029. // var laboratory_fulamt_ownpay_amt float64 = 0
  12030. // var treat_fulamt_ownpay_amt float64 = 0
  12031. //
  12032. // var bed_claa_sunmfee float64 = 0
  12033. // var bed_clab_amt float64 = 0
  12034. // var bed_other_amt float64 = 0
  12035. //
  12036. // var operation_claa_sunmfee float64 = 0
  12037. // var operation_clab_amt float64 = 0
  12038. // var operation_other_amt float64 = 0
  12039. //
  12040. // var other_claa_sunmfee float64 = 0
  12041. // var other_clab_amt float64 = 0
  12042. // var other_other_amt float64 = 0
  12043. //
  12044. // var westernMedicine_claa_sunmfee float64 = 0
  12045. // var westernMedicine_clab_amt float64 = 0
  12046. // var westernMedicine_other_amt float64 = 0
  12047. //
  12048. // var chineseTraditional_claa_sunmfee float64 = 0
  12049. // var chineseTraditional_clab_amt float64 = 0
  12050. // var chineseTraditional_other_amt float64 = 0
  12051. //
  12052. // var check_claa_sunmfee float64 = 0
  12053. // var check_clab_amt float64 = 0
  12054. // var check_other_amt float64 = 0
  12055. //
  12056. // var material_claa_sunmfee float64 = 0
  12057. // var material_clab_amt float64 = 0
  12058. // var material_other_amt float64 = 0
  12059. //
  12060. // var laboratory_claa_sunmfee float64 = 0
  12061. // var laboratory_clab_amt float64 = 0
  12062. // var laboratory_other_amt float64 = 0
  12063. //
  12064. // var treat_claa_sunmfee float64 = 0
  12065. // var treat_clab_amt float64 = 0
  12066. // var treat_other_amt float64 = 0
  12067. //
  12068. // for _, item := range order.HisOrderInfo {
  12069. // if item.MedChrgitmType == "01" { //床位费
  12070. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12071. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12072. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12073. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12074. // if item.ChrgitmLv == "1" {
  12075. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12076. // }
  12077. // if item.ChrgitmLv == "2" {
  12078. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12079. //
  12080. // }
  12081. // if item.ChrgitmLv == "3" {
  12082. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12083. // }
  12084. //
  12085. // }
  12086. //
  12087. // if item.MedChrgitmType == "03" { //检查费
  12088. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12089. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12090. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12091. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12092. // if item.ChrgitmLv == "1" {
  12093. //
  12094. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12095. //
  12096. // }
  12097. // if item.ChrgitmLv == "2" {
  12098. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12099. //
  12100. // }
  12101. // if item.ChrgitmLv == "3" {
  12102. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12103. // }
  12104. // }
  12105. //
  12106. // if item.MedChrgitmType == "04" { //化验费
  12107. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12108. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12109. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12110. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12111. // if item.ChrgitmLv == "1" {
  12112. //
  12113. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12114. //
  12115. // }
  12116. // if item.ChrgitmLv == "2" {
  12117. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12118. //
  12119. // }
  12120. // if item.ChrgitmLv == "3" {
  12121. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12122. // }
  12123. // }
  12124. //
  12125. // if item.MedChrgitmType == "05" { //治疗费
  12126. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12127. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12128. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12129. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12130. // if item.ChrgitmLv == "1" {
  12131. //
  12132. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12133. //
  12134. // }
  12135. // if item.ChrgitmLv == "2" {
  12136. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12137. //
  12138. // }
  12139. // if item.ChrgitmLv == "3" {
  12140. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12141. // }
  12142. // }
  12143. //
  12144. // if item.MedChrgitmType == "06" { //手术费
  12145. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12146. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12147. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12148. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12149. //
  12150. // if item.ChrgitmLv == "1" {
  12151. //
  12152. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12153. //
  12154. // }
  12155. // if item.ChrgitmLv == "2" {
  12156. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12157. //
  12158. // }
  12159. // if item.ChrgitmLv == "3" {
  12160. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12161. // }
  12162. // }
  12163. //
  12164. // if item.MedChrgitmType == "08" { //材料费
  12165. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12166. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12167. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12168. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12169. // if item.ChrgitmLv == "1" {
  12170. //
  12171. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12172. //
  12173. // }
  12174. // if item.ChrgitmLv == "2" {
  12175. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12176. //
  12177. // }
  12178. // if item.ChrgitmLv == "3" {
  12179. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12180. // }
  12181. // }
  12182. //
  12183. // if item.MedChrgitmType == "09" { //西药费
  12184. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12185. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12186. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12187. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12188. // if item.ChrgitmLv == "1" {
  12189. //
  12190. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12191. //
  12192. // }
  12193. // if item.ChrgitmLv == "2" {
  12194. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12195. //
  12196. // }
  12197. // if item.ChrgitmLv == "3" {
  12198. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12199. // }
  12200. // }
  12201. //
  12202. // if item.MedChrgitmType == "11" { //中成费
  12203. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12204. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12205. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12206. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12207. // if item.ChrgitmLv == "1" {
  12208. //
  12209. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12210. //
  12211. // }
  12212. // if item.ChrgitmLv == "2" {
  12213. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12214. //
  12215. // }
  12216. // if item.ChrgitmLv == "3" {
  12217. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12218. // }
  12219. // }
  12220. //
  12221. // if item.MedChrgitmType == "14" { //其他费
  12222. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12223. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12224. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12225. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12226. // if item.ChrgitmLv == "1" {
  12227. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12228. //
  12229. // }
  12230. // if item.ChrgitmLv == "2" {
  12231. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12232. //
  12233. // }
  12234. // if item.ChrgitmLv == "3" {
  12235. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12236. // }
  12237. // }
  12238. //
  12239. // }
  12240. //
  12241. // var iteminfoStructs []service.IteminfoStruct
  12242. //
  12243. // if bedCostTotal != 0 {
  12244. // iteminfo.MedChrgitm = "01"
  12245. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12246. // iteminfo.Amt = bedCostTotal
  12247. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  12248. // iteminfo.ClabAmt = bed_clab_amt
  12249. // iteminfo.OthAmt = bed_other_amt
  12250. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12251. // }
  12252. //
  12253. // if checkCostTotal != 0 {
  12254. // iteminfo.MedChrgitm = "03"
  12255. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12256. // iteminfo.Amt = checkCostTotal
  12257. // iteminfo.ClaaSumfee = check_claa_sunmfee
  12258. // iteminfo.ClabAmt = check_clab_amt
  12259. // iteminfo.OthAmt = check_other_amt
  12260. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12261. //
  12262. // }
  12263. //
  12264. // if laboratoryCostTotal != 0 {
  12265. // iteminfo.MedChrgitm = "04"
  12266. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12267. // iteminfo.Amt = laboratoryCostTotal
  12268. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12269. // iteminfo.ClabAmt = laboratory_clab_amt
  12270. // iteminfo.OthAmt = laboratory_other_amt
  12271. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12272. //
  12273. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12274. //
  12275. // }
  12276. //
  12277. // if treatCostTotal != 0 {
  12278. // iteminfo.MedChrgitm = "05"
  12279. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12280. // iteminfo.Amt = treatCostTotal
  12281. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  12282. // iteminfo.ClabAmt = treat_clab_amt
  12283. // iteminfo.OthAmt = treat_other_amt
  12284. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12285. // //(struct4101.IteminfoStruct, iteminfo)
  12286. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12287. // }
  12288. //
  12289. // if operationCostTotal != 0 {
  12290. // iteminfo.MedChrgitm = "06"
  12291. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12292. // iteminfo.Amt = operationCostTotal
  12293. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  12294. // iteminfo.ClabAmt = operation_clab_amt
  12295. // iteminfo.OthAmt = operation_other_amt
  12296. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12297. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12298. // }
  12299. //
  12300. // if materialCostTotal != 0 {
  12301. // iteminfo.MedChrgitm = "08"
  12302. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12303. // iteminfo.Amt = materialCostTotal
  12304. // iteminfo.ClaaSumfee = material_claa_sunmfee
  12305. // iteminfo.ClabAmt = material_clab_amt
  12306. // iteminfo.OthAmt = material_other_amt
  12307. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12308. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12309. // }
  12310. //
  12311. // if westernMedicineCostTotal != 0 {
  12312. // iteminfo.MedChrgitm = "09"
  12313. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12314. // iteminfo.Amt = westernMedicineCostTotal
  12315. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12316. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12317. // iteminfo.OthAmt = westernMedicine_other_amt
  12318. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12319. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12320. //
  12321. // }
  12322. // if chineseTraditionalMedicineCostTotal != 0 {
  12323. // iteminfo.MedChrgitm = "11"
  12324. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12325. // iteminfo.Amt = westernMedicineCostTotal
  12326. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12327. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12328. // iteminfo.OthAmt = westernMedicine_other_amt
  12329. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12330. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12331. //
  12332. // }
  12333. // if otherCostTotal != 0 {
  12334. // iteminfo.MedChrgitm = "14"
  12335. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12336. // iteminfo.Amt = otherCostTotal
  12337. // iteminfo.ClaaSumfee = other_claa_sunmfee
  12338. // iteminfo.ClabAmt = other_clab_amt
  12339. // iteminfo.OthAmt = other_other_amt
  12340. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12341. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12342. //
  12343. // }
  12344. // struct4101.IteminfoStruct = iteminfoStructs
  12345. // struct4101.Ntly = "中国"
  12346. // struct4101.AdmCaty = "A03.06"
  12347. //
  12348. // struct4101.DoctorName = doctor.UserName
  12349. // struct4101.DoctorCode = doctor.DoctorNumber
  12350. //
  12351. // var res ResultSeventeen
  12352. //
  12353. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12354. // struct4101.BillCode = order.Number
  12355. // struct4101.BillNo = order.SetlId
  12356. // var resOther ResultSeventeenOther
  12357. // var pp models.PublicParams
  12358. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12359. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12360. // pp.FixmedinsName = miConfig.OrgName
  12361. // pp.FixmedinsCode = miConfig.Code
  12362. // pp.RequestUrl = miConfig.Url
  12363. // pp.Cainfo = miConfig.Cainfo
  12364. // pp.SecretKey = miConfig.SecretKey
  12365. // pp.AccessKey = miConfig.AccessKey
  12366. // pp.OpterName = curRoles.UserName
  12367. //
  12368. // client := &http.Client{}
  12369. // var req *http.Request
  12370. // data := make(map[string]interface{})
  12371. // data["struct4101"] = struct4101
  12372. // data["pp"] = pp
  12373. // bytesData, _ := json.Marshal(data)
  12374. // if miConfig.MdtrtareaAdmvs == "320921" {
  12375. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12376. // } else {
  12377. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12378. // }
  12379. // resp, _ := client.Do(req)
  12380. // defer resp.Body.Close()
  12381. // body, ioErr := ioutil.ReadAll(resp.Body)
  12382. // if ioErr != nil {
  12383. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12385. // return
  12386. // }
  12387. // var respJSON map[string]interface{}
  12388. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12389. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12390. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12391. // return
  12392. // }
  12393. //
  12394. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12395. // userJSONBytes, _ := json.Marshal(respJSON)
  12396. // fmt.Println("log")
  12397. // fmt.Println(string(userJSONBytes))
  12398. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12399. // utils.ErrorLog("解析失败:%v", err)
  12400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12401. // return
  12402. // }
  12403. // res.InfRefmsgid = resOther.InfRefmsgid
  12404. // res.Output = resOther.Output
  12405. // res.ErrMsg = resOther.ErrMsg
  12406. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12407. // res.Infcode = infocode
  12408. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  12409. //
  12410. // var pp models.PublicParams
  12411. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12412. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12413. // pp.FixmedinsName = miConfig.OrgName
  12414. // pp.FixmedinsCode = miConfig.Code
  12415. // pp.RequestUrl = miConfig.Url
  12416. // pp.Cainfo = miConfig.Cainfo
  12417. // pp.SecretKey = miConfig.SecretKey
  12418. // pp.AccessKey = miConfig.AccessKey
  12419. // pp.OpterName = curRoles.UserName
  12420. // result, _ := service.Jxyb4101(struct4101, pp)
  12421. // var dat map[string]interface{}
  12422. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12423. // fmt.Println(dat)
  12424. // } else {
  12425. // fmt.Println(err)
  12426. // }
  12427. // userJSONBytes, _ := json.Marshal(dat)
  12428. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12429. // utils.ErrorLog("解析失败:%v", err)
  12430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12431. // return
  12432. // }
  12433. //
  12434. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  12435. // var pp models.PublicParams
  12436. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12437. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12438. // pp.FixmedinsName = miConfig.OrgName
  12439. // pp.FixmedinsCode = miConfig.Code
  12440. // pp.RequestUrl = miConfig.Url
  12441. // pp.Cainfo = miConfig.Cainfo
  12442. // pp.SecretKey = miConfig.SecretKey
  12443. // pp.AccessKey = miConfig.AccessKey
  12444. // pp.OpterName = curRoles.UserName
  12445. // result, _ := service.Hnyb4101(struct4101, pp)
  12446. // var dat map[string]interface{}
  12447. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12448. // fmt.Println(dat)
  12449. // } else {
  12450. // fmt.Println(err)
  12451. // }
  12452. // userJSONBytes, _ := json.Marshal(dat)
  12453. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12454. // utils.ErrorLog("解析失败:%v", err)
  12455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12456. // return
  12457. // }
  12458. //
  12459. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  12460. // var resOther ResultSeventeenOther
  12461. //
  12462. // var pp models.PublicParams
  12463. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12464. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12465. // pp.FixmedinsName = miConfig.OrgName
  12466. // pp.FixmedinsCode = miConfig.Code
  12467. // pp.RequestUrl = miConfig.Url
  12468. // pp.Cainfo = miConfig.Cainfo
  12469. // pp.SecretKey = miConfig.SecretKey
  12470. // pp.AccessKey = miConfig.AccessKey
  12471. // pp.OpterName = curRoles.UserName
  12472. // client := &http.Client{}
  12473. // var req *http.Request
  12474. // data := make(map[string]interface{})
  12475. // data["struct4101"] = struct4101
  12476. // data["pp"] = pp
  12477. // bytesData, _ := json.Marshal(data)
  12478. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12479. // resp, _ := client.Do(req)
  12480. // defer resp.Body.Close()
  12481. // body, ioErr := ioutil.ReadAll(resp.Body)
  12482. // if ioErr != nil {
  12483. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12485. // return
  12486. // }
  12487. // var respJSON map[string]interface{}
  12488. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12489. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12490. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12491. // return
  12492. // }
  12493. //
  12494. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12495. // userJSONBytes, _ := json.Marshal(respJSON)
  12496. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12497. // utils.ErrorLog("解析失败:%v", err)
  12498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12499. // return
  12500. // }
  12501. // res.InfRefmsgid = resOther.InfRefmsgid
  12502. // res.Output = resOther.Output
  12503. // res.ErrMsg = resOther.ErrMsg
  12504. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12505. // res.Infcode = infocode
  12506. //
  12507. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  12508. // var pp models.PublicParams
  12509. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12510. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12511. // pp.FixmedinsName = miConfig.OrgName
  12512. // pp.FixmedinsCode = miConfig.Code
  12513. // pp.RequestUrl = miConfig.Url
  12514. // pp.Cainfo = miConfig.Cainfo
  12515. // pp.SecretKey = miConfig.SecretKey
  12516. // pp.AccessKey = miConfig.AccessKey
  12517. // pp.OpterName = curRoles.UserName
  12518. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12519. // fmt.Println(requestLog)
  12520. // fmt.Println(errMsgLog)
  12521. //
  12522. // saveLog(result, requestLog, "4101a", "上传清单")
  12523. //
  12524. // var dat map[string]interface{}
  12525. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12526. // fmt.Println(dat)
  12527. // } else {
  12528. // fmt.Println(err)
  12529. // }
  12530. // userJSONBytes, _ := json.Marshal(dat)
  12531. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12532. // utils.ErrorLog("解析失败:%v", err)
  12533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12534. // return
  12535. // }
  12536. //
  12537. // } else {
  12538. //
  12539. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  12540. // var dat map[string]interface{}
  12541. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12542. // fmt.Println(dat)
  12543. // } else {
  12544. // fmt.Println(err)
  12545. // }
  12546. // userJSONBytes, _ := json.Marshal(dat)
  12547. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12548. // utils.ErrorLog("解析失败:%v", err)
  12549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12550. // return
  12551. // }
  12552. // }
  12553. //
  12554. // if res.Infcode != 0 {
  12555. // adminUser := c.GetAdminUserInfo()
  12556. // errlog := &models.HisOrderError{
  12557. // UserOrgId: adminUser.CurrentOrgId,
  12558. // Ctime: time.Now().Unix(),
  12559. // Mtime: time.Now().Unix(),
  12560. // ErrMsg: res.ErrMsg,
  12561. // Status: 1,
  12562. // PatientId: order.ID,
  12563. // Stage: 10265,
  12564. // }
  12565. // service.CreateErrMsgLog(errlog)
  12566. // continue
  12567. // } else {
  12568. // //order.FaPiaoNumber = zero
  12569. // //order.FaPiaoCode = last_order.FaPiaoCode
  12570. // //service.UpdateOrder(order)
  12571. // hisFundSettleListResult := &models.HisFundSettleListResult{
  12572. // Number: res.Output.SetlListId,
  12573. // Status: 1,
  12574. // Ctime: time.Now().Unix(),
  12575. // Mtime: time.Now().Unix(),
  12576. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12577. // IsUpload: 1,
  12578. // OrderId: order.ID,
  12579. // }
  12580. // service.CreateUploadRecord(hisFundSettleListResult)
  12581. // c.ServeSuccessJSON(map[string]interface{}{
  12582. // "msg": "上传成功",
  12583. // "result": hisFundSettleListResult,
  12584. // })
  12585. // continue
  12586. // }
  12587. // }
  12588. //}
  12589. func (c *HisApiController) GetbatchSettleList() {
  12590. //order_id, _ := c.GetInt64("order_id")
  12591. admin_user_id, _ := c.GetInt64("admin_user_id")
  12592. orders, _ := service.GetAllHisOrderTwo10485()
  12593. for _, item := range orders {
  12594. order, _ := service.GetHisOrderByIDTwo(item.ID)
  12595. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12596. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12597. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12598. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12599. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12600. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12601. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12602. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12603. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12604. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12605. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12606. //fmt.Println(count)
  12607. //var zero string
  12608. //number := count + 1
  12609. //if number >= 1000 {
  12610. // zero = "0000" + strconv.FormatInt(number, 10)
  12611. //} else if number >= 10000 {
  12612. // zero = "000" + strconv.FormatInt(number, 10)
  12613. //} else if number >= 100000 {
  12614. // zero = "00" + strconv.FormatInt(number, 10)
  12615. //} else if number >= 1000000 {
  12616. // zero = "0" + strconv.FormatInt(number, 10)
  12617. //} else {
  12618. // zero = strconv.FormatInt(number, 10)
  12619. //}
  12620. //fmt.Println(zero)
  12621. struct4101 := service.Struct4101{
  12622. PsnNo: order.PsnNo,
  12623. MdtrtId: order.MdtrtId,
  12624. SetlId: order.SetlId,
  12625. PsnName: order.PsnName,
  12626. Gend: order.Gend,
  12627. Brdy: his.Brdy,
  12628. Age: his.Age,
  12629. Naty: order.Naty,
  12630. PatnCertType: "01",
  12631. Certno: order.Certno,
  12632. Prfs: "90",
  12633. ConerName: roles[0].UserName,
  12634. PatnRlts: "99",
  12635. ConerAddr: miConfig.OrgName,
  12636. ConerTel: admin.Mobile,
  12637. HiType: order.Insutype,
  12638. Insuplc: miConfig.InsuplcAdmdvs,
  12639. MaindiagFlag: "1",
  12640. BillCode: order.SetlId,
  12641. BillNo: order.SetlId,
  12642. BizSn: order.Number,
  12643. PsnSelfPay: order.PsnPartAmt,
  12644. PsnOwnPay: order.PsnPartAmt,
  12645. AcctPay: order.AcctPay,
  12646. PsnCashpay: order.PsnCashPay,
  12647. HiPaymtd: "1",
  12648. Hsorg: miConfig.InsuplcAdmdvs,
  12649. HsorgOpter: miConfig.InsuplcAdmdvs,
  12650. MedinsFillPsn: curRoles.UserName,
  12651. MedinsFillDept: miConfig.OrgName,
  12652. IptMedType: "2",
  12653. }
  12654. struct4101.SetlBegnDate = order.SetlTime
  12655. struct4101.SetlEndDate = order.SetlTime
  12656. time_arr := strings.Split(order.SetlTime, " ")
  12657. struct4101.AdmTime = time_arr[0]
  12658. struct4101.AdmEndTime = time_arr[0]
  12659. //var rf []CustomFundPay
  12660. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12661. //
  12662. //var tempFunPays []service.CustomStruct
  12663. //for _, item := range rf {
  12664. // var tempFunPay service.CustomStruct
  12665. // tempFunPay.FundPayamt = item.FundPayamt
  12666. // tempFunPay.FundPayType = item.FundPayType
  12667. // tempFunPays = append(tempFunPays, tempFunPay)
  12668. //}
  12669. //struct4101.CustomStruct = tempFunPays
  12670. var tempDiaginfos []service.DiaginfoStructTwo
  12671. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12672. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12673. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12674. var config []*models.HisXtDiagnoseConfig
  12675. for _, item := range diagnosis_ids {
  12676. id, _ := strconv.ParseInt(item, 10, 64)
  12677. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12678. config = append(config, &diagnosisConfig)
  12679. }
  12680. for index, item := range config {
  12681. if index == 0 {
  12682. var tempDiaginfo service.DiaginfoStructTwo
  12683. tempDiaginfo.DiagCode = item.CountryCode
  12684. tempDiaginfo.DiagName = item.CountryContentName
  12685. tempDiaginfo.DiagType = "1"
  12686. tempDiaginfo.MaindiagFlag = "1"
  12687. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12688. } else {
  12689. var tempDiaginfo service.DiaginfoStructTwo
  12690. tempDiaginfo.DiagCode = item.CountryCode
  12691. tempDiaginfo.DiagName = item.CountryContentName
  12692. tempDiaginfo.DiagType = "1"
  12693. tempDiaginfo.MaindiagFlag = "0"
  12694. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12695. }
  12696. }
  12697. struct4101.Diseinfo = tempDiaginfos
  12698. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12699. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12700. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12701. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12702. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12703. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12704. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12705. var iteminfo service.IteminfoStruct
  12706. var bedCostTotal float64 = 0 //床位总费
  12707. var bedCostSelfTotal float64 = 0 //床位自费
  12708. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12709. var operationCostTotal float64 = 0 //手术费
  12710. var operationCostSelfTotal float64 = 0 //手术费
  12711. var operationCostPartSelfTotal float64 = 0 //手术费
  12712. var otherCostTotal float64 = 0 //其他费用
  12713. var otherCostSelfTotal float64 = 0 //其他费用
  12714. var otherCostPartSelfTotal float64 = 0 //其他费用
  12715. var materialCostTotal float64 = 0 //材料费
  12716. var materialCostSelfTotal float64 = 0 //材料费
  12717. var materialCostPartSelfTotal float64 = 0 //材料费
  12718. var westernMedicineCostTotal float64 = 0 //西药费
  12719. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12720. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12721. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12722. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12723. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12724. var checkCostTotal float64 = 0 //检查费
  12725. var checkCostSelfTotal float64 = 0 //检查费
  12726. var checkCostPartSelfTotal float64 = 0 //检查费
  12727. var laboratoryCostTotal float64 = 0 //化验费
  12728. var laboratoryCostSelfTotal float64 = 0 //化验费
  12729. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12730. var treatCostTotal float64 = 0 //治疗费用
  12731. var treatCostSelfTotal float64 = 0 //治疗费用
  12732. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12733. decimal.DivisionPrecision = 2
  12734. var bed_fulamt_ownpay_amt float64 = 0
  12735. var operation_fulamt_ownpay_amt float64 = 0
  12736. var other_fulamt_ownpay_amt float64 = 0
  12737. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12738. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12739. var check_fulamt_ownpay_amt float64 = 0
  12740. var material_fulamt_ownpay_amt float64 = 0
  12741. var laboratory_fulamt_ownpay_amt float64 = 0
  12742. var treat_fulamt_ownpay_amt float64 = 0
  12743. var bed_claa_sunmfee float64 = 0
  12744. var bed_clab_amt float64 = 0
  12745. var bed_other_amt float64 = 0
  12746. var operation_claa_sunmfee float64 = 0
  12747. var operation_clab_amt float64 = 0
  12748. var operation_other_amt float64 = 0
  12749. var other_claa_sunmfee float64 = 0
  12750. var other_clab_amt float64 = 0
  12751. var other_other_amt float64 = 0
  12752. var westernMedicine_claa_sunmfee float64 = 0
  12753. var westernMedicine_clab_amt float64 = 0
  12754. var westernMedicine_other_amt float64 = 0
  12755. var chineseTraditional_claa_sunmfee float64 = 0
  12756. var chineseTraditional_clab_amt float64 = 0
  12757. var chineseTraditional_other_amt float64 = 0
  12758. var check_claa_sunmfee float64 = 0
  12759. var check_clab_amt float64 = 0
  12760. var check_other_amt float64 = 0
  12761. var material_claa_sunmfee float64 = 0
  12762. var material_clab_amt float64 = 0
  12763. var material_other_amt float64 = 0
  12764. var laboratory_claa_sunmfee float64 = 0
  12765. var laboratory_clab_amt float64 = 0
  12766. var laboratory_other_amt float64 = 0
  12767. var treat_claa_sunmfee float64 = 0
  12768. var treat_clab_amt float64 = 0
  12769. var treat_other_amt float64 = 0
  12770. for _, item := range order.HisOrderInfo {
  12771. if item.MedChrgitmType == "01" { //床位费
  12772. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12773. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12774. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12775. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12776. if item.ChrgitmLv == "1" {
  12777. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12778. }
  12779. if item.ChrgitmLv == "2" {
  12780. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12781. }
  12782. if item.ChrgitmLv == "3" {
  12783. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12784. }
  12785. }
  12786. if item.MedChrgitmType == "03" { //检查费
  12787. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12788. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12789. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12790. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12791. if item.ChrgitmLv == "1" {
  12792. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12793. }
  12794. if item.ChrgitmLv == "2" {
  12795. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12796. }
  12797. if item.ChrgitmLv == "3" {
  12798. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12799. }
  12800. }
  12801. if item.MedChrgitmType == "04" { //化验费
  12802. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12803. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12804. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12805. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12806. if item.ChrgitmLv == "1" {
  12807. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12808. }
  12809. if item.ChrgitmLv == "2" {
  12810. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12811. }
  12812. if item.ChrgitmLv == "3" {
  12813. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12814. }
  12815. }
  12816. if item.MedChrgitmType == "05" { //治疗费
  12817. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12818. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12819. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12820. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12821. if item.ChrgitmLv == "1" {
  12822. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12823. }
  12824. if item.ChrgitmLv == "2" {
  12825. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12826. }
  12827. if item.ChrgitmLv == "3" {
  12828. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12829. }
  12830. }
  12831. if item.MedChrgitmType == "06" { //手术费
  12832. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12833. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12834. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12835. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12836. if item.ChrgitmLv == "1" {
  12837. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12838. }
  12839. if item.ChrgitmLv == "2" {
  12840. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12841. }
  12842. if item.ChrgitmLv == "3" {
  12843. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12844. }
  12845. }
  12846. if item.MedChrgitmType == "08" { //材料费
  12847. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12848. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12849. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12850. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12851. if item.ChrgitmLv == "1" {
  12852. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12853. }
  12854. if item.ChrgitmLv == "2" {
  12855. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12856. }
  12857. if item.ChrgitmLv == "3" {
  12858. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12859. }
  12860. }
  12861. if item.MedChrgitmType == "09" { //西药费
  12862. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12863. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12864. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12865. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12866. if item.ChrgitmLv == "1" {
  12867. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12868. }
  12869. if item.ChrgitmLv == "2" {
  12870. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12871. }
  12872. if item.ChrgitmLv == "3" {
  12873. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12874. }
  12875. }
  12876. if item.MedChrgitmType == "11" { //中成费
  12877. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12878. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12879. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12880. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12881. if item.ChrgitmLv == "1" {
  12882. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12883. }
  12884. if item.ChrgitmLv == "2" {
  12885. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12886. }
  12887. if item.ChrgitmLv == "3" {
  12888. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12889. }
  12890. }
  12891. if item.MedChrgitmType == "14" { //其他费
  12892. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12893. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12894. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12895. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12896. if item.ChrgitmLv == "1" {
  12897. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12898. }
  12899. if item.ChrgitmLv == "2" {
  12900. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12901. }
  12902. if item.ChrgitmLv == "3" {
  12903. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12904. }
  12905. }
  12906. }
  12907. var iteminfoStructs []service.IteminfoStruct
  12908. if bedCostTotal != 0 {
  12909. iteminfo.MedChrgitm = "01"
  12910. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12911. iteminfo.Amt = bedCostTotal
  12912. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12913. iteminfo.ClabAmt = bed_clab_amt
  12914. iteminfo.OthAmt = bed_other_amt
  12915. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12916. }
  12917. if checkCostTotal != 0 {
  12918. iteminfo.MedChrgitm = "03"
  12919. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12920. iteminfo.Amt = checkCostTotal
  12921. iteminfo.ClaaSumfee = check_claa_sunmfee
  12922. iteminfo.ClabAmt = check_clab_amt
  12923. iteminfo.OthAmt = check_other_amt
  12924. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12925. }
  12926. if laboratoryCostTotal != 0 {
  12927. iteminfo.MedChrgitm = "04"
  12928. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12929. iteminfo.Amt = laboratoryCostTotal
  12930. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12931. iteminfo.ClabAmt = laboratory_clab_amt
  12932. iteminfo.OthAmt = laboratory_other_amt
  12933. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12934. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12935. }
  12936. if treatCostTotal != 0 {
  12937. iteminfo.MedChrgitm = "05"
  12938. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12939. iteminfo.Amt = treatCostTotal
  12940. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12941. iteminfo.ClabAmt = treat_clab_amt
  12942. iteminfo.OthAmt = treat_other_amt
  12943. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12944. //(struct4101.IteminfoStruct, iteminfo)
  12945. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12946. }
  12947. if operationCostTotal != 0 {
  12948. iteminfo.MedChrgitm = "06"
  12949. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12950. iteminfo.Amt = operationCostTotal
  12951. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12952. iteminfo.ClabAmt = operation_clab_amt
  12953. iteminfo.OthAmt = operation_other_amt
  12954. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12955. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12956. }
  12957. if materialCostTotal != 0 {
  12958. iteminfo.MedChrgitm = "08"
  12959. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12960. iteminfo.Amt = materialCostTotal
  12961. iteminfo.ClaaSumfee = material_claa_sunmfee
  12962. iteminfo.ClabAmt = material_clab_amt
  12963. iteminfo.OthAmt = material_other_amt
  12964. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12965. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12966. }
  12967. if westernMedicineCostTotal != 0 {
  12968. iteminfo.MedChrgitm = "09"
  12969. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12970. iteminfo.Amt = westernMedicineCostTotal
  12971. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12972. iteminfo.ClabAmt = westernMedicine_clab_amt
  12973. iteminfo.OthAmt = westernMedicine_other_amt
  12974. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12975. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12976. }
  12977. if chineseTraditionalMedicineCostTotal != 0 {
  12978. iteminfo.MedChrgitm = "11"
  12979. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12980. iteminfo.Amt = westernMedicineCostTotal
  12981. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12982. iteminfo.ClabAmt = westernMedicine_clab_amt
  12983. iteminfo.OthAmt = westernMedicine_other_amt
  12984. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12985. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12986. }
  12987. if otherCostTotal != 0 {
  12988. iteminfo.MedChrgitm = "14"
  12989. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12990. iteminfo.Amt = otherCostTotal
  12991. iteminfo.ClaaSumfee = other_claa_sunmfee
  12992. iteminfo.ClabAmt = other_clab_amt
  12993. iteminfo.OthAmt = other_other_amt
  12994. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12995. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12996. }
  12997. struct4101.IteminfoStruct = iteminfoStructs
  12998. struct4101.Ntly = "中国"
  12999. struct4101.AdmCaty = "A03.06"
  13000. struct4101.DoctorName = doctor.UserName
  13001. struct4101.DoctorCode = doctor.DoctorNumber
  13002. var res ResultSeventeen
  13003. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13004. struct4101.BillCode = order.Number
  13005. struct4101.BillNo = order.SetlId
  13006. var resOther ResultSeventeenOther
  13007. var pp models.PublicParams
  13008. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13009. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13010. pp.FixmedinsName = miConfig.OrgName
  13011. pp.FixmedinsCode = miConfig.Code
  13012. pp.RequestUrl = miConfig.Url
  13013. pp.Cainfo = miConfig.Cainfo
  13014. pp.SecretKey = miConfig.SecretKey
  13015. pp.AccessKey = miConfig.AccessKey
  13016. pp.OpterName = curRoles.UserName
  13017. client := &http.Client{}
  13018. var req *http.Request
  13019. data := make(map[string]interface{})
  13020. data["struct4101"] = struct4101
  13021. data["pp"] = pp
  13022. bytesData, _ := json.Marshal(data)
  13023. if miConfig.MdtrtareaAdmvs == "320921" {
  13024. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13025. } else {
  13026. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13027. }
  13028. resp, _ := client.Do(req)
  13029. defer resp.Body.Close()
  13030. body, ioErr := ioutil.ReadAll(resp.Body)
  13031. if ioErr != nil {
  13032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13034. return
  13035. }
  13036. var respJSON map[string]interface{}
  13037. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13040. return
  13041. }
  13042. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13043. userJSONBytes, _ := json.Marshal(respJSON)
  13044. fmt.Println("log")
  13045. fmt.Println(string(userJSONBytes))
  13046. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13047. utils.ErrorLog("解析失败:%v", err)
  13048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13049. return
  13050. }
  13051. res.InfRefmsgid = resOther.InfRefmsgid
  13052. res.Output = resOther.Output
  13053. res.ErrMsg = resOther.ErrMsg
  13054. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13055. res.Infcode = infocode
  13056. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13057. var pp models.PublicParams
  13058. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13059. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13060. pp.FixmedinsName = miConfig.OrgName
  13061. pp.FixmedinsCode = miConfig.Code
  13062. pp.RequestUrl = miConfig.Url
  13063. pp.Cainfo = miConfig.Cainfo
  13064. pp.SecretKey = miConfig.SecretKey
  13065. pp.AccessKey = miConfig.AccessKey
  13066. pp.OpterName = curRoles.UserName
  13067. result, _ := service.Jxyb4101(struct4101, pp)
  13068. var dat map[string]interface{}
  13069. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13070. fmt.Println(dat)
  13071. } else {
  13072. fmt.Println(err)
  13073. }
  13074. userJSONBytes, _ := json.Marshal(dat)
  13075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13076. utils.ErrorLog("解析失败:%v", err)
  13077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13078. return
  13079. }
  13080. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13081. var pp models.PublicParams
  13082. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13083. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13084. pp.FixmedinsName = miConfig.OrgName
  13085. pp.FixmedinsCode = miConfig.Code
  13086. pp.RequestUrl = miConfig.Url
  13087. pp.Cainfo = miConfig.Cainfo
  13088. pp.SecretKey = miConfig.SecretKey
  13089. pp.AccessKey = miConfig.AccessKey
  13090. pp.OpterName = curRoles.UserName
  13091. result, _ := service.Hnyb4101(struct4101, pp)
  13092. var dat map[string]interface{}
  13093. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13094. fmt.Println(dat)
  13095. } else {
  13096. fmt.Println(err)
  13097. }
  13098. userJSONBytes, _ := json.Marshal(dat)
  13099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13100. utils.ErrorLog("解析失败:%v", err)
  13101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13102. return
  13103. }
  13104. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13105. var resOther ResultSeventeenOther
  13106. var pp models.PublicParams
  13107. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13108. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13109. pp.FixmedinsName = miConfig.OrgName
  13110. pp.FixmedinsCode = miConfig.Code
  13111. pp.RequestUrl = miConfig.Url
  13112. pp.Cainfo = miConfig.Cainfo
  13113. pp.SecretKey = miConfig.SecretKey
  13114. pp.AccessKey = miConfig.AccessKey
  13115. pp.OpterName = curRoles.UserName
  13116. client := &http.Client{}
  13117. var req *http.Request
  13118. data := make(map[string]interface{})
  13119. data["struct4101"] = struct4101
  13120. data["pp"] = pp
  13121. bytesData, _ := json.Marshal(data)
  13122. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13123. resp, _ := client.Do(req)
  13124. defer resp.Body.Close()
  13125. body, ioErr := ioutil.ReadAll(resp.Body)
  13126. if ioErr != nil {
  13127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13129. return
  13130. }
  13131. var respJSON map[string]interface{}
  13132. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13135. return
  13136. }
  13137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13138. userJSONBytes, _ := json.Marshal(respJSON)
  13139. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13140. utils.ErrorLog("解析失败:%v", err)
  13141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13142. return
  13143. }
  13144. res.InfRefmsgid = resOther.InfRefmsgid
  13145. res.Output = resOther.Output
  13146. res.ErrMsg = resOther.ErrMsg
  13147. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13148. res.Infcode = infocode
  13149. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13150. var pp models.PublicParams
  13151. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13152. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13153. pp.FixmedinsName = miConfig.OrgName
  13154. pp.FixmedinsCode = miConfig.Code
  13155. pp.RequestUrl = miConfig.Url
  13156. pp.Cainfo = miConfig.Cainfo
  13157. pp.SecretKey = miConfig.SecretKey
  13158. pp.AccessKey = miConfig.AccessKey
  13159. pp.OpterName = curRoles.UserName
  13160. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13161. fmt.Println(requestLog)
  13162. fmt.Println(errMsgLog)
  13163. saveLog(result, requestLog, "4101a", "上传清单")
  13164. var dat map[string]interface{}
  13165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13166. fmt.Println(dat)
  13167. } else {
  13168. fmt.Println(err)
  13169. }
  13170. userJSONBytes, _ := json.Marshal(dat)
  13171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13172. utils.ErrorLog("解析失败:%v", err)
  13173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13174. return
  13175. }
  13176. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13177. var pp models.PublicParams
  13178. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13179. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13180. pp.FixmedinsName = miConfig.OrgName
  13181. pp.FixmedinsCode = miConfig.Code
  13182. pp.RequestUrl = miConfig.Url
  13183. pp.Cainfo = miConfig.Cainfo
  13184. pp.SecretKey = miConfig.SecretKey
  13185. pp.AccessKey = miConfig.AccessKey
  13186. pp.OpterName = curRoles.UserName
  13187. client := &http.Client{}
  13188. var req *http.Request
  13189. data := make(map[string]interface{})
  13190. data["struct4101"] = struct4101
  13191. data["pp"] = pp
  13192. bytesData, _ := json.Marshal(data)
  13193. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13194. resp, _ := client.Do(req)
  13195. defer resp.Body.Close()
  13196. body, ioErr := ioutil.ReadAll(resp.Body)
  13197. if ioErr != nil {
  13198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13200. return
  13201. }
  13202. var respJSON map[string]interface{}
  13203. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13206. return
  13207. }
  13208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13209. userJSONBytes, _ := json.Marshal(respJSON)
  13210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13211. utils.ErrorLog("解析失败:%v", err)
  13212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13213. return
  13214. }
  13215. } else {
  13216. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13217. var dat map[string]interface{}
  13218. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13219. fmt.Println(dat)
  13220. } else {
  13221. fmt.Println(err)
  13222. }
  13223. userJSONBytes, _ := json.Marshal(dat)
  13224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13225. utils.ErrorLog("解析失败:%v", err)
  13226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13227. return
  13228. }
  13229. }
  13230. if res.Infcode != 0 {
  13231. errlog := &models.HisOrderError{
  13232. UserOrgId: order.UserOrgId,
  13233. Ctime: time.Now().Unix(),
  13234. Mtime: time.Now().Unix(),
  13235. ErrMsg: res.ErrMsg + "解析失败",
  13236. Status: 1,
  13237. PatientId: order.ID,
  13238. Stage: 10485,
  13239. }
  13240. service.CreateErrMsgLog(errlog)
  13241. continue
  13242. //c.ServeSuccessJSON(map[string]interface{}{
  13243. // "failed_code": -10,
  13244. // "msg": res.ErrMsg,
  13245. //})
  13246. } else {
  13247. //order.FaPiaoNumber = zero
  13248. //order.FaPiaoCode = last_order.FaPiaoCode
  13249. //service.UpdateOrder(order)
  13250. hisFundSettleListResult := &models.HisFundSettleListResult{
  13251. Number: res.Output.SetlListId,
  13252. Status: 1,
  13253. Ctime: time.Now().Unix(),
  13254. Mtime: time.Now().Unix(),
  13255. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13256. IsUpload: 1,
  13257. OrderId: order.ID,
  13258. }
  13259. service.CreateUploadRecord(hisFundSettleListResult)
  13260. continue
  13261. }
  13262. }
  13263. }
  13264. func (c *HisApiController) GetSettleList() {
  13265. order_id, _ := c.GetInt64("order_id")
  13266. admin_user_id, _ := c.GetInt64("admin_user_id")
  13267. order, _ := service.GetHisOrderByIDTwo(order_id)
  13268. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13269. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13270. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13271. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13272. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13273. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13274. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13275. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13276. if order.ID == 0 {
  13277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13278. return
  13279. }
  13280. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13281. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13282. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13283. //fmt.Println(count)
  13284. //var zero string
  13285. //number := count + 1
  13286. //if number >= 1000 {
  13287. // zero = "0000" + strconv.FormatInt(number, 10)
  13288. //} else if number >= 10000 {
  13289. // zero = "000" + strconv.FormatInt(number, 10)
  13290. //} else if number >= 100000 {
  13291. // zero = "00" + strconv.FormatInt(number, 10)
  13292. //} else if number >= 1000000 {
  13293. // zero = "0" + strconv.FormatInt(number, 10)
  13294. //} else {
  13295. // zero = strconv.FormatInt(number, 10)
  13296. //}
  13297. //fmt.Println(zero)
  13298. struct4101 := service.Struct4101{
  13299. PsnNo: order.PsnNo,
  13300. MdtrtId: order.MdtrtId,
  13301. SetlId: order.SetlId,
  13302. PsnName: order.PsnName,
  13303. Gend: order.Gend,
  13304. Brdy: his.Brdy,
  13305. Age: his.Age,
  13306. Naty: order.Naty,
  13307. PatnCertType: "01",
  13308. Certno: order.Certno,
  13309. Prfs: "90",
  13310. ConerName: roles[0].UserName,
  13311. PatnRlts: "99",
  13312. ConerAddr: miConfig.OrgName,
  13313. ConerTel: admin.Mobile,
  13314. HiType: order.Insutype,
  13315. Insuplc: miConfig.InsuplcAdmdvs,
  13316. MaindiagFlag: "1",
  13317. BillCode: order.SetlId,
  13318. BillNo: order.SetlId,
  13319. BizSn: order.Number,
  13320. PsnSelfPay: order.PsnPartAmt,
  13321. PsnOwnPay: order.PsnPartAmt,
  13322. AcctPay: order.AcctPay,
  13323. PsnCashpay: order.PsnCashPay,
  13324. HiPaymtd: "1",
  13325. Hsorg: miConfig.InsuplcAdmdvs,
  13326. HsorgOpter: miConfig.InsuplcAdmdvs,
  13327. MedinsFillPsn: curRoles.UserName,
  13328. MedinsFillDept: miConfig.OrgName,
  13329. IptMedType: "2",
  13330. }
  13331. struct4101.SetlBegnDate = order.SetlTime
  13332. struct4101.SetlEndDate = order.SetlTime
  13333. time_arr := strings.Split(order.SetlTime, " ")
  13334. struct4101.AdmTime = time_arr[0]
  13335. struct4101.AdmEndTime = time_arr[0]
  13336. //
  13337. //var rf []CustomFundPay
  13338. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13339. //
  13340. //var tempFunPays []service.CustomStruct
  13341. //for _, item := range rf {
  13342. // var tempFunPay service.CustomStruct
  13343. // tempFunPay.FundPayamt = item.FundPayamt
  13344. // tempFunPay.FundPayType = item.FundPayType
  13345. // tempFunPays = append(tempFunPays, tempFunPay)
  13346. //}
  13347. //struct4101.CustomStruct = tempFunPays
  13348. var tempDiaginfos []service.DiaginfoStructTwo
  13349. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13350. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13351. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  13352. var config []*models.HisXtDiagnoseConfig
  13353. for _, item := range diagnosis_ids {
  13354. id, _ := strconv.ParseInt(item, 10, 64)
  13355. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13356. config = append(config, &diagnosisConfig)
  13357. }
  13358. if miConfig.Code == "H15049901371" {
  13359. //for _, item := range config {
  13360. // if item.ID == 138 {
  13361. diagnosisConfig, _ := service.FindDiagnoseById(138)
  13362. var tempDiaginfo service.DiaginfoStructTwo
  13363. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  13364. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  13365. tempDiaginfo.DiagType = "1"
  13366. tempDiaginfo.MaindiagFlag = "1"
  13367. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13368. //}
  13369. //}
  13370. for _, item := range config {
  13371. if item.ID != 138 {
  13372. var tempDiaginfo service.DiaginfoStructTwo
  13373. tempDiaginfo.DiagCode = item.CountryCode
  13374. tempDiaginfo.DiagName = item.CountryContentName
  13375. tempDiaginfo.DiagType = "1"
  13376. tempDiaginfo.MaindiagFlag = "0"
  13377. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13378. }
  13379. }
  13380. } else {
  13381. for index, item := range config {
  13382. if index == 0 {
  13383. var tempDiaginfo service.DiaginfoStructTwo
  13384. tempDiaginfo.DiagCode = item.CountryCode
  13385. tempDiaginfo.DiagName = item.CountryContentName
  13386. tempDiaginfo.DiagType = "1"
  13387. tempDiaginfo.MaindiagFlag = "1"
  13388. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13389. } else {
  13390. var tempDiaginfo service.DiaginfoStructTwo
  13391. tempDiaginfo.DiagCode = item.CountryCode
  13392. tempDiaginfo.DiagName = item.CountryContentName
  13393. tempDiaginfo.DiagType = "1"
  13394. tempDiaginfo.MaindiagFlag = "0"
  13395. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13396. }
  13397. }
  13398. }
  13399. struct4101.Diseinfo = tempDiaginfos
  13400. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13401. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13402. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13403. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13404. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13405. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13406. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13407. var iteminfo service.IteminfoStruct
  13408. var bedCostTotal float64 = 0 //床位总费
  13409. var bedCostSelfTotal float64 = 0 //床位自费
  13410. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13411. var operationCostTotal float64 = 0 //手术费
  13412. var operationCostSelfTotal float64 = 0 //手术费
  13413. var operationCostPartSelfTotal float64 = 0 //手术费
  13414. var otherCostTotal float64 = 0 //其他费用
  13415. var otherCostSelfTotal float64 = 0 //其他费用
  13416. var otherCostPartSelfTotal float64 = 0 //其他费用
  13417. var materialCostTotal float64 = 0 //材料费
  13418. var materialCostSelfTotal float64 = 0 //材料费
  13419. var materialCostPartSelfTotal float64 = 0 //材料费
  13420. var westernMedicineCostTotal float64 = 0 //西药费
  13421. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13422. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13423. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13424. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13425. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13426. var checkCostTotal float64 = 0 //检查费
  13427. var checkCostSelfTotal float64 = 0 //检查费
  13428. var checkCostPartSelfTotal float64 = 0 //检查费
  13429. var laboratoryCostTotal float64 = 0 //化验费
  13430. var laboratoryCostSelfTotal float64 = 0 //化验费
  13431. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13432. var treatCostTotal float64 = 0 //治疗费用
  13433. var treatCostSelfTotal float64 = 0 //治疗费用
  13434. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13435. decimal.DivisionPrecision = 2
  13436. var bed_fulamt_ownpay_amt float64 = 0
  13437. var operation_fulamt_ownpay_amt float64 = 0
  13438. var other_fulamt_ownpay_amt float64 = 0
  13439. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13440. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13441. var check_fulamt_ownpay_amt float64 = 0
  13442. var material_fulamt_ownpay_amt float64 = 0
  13443. var laboratory_fulamt_ownpay_amt float64 = 0
  13444. var treat_fulamt_ownpay_amt float64 = 0
  13445. var bed_claa_sunmfee float64 = 0
  13446. var bed_clab_amt float64 = 0
  13447. var bed_other_amt float64 = 0
  13448. var operation_claa_sunmfee float64 = 0
  13449. var operation_clab_amt float64 = 0
  13450. var operation_other_amt float64 = 0
  13451. var other_claa_sunmfee float64 = 0
  13452. var other_clab_amt float64 = 0
  13453. var other_other_amt float64 = 0
  13454. var westernMedicine_claa_sunmfee float64 = 0
  13455. var westernMedicine_clab_amt float64 = 0
  13456. var westernMedicine_other_amt float64 = 0
  13457. var chineseTraditional_claa_sunmfee float64 = 0
  13458. var chineseTraditional_clab_amt float64 = 0
  13459. var chineseTraditional_other_amt float64 = 0
  13460. var check_claa_sunmfee float64 = 0
  13461. var check_clab_amt float64 = 0
  13462. var check_other_amt float64 = 0
  13463. var material_claa_sunmfee float64 = 0
  13464. var material_clab_amt float64 = 0
  13465. var material_other_amt float64 = 0
  13466. var laboratory_claa_sunmfee float64 = 0
  13467. var laboratory_clab_amt float64 = 0
  13468. var laboratory_other_amt float64 = 0
  13469. var treat_claa_sunmfee float64 = 0
  13470. var treat_clab_amt float64 = 0
  13471. var treat_other_amt float64 = 0
  13472. for _, item := range order.HisOrderInfo {
  13473. if item.MedChrgitmType == "01" { //床位费
  13474. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13475. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13476. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13477. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13478. if item.ChrgitmLv == "1" {
  13479. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13480. }
  13481. if item.ChrgitmLv == "2" {
  13482. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13483. }
  13484. if item.ChrgitmLv == "3" {
  13485. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13486. }
  13487. }
  13488. if item.MedChrgitmType == "03" { //检查费
  13489. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13490. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13491. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13492. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13493. if item.ChrgitmLv == "1" {
  13494. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13495. }
  13496. if item.ChrgitmLv == "2" {
  13497. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13498. }
  13499. if item.ChrgitmLv == "3" {
  13500. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13501. }
  13502. }
  13503. if item.MedChrgitmType == "04" { //化验费
  13504. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13505. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13506. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13507. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13508. if item.ChrgitmLv == "1" {
  13509. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13510. }
  13511. if item.ChrgitmLv == "2" {
  13512. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13513. }
  13514. if item.ChrgitmLv == "3" {
  13515. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13516. }
  13517. }
  13518. if item.MedChrgitmType == "05" { //治疗费
  13519. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13520. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13521. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13522. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13523. if item.ChrgitmLv == "1" {
  13524. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13525. }
  13526. if item.ChrgitmLv == "2" {
  13527. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13528. }
  13529. if item.ChrgitmLv == "3" {
  13530. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13531. }
  13532. }
  13533. if item.MedChrgitmType == "06" { //手术费
  13534. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13535. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13536. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13537. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13538. if item.ChrgitmLv == "1" {
  13539. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13540. }
  13541. if item.ChrgitmLv == "2" {
  13542. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13543. }
  13544. if item.ChrgitmLv == "3" {
  13545. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13546. }
  13547. }
  13548. if item.MedChrgitmType == "08" { //材料费
  13549. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13550. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13551. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13552. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13553. if item.ChrgitmLv == "1" {
  13554. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13555. }
  13556. if item.ChrgitmLv == "2" {
  13557. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13558. }
  13559. if item.ChrgitmLv == "3" {
  13560. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13561. }
  13562. }
  13563. if item.MedChrgitmType == "09" { //西药费
  13564. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13565. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13566. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13567. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13568. if item.ChrgitmLv == "1" {
  13569. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13570. }
  13571. if item.ChrgitmLv == "2" {
  13572. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13573. }
  13574. if item.ChrgitmLv == "3" {
  13575. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13576. }
  13577. }
  13578. if item.MedChrgitmType == "11" { //中成费
  13579. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13580. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13581. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13582. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13583. if item.ChrgitmLv == "1" {
  13584. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13585. }
  13586. if item.ChrgitmLv == "2" {
  13587. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13588. }
  13589. if item.ChrgitmLv == "3" {
  13590. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13591. }
  13592. }
  13593. if item.MedChrgitmType == "14" { //其他费
  13594. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13595. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13596. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13597. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13598. if item.ChrgitmLv == "1" {
  13599. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13600. }
  13601. if item.ChrgitmLv == "2" {
  13602. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13603. }
  13604. if item.ChrgitmLv == "3" {
  13605. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13606. }
  13607. }
  13608. }
  13609. var iteminfoStructs []service.IteminfoStruct
  13610. if bedCostTotal != 0 {
  13611. iteminfo.MedChrgitm = "01"
  13612. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13613. iteminfo.Amt = bedCostTotal
  13614. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13615. iteminfo.ClabAmt = bed_clab_amt
  13616. iteminfo.OthAmt = bed_other_amt
  13617. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13618. }
  13619. if checkCostTotal != 0 {
  13620. iteminfo.MedChrgitm = "03"
  13621. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13622. iteminfo.Amt = checkCostTotal
  13623. iteminfo.ClaaSumfee = check_claa_sunmfee
  13624. iteminfo.ClabAmt = check_clab_amt
  13625. iteminfo.OthAmt = check_other_amt
  13626. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13627. }
  13628. if laboratoryCostTotal != 0 {
  13629. iteminfo.MedChrgitm = "04"
  13630. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13631. iteminfo.Amt = laboratoryCostTotal
  13632. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13633. iteminfo.ClabAmt = laboratory_clab_amt
  13634. iteminfo.OthAmt = laboratory_other_amt
  13635. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13636. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13637. }
  13638. if treatCostTotal != 0 {
  13639. iteminfo.MedChrgitm = "05"
  13640. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13641. iteminfo.Amt = treatCostTotal
  13642. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13643. iteminfo.ClabAmt = treat_clab_amt
  13644. iteminfo.OthAmt = treat_other_amt
  13645. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13646. //(struct4101.IteminfoStruct, iteminfo)
  13647. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13648. }
  13649. if operationCostTotal != 0 {
  13650. iteminfo.MedChrgitm = "06"
  13651. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13652. iteminfo.Amt = operationCostTotal
  13653. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13654. iteminfo.ClabAmt = operation_clab_amt
  13655. iteminfo.OthAmt = operation_other_amt
  13656. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13657. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13658. }
  13659. if materialCostTotal != 0 {
  13660. iteminfo.MedChrgitm = "08"
  13661. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13662. iteminfo.Amt = materialCostTotal
  13663. iteminfo.ClaaSumfee = material_claa_sunmfee
  13664. iteminfo.ClabAmt = material_clab_amt
  13665. iteminfo.OthAmt = material_other_amt
  13666. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13667. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13668. }
  13669. if westernMedicineCostTotal != 0 {
  13670. iteminfo.MedChrgitm = "09"
  13671. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13672. iteminfo.Amt = westernMedicineCostTotal
  13673. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13674. iteminfo.ClabAmt = westernMedicine_clab_amt
  13675. iteminfo.OthAmt = westernMedicine_other_amt
  13676. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13677. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13678. }
  13679. if chineseTraditionalMedicineCostTotal != 0 {
  13680. iteminfo.MedChrgitm = "11"
  13681. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13682. iteminfo.Amt = westernMedicineCostTotal
  13683. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13684. iteminfo.ClabAmt = westernMedicine_clab_amt
  13685. iteminfo.OthAmt = westernMedicine_other_amt
  13686. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13687. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13688. }
  13689. if otherCostTotal != 0 {
  13690. iteminfo.MedChrgitm = "14"
  13691. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13692. iteminfo.Amt = otherCostTotal
  13693. iteminfo.ClaaSumfee = other_claa_sunmfee
  13694. iteminfo.ClabAmt = other_clab_amt
  13695. iteminfo.OthAmt = other_other_amt
  13696. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13697. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13698. }
  13699. struct4101.IteminfoStruct = iteminfoStructs
  13700. struct4101.Ntly = "中国"
  13701. struct4101.AdmCaty = "A03.06"
  13702. struct4101.DoctorName = doctor.UserName
  13703. struct4101.DoctorCode = doctor.DoctorNumber
  13704. var res ResultSeventeen
  13705. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13706. struct4101.BillCode = order.Number
  13707. struct4101.BillNo = order.SetlId
  13708. var resOther ResultSeventeenOther
  13709. var pp models.PublicParams
  13710. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13711. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13712. pp.FixmedinsName = miConfig.OrgName
  13713. pp.FixmedinsCode = miConfig.Code
  13714. pp.RequestUrl = miConfig.Url
  13715. pp.Cainfo = miConfig.Cainfo
  13716. pp.SecretKey = miConfig.SecretKey
  13717. pp.AccessKey = miConfig.AccessKey
  13718. pp.OpterName = curRoles.UserName
  13719. client := &http.Client{}
  13720. var req *http.Request
  13721. data := make(map[string]interface{})
  13722. data["struct4101"] = struct4101
  13723. data["pp"] = pp
  13724. bytesData, _ := json.Marshal(data)
  13725. if miConfig.MdtrtareaAdmvs == "320921" {
  13726. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13727. } else {
  13728. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13729. }
  13730. resp, _ := client.Do(req)
  13731. defer resp.Body.Close()
  13732. body, ioErr := ioutil.ReadAll(resp.Body)
  13733. if ioErr != nil {
  13734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13736. return
  13737. }
  13738. var respJSON map[string]interface{}
  13739. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13742. return
  13743. }
  13744. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13745. userJSONBytes, _ := json.Marshal(respJSON)
  13746. fmt.Println("log")
  13747. fmt.Println(string(userJSONBytes))
  13748. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13749. utils.ErrorLog("解析失败:%v", err)
  13750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13751. return
  13752. }
  13753. res.InfRefmsgid = resOther.InfRefmsgid
  13754. res.Output = resOther.Output
  13755. res.ErrMsg = resOther.ErrMsg
  13756. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13757. res.Infcode = infocode
  13758. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13759. var pp models.PublicParams
  13760. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13761. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13762. pp.FixmedinsName = miConfig.OrgName
  13763. pp.FixmedinsCode = miConfig.Code
  13764. pp.RequestUrl = miConfig.Url
  13765. pp.Cainfo = miConfig.Cainfo
  13766. pp.SecretKey = miConfig.SecretKey
  13767. pp.AccessKey = miConfig.AccessKey
  13768. pp.OpterName = curRoles.UserName
  13769. result, _ := service.Jxyb4101(struct4101, pp)
  13770. var dat map[string]interface{}
  13771. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13772. fmt.Println(dat)
  13773. } else {
  13774. fmt.Println(err)
  13775. }
  13776. userJSONBytes, _ := json.Marshal(dat)
  13777. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13778. utils.ErrorLog("解析失败:%v", err)
  13779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13780. return
  13781. }
  13782. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13783. var pp models.PublicParams
  13784. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13785. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13786. pp.FixmedinsName = miConfig.OrgName
  13787. pp.FixmedinsCode = miConfig.Code
  13788. pp.RequestUrl = miConfig.Url
  13789. pp.Cainfo = miConfig.Cainfo
  13790. pp.SecretKey = miConfig.SecretKey
  13791. pp.AccessKey = miConfig.AccessKey
  13792. pp.OpterName = curRoles.UserName
  13793. result, _ := service.Hnyb4101(struct4101, pp)
  13794. var dat map[string]interface{}
  13795. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13796. fmt.Println(dat)
  13797. } else {
  13798. fmt.Println(err)
  13799. }
  13800. userJSONBytes, _ := json.Marshal(dat)
  13801. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13802. utils.ErrorLog("解析失败:%v", err)
  13803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13804. return
  13805. }
  13806. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13807. var resOther ResultSeventeenOther
  13808. var pp models.PublicParams
  13809. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13810. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13811. pp.FixmedinsName = miConfig.OrgName
  13812. pp.FixmedinsCode = miConfig.Code
  13813. pp.RequestUrl = miConfig.Url
  13814. pp.Cainfo = miConfig.Cainfo
  13815. pp.SecretKey = miConfig.SecretKey
  13816. pp.AccessKey = miConfig.AccessKey
  13817. pp.OpterName = curRoles.UserName
  13818. client := &http.Client{}
  13819. var req *http.Request
  13820. data := make(map[string]interface{})
  13821. data["struct4101"] = struct4101
  13822. data["pp"] = pp
  13823. bytesData, _ := json.Marshal(data)
  13824. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13825. resp, _ := client.Do(req)
  13826. defer resp.Body.Close()
  13827. body, ioErr := ioutil.ReadAll(resp.Body)
  13828. if ioErr != nil {
  13829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13831. return
  13832. }
  13833. var respJSON map[string]interface{}
  13834. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13837. return
  13838. }
  13839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13840. userJSONBytes, _ := json.Marshal(respJSON)
  13841. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13842. utils.ErrorLog("解析失败:%v", err)
  13843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13844. return
  13845. }
  13846. res.InfRefmsgid = resOther.InfRefmsgid
  13847. res.Output = resOther.Output
  13848. res.ErrMsg = resOther.ErrMsg
  13849. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13850. res.Infcode = infocode
  13851. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13852. var pp models.PublicParams
  13853. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13854. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13855. pp.FixmedinsName = miConfig.OrgName
  13856. pp.FixmedinsCode = miConfig.Code
  13857. pp.RequestUrl = miConfig.Url
  13858. pp.Cainfo = miConfig.Cainfo
  13859. pp.SecretKey = miConfig.SecretKey
  13860. pp.AccessKey = miConfig.AccessKey
  13861. pp.OpterName = curRoles.UserName
  13862. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13863. fmt.Println(requestLog)
  13864. fmt.Println(errMsgLog)
  13865. saveLog(result, requestLog, "4101a", "上传清单")
  13866. var dat map[string]interface{}
  13867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13868. fmt.Println(dat)
  13869. } else {
  13870. fmt.Println(err)
  13871. }
  13872. userJSONBytes, _ := json.Marshal(dat)
  13873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13874. utils.ErrorLog("解析失败:%v", err)
  13875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13876. return
  13877. }
  13878. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13879. var pp models.PublicParams
  13880. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13881. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13882. pp.FixmedinsName = miConfig.OrgName
  13883. pp.FixmedinsCode = miConfig.Code
  13884. pp.RequestUrl = miConfig.Url
  13885. pp.Cainfo = miConfig.Cainfo
  13886. pp.SecretKey = miConfig.SecretKey
  13887. pp.AccessKey = miConfig.AccessKey
  13888. pp.OpterName = curRoles.UserName
  13889. client := &http.Client{}
  13890. var req *http.Request
  13891. data := make(map[string]interface{})
  13892. data["struct4101"] = struct4101
  13893. data["pp"] = pp
  13894. bytesData, _ := json.Marshal(data)
  13895. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13896. resp, _ := client.Do(req)
  13897. defer resp.Body.Close()
  13898. body, ioErr := ioutil.ReadAll(resp.Body)
  13899. if ioErr != nil {
  13900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13902. return
  13903. }
  13904. var respJSON map[string]interface{}
  13905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13908. return
  13909. }
  13910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13911. userJSONBytes, _ := json.Marshal(respJSON)
  13912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13913. utils.ErrorLog("解析失败:%v", err)
  13914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13915. return
  13916. }
  13917. } else {
  13918. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13919. var dat map[string]interface{}
  13920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13921. fmt.Println(dat)
  13922. } else {
  13923. fmt.Println(err)
  13924. }
  13925. userJSONBytes, _ := json.Marshal(dat)
  13926. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13927. utils.ErrorLog("解析失败:%v", err)
  13928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13929. return
  13930. }
  13931. }
  13932. if res.Infcode != 0 {
  13933. c.ServeSuccessJSON(map[string]interface{}{
  13934. "failed_code": -10,
  13935. "msg": res.ErrMsg,
  13936. })
  13937. return
  13938. } else {
  13939. //order.FaPiaoNumber = zero
  13940. //order.FaPiaoCode = last_order.FaPiaoCode
  13941. //service.UpdateOrder(order)
  13942. hisFundSettleListResult := &models.HisFundSettleListResult{
  13943. Number: res.Output.SetlListId,
  13944. Status: 1,
  13945. Ctime: time.Now().Unix(),
  13946. Mtime: time.Now().Unix(),
  13947. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13948. IsUpload: 1,
  13949. OrderId: order_id,
  13950. }
  13951. service.CreateUploadRecord(hisFundSettleListResult)
  13952. c.ServeSuccessJSON(map[string]interface{}{
  13953. "msg": "上传成功",
  13954. "result": hisFundSettleListResult,
  13955. })
  13956. return
  13957. }
  13958. }
  13959. func (c *HisApiController) GetSettleListHospital() {
  13960. order_id, _ := c.GetInt64("order_id")
  13961. admin_user_id, _ := c.GetInt64("admin_user_id")
  13962. order, _ := service.GetHisOrderByIDTwo(order_id)
  13963. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13964. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13965. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13966. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13967. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13968. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13969. if order.ID == 0 {
  13970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13971. return
  13972. }
  13973. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13974. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13975. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13976. fmt.Println(count)
  13977. var zero string
  13978. number := count + 1
  13979. if number >= 1000 {
  13980. zero = "0000" + strconv.FormatInt(number, 10)
  13981. } else if number >= 10000 {
  13982. zero = "000" + strconv.FormatInt(number, 10)
  13983. } else if number >= 100000 {
  13984. zero = "00" + strconv.FormatInt(number, 10)
  13985. } else if number >= 1000000 {
  13986. zero = "0" + strconv.FormatInt(number, 10)
  13987. } else {
  13988. zero = strconv.FormatInt(number, 10)
  13989. }
  13990. fmt.Println(zero)
  13991. struct4101 := service.Struct4101{
  13992. PsnNo: order.PsnNo,
  13993. MdtrtId: order.MdtrtId,
  13994. SetlId: order.SetlId,
  13995. PsnName: order.PsnName,
  13996. Gend: order.Gend,
  13997. Brdy: his.Brdy,
  13998. Age: int64(order.Age),
  13999. Naty: order.Naty,
  14000. PatnCertType: "01",
  14001. Certno: order.Certno,
  14002. Prfs: "90",
  14003. ConerName: roles[0].UserName,
  14004. PatnRlts: "99",
  14005. ConerAddr: miConfig.OrgName,
  14006. ConerTel: admin.Mobile,
  14007. HiType: order.Insutype,
  14008. Insuplc: miConfig.InsuplcAdmdvs,
  14009. MaindiagFlag: "1",
  14010. BillCode: order.SetlId,
  14011. BillNo: order.SetlId,
  14012. BizSn: order.Number,
  14013. PsnSelfPay: order.PsnPartAmt,
  14014. PsnOwnPay: order.PsnPartAmt,
  14015. AcctPay: order.AcctPay,
  14016. PsnCashpay: order.PsnCashPay,
  14017. HiPaymtd: "1",
  14018. Hsorg: miConfig.InsuplcAdmdvs,
  14019. HsorgOpter: miConfig.InsuplcAdmdvs,
  14020. MedinsFillPsn: curRoles.UserName,
  14021. MedinsFillDept: depart.Name,
  14022. IptMedType: "2",
  14023. AdmTime: his.InHosptialTime,
  14024. AdmEndTime: his.OutHosptialTime,
  14025. }
  14026. struct4101.SetlBegnDate = order.SetlTime
  14027. struct4101.SetlEndDate = order.SetlTime
  14028. //var rf []CustomFundPay
  14029. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  14030. //
  14031. //var tempFunPays []service.CustomStruct
  14032. //for _, item := range rf {
  14033. // var tempFunPay service.CustomStruct
  14034. // tempFunPay.FundPayamt = item.FundPayamt
  14035. // tempFunPay.FundPayType = item.FundPayType
  14036. // tempFunPays = append(tempFunPays, tempFunPay)
  14037. //}
  14038. //struct4101.CustomStruct = tempFunPays
  14039. var tempDiaginfos []service.DiaginfoStructTwo
  14040. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14041. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14042. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  14043. //for _, item := range infos {
  14044. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  14045. //}
  14046. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  14047. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  14048. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14049. fmt.Println(diagnosis_ids_arr)
  14050. if order.UserOrgId == 10210 {
  14051. var diagnosis_ids_arr_two []int64
  14052. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  14053. var config []*models.HisXtDiagnoseConfig
  14054. for _, id := range diagnosis_ids_arr_two {
  14055. //id, _ := strconv.ParseInt(item, 10, 64)
  14056. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14057. if diagnosisConfig.ID > 0 {
  14058. config = append(config, &diagnosisConfig)
  14059. }
  14060. }
  14061. for index, item := range config {
  14062. if item.ID > 0 {
  14063. if index == 0 {
  14064. var tempDiaginfo service.DiaginfoStructTwo
  14065. tempDiaginfo.DiagCode = item.CountryCode
  14066. tempDiaginfo.DiagName = item.CountryContentName
  14067. tempDiaginfo.DiagType = "1"
  14068. tempDiaginfo.MaindiagFlag = "1"
  14069. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14070. } else {
  14071. var tempDiaginfo service.DiaginfoStructTwo
  14072. tempDiaginfo.DiagCode = item.CountryCode
  14073. tempDiaginfo.DiagName = item.CountryContentName
  14074. tempDiaginfo.DiagType = "1"
  14075. tempDiaginfo.MaindiagFlag = "0"
  14076. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14077. }
  14078. }
  14079. }
  14080. struct4101.Diseinfo = tempDiaginfos
  14081. } else {
  14082. var config []*models.HisXtDiagnoseConfig
  14083. for _, item := range diagnosis_ids_arr {
  14084. id, _ := strconv.ParseInt(item, 10, 64)
  14085. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14086. if diagnosisConfig.ID > 0 {
  14087. config = append(config, &diagnosisConfig)
  14088. }
  14089. }
  14090. for index, item := range config {
  14091. if item.ID > 0 {
  14092. if index == 0 {
  14093. var tempDiaginfo service.DiaginfoStructTwo
  14094. tempDiaginfo.DiagCode = item.CountryCode
  14095. tempDiaginfo.DiagName = item.CountryContentName
  14096. tempDiaginfo.DiagType = "1"
  14097. tempDiaginfo.MaindiagFlag = "1"
  14098. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14099. } else {
  14100. var tempDiaginfo service.DiaginfoStructTwo
  14101. tempDiaginfo.DiagCode = item.CountryCode
  14102. tempDiaginfo.DiagName = item.CountryContentName
  14103. tempDiaginfo.DiagType = "1"
  14104. tempDiaginfo.MaindiagFlag = "0"
  14105. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14106. }
  14107. }
  14108. }
  14109. struct4101.Diseinfo = tempDiaginfos
  14110. }
  14111. sickConfigTwo, _ := service.FindSickById(his.SickType)
  14112. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14113. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14114. tempOpspdiseinfo2.OprnOprtCode = ""
  14115. tempOpspdiseinfo2.OprnOprtName = ""
  14116. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14117. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14118. var iteminfo service.IteminfoStruct
  14119. var bedCostTotal float64 = 0 //床位总费
  14120. var bedCostSelfTotal float64 = 0 //床位自费
  14121. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14122. var operationCostTotal float64 = 0 //手术费
  14123. var operationCostSelfTotal float64 = 0 //手术费
  14124. var operationCostPartSelfTotal float64 = 0 //手术费
  14125. var otherCostTotal float64 = 0 //其他费用
  14126. var otherCostSelfTotal float64 = 0 //其他费用
  14127. var otherCostPartSelfTotal float64 = 0 //其他费用
  14128. var materialCostTotal float64 = 0 //材料费
  14129. var materialCostSelfTotal float64 = 0 //材料费
  14130. var materialCostPartSelfTotal float64 = 0 //材料费
  14131. var westernMedicineCostTotal float64 = 0 //西药费
  14132. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14133. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14134. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14135. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14136. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14137. var checkCostTotal float64 = 0 //检查费
  14138. var checkCostSelfTotal float64 = 0 //检查费
  14139. var checkCostPartSelfTotal float64 = 0 //检查费
  14140. var laboratoryCostTotal float64 = 0 //化验费
  14141. var laboratoryCostSelfTotal float64 = 0 //化验费
  14142. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14143. var treatCostTotal float64 = 0 //治疗费用
  14144. var treatCostSelfTotal float64 = 0 //治疗费用
  14145. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14146. decimal.DivisionPrecision = 2
  14147. var bed_fulamt_ownpay_amt float64 = 0
  14148. var operation_fulamt_ownpay_amt float64 = 0
  14149. var other_fulamt_ownpay_amt float64 = 0
  14150. var westernMedicine_fulamt_ownpay_amt float64 = 0
  14151. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14152. var check_fulamt_ownpay_amt float64 = 0
  14153. var material_fulamt_ownpay_amt float64 = 0
  14154. var laboratory_fulamt_ownpay_amt float64 = 0
  14155. var treat_fulamt_ownpay_amt float64 = 0
  14156. var bed_claa_sunmfee float64 = 0
  14157. var bed_clab_amt float64 = 0
  14158. var bed_other_amt float64 = 0
  14159. var operation_claa_sunmfee float64 = 0
  14160. var operation_clab_amt float64 = 0
  14161. var operation_other_amt float64 = 0
  14162. var other_claa_sunmfee float64 = 0
  14163. var other_clab_amt float64 = 0
  14164. var other_other_amt float64 = 0
  14165. var westernMedicine_claa_sunmfee float64 = 0
  14166. var westernMedicine_clab_amt float64 = 0
  14167. var westernMedicine_other_amt float64 = 0
  14168. var chineseTraditional_claa_sunmfee float64 = 0
  14169. var chineseTraditional_clab_amt float64 = 0
  14170. var chineseTraditional_other_amt float64 = 0
  14171. var check_claa_sunmfee float64 = 0
  14172. var check_clab_amt float64 = 0
  14173. var check_other_amt float64 = 0
  14174. var material_claa_sunmfee float64 = 0
  14175. var material_clab_amt float64 = 0
  14176. var material_other_amt float64 = 0
  14177. var laboratory_claa_sunmfee float64 = 0
  14178. var laboratory_clab_amt float64 = 0
  14179. var laboratory_other_amt float64 = 0
  14180. var treat_claa_sunmfee float64 = 0
  14181. var treat_clab_amt float64 = 0
  14182. var treat_other_amt float64 = 0
  14183. for _, item := range order.HisOrderInfo {
  14184. if item.MedChrgitmType == "01" { //床位费
  14185. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14186. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14187. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14188. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14189. if item.ChrgitmLv == "1" {
  14190. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14191. }
  14192. if item.ChrgitmLv == "2" {
  14193. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14194. }
  14195. if item.ChrgitmLv == "3" {
  14196. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14197. }
  14198. }
  14199. if item.MedChrgitmType == "03" { //检查费
  14200. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14201. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14202. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14203. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14204. if item.ChrgitmLv == "1" {
  14205. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14206. }
  14207. if item.ChrgitmLv == "2" {
  14208. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14209. }
  14210. if item.ChrgitmLv == "3" {
  14211. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14212. }
  14213. }
  14214. if item.MedChrgitmType == "04" { //化验费
  14215. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14216. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14217. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14218. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14219. if item.ChrgitmLv == "1" {
  14220. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14221. }
  14222. if item.ChrgitmLv == "2" {
  14223. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14224. }
  14225. if item.ChrgitmLv == "3" {
  14226. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14227. }
  14228. }
  14229. if item.MedChrgitmType == "05" { //治疗费
  14230. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14231. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14232. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14233. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14234. if item.ChrgitmLv == "1" {
  14235. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14236. }
  14237. if item.ChrgitmLv == "2" {
  14238. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14239. }
  14240. if item.ChrgitmLv == "3" {
  14241. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14242. }
  14243. }
  14244. if item.MedChrgitmType == "06" { //手术费
  14245. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14246. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14247. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14248. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14249. if item.ChrgitmLv == "1" {
  14250. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14251. }
  14252. if item.ChrgitmLv == "2" {
  14253. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14254. }
  14255. if item.ChrgitmLv == "3" {
  14256. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14257. }
  14258. }
  14259. if item.MedChrgitmType == "08" { //材料费
  14260. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14261. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14262. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14263. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14264. if item.ChrgitmLv == "1" {
  14265. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14266. }
  14267. if item.ChrgitmLv == "2" {
  14268. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14269. }
  14270. if item.ChrgitmLv == "3" {
  14271. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14272. }
  14273. }
  14274. if item.MedChrgitmType == "09" { //西药费
  14275. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14276. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14277. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14278. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14279. if item.ChrgitmLv == "1" {
  14280. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14281. }
  14282. if item.ChrgitmLv == "2" {
  14283. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14284. }
  14285. if item.ChrgitmLv == "3" {
  14286. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14287. }
  14288. }
  14289. if item.MedChrgitmType == "11" { //中成费
  14290. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14291. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14292. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14293. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14294. if item.ChrgitmLv == "1" {
  14295. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14296. }
  14297. if item.ChrgitmLv == "2" {
  14298. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14299. }
  14300. if item.ChrgitmLv == "3" {
  14301. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14302. }
  14303. }
  14304. if item.MedChrgitmType == "14" { //其他费
  14305. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14306. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14307. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14308. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14309. if item.ChrgitmLv == "1" {
  14310. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14311. }
  14312. if item.ChrgitmLv == "2" {
  14313. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14314. }
  14315. if item.ChrgitmLv == "3" {
  14316. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14317. }
  14318. }
  14319. }
  14320. var iteminfoStructs []service.IteminfoStruct
  14321. if bedCostTotal != 0 {
  14322. iteminfo.MedChrgitm = "01"
  14323. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14324. iteminfo.Amt = bedCostTotal
  14325. iteminfo.ClaaSumfee = bed_claa_sunmfee
  14326. iteminfo.ClabAmt = bed_clab_amt
  14327. iteminfo.OthAmt = bed_other_amt
  14328. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14329. }
  14330. if checkCostTotal != 0 {
  14331. iteminfo.MedChrgitm = "03"
  14332. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14333. iteminfo.Amt = checkCostTotal
  14334. iteminfo.ClaaSumfee = check_claa_sunmfee
  14335. iteminfo.ClabAmt = check_clab_amt
  14336. iteminfo.OthAmt = check_other_amt
  14337. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14338. }
  14339. if laboratoryCostTotal != 0 {
  14340. iteminfo.MedChrgitm = "04"
  14341. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14342. iteminfo.Amt = laboratoryCostTotal
  14343. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14344. iteminfo.ClabAmt = laboratory_clab_amt
  14345. iteminfo.OthAmt = laboratory_other_amt
  14346. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14347. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14348. }
  14349. if treatCostTotal != 0 {
  14350. iteminfo.MedChrgitm = "05"
  14351. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14352. iteminfo.Amt = treatCostTotal
  14353. iteminfo.ClaaSumfee = treat_claa_sunmfee
  14354. iteminfo.ClabAmt = treat_clab_amt
  14355. iteminfo.OthAmt = treat_other_amt
  14356. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14357. //(struct4101.IteminfoStruct, iteminfo)
  14358. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14359. }
  14360. if operationCostTotal != 0 {
  14361. iteminfo.MedChrgitm = "06"
  14362. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14363. iteminfo.Amt = operationCostTotal
  14364. iteminfo.ClaaSumfee = operation_claa_sunmfee
  14365. iteminfo.ClabAmt = operation_clab_amt
  14366. iteminfo.OthAmt = operation_other_amt
  14367. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14368. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14369. }
  14370. if materialCostTotal != 0 {
  14371. iteminfo.MedChrgitm = "08"
  14372. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14373. iteminfo.Amt = materialCostTotal
  14374. iteminfo.ClaaSumfee = material_claa_sunmfee
  14375. iteminfo.ClabAmt = material_clab_amt
  14376. iteminfo.OthAmt = material_other_amt
  14377. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14378. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14379. }
  14380. if westernMedicineCostTotal != 0 {
  14381. iteminfo.MedChrgitm = "09"
  14382. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14383. iteminfo.Amt = westernMedicineCostTotal
  14384. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14385. iteminfo.ClabAmt = westernMedicine_clab_amt
  14386. iteminfo.OthAmt = westernMedicine_other_amt
  14387. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14388. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14389. }
  14390. if chineseTraditionalMedicineCostTotal != 0 {
  14391. iteminfo.MedChrgitm = "11"
  14392. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14393. iteminfo.Amt = westernMedicineCostTotal
  14394. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14395. iteminfo.ClabAmt = westernMedicine_clab_amt
  14396. iteminfo.OthAmt = westernMedicine_other_amt
  14397. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14398. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14399. }
  14400. if otherCostTotal != 0 {
  14401. iteminfo.MedChrgitm = "14"
  14402. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14403. iteminfo.Amt = otherCostTotal
  14404. iteminfo.ClaaSumfee = other_claa_sunmfee
  14405. iteminfo.ClabAmt = other_clab_amt
  14406. iteminfo.OthAmt = other_other_amt
  14407. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14408. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14409. }
  14410. struct4101.IteminfoStruct = iteminfoStructs
  14411. struct4101.Ntly = "中国"
  14412. struct4101.AdmCaty = "A03.06"
  14413. var resOther ResultSeventeenOther
  14414. var res ResultSeventeen
  14415. if miConfig.MdtrtareaAdmvs == "150499" {
  14416. var pp models.PublicParams
  14417. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14418. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14419. pp.FixmedinsName = miConfig.OrgName
  14420. pp.FixmedinsCode = miConfig.Code
  14421. pp.RequestUrl = miConfig.Url
  14422. pp.Cainfo = miConfig.Cainfo
  14423. pp.SecretKey = miConfig.SecretKey
  14424. pp.AccessKey = miConfig.AccessKey
  14425. pp.OpterName = curRoles.UserName
  14426. client := &http.Client{}
  14427. var req *http.Request
  14428. data := make(map[string]interface{})
  14429. data["struct4101"] = struct4101
  14430. data["pp"] = pp
  14431. bytesData, _ := json.Marshal(data)
  14432. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14433. resp, _ := client.Do(req)
  14434. defer resp.Body.Close()
  14435. body, ioErr := ioutil.ReadAll(resp.Body)
  14436. if ioErr != nil {
  14437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14439. return
  14440. }
  14441. var respJSON map[string]interface{}
  14442. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14445. return
  14446. }
  14447. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14448. userJSONBytes, _ := json.Marshal(respJSON)
  14449. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14450. utils.ErrorLog("解析失败:%v", err)
  14451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14452. return
  14453. }
  14454. res.InfRefmsgid = resOther.InfRefmsgid
  14455. res.Output = resOther.Output
  14456. res.ErrMsg = resOther.ErrMsg
  14457. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14458. res.Infcode = infocode
  14459. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14460. var pp models.PublicParams
  14461. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14462. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14463. pp.FixmedinsName = miConfig.OrgName
  14464. pp.FixmedinsCode = miConfig.Code
  14465. pp.RequestUrl = miConfig.Url
  14466. pp.Cainfo = miConfig.Cainfo
  14467. pp.SecretKey = miConfig.SecretKey
  14468. pp.AccessKey = miConfig.AccessKey
  14469. pp.OpterName = curRoles.UserName
  14470. result, _ := service.Jxyb4101(struct4101, pp)
  14471. var dat map[string]interface{}
  14472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14473. fmt.Println(dat)
  14474. } else {
  14475. fmt.Println(err)
  14476. }
  14477. userJSONBytes, _ := json.Marshal(dat)
  14478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14479. utils.ErrorLog("解析失败:%v", err)
  14480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14481. return
  14482. }
  14483. } else {
  14484. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14485. var dat map[string]interface{}
  14486. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14487. fmt.Println(dat)
  14488. } else {
  14489. fmt.Println(err)
  14490. }
  14491. userJSONBytes, _ := json.Marshal(dat)
  14492. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14493. utils.ErrorLog("解析失败:%v", err)
  14494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14495. return
  14496. }
  14497. }
  14498. if res.Infcode != 0 {
  14499. c.ServeSuccessJSON(map[string]interface{}{
  14500. "failed_code": -10,
  14501. "msg": res.ErrMsg,
  14502. })
  14503. return
  14504. } else {
  14505. if miConfig.MdtrtareaAdmvs != "150499" {
  14506. order.FaPiaoNumber = zero
  14507. order.FaPiaoCode = last_order.FaPiaoCode
  14508. service.UpdateOrder(order)
  14509. }
  14510. hisFundSettleListResult := &models.HisFundSettleListResult{
  14511. Number: res.Output.SetlListId,
  14512. Status: 1,
  14513. Ctime: time.Now().Unix(),
  14514. Mtime: time.Now().Unix(),
  14515. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14516. IsUpload: 1,
  14517. OrderId: order_id,
  14518. }
  14519. service.CreateUploadRecord(hisFundSettleListResult)
  14520. c.ServeSuccessJSON(map[string]interface{}{
  14521. "msg": "上传成功",
  14522. "result": hisFundSettleListResult,
  14523. })
  14524. return
  14525. }
  14526. }
  14527. //func (c *HisApiController) GetBatchSettleList() {
  14528. // orders, _ := service.GetAllHisOrder(10106)
  14529. // for _, item := range orders {
  14530. // order_id := item.ID
  14531. // order, _ := service.GetHisOrderByIDTwo(order_id)
  14532. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14533. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14534. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14535. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  14536. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14537. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14538. //
  14539. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14540. //
  14541. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14542. //
  14543. // if order.ID == 0 {
  14544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14545. // return
  14546. // }
  14547. // if his.BalanceAccountsType == 2 {
  14548. // continue
  14549. // }
  14550. // struct4101 := service.Struct4101{
  14551. // PsnNo: order.PsnNo,
  14552. // MdtrtId: order.MdtrtId,
  14553. // SetlId: order.SetlId,
  14554. // PsnName: order.PsnName,
  14555. // Gend: order.Gend,
  14556. // Brdy: his.Brdy,
  14557. // Age: his.Age,
  14558. // Naty: order.Naty,
  14559. // PatnCertType: "01",
  14560. // Certno: order.Certno,
  14561. // Prfs: "90",
  14562. // ConerName: roles[0].UserName,
  14563. // PatnRlts: "99",
  14564. // ConerAddr: miConfig.OrgName,
  14565. // ConerTel: admin.Mobile,
  14566. // HiType: order.Insutype,
  14567. // Insuplc: his.InsuplcAdmdvs,
  14568. // MaindiagFlag: "1",
  14569. // BillCode: order.SetlId,
  14570. // BillNo: order.SetlId,
  14571. // BizSn: order.Number,
  14572. // PsnSelfPay: order.PsnPartAmt,
  14573. // PsnOwnPay: order.PsnPartAmt,
  14574. // AcctPay: order.AcctPay,
  14575. // PsnCashpay: order.PsnCashPay,
  14576. // HiPaymtd: "1",
  14577. // Hsorg: his.InsuplcAdmdvs,
  14578. // HsorgOpter: his.InsuplcAdmdvs,
  14579. // MedinsFillPsn: curRoles.UserName,
  14580. // MedinsFillDept: depart.Name,
  14581. // IptMedType: "2",
  14582. // }
  14583. // struct4101.SetlBegnDate = order.SetlTime
  14584. // struct4101.SetlEndDate = order.SetlTime
  14585. // //if order.SettleType == 1 {
  14586. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  14587. // // dateStr := t.Format("2006-01-02")
  14588. // // struct4101.SetlBegnDate = dateStr
  14589. // // struct4101.SetlEndDate = dateStr
  14590. // //} else {
  14591. // // t := time.Unix(int64(order.SettleStartTime), 0)
  14592. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  14593. // // dateStartStr := t.Format("2006-01-02")
  14594. // // dateEndStr := t2.Format("2006-01-02")
  14595. // // struct4101.SetlBegnDate = dateStartStr
  14596. // // struct4101.SetlEndDate = dateEndStr
  14597. // //}
  14598. //
  14599. // var rf []CustomFundPay
  14600. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  14601. //
  14602. // var tempFunPays []service.CustomStruct
  14603. // var tempFunPay610100 service.CustomStruct
  14604. //
  14605. // for _, item := range rf {
  14606. // if item.FundPayType == "610100" {
  14607. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  14608. // tempFunPay610100.FundPayType = item.FundPayType
  14609. // } else {
  14610. // var tempFunPay service.CustomStruct
  14611. // tempFunPay.FundPayamt = item.FundPayamt
  14612. // tempFunPay.FundPayType = item.FundPayType
  14613. // tempFunPays = append(tempFunPays, tempFunPay)
  14614. // }
  14615. // }
  14616. // tempFunPays = append(tempFunPays, tempFunPay610100)
  14617. // struct4101.CustomStruct = tempFunPays
  14618. //
  14619. // var tempDiaginfos []service.DiaginfoStructTwo
  14620. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14621. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14622. //
  14623. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14624. // var config []*models.HisXtDiagnoseConfig
  14625. // for _, item := range diagnosis_ids {
  14626. // id, _ := strconv.ParseInt(item, 10, 64)
  14627. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  14628. // config = append(config, &diagnosisConfig)
  14629. // }
  14630. //
  14631. // for index, item := range config {
  14632. // if index == 0 {
  14633. // var tempDiaginfo service.DiaginfoStructTwo
  14634. // tempDiaginfo.DiagCode = item.CountryCode
  14635. // tempDiaginfo.DiagName = item.CountryContentName
  14636. // tempDiaginfo.DiagType = "1"
  14637. // tempDiaginfo.MaindiagFlag = "1"
  14638. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14639. // } else {
  14640. //
  14641. // var tempDiaginfo service.DiaginfoStructTwo
  14642. // tempDiaginfo.DiagCode = item.CountryCode
  14643. // tempDiaginfo.DiagName = item.CountryContentName
  14644. // tempDiaginfo.DiagType = "2"
  14645. // tempDiaginfo.MaindiagFlag = "0"
  14646. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14647. // }
  14648. // }
  14649. // struct4101.Diseinfo = tempDiaginfos
  14650. //
  14651. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  14652. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14653. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14654. // tempOpspdiseinfo2.OprnOprtCode = ""
  14655. // tempOpspdiseinfo2.OprnOprtName = ""
  14656. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14657. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14658. //
  14659. // var iteminfo service.IteminfoStruct
  14660. //
  14661. // var bedCostTotal float64 = 0 //床位总费
  14662. // var bedCostSelfTotal float64 = 0 //床位自费
  14663. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14664. //
  14665. // var examineCostTotal float64 = 0 //诊查总费
  14666. // var examineCostSelfTotal float64 = 0 //诊查自费
  14667. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  14668. //
  14669. // var nursingCostTotal float64 = 0 //护理总费
  14670. // var nursingCostSelfTotal float64 = 0 //护理自费
  14671. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  14672. //
  14673. // var chineseMedicineCostTotal float64 = 0 //中成药
  14674. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  14675. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  14676. //
  14677. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  14678. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  14679. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  14680. //
  14681. // var registerCostTotal float64 = 0 //一般诊疗费
  14682. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  14683. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  14684. //
  14685. // var operationCostTotal float64 = 0 //手术费
  14686. // var operationCostSelfTotal float64 = 0 //手术费
  14687. // var operationCostPartSelfTotal float64 = 0 //手术费
  14688. //
  14689. // var otherCostTotal float64 = 0 //其他费用
  14690. // var otherCostSelfTotal float64 = 0 //其他费用
  14691. // var otherCostPartSelfTotal float64 = 0 //其他费用
  14692. //
  14693. // var materialCostTotal float64 = 0 //材料费
  14694. // var materialCostSelfTotal float64 = 0 //材料费
  14695. // var materialCostPartSelfTotal float64 = 0 //材料费
  14696. //
  14697. // var westernMedicineCostTotal float64 = 0 //西药费
  14698. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  14699. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14700. //
  14701. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14702. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14703. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14704. //
  14705. // var checkCostTotal float64 = 0 //检查费
  14706. // var checkCostSelfTotal float64 = 0 //检查费
  14707. // var checkCostPartSelfTotal float64 = 0 //检查费
  14708. //
  14709. // var laboratoryCostTotal float64 = 0 //化验费
  14710. // var laboratoryCostSelfTotal float64 = 0 //化验费
  14711. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14712. //
  14713. // var treatCostTotal float64 = 0 //治疗费用
  14714. // var treatCostSelfTotal float64 = 0 //治疗费用
  14715. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  14716. //
  14717. // decimal.DivisionPrecision = 2
  14718. //
  14719. // var bed_fulamt_ownpay_amt float64 = 0
  14720. //
  14721. // var examine_fulamt_ownpay_amt float64 = 0
  14722. //
  14723. // var nursing_fulamt_ownpay_amt float64 = 0
  14724. //
  14725. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  14726. //
  14727. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  14728. //
  14729. // var register_fulamt_ownpay_amt float64 = 0
  14730. //
  14731. // var operation_fulamt_ownpay_amt float64 = 0
  14732. // var other_fulamt_ownpay_amt float64 = 0
  14733. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14734. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14735. // var check_fulamt_ownpay_amt float64 = 0
  14736. // var material_fulamt_ownpay_amt float64 = 0
  14737. // var laboratory_fulamt_ownpay_amt float64 = 0
  14738. // var treat_fulamt_ownpay_amt float64 = 0
  14739. //
  14740. // var bed_claa_sunmfee float64 = 0
  14741. // var bed_clab_amt float64 = 0
  14742. // var bed_other_amt float64 = 0
  14743. //
  14744. // var examine_claa_sunmfee float64 = 0
  14745. // var examine_clab_amt float64 = 0
  14746. // var examine_other_amt float64 = 0
  14747. //
  14748. // var nursing_claa_sunmfee float64 = 0
  14749. // var nursing_clab_amt float64 = 0
  14750. // var nursing_other_amt float64 = 0
  14751. //
  14752. // var chinese_medicine_claa_sunmfee float64 = 0
  14753. // var chinese_medicine_clab_amt float64 = 0
  14754. // var chinese_medicine_other_amt float64 = 0
  14755. //
  14756. // var commonly_treatment_claa_sunmfee float64 = 0
  14757. // var commonly_treatment_clab_amt float64 = 0
  14758. // var commonly_treatment_other_amt float64 = 0
  14759. //
  14760. // var operation_claa_sunmfee float64 = 0
  14761. // var operation_clab_amt float64 = 0
  14762. // var operation_other_amt float64 = 0
  14763. //
  14764. // var other_claa_sunmfee float64 = 0
  14765. // var other_clab_amt float64 = 0
  14766. // var other_other_amt float64 = 0
  14767. //
  14768. // var westernMedicine_claa_sunmfee float64 = 0
  14769. // var westernMedicine_clab_amt float64 = 0
  14770. // var westernMedicine_other_amt float64 = 0
  14771. //
  14772. // var chineseTraditional_claa_sunmfee float64 = 0
  14773. // var chineseTraditional_clab_amt float64 = 0
  14774. // var chineseTraditional_other_amt float64 = 0
  14775. //
  14776. // var check_claa_sunmfee float64 = 0
  14777. // var check_clab_amt float64 = 0
  14778. // var check_other_amt float64 = 0
  14779. //
  14780. // var material_claa_sunmfee float64 = 0
  14781. // var material_clab_amt float64 = 0
  14782. // var material_other_amt float64 = 0
  14783. //
  14784. // var laboratory_claa_sunmfee float64 = 0
  14785. // var laboratory_clab_amt float64 = 0
  14786. // var laboratory_other_amt float64 = 0
  14787. //
  14788. // var treat_claa_sunmfee float64 = 0
  14789. // var treat_clab_amt float64 = 0
  14790. // var treat_other_amt float64 = 0
  14791. //
  14792. // var register_claa_sunmfee float64 = 0
  14793. // var register_clab_amt float64 = 0
  14794. // var register_other_amt float64 = 0
  14795. //
  14796. // for _, item := range order.HisOrderInfo {
  14797. // if item.MedChrgitmType == "01" { //床位费
  14798. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14799. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14800. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14801. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14802. // if item.ChrgitmLv == "1" {
  14803. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14804. // }
  14805. // if item.ChrgitmLv == "2" {
  14806. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14807. //
  14808. // }
  14809. // if item.ChrgitmLv == "3" {
  14810. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14811. // }
  14812. //
  14813. // }
  14814. //
  14815. // if item.MedChrgitmType == "02" { //诊查
  14816. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14817. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14818. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14819. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14820. // if item.ChrgitmLv == "1" {
  14821. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14822. // }
  14823. // if item.ChrgitmLv == "2" {
  14824. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14825. //
  14826. // }
  14827. // if item.ChrgitmLv == "3" {
  14828. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14829. // }
  14830. //
  14831. // }
  14832. //
  14833. // if item.MedChrgitmType == "03" { //检查费
  14834. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14835. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14836. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14837. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14838. // if item.ChrgitmLv == "1" {
  14839. //
  14840. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14841. //
  14842. // }
  14843. // if item.ChrgitmLv == "2" {
  14844. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14845. //
  14846. // }
  14847. // if item.ChrgitmLv == "3" {
  14848. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14849. // }
  14850. // }
  14851. //
  14852. // if item.MedChrgitmType == "04" { //化验费
  14853. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14854. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14855. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14856. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14857. // if item.ChrgitmLv == "1" {
  14858. //
  14859. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14860. //
  14861. // }
  14862. // if item.ChrgitmLv == "2" {
  14863. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14864. //
  14865. // }
  14866. // if item.ChrgitmLv == "3" {
  14867. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14868. // }
  14869. // }
  14870. //
  14871. // if item.MedChrgitmType == "05" { //治疗费
  14872. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14873. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14874. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14875. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14876. // if item.ChrgitmLv == "1" {
  14877. //
  14878. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14879. //
  14880. // }
  14881. // if item.ChrgitmLv == "2" {
  14882. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14883. //
  14884. // }
  14885. // if item.ChrgitmLv == "3" {
  14886. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14887. // }
  14888. // }
  14889. //
  14890. // if item.MedChrgitmType == "06" { //手术费
  14891. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14892. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14893. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14894. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14895. //
  14896. // if item.ChrgitmLv == "1" {
  14897. //
  14898. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14899. //
  14900. // }
  14901. // if item.ChrgitmLv == "2" {
  14902. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14903. //
  14904. // }
  14905. // if item.ChrgitmLv == "3" {
  14906. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14907. // }
  14908. // }
  14909. //
  14910. // if item.MedChrgitmType == "07" { //手术费
  14911. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14912. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14913. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14914. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14915. //
  14916. // if item.ChrgitmLv == "1" {
  14917. //
  14918. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14919. //
  14920. // }
  14921. // if item.ChrgitmLv == "2" {
  14922. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14923. //
  14924. // }
  14925. // if item.ChrgitmLv == "3" {
  14926. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14927. // }
  14928. // }
  14929. //
  14930. // if item.MedChrgitmType == "08" { //材料费
  14931. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14932. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14933. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14934. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14935. // if item.ChrgitmLv == "1" {
  14936. //
  14937. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14938. //
  14939. // }
  14940. // if item.ChrgitmLv == "2" {
  14941. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14942. //
  14943. // }
  14944. // if item.ChrgitmLv == "3" {
  14945. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14946. // }
  14947. // }
  14948. // if item.MedChrgitmType == "09" { //西药费
  14949. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14950. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14951. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14952. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14953. // if item.ChrgitmLv == "1" {
  14954. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14955. // }
  14956. // if item.ChrgitmLv == "2" {
  14957. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14958. // }
  14959. // if item.ChrgitmLv == "3" {
  14960. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14961. // }
  14962. // }
  14963. // if item.MedChrgitmType == "10" { //中药饮片
  14964. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14965. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14966. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14967. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14968. // if item.ChrgitmLv == "1" {
  14969. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14970. // }
  14971. // if item.ChrgitmLv == "2" {
  14972. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14973. // }
  14974. // if item.ChrgitmLv == "3" {
  14975. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14976. // }
  14977. // }
  14978. //
  14979. // if item.MedChrgitmType == "11" { //中成费
  14980. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14981. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14982. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14983. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14984. // if item.ChrgitmLv == "1" {
  14985. //
  14986. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14987. //
  14988. // }
  14989. // if item.ChrgitmLv == "2" {
  14990. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14991. //
  14992. // }
  14993. // if item.ChrgitmLv == "3" {
  14994. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14995. // }
  14996. // }
  14997. //
  14998. // if item.MedChrgitmType == "12" { //中成费
  14999. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15000. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15001. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15002. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15003. // if item.ChrgitmLv == "1" {
  15004. //
  15005. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15006. //
  15007. // }
  15008. // if item.ChrgitmLv == "2" {
  15009. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15010. //
  15011. // }
  15012. // if item.ChrgitmLv == "3" {
  15013. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15014. // }
  15015. // }
  15016. //
  15017. // if item.MedChrgitmType == "13" { //中成费
  15018. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15019. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15020. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15021. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15022. // if item.ChrgitmLv == "1" {
  15023. //
  15024. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15025. //
  15026. // }
  15027. // if item.ChrgitmLv == "2" {
  15028. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15029. //
  15030. // }
  15031. // if item.ChrgitmLv == "3" {
  15032. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15033. // }
  15034. // }
  15035. //
  15036. // if item.MedChrgitmType == "14" { //其他费
  15037. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15038. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15039. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15040. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15041. // if item.ChrgitmLv == "1" {
  15042. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15043. //
  15044. // }
  15045. // if item.ChrgitmLv == "2" {
  15046. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15047. //
  15048. // }
  15049. // if item.ChrgitmLv == "3" {
  15050. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15051. // }
  15052. // }
  15053. //
  15054. // }
  15055. //
  15056. // var iteminfoStructs []service.IteminfoStruct
  15057. //
  15058. // if bedCostTotal != 0 {
  15059. // iteminfo.MedChrgitm = "01"
  15060. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15061. // iteminfo.Amt = bedCostTotal
  15062. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  15063. // iteminfo.ClabAmt = bed_clab_amt
  15064. // iteminfo.OthAmt = bed_other_amt
  15065. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15066. // }
  15067. //
  15068. // if examineCostTotal != 0 {
  15069. // iteminfo.MedChrgitm = "02"
  15070. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  15071. // iteminfo.Amt = examineCostTotal
  15072. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  15073. // iteminfo.ClabAmt = examine_clab_amt
  15074. // iteminfo.OthAmt = examine_other_amt
  15075. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15076. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15077. // }
  15078. //
  15079. // if checkCostTotal != 0 {
  15080. // iteminfo.MedChrgitm = "03"
  15081. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  15082. // iteminfo.Amt = checkCostTotal
  15083. // iteminfo.ClaaSumfee = check_claa_sunmfee
  15084. // iteminfo.ClabAmt = check_clab_amt
  15085. // iteminfo.OthAmt = check_other_amt
  15086. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15087. //
  15088. // }
  15089. //
  15090. // if laboratoryCostTotal != 0 {
  15091. // iteminfo.MedChrgitm = "04"
  15092. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  15093. // iteminfo.Amt = laboratoryCostTotal
  15094. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  15095. // iteminfo.ClabAmt = laboratory_clab_amt
  15096. // iteminfo.OthAmt = laboratory_other_amt
  15097. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15098. //
  15099. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15100. //
  15101. // }
  15102. //
  15103. // if treatCostTotal != 0 {
  15104. // iteminfo.MedChrgitm = "05"
  15105. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  15106. // iteminfo.Amt = treatCostTotal
  15107. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  15108. // iteminfo.ClabAmt = treat_clab_amt
  15109. // iteminfo.OthAmt = treat_other_amt
  15110. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15111. // //(struct4101.IteminfoStruct, iteminfo)
  15112. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15113. // }
  15114. //
  15115. // if operationCostTotal != 0 {
  15116. // iteminfo.MedChrgitm = "06"
  15117. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15118. // iteminfo.Amt = operationCostTotal
  15119. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  15120. // iteminfo.ClabAmt = operation_clab_amt
  15121. // iteminfo.OthAmt = operation_other_amt
  15122. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15123. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15124. // }
  15125. //
  15126. // if nursingCostTotal != 0 {
  15127. // iteminfo.MedChrgitm = "07"
  15128. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  15129. // iteminfo.Amt = nursingCostTotal
  15130. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  15131. // iteminfo.ClabAmt = nursing_clab_amt
  15132. // iteminfo.OthAmt = nursing_other_amt
  15133. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15134. // }
  15135. //
  15136. // if materialCostTotal != 0 {
  15137. // iteminfo.MedChrgitm = "08"
  15138. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  15139. // iteminfo.Amt = materialCostTotal
  15140. // iteminfo.ClaaSumfee = material_claa_sunmfee
  15141. // iteminfo.ClabAmt = material_clab_amt
  15142. // iteminfo.OthAmt = material_other_amt
  15143. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15144. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15145. // }
  15146. //
  15147. // if westernMedicineCostTotal != 0 {
  15148. // iteminfo.MedChrgitm = "09"
  15149. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15150. // iteminfo.Amt = westernMedicineCostTotal
  15151. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15152. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15153. // iteminfo.OthAmt = westernMedicine_other_amt
  15154. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15155. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15156. //
  15157. // }
  15158. //
  15159. // if chineseMedicineCostTotal != 0 {
  15160. // iteminfo.MedChrgitm = "10"
  15161. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  15162. // iteminfo.Amt = chineseMedicineCostTotal
  15163. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  15164. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  15165. // iteminfo.OthAmt = chinese_medicine_other_amt
  15166. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15167. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15168. //
  15169. // }
  15170. //
  15171. // if chineseTraditionalMedicineCostTotal != 0 {
  15172. // iteminfo.MedChrgitm = "11"
  15173. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15174. // iteminfo.Amt = westernMedicineCostTotal
  15175. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15176. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15177. // iteminfo.OthAmt = westernMedicine_other_amt
  15178. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15179. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15180. //
  15181. // }
  15182. //
  15183. // if commonlyTreatmentCostTotal != 0 {
  15184. // iteminfo.MedChrgitm = "12"
  15185. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  15186. // iteminfo.Amt = commonlyTreatmentCostTotal
  15187. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  15188. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  15189. // iteminfo.OthAmt = commonly_treatment_other_amt
  15190. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15191. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15192. //
  15193. // }
  15194. //
  15195. // if registerCostTotal != 0 {
  15196. // iteminfo.MedChrgitm = "13"
  15197. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  15198. // iteminfo.Amt = registerCostTotal
  15199. // iteminfo.ClaaSumfee = register_claa_sunmfee
  15200. // iteminfo.ClabAmt = register_clab_amt
  15201. // iteminfo.OthAmt = register_other_amt
  15202. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15203. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15204. //
  15205. // }
  15206. //
  15207. // if otherCostTotal != 0 {
  15208. // iteminfo.MedChrgitm = "14"
  15209. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15210. // iteminfo.Amt = otherCostTotal
  15211. // iteminfo.ClaaSumfee = other_claa_sunmfee
  15212. // iteminfo.ClabAmt = other_clab_amt
  15213. // iteminfo.OthAmt = other_other_amt
  15214. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15215. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15216. //
  15217. // }
  15218. // struct4101.IteminfoStruct = iteminfoStructs
  15219. // time_arr := strings.Split(order.SetlTime, " ")
  15220. // struct4101.AdmTime = time_arr[0]
  15221. // struct4101.AdmEndTime = time_arr[0]
  15222. //
  15223. // struct4101.DoctorName = doctor.UserName
  15224. // struct4101.DoctorCode = doctor.DoctorNumber
  15225. //
  15226. // struct4101.Ntly = "中国"
  15227. // struct4101.AdmCaty = "A03.06"
  15228. // var res ResultSeventeen
  15229. // if miConfig.MdtrtareaAdmvs == "421300" {
  15230. // data := make(map[string]interface{})
  15231. // data["struct4101"] = struct4101
  15232. // data["secret_key"] = miConfig.SecretKey
  15233. // data["org_name"] = miConfig.OrgName
  15234. // data["opera"] = curRoles.UserName
  15235. // data["code"] = miConfig.Code
  15236. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15237. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15238. //
  15239. // client := &http.Client{}
  15240. // bytesData, _ := json.Marshal(data)
  15241. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15242. // resp, _ := client.Do(req)
  15243. // defer resp.Body.Close()
  15244. // body, ioErr := ioutil.ReadAll(resp.Body)
  15245. // if ioErr != nil {
  15246. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15247. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15248. // return
  15249. // }
  15250. // var respJSON map[string]interface{}
  15251. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15252. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15254. // return
  15255. // }
  15256. //
  15257. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15258. // userJSONBytes, _ := json.Marshal(respJSON)
  15259. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15260. // utils.ErrorLog("解析失败:%v", err)
  15261. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15262. // adminUser := c.GetAdminUserInfo()
  15263. // errlog := &models.HisOrderError{
  15264. // UserOrgId: adminUser.CurrentOrgId,
  15265. // Ctime: time.Now().Unix(),
  15266. // Mtime: time.Now().Unix(),
  15267. // ErrMsg: res.ErrMsg + "解析失败",
  15268. // Status: 1,
  15269. // PatientId: order_id,
  15270. // Stage: 10088,
  15271. // }
  15272. // service.CreateErrMsgLog(errlog)
  15273. // continue
  15274. // }
  15275. //
  15276. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  15277. // data := make(map[string]interface{})
  15278. // data["struct4101"] = struct4101
  15279. // data["secret_key"] = miConfig.SecretKey
  15280. // data["org_name"] = miConfig.OrgName
  15281. // data["opera"] = curRoles.UserName
  15282. // data["code"] = miConfig.Code
  15283. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15284. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15285. //
  15286. // client := &http.Client{}
  15287. // bytesData, _ := json.Marshal(data)
  15288. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15289. // resp, _ := client.Do(req)
  15290. // defer resp.Body.Close()
  15291. // body, ioErr := ioutil.ReadAll(resp.Body)
  15292. // if ioErr != nil {
  15293. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15294. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15295. // return
  15296. // }
  15297. // var respJSON map[string]interface{}
  15298. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15299. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15301. // return
  15302. // }
  15303. //
  15304. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15305. // userJSONBytes, _ := json.Marshal(respJSON)
  15306. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15307. // utils.ErrorLog("解析失败:%v", err)
  15308. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15309. // adminUser := c.GetAdminUserInfo()
  15310. // errlog := &models.HisOrderError{
  15311. // UserOrgId: adminUser.CurrentOrgId,
  15312. // Ctime: time.Now().Unix(),
  15313. // Mtime: time.Now().Unix(),
  15314. // ErrMsg: res.ErrMsg + "解析失败",
  15315. // Status: 1,
  15316. // PatientId: order_id,
  15317. // Stage: 10088,
  15318. // }
  15319. // service.CreateErrMsgLog(errlog)
  15320. // continue
  15321. // }
  15322. //
  15323. // } else {
  15324. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  15325. // fmt.Println(result)
  15326. //
  15327. // var dat map[string]interface{}
  15328. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15329. // fmt.Println(dat)
  15330. // } else {
  15331. // fmt.Println(err)
  15332. // }
  15333. // userJSONBytes, _ := json.Marshal(dat)
  15334. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15335. // utils.ErrorLog("解析失败:%v", err)
  15336. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15337. // adminUser := c.GetAdminUserInfo()
  15338. // errlog := &models.HisOrderError{
  15339. // UserOrgId: adminUser.CurrentOrgId,
  15340. // Ctime: time.Now().Unix(),
  15341. // Mtime: time.Now().Unix(),
  15342. // ErrMsg: res.ErrMsg + "解析失败",
  15343. // Status: 1,
  15344. // PatientId: order_id,
  15345. // Stage: 10106,
  15346. // }
  15347. // service.CreateErrMsgLog(errlog)
  15348. // continue
  15349. // }
  15350. // }
  15351. //
  15352. // if res.Infcode != 0 {
  15353. // adminUser := c.GetAdminUserInfo()
  15354. // errlog := &models.HisOrderError{
  15355. // UserOrgId: adminUser.CurrentOrgId,
  15356. // Ctime: time.Now().Unix(),
  15357. // Mtime: time.Now().Unix(),
  15358. // ErrMsg: res.ErrMsg,
  15359. // Status: 1,
  15360. // PatientId: order_id,
  15361. // Stage: 10106,
  15362. // }
  15363. // service.CreateErrMsgLog(errlog)
  15364. // continue
  15365. // } else {
  15366. // hisFundSettleListResult := &models.HisFundSettleListResult{
  15367. // Number: res.Output.SetlListId,
  15368. // Status: 1,
  15369. // Ctime: time.Now().Unix(),
  15370. // Mtime: time.Now().Unix(),
  15371. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15372. // IsUpload: 1,
  15373. // OrderId: order_id,
  15374. // }
  15375. // service.CreateUploadRecord(hisFundSettleListResult)
  15376. // continue
  15377. // }
  15378. // }
  15379. //}
  15380. func (c *HisApiController) GetOrgInfo() {
  15381. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  15382. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  15383. }
  15384. func (c *HisApiController) GetHisPatientInfo() {
  15385. medical_insurance_card := c.GetString("medical_insurance_card")
  15386. id_card_type, _ := c.GetInt64("id_card_type")
  15387. id_card := c.GetString("id_card")
  15388. adminInfo := c.GetAdminUserInfo()
  15389. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15390. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15391. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  15392. IdCardNo := ""
  15393. if id_card_type == 1 {
  15394. IdCardNo = medical_insurance_card
  15395. } else if id_card_type == 2 {
  15396. IdCardNo = id_card
  15397. }
  15398. if config.IsOpen == 1 {
  15399. 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
  15400. resp, requestErr := http.Get(api)
  15401. if requestErr != nil {
  15402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15403. return
  15404. }
  15405. defer resp.Body.Close()
  15406. body, ioErr := ioutil.ReadAll(resp.Body)
  15407. if ioErr != nil {
  15408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15410. return
  15411. }
  15412. var respJSON map[string]interface{}
  15413. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15416. return
  15417. }
  15418. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15419. userJSONBytes, _ := json.Marshal(userJSON)
  15420. var res ResultTwo
  15421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15422. utils.ErrorLog("解析失败:%v", err)
  15423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15424. return
  15425. }
  15426. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15427. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15428. infoStr := string(Iinfos)
  15429. idetinfoStr := string(Idetinfos)
  15430. if res.Infcode == 0 {
  15431. his := models.VMHisPatient{
  15432. Status: 1,
  15433. Ctime: time.Now().Unix(),
  15434. Mtime: time.Now().Unix(),
  15435. PsnNo: res.Output.Baseinfo.PsnNo,
  15436. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15437. Certno: res.Output.Baseinfo.Certno,
  15438. PsnName: res.Output.Baseinfo.PsnName,
  15439. Gend: res.Output.Baseinfo.Gend,
  15440. Naty: res.Output.Baseinfo.Naty,
  15441. Iinfo: infoStr,
  15442. Idetinfo: idetinfoStr,
  15443. UserOrgId: adminInfo.CurrentOrgId,
  15444. IsReturn: 1,
  15445. IdCardType: id_card_type,
  15446. }
  15447. c.ServeSuccessJSON(map[string]interface{}{
  15448. "info": his,
  15449. })
  15450. } else {
  15451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15452. return
  15453. }
  15454. }
  15455. }
  15456. //func GetBasBaseInfo() (jsonStr string, err error) {
  15457. //
  15458. // handle := syscall.NewLazyDLL("SSCard.dll")
  15459. // add := handle.NewProc("ReadCardBas")
  15460. // str := make([]byte, 1024)
  15461. // str1 := make([]byte, 1024)
  15462. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15463. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  15464. //
  15465. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  15466. //
  15467. // fmt.Println("> Add(4,5)的结果为:", ret)
  15468. // handle.Release()
  15469. //
  15470. // return "", nil
  15471. //
  15472. //}
  15473. //func GetQRBaseInfo() (jsonStr string, err error) {
  15474. // handle := syscall.LoadDLL("SSCard.dll")
  15475. // ReadCardBas := handle.FindProc("GetQRBase")
  15476. //
  15477. // str := make([]byte, 256)
  15478. // str1 := make([]byte, 256)
  15479. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15480. //
  15481. // fmt.Println(string(str))
  15482. // fmt.Println(r)
  15483. // return string(str), nil
  15484. //}
  15485. //func CardInit() int {
  15486. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  15487. // add := DllTestDef.MustFindProc("Init")
  15488. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15489. // if err != nil {
  15490. // fmt.Println("SSCard的运算结果为:", ret)
  15491. // }
  15492. // result := int(ret)
  15493. // return result
  15494. //}
  15495. //func CardInit() int {
  15496. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15497. // if err != nil {
  15498. // fmt.Println("SSCard的运算结果为:", ret)
  15499. // }
  15500. // fmt.Println(err)
  15501. // result := int(ret)
  15502. // return result
  15503. //}
  15504. func IntPtr(n int) uintptr {
  15505. return uintptr(n)
  15506. }
  15507. func StrPtr(s string) uintptr {
  15508. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  15509. }
  15510. type Result2001 struct {
  15511. Cainfo interface{} `json:"cainfo"`
  15512. ErrMsg string `json:"err_msg"`
  15513. InfRefmsgid string `json:"inf_refmsgid"`
  15514. Infcode int64 `json:"infcode"`
  15515. Output struct {
  15516. Trtinfo struct {
  15517. PsnNo string `json:"psn_no"`
  15518. TrtChkType string `json:"trt_chk_type"`
  15519. FundPayType string `json:"fund_pay_type"`
  15520. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15521. Begndate string `json:"begndate"`
  15522. Enddate string `json:"enddate"`
  15523. TrtChkRslt string `json:"trt_chk_rslt"`
  15524. } `json:"trtinfo"`
  15525. } `json:"output"`
  15526. RefmsgTime string `json:"refmsg_time"`
  15527. RespondTime string `json:"respond_time"`
  15528. Signtype interface{} `json:"signtype"`
  15529. WarnMsg interface{} `json:"warn_msg"`
  15530. }
  15531. type Result2001Org10265 struct {
  15532. Cainfo interface{} `json:"cainfo"`
  15533. ErrMsg string `json:"err_msg"`
  15534. InfRefmsgid string `json:"inf_refmsgid"`
  15535. Infcode string `json:"infcode"`
  15536. Output struct {
  15537. Trtinfo struct {
  15538. PsnNo string `json:"psn_no"`
  15539. TrtChkType string `json:"trt_chk_type"`
  15540. FundPayType string `json:"fund_pay_type"`
  15541. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15542. Begndate string `json:"begndate"`
  15543. Enddate string `json:"enddate"`
  15544. TrtChkRslt string `json:"trt_chk_rslt"`
  15545. } `json:"trtinfo"`
  15546. } `json:"output"`
  15547. RefmsgTime string `json:"refmsg_time"`
  15548. RespondTime string `json:"respond_time"`
  15549. Signtype interface{} `json:"signtype"`
  15550. WarnMsg interface{} `json:"warn_msg"`
  15551. }
  15552. type ResultTwo struct {
  15553. ErrMsg string `json:"err_msg"`
  15554. InfRefmsgid string `json:"inf_refmsgid"`
  15555. Infcode int64 `json:"infcode"`
  15556. Output struct {
  15557. Baseinfo struct {
  15558. //Brdy string `json:"brdy"`
  15559. Certno string `json:"certno"`
  15560. Gend string `json:"gend"`
  15561. Naty string `json:"naty"`
  15562. PsnCertType string `json:"psn_cert_type"`
  15563. PsnName string `json:"psn_name"`
  15564. PsnNo string `json:"psn_no"`
  15565. } `json:"baseinfo"`
  15566. Idetinfo []interface{} `json:"idetinfo"`
  15567. Iinfo []struct {
  15568. Balc float64 `json:"balc"`
  15569. CvlservFlag string `json:"cvlserv_flag"`
  15570. EmpName string `json:"emp_name"`
  15571. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15572. Insutype string `json:"insutype"`
  15573. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15574. //PausInsuDate string `json:"paus_insu_date"`
  15575. //PsnInsuDate string `json:"psn_insu_date"`
  15576. PsnInsuStas string `json:"psn_insu_stas"`
  15577. PsnType string `json:"psn_type"`
  15578. } `json:"insuinfo"`
  15579. } `json:"output"`
  15580. RefmsgTime string `json:"refmsg_time"`
  15581. RespondTime string `json:"respond_time"`
  15582. Signtype interface{} `json:"signtype"`
  15583. WarnInfo interface{} `json:"warn_info"`
  15584. }
  15585. type ResultTwo10265 struct {
  15586. ErrMsg string `json:"err_msg"`
  15587. InfRefmsgid string `json:"inf_refmsgid"`
  15588. Infcode string `json:"infcode"`
  15589. Output struct {
  15590. Baseinfo struct {
  15591. //Brdy string `json:"brdy"`
  15592. Certno string `json:"certno"`
  15593. Gend string `json:"gend"`
  15594. Naty string `json:"naty"`
  15595. PsnCertType string `json:"psn_cert_type"`
  15596. PsnName string `json:"psn_name"`
  15597. PsnNo string `json:"psn_no"`
  15598. } `json:"baseinfo"`
  15599. Idetinfo []interface{} `json:"idetinfo"`
  15600. Iinfo []struct {
  15601. Balc float64 `json:"balc"`
  15602. CvlservFlag string `json:"cvlserv_flag"`
  15603. EmpName string `json:"emp_name"`
  15604. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15605. Insutype string `json:"insutype"`
  15606. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15607. PsnInsuStas string `json:"psn_insu_stas"`
  15608. PsnType string `json:"psn_type"`
  15609. } `json:"insuinfo"`
  15610. } `json:"output"`
  15611. RefmsgTime string `json:"refmsg_time"`
  15612. RespondTime string `json:"respond_time"`
  15613. Signtype interface{} `json:"signtype"`
  15614. WarnInfo interface{} `json:"warn_info"`
  15615. }
  15616. type ResultThree struct {
  15617. Cainfo interface{} `json:"cainfo"`
  15618. ErrMsg string `json:"err_msg"`
  15619. InfRefmsgid string `json:"inf_refmsgid"`
  15620. Infcode int64 `json:"infcode"`
  15621. Output struct {
  15622. Data struct {
  15623. IptOtpNo string `json:"ipt_otp_no"`
  15624. MdtrtID string `json:"mdtrt_id"`
  15625. PsnNo string `json:"psn_no"`
  15626. } `json:"data"`
  15627. } `json:"output"`
  15628. RefmsgTime string `json:"refmsg_time"`
  15629. RespondTime string `json:"respond_time"`
  15630. Signtype interface{} `json:"signtype"`
  15631. WarnMsg interface{} `json:"warn_msg"`
  15632. }
  15633. type ResultThree10265 struct {
  15634. Cainfo interface{} `json:"cainfo"`
  15635. ErrMsg string `json:"err_msg"`
  15636. InfRefmsgid string `json:"inf_refmsgid"`
  15637. Infcode string `json:"infcode"`
  15638. Output struct {
  15639. Data struct {
  15640. IptOtpNo string `json:"ipt_otp_no"`
  15641. MdtrtID string `json:"mdtrt_id"`
  15642. PsnNo string `json:"psn_no"`
  15643. } `json:"data"`
  15644. } `json:"output"`
  15645. RefmsgTime string `json:"refmsg_time"`
  15646. RespondTime string `json:"respond_time"`
  15647. Signtype interface{} `json:"signtype"`
  15648. WarnMsg interface{} `json:"warn_msg"`
  15649. }
  15650. type ResultFour struct {
  15651. Cainfo string `json:"cainfo"`
  15652. ErrMsg string `json:"err_msg"`
  15653. InfRefmsgid string `json:"inf_refmsgid"`
  15654. Infcode int64 `json:"infcode"`
  15655. Output struct {
  15656. Result []struct {
  15657. BasMednFlag string `json:"bas_medn_flag"`
  15658. ChldMedcFlag string `json:"chld_medc_flag"`
  15659. ChrgitmLv string `json:"chrgitm_lv"`
  15660. Cnt float64 `json:"cnt"`
  15661. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15662. DrtReimFlag string `json:"drt_reim_flag"`
  15663. FeedetlSn string `json:"feedetl_sn"`
  15664. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15665. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15666. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15667. ListSpItemFlag string `json:"list_sp_item_flag"`
  15668. LmtUsedFlag string `json:"lmt_used_flag"`
  15669. MedChrgitmType string `json:"med_chrgitm_type"`
  15670. Memo string `json:"memo"`
  15671. OverlmtAmt float64 `json:"overlmt_amt"`
  15672. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15673. Pric float64 `json:"pric"`
  15674. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15675. SelfpayProp float64 `json:"selfpay_prop"`
  15676. } `json:"result"`
  15677. } `json:"output"`
  15678. RefmsgTime string `json:"refmsg_time"`
  15679. RespondTime string `json:"respond_time"`
  15680. Signtype string `json:"signtype"`
  15681. WarnMsg string `json:"warn_msg"`
  15682. }
  15683. type ResultFour10265 struct {
  15684. Cainfo string `json:"cainfo"`
  15685. ErrMsg string `json:"err_msg"`
  15686. InfRefmsgid string `json:"inf_refmsgid"`
  15687. Infcode string `json:"infcode"`
  15688. Output struct {
  15689. Result []struct {
  15690. BasMednFlag string `json:"bas_medn_flag"`
  15691. ChldMedcFlag string `json:"chld_medc_flag"`
  15692. ChrgitmLv string `json:"chrgitm_lv"`
  15693. Cnt float64 `json:"cnt"`
  15694. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15695. DrtReimFlag string `json:"drt_reim_flag"`
  15696. FeedetlSn string `json:"feedetl_sn"`
  15697. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15698. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15699. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15700. ListSpItemFlag string `json:"list_sp_item_flag"`
  15701. LmtUsedFlag string `json:"lmt_used_flag"`
  15702. MedChrgitmType string `json:"med_chrgitm_type"`
  15703. Memo string `json:"memo"`
  15704. OverlmtAmt float64 `json:"overlmt_amt"`
  15705. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15706. Pric float64 `json:"pric"`
  15707. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15708. SelfpayProp float64 `json:"selfpay_prop"`
  15709. } `json:"result"`
  15710. } `json:"output"`
  15711. RefmsgTime string `json:"refmsg_time"`
  15712. RespondTime string `json:"respond_time"`
  15713. Signtype string `json:"signtype"`
  15714. WarnMsg string `json:"warn_msg"`
  15715. }
  15716. type ResultMemo struct {
  15717. InsuAdmdvs string `json:"insuAdmdvs"`
  15718. }
  15719. // [{"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}]
  15720. type ResultIDInfo struct {
  15721. Begntime string `json:"begntime"`
  15722. Endtime string `json:"endtime"`
  15723. Memo string `json:"memo"`
  15724. }
  15725. type ResultFive struct {
  15726. Balc float64 `json:"balc"`
  15727. CvlservFlag string `json:"cvlserv_flag"`
  15728. EmpName string `json:"emp_name"`
  15729. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15730. Insutype string `json:"insutype"`
  15731. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15732. PausInsuDate string `json:"paus_insu_date"`
  15733. PsnInsuDate string `json:"psn_insu_date"`
  15734. PsnInsuStas string `json:"psn_insu_stas"`
  15735. PsnType string `json:"psn_type"`
  15736. }
  15737. type ResultSix struct {
  15738. Cainfo interface{} `json:"cainfo"`
  15739. ErrMsg string `json:"err_msg"`
  15740. InfRefmsgid string `json:"inf_refmsgid"`
  15741. Infcode int64 `json:"infcode"`
  15742. Output struct {
  15743. } `json:"output"`
  15744. RefmsgTime string `json:"refmsg_time"`
  15745. RespondTime string `json:"respond_time"`
  15746. Signtype interface{} `json:"signtype"`
  15747. WarnMsg interface{} `json:"warn_msg"`
  15748. }
  15749. type FJ3507Result struct {
  15750. Cainfo interface{} `json:"cainfo"`
  15751. ErrMsg string `json:"err_msg"`
  15752. InfRefmsgid string `json:"inf_refmsgid"`
  15753. Infcode int64 `json:"infcode"`
  15754. Output struct {
  15755. retRslt string `json:"retRslt"`
  15756. msgRslt string `json:"msgRslt"`
  15757. } `json:"output"`
  15758. RefmsgTime string `json:"refmsg_time"`
  15759. RespondTime string `json:"respond_time"`
  15760. Signtype interface{} `json:"signtype"`
  15761. WarnMsg interface{} `json:"warn_msg"`
  15762. }
  15763. type Result2406 struct {
  15764. Cainfo interface{} `json:"cainfo"`
  15765. ErrMsg string `json:"err_msg"`
  15766. InfRefmsgid string `json:"inf_refmsgid"`
  15767. Infcode int64 `json:"infcode"`
  15768. Output struct {
  15769. Result struct {
  15770. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15771. } `json:"result"`
  15772. } `json:"output"`
  15773. RefmsgTime string `json:"refmsg_time"`
  15774. RespondTime string `json:"respond_time"`
  15775. Signtype interface{} `json:"signtype"`
  15776. WarnMsg interface{} `json:"warn_msg"`
  15777. }
  15778. type GZResultSix struct {
  15779. Cainfo interface{} `json:"cainfo"`
  15780. ErrMsg string `json:"err_msg"`
  15781. InfRefmsgid string `json:"inf_refmsgid"`
  15782. Infcode int64 `json:"infcode"`
  15783. Output string `json:"output"`
  15784. RefmsgTime string `json:"refmsg_time"`
  15785. RespondTime string `json:"respond_time"`
  15786. Signtype interface{} `json:"signtype"`
  15787. WarnMsg interface{} `json:"warn_msg"`
  15788. }
  15789. type ResultSix10265 struct {
  15790. Cainfo interface{} `json:"cainfo"`
  15791. ErrMsg string `json:"err_msg"`
  15792. InfRefmsgid string `json:"inf_refmsgid"`
  15793. Infcode string `json:"infcode"`
  15794. Output struct {
  15795. } `json:"output"`
  15796. RefmsgTime string `json:"refmsg_time"`
  15797. RespondTime string `json:"respond_time"`
  15798. Signtype interface{} `json:"signtype"`
  15799. WarnMsg interface{} `json:"warn_msg"`
  15800. }
  15801. type ResultSeven struct {
  15802. Cainfo string `json:"cainfo"`
  15803. ErrMsg string `json:"err_msg"`
  15804. InfRefmsgid string `json:"inf_refmsgid"`
  15805. Infcode int64 `json:"infcode"`
  15806. Output struct {
  15807. Setlinfo struct {
  15808. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15809. AcctPay float64 `json:"acct_pay"`
  15810. ActPayDedc float64 `json:"act_pay_dedc"`
  15811. Age float64 `json:"age"`
  15812. Balc float64 `json:"balc"`
  15813. Certno string `json:"certno"`
  15814. ClrOptins string `json:"clr_optins"`
  15815. ClrType string `json:"clr_type"`
  15816. ClrWay string `json:"clr_way"`
  15817. CvlservFlag string `json:"cvlserv_flag"`
  15818. CvlservPay float64 `json:"cvlserv_pay"`
  15819. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15820. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15821. Gend string `json:"gend"`
  15822. HifesPay float64 `json:"hifes_pay"`
  15823. HifmiPay float64 `json:"hifmi_pay"`
  15824. HifpPay float64 `json:"hifp_pay"`
  15825. HospPartAmt float64 `json:"hosp_part_amt"`
  15826. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15827. Insutype string `json:"insutype"`
  15828. MafPay float64 `json:"maf_pay"`
  15829. MdtrtCertType string `json:"mdtrt_cert_type"`
  15830. HifobPay float64 `json:"hifob_pay"`
  15831. MdtrtID string `json:"mdtrt_id"`
  15832. MedType string `json:"med_type"`
  15833. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15834. MedinsSetlID string `json:"medins_setl_id"`
  15835. Naty string `json:"naty"`
  15836. OthPay float64 `json:"oth_pay"`
  15837. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15838. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15839. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15840. PsnCashPay float64 `json:"psn_cash_pay"`
  15841. PsnCertType string `json:"psn_cert_type"`
  15842. PsnName string `json:"psn_name"`
  15843. PsnNo string `json:"psn_no"`
  15844. PsnPartAmt float64 `json:"psn_part_amt"`
  15845. PsnType string `json:"psn_type"`
  15846. SetlID string `json:"setl_id"`
  15847. SetlTime string `json:"setl_time"`
  15848. } `json:"setlinfo"`
  15849. Setldetail interface{} `json:"setldetail"`
  15850. } `json:"output"`
  15851. RefmsgTime string `json:"refmsg_time"`
  15852. RespondTime string `json:"respond_time"`
  15853. Signtype interface{} `json:"signtype"`
  15854. WarnMsg interface{} `json:"warn_msg"`
  15855. }
  15856. type ResultSevenAH struct {
  15857. Cainfo string `json:"cainfo"`
  15858. ErrMsg string `json:"err_msg"`
  15859. InfRefmsgid string `json:"inf_refmsgid"`
  15860. Infcode int64 `json:"infcode"`
  15861. Output struct {
  15862. Setlinfo struct {
  15863. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15864. AcctPay float64 `json:"acct_pay"`
  15865. ActPayDedc float64 `json:"act_pay_dedc"`
  15866. Age float64 `json:"age"`
  15867. Balc float64 `json:"balc"`
  15868. Certno string `json:"certno"`
  15869. ClrOptins string `json:"clr_optins"`
  15870. ClrType string `json:"clr_type"`
  15871. ClrWay string `json:"clr_way"`
  15872. CvlservFlag string `json:"cvlserv_flag"`
  15873. CvlservPay float64 `json:"cvlserv_pay"`
  15874. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15875. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15876. Gend string `json:"gend"`
  15877. HifesPay float64 `json:"hifes_pay"`
  15878. HifmiPay float64 `json:"hifmi_pay"`
  15879. HifpPay float64 `json:"hifp_pay"`
  15880. HospPartAmt float64 `json:"hosp_part_amt"`
  15881. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15882. Insutype string `json:"insutype"`
  15883. MafPay float64 `json:"maf_pay"`
  15884. MdtrtCertType string `json:"mdtrt_cert_type"`
  15885. HifobPay float64 `json:"hifob_pay"`
  15886. MdtrtID string `json:"mdtrt_id"`
  15887. MedType string `json:"med_type"`
  15888. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15889. MedinsSetlID string `json:"medins_setl_id"`
  15890. Naty string `json:"naty"`
  15891. OthPay float64 `json:"oth_pay"`
  15892. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15893. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15894. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15895. PsnCashPay float64 `json:"psn_cash_pay"`
  15896. PsnCertType string `json:"psn_cert_type"`
  15897. PsnName string `json:"psn_name"`
  15898. PsnNo string `json:"psn_no"`
  15899. PsnPartAmt float64 `json:"psn_part_amt"`
  15900. PsnType string `json:"psn_type"`
  15901. SetlID string `json:"setl_id"`
  15902. SetlTime int64 `json:"setl_time"`
  15903. } `json:"setlinfo"`
  15904. Setldetail interface{} `json:"setldetail"`
  15905. } `json:"output"`
  15906. RefmsgTime string `json:"refmsg_time"`
  15907. RespondTime string `json:"respond_time"`
  15908. Signtype interface{} `json:"signtype"`
  15909. WarnMsg interface{} `json:"warn_msg"`
  15910. }
  15911. type ResultSeven10265 struct {
  15912. Cainfo string `json:"cainfo"`
  15913. ErrMsg string `json:"err_msg"`
  15914. InfRefmsgid string `json:"inf_refmsgid"`
  15915. Infcode string `json:"infcode"`
  15916. Output struct {
  15917. Setlinfo struct {
  15918. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15919. AcctPay float64 `json:"acct_pay"`
  15920. ActPayDedc float64 `json:"act_pay_dedc"`
  15921. Age float64 `json:"age"`
  15922. Balc float64 `json:"balc"`
  15923. Certno string `json:"certno"`
  15924. ClrOptins string `json:"clr_optins"`
  15925. ClrType string `json:"clr_type"`
  15926. ClrWay string `json:"clr_way"`
  15927. CvlservFlag string `json:"cvlserv_flag"`
  15928. CvlservPay float64 `json:"cvlserv_pay"`
  15929. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15930. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15931. Gend string `json:"gend"`
  15932. HifesPay float64 `json:"hifes_pay"`
  15933. HifmiPay float64 `json:"hifmi_pay"`
  15934. HifpPay float64 `json:"hifp_pay"`
  15935. HospPartAmt float64 `json:"hosp_part_amt"`
  15936. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15937. Insutype string `json:"insutype"`
  15938. MafPay float64 `json:"maf_pay"`
  15939. MdtrtCertType string `json:"mdtrt_cert_type"`
  15940. HifobPay float64 `json:"hifob_pay"`
  15941. MdtrtID string `json:"mdtrt_id"`
  15942. MedType string `json:"med_type"`
  15943. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15944. MedinsSetlID string `json:"medins_setl_id"`
  15945. Naty string `json:"naty"`
  15946. OthPay float64 `json:"oth_pay"`
  15947. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15948. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15949. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15950. PsnCashPay float64 `json:"psn_cash_pay"`
  15951. PsnCertType string `json:"psn_cert_type"`
  15952. PsnName string `json:"psn_name"`
  15953. PsnNo string `json:"psn_no"`
  15954. PsnPartAmt float64 `json:"psn_part_amt"`
  15955. PsnType string `json:"psn_type"`
  15956. SetlID string `json:"setl_id"`
  15957. SetlTime string `json:"setl_time"`
  15958. } `json:"setlinfo"`
  15959. Setldetail interface{} `json:"setldetail"`
  15960. } `json:"output"`
  15961. RefmsgTime string `json:"refmsg_time"`
  15962. RespondTime string `json:"respond_time"`
  15963. Signtype interface{} `json:"signtype"`
  15964. WarnMsg interface{} `json:"warn_msg"`
  15965. }
  15966. type ResultSeven10265Two struct {
  15967. Cainfo string `json:"cainfo"`
  15968. ErrMsg string `json:"err_msg"`
  15969. InfRefmsgid string `json:"inf_refmsgid"`
  15970. Infcode string `json:"infcode"`
  15971. Output struct {
  15972. Setlinfo struct {
  15973. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15974. AcctPay float64 `json:"acct_pay"`
  15975. ActPayDedc float64 `json:"act_pay_dedc"`
  15976. Age float64 `json:"age"`
  15977. Balc float64 `json:"balc"`
  15978. Certno string `json:"certno"`
  15979. ClrOptins string `json:"clr_optins"`
  15980. ClrType string `json:"clr_type"`
  15981. ClrWay string `json:"clr_way"`
  15982. CvlservFlag string `json:"cvlserv_flag"`
  15983. CvlservPay float64 `json:"cvlserv_pay"`
  15984. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15985. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15986. Gend string `json:"gend"`
  15987. HifesPay float64 `json:"hifes_pay"`
  15988. HifmiPay float64 `json:"hifmi_pay"`
  15989. HifpPay float64 `json:"hifp_pay"`
  15990. HospPartAmt string `json:"hosp_part_amt"`
  15991. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15992. Insutype string `json:"insutype"`
  15993. MafPay float64 `json:"maf_pay"`
  15994. MdtrtCertType string `json:"mdtrt_cert_type"`
  15995. HifobPay float64 `json:"hifob_pay"`
  15996. MdtrtID string `json:"mdtrt_id"`
  15997. MedType string `json:"med_type"`
  15998. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15999. MedinsSetlID string `json:"medins_setl_id"`
  16000. Naty string `json:"naty"`
  16001. OthPay float64 `json:"oth_pay"`
  16002. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16003. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  16004. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16005. PsnCashPay float64 `json:"psn_cash_pay"`
  16006. PsnCertType string `json:"psn_cert_type"`
  16007. PsnName string `json:"psn_name"`
  16008. PsnNo string `json:"psn_no"`
  16009. PsnPartAmt float64 `json:"psn_part_amt"`
  16010. PsnType string `json:"psn_type"`
  16011. SetlID string `json:"setl_id"`
  16012. SetlTime string `json:"setl_time"`
  16013. } `json:"setlinfo"`
  16014. Setldetail interface{} `json:"setldetail"`
  16015. } `json:"output"`
  16016. RefmsgTime string `json:"refmsg_time"`
  16017. RespondTime string `json:"respond_time"`
  16018. Signtype interface{} `json:"signtype"`
  16019. WarnMsg interface{} `json:"warn_msg"`
  16020. }
  16021. type GZResultSeven10265Two struct {
  16022. Cainfo string `json:"cainfo"`
  16023. ErrMsg string `json:"err_msg"`
  16024. InfRefmsgid string `json:"inf_refmsgid"`
  16025. Infcode int64 `json:"infcode"`
  16026. Output struct {
  16027. Setlinfo struct {
  16028. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16029. AcctPay float64 `json:"acct_pay"`
  16030. ActPayDedc float64 `json:"act_pay_dedc"`
  16031. Age float64 `json:"age"`
  16032. Balc float64 `json:"balc"`
  16033. Certno string `json:"certno"`
  16034. ClrOptins string `json:"clr_optins"`
  16035. ClrType string `json:"clr_type"`
  16036. ClrWay string `json:"clr_way"`
  16037. CvlservFlag string `json:"cvlserv_flag"`
  16038. CvlservPay float64 `json:"cvlserv_pay"`
  16039. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16040. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16041. Gend string `json:"gend"`
  16042. HifesPay float64 `json:"hifes_pay"`
  16043. HifmiPay float64 `json:"hifmi_pay"`
  16044. HifpPay float64 `json:"hifp_pay"`
  16045. HospPartAmt float64 `json:"hosp_part_amt"`
  16046. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16047. Insutype string `json:"insutype"`
  16048. MafPay float64 `json:"maf_pay"`
  16049. MdtrtCertType string `json:"mdtrt_cert_type"`
  16050. HifobPay float64 `json:"hifob_pay"`
  16051. MdtrtID string `json:"mdtrt_id"`
  16052. MedType string `json:"med_type"`
  16053. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16054. MedinsSetlID string `json:"medins_setl_id"`
  16055. Naty string `json:"naty"`
  16056. OthPay float64 `json:"oth_pay"`
  16057. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16058. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  16059. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16060. PsnCashPay float64 `json:"psn_cash_pay"`
  16061. PsnCertType string `json:"psn_cert_type"`
  16062. PsnName string `json:"psn_name"`
  16063. PsnNo string `json:"psn_no"`
  16064. PsnPartAmt float64 `json:"psn_part_amt"`
  16065. PsnType string `json:"psn_type"`
  16066. SetlID string `json:"setl_id"`
  16067. SetlTime string `json:"setl_time"`
  16068. } `json:"setlinfo"`
  16069. Setldetail interface{} `json:"setldetail"`
  16070. } `json:"output"`
  16071. RefmsgTime string `json:"refmsg_time"`
  16072. RespondTime string `json:"respond_time"`
  16073. Signtype interface{} `json:"signtype"`
  16074. WarnMsg interface{} `json:"warn_msg"`
  16075. }
  16076. type ResultEight struct {
  16077. Cainfo string `json:"cainfo"`
  16078. ErrMsg string `json:"err_msg"`
  16079. InfRefmsgid string `json:"inf_refmsgid"`
  16080. Infcode int64 `json:"infcode"`
  16081. Output struct {
  16082. Stmtinfo struct {
  16083. SetlOptins string `json:"setl_optins"`
  16084. StmtRslt string `json:"stmt_rslt"`
  16085. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  16086. } `json:"stmtinfo"`
  16087. } `json:"output"`
  16088. RefmsgTime string `json:"refmsg_time"`
  16089. RespondTime string `json:"respond_time"`
  16090. Signtype interface{} `json:"signtype"`
  16091. WarnMsg interface{} `json:"warn_msg"`
  16092. }
  16093. type ResultEightFor10188 struct {
  16094. Cainfo string `json:"cainfo"`
  16095. ErrMsg string `json:"err_msg"`
  16096. InfRefmsgid string `json:"inf_refmsgid"`
  16097. Infcode string `json:"infcode"`
  16098. Output struct {
  16099. Stmtinfo struct {
  16100. SetlOptins string `json:"setl_optins"`
  16101. StmtRslt string `json:"stmt_rslt"`
  16102. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  16103. } `json:"stmtinfo"`
  16104. } `json:"output"`
  16105. RefmsgTime string `json:"refmsg_time"`
  16106. RespondTime string `json:"respond_time"`
  16107. Signtype interface{} `json:"signtype"`
  16108. WarnMsg interface{} `json:"warn_msg"`
  16109. }
  16110. type ResultNine struct {
  16111. Cainfo string `json:"cainfo"`
  16112. ErrMsg string `json:"err_msg"`
  16113. InfRefmsgid string `json:"inf_refmsgid"`
  16114. Infcode int64 `json:"infcode"`
  16115. Output struct {
  16116. FileQuryNo string `json:"file_qury_no"`
  16117. } `json:"output"`
  16118. RefmsgTime string `json:"refmsg_time"`
  16119. RespondTime string `json:"respond_time"`
  16120. Signtype interface{} `json:"signtype"`
  16121. WarnMsg interface{} `json:"warn_msg"`
  16122. }
  16123. type ResultTen struct {
  16124. Cainfo string `json:"cainfo"`
  16125. ErrMsg string `json:"err_msg"`
  16126. InfRefmsgid string `json:"inf_refmsgid"`
  16127. Infcode int64 `json:"infcode"`
  16128. Output struct {
  16129. Fileinfo struct {
  16130. DldEndtime string `json:"dld_endtime"`
  16131. FileQuryNo string `json:"file_qury_no"`
  16132. Filename string `json:"filename"`
  16133. } `json:"fileinfo"`
  16134. } `json:"output"`
  16135. RefmsgTime string `json:"refmsg_time"`
  16136. RespondTime string `json:"respond_time"`
  16137. Signtype interface{} `json:"signtype"`
  16138. WarnMsg interface{} `json:"warn_msg"`
  16139. }
  16140. type Result5262 struct {
  16141. ErrMsg string `json:"err_msg"`
  16142. InfRefmsgid string `json:"inf_refmsgid"`
  16143. Infcode int64 `json:"infcode"`
  16144. Output struct {
  16145. PageInfo struct {
  16146. Size int `json:"size"`
  16147. RecordCounts int `json:"record_counts"`
  16148. } `json:"page_info"`
  16149. Idetinfo []interface{} `json:"idetinfo"`
  16150. Result []struct {
  16151. SetlID string `json:"setl_id"`
  16152. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16153. MdtrtID string `json:"mdtrt_id"`
  16154. InitSetlID string `json:"init_setl_id,omitempty"`
  16155. PsnNo string `json:"psn_no"`
  16156. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16157. PsnName string `json:"psn_name"`
  16158. PsnCertType string `json:"psn_cert_type"`
  16159. Certno string `json:"certno"`
  16160. Gend string `json:"gend,omitempty"`
  16161. Naty string `json:"naty,omitempty"`
  16162. Brdy string `json:"brdy,omitempty"`
  16163. Age float64 `json:"age,omitempty"`
  16164. Insutype string `json:"insutype,omitempty"`
  16165. PsnType string `json:"psn_type"`
  16166. CvlservFlag string `json:"cvlserv_flag"`
  16167. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16168. SpPsnType string `json:"sp_psn_type,omitempty"`
  16169. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16170. ClctGrde string `json:"clct_grde,omitempty"`
  16171. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16172. NwbFlag string `json:"nwb_flag,omitempty"`
  16173. InsuAdmdvs string `json:"insu_admdvs"`
  16174. EmpNo string `json:"emp_no,omitempty"`
  16175. EmpName string `json:"emp_name,omitempty"`
  16176. EmpType string `json:"emp_type,omitempty"`
  16177. EconType string `json:"econ_type,omitempty"`
  16178. AfilIndu string `json:"afil_indu,omitempty"`
  16179. AfilRlts string `json:"afil_rlts,omitempty"`
  16180. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16181. PayLoc string `json:"pay_loc,omitempty"`
  16182. FixmedinsCode string `json:"fixmedins_code"`
  16183. FixmedinsName string `json:"fixmedins_name"`
  16184. HospLv string `json:"hosp_lv,omitempty"`
  16185. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16186. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16187. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16188. Begndate string `json:"begndate"`
  16189. Enddate string `json:"enddate"`
  16190. SetlTime string `json:"setl_time"`
  16191. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16192. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16193. MedType string `json:"med_type"`
  16194. SetlType string `json:"setl_type,omitempty"`
  16195. ClrType string `json:"clr_type,omitempty"`
  16196. ClrWay string `json:"clr_way,omitempty"`
  16197. PsnSetlway string `json:"psn_setlway,omitempty"`
  16198. ClrOptins string `json:"clr_optins,omitempty"`
  16199. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16200. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16201. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16202. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16203. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16204. DedcStd float64 `json:"dedc_std,omitempty"`
  16205. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16206. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16207. HifpPay float64 `json:"hifp_pay,omitempty"`
  16208. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16209. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16210. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16211. HifesPay float64 `json:"hifes_pay,omitempty"`
  16212. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16213. HifobPay float64 `json:"hifob_pay,omitempty"`
  16214. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16215. MafPay float64 `json:"maf_pay,omitempty"`
  16216. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16217. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16218. PsnPay float64 `json:"psn_pay,omitempty"`
  16219. AcctPay float64 `json:"acct_pay,omitempty"`
  16220. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16221. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16222. Balc float64 `json:"balc,omitempty"`
  16223. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16224. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16225. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16226. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16227. Year string `json:"year,omitempty"`
  16228. DiseNo string `json:"dise_no,omitempty"`
  16229. DiseName string `json:"dise_name,omitempty"`
  16230. Invono string `json:"invono,omitempty"`
  16231. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16232. ValiFlag string `json:"vali_flag,omitempty"`
  16233. Memo string `json:"memo,omitempty"`
  16234. Rid string `json:"rid"`
  16235. UpdtTime string `json:"updt_time,omitempty"`
  16236. CrterID string `json:"crter_id,omitempty"`
  16237. CrterName string `json:"crter_name,omitempty"`
  16238. CrteTime string `json:"crte_time,omitempty"`
  16239. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  16240. OpterID string `json:"opter_id,omitempty"`
  16241. OpterName string `json:"opter_name,omitempty"`
  16242. OptTime string `json:"opt_time,omitempty"`
  16243. OptinsNo string `json:"optins_no,omitempty"`
  16244. PoolareaNo string `json:"poolarea_no,omitempty"`
  16245. } `json:"result"`
  16246. } `json:"output"`
  16247. RefmsgTime string `json:"refmsg_time"`
  16248. RespondTime string `json:"respond_time"`
  16249. Signtype interface{} `json:"signtype"`
  16250. WarnInfo interface{} `json:"warn_info"`
  16251. }
  16252. type Result5267 struct {
  16253. ErrMsg string `json:"err_msg"`
  16254. InfRefmsgid string `json:"inf_refmsgid"`
  16255. Infcode int64 `json:"infcode"`
  16256. Output struct {
  16257. PageInfo struct {
  16258. Size int `json:"size"`
  16259. RecordCounts int `json:"record_counts"`
  16260. } `json:"pageinfo"`
  16261. Result []struct {
  16262. SetlID string `json:"setl_id"`
  16263. ClrOptins string `json:"clr_optins"`
  16264. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16265. MdtrtID string `json:"mdtrt_id"`
  16266. InitSetlID string `json:"init_setl_id,omitempty"`
  16267. PsnNo string `json:"psn_no"`
  16268. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16269. PsnName string `json:"psn_name"`
  16270. PsnCertType string `json:"psn_cert_type"`
  16271. Certno string `json:"certno"`
  16272. Gend string `json:"gend,omitempty"`
  16273. Naty string `json:"naty,omitempty"`
  16274. Brdy string `json:"brdy,omitempty"`
  16275. Age float64 `json:"age,omitempty"`
  16276. Insutype string `json:"insutype,omitempty"`
  16277. PsnType string `json:"psn_type"`
  16278. CvlservFlag string `json:"cvlserv_flag"`
  16279. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16280. SpPsnType string `json:"sp_psn_type,omitempty"`
  16281. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16282. ClctGrde string `json:"clct_grde,omitempty"`
  16283. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16284. NwbFlag string `json:"nwb_flag,omitempty"`
  16285. InsuAdmdvs string `json:"insu_admdvs"`
  16286. EmpNo string `json:"emp_no,omitempty"`
  16287. EmpName string `json:"emp_name,omitempty"`
  16288. EmpType string `json:"emp_type,omitempty"`
  16289. EconType string `json:"econ_type,omitempty"`
  16290. AfilIndu string `json:"afil_indu,omitempty"`
  16291. AfilRlts string `json:"afil_rlts,omitempty"`
  16292. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16293. PayLoc string `json:"pay_loc,omitempty"`
  16294. FixmedinsCode string `json:"fixmedins_code"`
  16295. FixmedinsName string `json:"fixmedins_name"`
  16296. HospLv string `json:"hosp_lv,omitempty"`
  16297. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16298. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16299. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16300. Begndate string `json:"begndate,omitempty"`
  16301. Enddate string `json:"enddate,omitempty"`
  16302. SetlTime string `json:"setl_time,omitempty"`
  16303. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16304. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16305. MedType string `json:"med_type"`
  16306. SetlType string `json:"setl_type,omitempty"`
  16307. ClrType string `json:"clr_type,omitempty"`
  16308. ClrWay string `json:"clr_way,omitempty"`
  16309. PsnSetlway string `json:"psn_setlway,omitempty"`
  16310. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16311. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16312. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16313. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16314. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16315. DedcStd float64 `json:"dedc_std,omitempty"`
  16316. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16317. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16318. HifpPay float64 `json:"hifp_pay,omitempty"`
  16319. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16320. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16321. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16322. HifesPay float64 `json:"hifes_pay,omitempty"`
  16323. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16324. HifobPay float64 `json:"hifob_pay,omitempty"`
  16325. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16326. MafPay float64 `json:"maf_pay,omitempty"`
  16327. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16328. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16329. PsnPay float64 `json:"psn_pay,omitempty"`
  16330. AcctPay float64 `json:"acct_pay,omitempty"`
  16331. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16332. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16333. Balc float64 `json:"balc,omitempty"`
  16334. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16335. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16336. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16337. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16338. Year string `json:"year,omitempty"`
  16339. DiseNo string `json:"dise_no,omitempty"`
  16340. DiseName string `json:"dise_name,omitempty"`
  16341. Invono string `json:"invono,omitempty"`
  16342. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16343. Memo string `json:"memo,omitempty"`
  16344. UpdtTime string `json:"updt_time,omitempty"`
  16345. OpterID string `json:"opter_id,omitempty"`
  16346. OpterName string `json:"opter_name,omitempty"`
  16347. OptTime string `json:"opt_time,omitempty"`
  16348. OptinsNo string `json:"optins_no,omitempty"`
  16349. PoolareaNo string `json:"poolarea_no,omitempty"`
  16350. } `json:"result"`
  16351. } `json:"output"`
  16352. RefmsgTime string `json:"refmsg_time"`
  16353. RespondTime string `json:"respond_time"`
  16354. Signtype interface{} `json:"signtype"`
  16355. WarnInfo interface{} `json:"warn_info"`
  16356. }
  16357. // type Autogenerated struct {
  16358. // Output struct {
  16359. // Setlinfo struct {
  16360. // SetlTime string `json:"setl_time"`
  16361. // CvlservPay float64 `json:"cvlserv_pay"`
  16362. // Year string `json:"year"`
  16363. // MedType string `json:"med_type"`
  16364. // PsnPay float64 `json:"psn_pay"`
  16365. // OpterID string `json:"opter_id"`
  16366. // Begndate string `json:"begndate"`
  16367. // FlxempeFlag string `json:"flxempe_flag"`
  16368. // HifmiPay float64 `json:"hifmi_pay"`
  16369. // PsnNo string `json:"psn_no"`
  16370. // ActPayDedc float64 `json:"act_pay_dedc"`
  16371. // MedinsSetlID interface{} `json:"medins_setl_id"`
  16372. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16373. // ClrWay string `json:"clr_way"`
  16374. // OthPay float64 `json:"oth_pay"`
  16375. // Gend string `json:"gend"`
  16376. // MdtrtID string `json:"mdtrt_id"`
  16377. // AcctPay float64 `json:"acct_pay"`
  16378. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  16379. // Insutype string `json:"insutype"`
  16380. // Invono interface{} `json:"invono"`
  16381. // Enddate string `json:"enddate"`
  16382. // CashPayamt float64 `json:"cash_payamt"`
  16383. // PsnType string `json:"psn_type"`
  16384. // FixmedinsName string `json:"fixmedins_name"`
  16385. // HifpPay float64 `json:"hifp_pay"`
  16386. // NewFlag interface{} `json:"new_flag"`
  16387. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16388. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  16389. // PayLoc string `json:"pay_loc"`
  16390. // ClrType string `json:"clr_type"`
  16391. // RefdSetlFlag string `json:"refd_setl_flag"`
  16392. // CvlservFlag string `json:"cvlserv_flag"`
  16393. // EmpName string `json:"emp_name"`
  16394. // Brdy string `json:"brdy"`
  16395. // Naty string `json:"naty"`
  16396. // Certno string `json:"certno"`
  16397. // DiseCode string `json:"dise_code"`
  16398. // FixmedinsCode string `json:"fixmedins_code"`
  16399. // DedcHospLv string `json:"dedc_hosp_lv"`
  16400. // OpterName string `json:"opter_name"`
  16401. // Balc float64 `json:"balc"`
  16402. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16403. // PsnCertType string `json:"psn_cert_type"`
  16404. // HifobPay float64 `json:"hifob_pay"`
  16405. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  16406. // HifesPay float64 `json:"hifes_pay"`
  16407. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16408. // OptTime string `json:"opt_time"`
  16409. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16410. // SetlID string `json:"setl_id"`
  16411. // MafPay float64 `json:"maf_pay"`
  16412. // PsnName string `json:"psn_name"`
  16413. // InsuOptins interface{} `json:"insu_optins"`
  16414. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16415. // ClrOptins string `json:"clr_optins"`
  16416. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16417. // DiseName string `json:"dise_name"`
  16418. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16419. // Age float64 `json:"age"`
  16420. // DtrtCertType string `json:"dtrt_cert_type"`
  16421. // HospLv string `json:"hosp_lv"`
  16422. // } `json:"setlinfo"`
  16423. // Setldetail []struct {
  16424. // FundPayType string `json:"fund_pay_type"`
  16425. // FundPayamt float64 `json:"fund_payamt"`
  16426. // SetlProcInfo interface{} `json:"setl_proc_info"`
  16427. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  16428. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  16429. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  16430. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16431. // } `json:"setldetail"`
  16432. // } `json:"output"`
  16433. // Infcode int `json:"infcode"`
  16434. // WarnMsg interface{} `json:"warn_msg"`
  16435. // Cainfo interface{} `json:"cainfo"`
  16436. // ErrMsg interface{} `json:"err_msg"`
  16437. // RefmsgTime string `json:"refmsg_time"`
  16438. // Signtype interface{} `json:"signtype"`
  16439. // RespondTime string `json:"respond_time"`
  16440. // InfRefmsgid string `json:"inf_refmsgid"`
  16441. // }
  16442. type Result002 struct {
  16443. Cainfo interface{} `json:"cainfo"`
  16444. ErrMsg string `json:"err_msg"`
  16445. InfRefmsgid string `json:"inf_refmsgid"`
  16446. Infcode int64 `json:"infcode"`
  16447. Output struct {
  16448. RxFile string `json:"rx_file"`
  16449. SignDigest string `json:"sign_digest"`
  16450. SignCertSn string `json:"sign_cert_sn"`
  16451. SignCertDn string `json:"sign_cert_dn"`
  16452. } `json:"output"`
  16453. RefmsgTime string `json:"refmsg_time"`
  16454. RespondTime string `json:"respond_time"`
  16455. Signtype interface{} `json:"signtype"`
  16456. WarnMsg interface{} `json:"warn_msg"`
  16457. }
  16458. type Result003 struct {
  16459. Cainfo interface{} `json:"cainfo"`
  16460. ErrMsg string `json:"err_msg"`
  16461. InfRefmsgid string `json:"inf_refmsgid"`
  16462. Infcode int64 `json:"infcode"`
  16463. Output struct {
  16464. HiRxno string `json:"hi_rxno"`
  16465. RxStasCodg string `json:"rx_stas_codg"`
  16466. RxStasName string `json:"rx_stas_name"`
  16467. } `json:"output"`
  16468. RefmsgTime string `json:"refmsg_time"`
  16469. RespondTime string `json:"respond_time"`
  16470. Signtype interface{} `json:"signtype"`
  16471. WarnMsg interface{} `json:"warn_msg"`
  16472. }
  16473. type ResultEleven struct {
  16474. Cainfo string `json:"cainfo"`
  16475. ErrMsg string `json:"err_msg"`
  16476. InfRefmsgid string `json:"inf_refmsgid"`
  16477. Infcode int64 `json:"infcode"`
  16478. Output struct {
  16479. Setlinfo struct {
  16480. SetlTime string `json:"setl_time"`
  16481. CvlservPay float64 `json:"cvlserv_pay"`
  16482. Year string `json:"year"`
  16483. MedType string `json:"med_type"`
  16484. PsnPay float64 `json:"psn_pay"`
  16485. OpterID string `json:"opter_id"`
  16486. Begndate string `json:"begndate"`
  16487. FlxempeFlag string `json:"flxempe_flag"`
  16488. HifmiPay float64 `json:"hifmi_pay"`
  16489. PsnNo string `json:"psn_no"`
  16490. ActPayDedc float64 `json:"act_pay_dedc"`
  16491. MedinsSetlID interface{} `json:"medins_setl_id"`
  16492. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16493. ClrWay string `json:"clr_way"`
  16494. OthPay float64 `json:"oth_pay"`
  16495. Gend string `json:"gend"`
  16496. MdtrtID string `json:"mdtrt_id"`
  16497. AcctPay float64 `json:"acct_pay"`
  16498. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16499. Insutype string `json:"insutype"`
  16500. Invono interface{} `json:"invono"`
  16501. Enddate string `json:"enddate"`
  16502. CashPayamt float64 `json:"cash_payamt"`
  16503. PsnType string `json:"psn_type"`
  16504. FixmedinsName string `json:"fixmedins_name"`
  16505. HifpPay float64 `json:"hifp_pay"`
  16506. NewFlag interface{} `json:"new_flag"`
  16507. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16508. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16509. PayLoc string `json:"pay_loc"`
  16510. ClrType string `json:"clr_type"`
  16511. RefdSetlFlag string `json:"refd_setl_flag"`
  16512. CvlservFlag string `json:"cvlserv_flag"`
  16513. EmpName string `json:"emp_name"`
  16514. Brdy string `json:"brdy"`
  16515. Naty string `json:"naty"`
  16516. Certno string `json:"certno"`
  16517. DiseCode string `json:"dise_code"`
  16518. FixmedinsCode string `json:"fixmedins_code"`
  16519. DedcHospLv string `json:"dedc_hosp_lv"`
  16520. OpterName string `json:"opter_name"`
  16521. Balc float64 `json:"balc"`
  16522. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16523. PsnCertType string `json:"psn_cert_type"`
  16524. HifobPay float64 `json:"hifob_pay"`
  16525. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16526. HifesPay float64 `json:"hifes_pay"`
  16527. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16528. OptTime string `json:"opt_time"`
  16529. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16530. SetlID string `json:"setl_id"`
  16531. MafPay float64 `json:"maf_pay"`
  16532. PsnName string `json:"psn_name"`
  16533. InsuOptins interface{} `json:"insu_optins"`
  16534. PrefFundPay interface{} `json:"pref_fund_pay"`
  16535. ClrOptins string `json:"clr_optins"`
  16536. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16537. DiseName string `json:"dise_name"`
  16538. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16539. Age float64 `json:"age"`
  16540. DtrtCertType string `json:"dtrt_cert_type"`
  16541. HospLv string `json:"hosp_lv"`
  16542. PsnCashPay float64 `json:"psn_cash_pay"`
  16543. } `json:"setlinfo"`
  16544. } `json:"output"`
  16545. RefmsgTime string `json:"refmsg_time"`
  16546. RespondTime string `json:"respond_time"`
  16547. Signtype interface{} `json:"signtype"`
  16548. WarnMsg interface{} `json:"warn_msg"`
  16549. }
  16550. type ResultElevenah struct {
  16551. Cainfo string `json:"cainfo"`
  16552. ErrMsg string `json:"err_msg"`
  16553. InfRefmsgid string `json:"inf_refmsgid"`
  16554. Infcode int64 `json:"infcode"`
  16555. Output struct {
  16556. Setlinfo struct {
  16557. SetlTime int64 `json:"setl_time"`
  16558. CvlservPay float64 `json:"cvlserv_pay"`
  16559. Year string `json:"year"`
  16560. MedType string `json:"med_type"`
  16561. PsnPay float64 `json:"psn_pay"`
  16562. OpterID string `json:"opter_id"`
  16563. Begndate int64 `json:"begndate"`
  16564. FlxempeFlag string `json:"flxempe_flag"`
  16565. HifmiPay float64 `json:"hifmi_pay"`
  16566. PsnNo string `json:"psn_no"`
  16567. ActPayDedc float64 `json:"act_pay_dedc"`
  16568. MedinsSetlID interface{} `json:"medins_setl_id"`
  16569. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16570. ClrWay string `json:"clr_way"`
  16571. OthPay float64 `json:"oth_pay"`
  16572. Gend string `json:"gend"`
  16573. MdtrtID string `json:"mdtrt_id"`
  16574. AcctPay float64 `json:"acct_pay"`
  16575. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16576. Insutype string `json:"insutype"`
  16577. Invono interface{} `json:"invono"`
  16578. Enddate int64 `json:"enddate"`
  16579. CashPayamt float64 `json:"cash_payamt"`
  16580. PsnType string `json:"psn_type"`
  16581. FixmedinsName string `json:"fixmedins_name"`
  16582. HifpPay float64 `json:"hifp_pay"`
  16583. NewFlag interface{} `json:"new_flag"`
  16584. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16585. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16586. PayLoc string `json:"pay_loc"`
  16587. ClrType string `json:"clr_type"`
  16588. RefdSetlFlag string `json:"refd_setl_flag"`
  16589. CvlservFlag string `json:"cvlserv_flag"`
  16590. EmpName string `json:"emp_name"`
  16591. Brdy int64 `json:"brdy"`
  16592. Naty string `json:"naty"`
  16593. Certno string `json:"certno"`
  16594. DiseCode string `json:"dise_code"`
  16595. FixmedinsCode string `json:"fixmedins_code"`
  16596. DedcHospLv string `json:"dedc_hosp_lv"`
  16597. OpterName string `json:"opter_name"`
  16598. Balc float64 `json:"balc"`
  16599. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16600. PsnCertType string `json:"psn_cert_type"`
  16601. HifobPay float64 `json:"hifob_pay"`
  16602. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16603. HifesPay float64 `json:"hifes_pay"`
  16604. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16605. OptTime int64 `json:"opt_time"`
  16606. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16607. SetlID string `json:"setl_id"`
  16608. MafPay float64 `json:"maf_pay"`
  16609. PsnName string `json:"psn_name"`
  16610. InsuOptins interface{} `json:"insu_optins"`
  16611. PrefFundPay interface{} `json:"pref_fund_pay"`
  16612. ClrOptins string `json:"clr_optins"`
  16613. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16614. DiseName string `json:"dise_name"`
  16615. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16616. Age float64 `json:"age"`
  16617. DtrtCertType string `json:"dtrt_cert_type"`
  16618. HospLv string `json:"hosp_lv"`
  16619. PsnCashPay float64 `json:"psn_cash_pay"`
  16620. } `json:"setlinfo"`
  16621. } `json:"output"`
  16622. RefmsgTime string `json:"refmsg_time"`
  16623. RespondTime string `json:"respond_time"`
  16624. Signtype interface{} `json:"signtype"`
  16625. WarnMsg interface{} `json:"warn_msg"`
  16626. }
  16627. type ResultEleven10265 struct {
  16628. Cainfo string `json:"cainfo"`
  16629. ErrMsg string `json:"err_msg"`
  16630. InfRefmsgid string `json:"inf_refmsgid"`
  16631. Infcode string `json:"infcode"`
  16632. Output struct {
  16633. Setlinfo struct {
  16634. SetlTime string `json:"setl_time"`
  16635. CvlservPay float64 `json:"cvlserv_pay"`
  16636. Year string `json:"year"`
  16637. MedType string `json:"med_type"`
  16638. PsnPay float64 `json:"psn_pay"`
  16639. OpterID string `json:"opter_id"`
  16640. Begndate string `json:"begndate"`
  16641. FlxempeFlag string `json:"flxempe_flag"`
  16642. HifmiPay float64 `json:"hifmi_pay"`
  16643. PsnNo string `json:"psn_no"`
  16644. ActPayDedc float64 `json:"act_pay_dedc"`
  16645. MedinsSetlID interface{} `json:"medins_setl_id"`
  16646. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16647. ClrWay string `json:"clr_way"`
  16648. OthPay float64 `json:"oth_pay"`
  16649. Gend string `json:"gend"`
  16650. MdtrtID string `json:"mdtrt_id"`
  16651. AcctPay float64 `json:"acct_pay"`
  16652. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16653. Insutype string `json:"insutype"`
  16654. Invono interface{} `json:"invono"`
  16655. Enddate string `json:"enddate"`
  16656. CashPayamt float64 `json:"cash_payamt"`
  16657. PsnType string `json:"psn_type"`
  16658. FixmedinsName string `json:"fixmedins_name"`
  16659. HifpPay float64 `json:"hifp_pay"`
  16660. NewFlag interface{} `json:"new_flag"`
  16661. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16662. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16663. PayLoc string `json:"pay_loc"`
  16664. ClrType string `json:"clr_type"`
  16665. RefdSetlFlag string `json:"refd_setl_flag"`
  16666. CvlservFlag string `json:"cvlserv_flag"`
  16667. EmpName string `json:"emp_name"`
  16668. Brdy string `json:"brdy"`
  16669. Naty string `json:"naty"`
  16670. Certno string `json:"certno"`
  16671. DiseCode string `json:"dise_code"`
  16672. FixmedinsCode string `json:"fixmedins_code"`
  16673. DedcHospLv string `json:"dedc_hosp_lv"`
  16674. OpterName string `json:"opter_name"`
  16675. Balc float64 `json:"balc"`
  16676. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16677. PsnCertType string `json:"psn_cert_type"`
  16678. HifobPay float64 `json:"hifob_pay"`
  16679. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16680. HifesPay float64 `json:"hifes_pay"`
  16681. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16682. OptTime string `json:"opt_time"`
  16683. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16684. SetlID string `json:"setl_id"`
  16685. MafPay float64 `json:"maf_pay"`
  16686. PsnName string `json:"psn_name"`
  16687. InsuOptins interface{} `json:"insu_optins"`
  16688. PrefFundPay interface{} `json:"pref_fund_pay"`
  16689. ClrOptins string `json:"clr_optins"`
  16690. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16691. DiseName string `json:"dise_name"`
  16692. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16693. Age float64 `json:"age"`
  16694. DtrtCertType string `json:"dtrt_cert_type"`
  16695. HospLv string `json:"hosp_lv"`
  16696. PsnCashPay float64 `json:"psn_cash_pay"`
  16697. } `json:"setlinfo"`
  16698. } `json:"output"`
  16699. RefmsgTime string `json:"refmsg_time"`
  16700. RespondTime string `json:"respond_time"`
  16701. Signtype interface{} `json:"signtype"`
  16702. WarnMsg interface{} `json:"warn_msg"`
  16703. }
  16704. type ResultTwelve struct {
  16705. Cainfo string `json:"cainfo"`
  16706. ErrMsg string `json:"err_msg"`
  16707. InfRefmsgid string `json:"inf_refmsgid"`
  16708. Infcode int64 `json:"infcode"`
  16709. Output struct {
  16710. MdtrtId string `json:"mdtrt_id"`
  16711. ChrgBchno string `json:"chrg_bchno"`
  16712. PsnNo string `json:"psn_no"`
  16713. } `json:"output"`
  16714. RefmsgTime string `json:"refmsg_time"`
  16715. RespondTime string `json:"respond_time"`
  16716. Signtype interface{} `json:"signtype"`
  16717. WarnMsg interface{} `json:"warn_msg"`
  16718. }
  16719. type ResultThirteen struct {
  16720. ErrMsg string `json:"err_msg"`
  16721. InfRefmsgid string `json:"inf_refmsgid"`
  16722. Infcode int64 `json:"infcode"`
  16723. Output struct {
  16724. Result struct {
  16725. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16726. } `json:"result"`
  16727. } `json:"output"`
  16728. RefmsgTime string `json:"refmsg_time"`
  16729. RespondTime string `json:"respond_time"`
  16730. Signtype interface{} `json:"signtype"`
  16731. WarnInfo interface{} `json:"warn_info"`
  16732. }
  16733. type ResultThirteen10265 struct {
  16734. ErrMsg string `json:"err_msg"`
  16735. InfRefmsgid string `json:"inf_refmsgid"`
  16736. Infcode string `json:"infcode"`
  16737. Output struct {
  16738. Result struct {
  16739. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16740. } `json:"result"`
  16741. } `json:"output"`
  16742. RefmsgTime string `json:"refmsg_time"`
  16743. RespondTime string `json:"respond_time"`
  16744. Signtype interface{} `json:"signtype"`
  16745. WarnInfo interface{} `json:"warn_info"`
  16746. }
  16747. type ResultFourteen struct {
  16748. ErrMsg string `json:"err_msg"`
  16749. InfRefmsgid string `json:"inf_refmsgid"`
  16750. Infcode int64 `json:"infcode"`
  16751. Output struct {
  16752. } `json:"output"`
  16753. RefmsgTime string `json:"refmsg_time"`
  16754. RespondTime string `json:"respond_time"`
  16755. Signtype interface{} `json:"signtype"`
  16756. WarnInfo interface{} `json:"warn_info"`
  16757. }
  16758. type ResultCFYLJG001 struct {
  16759. ErrMsg string `json:"err_msg"`
  16760. InfRefmsgid string `json:"inf_refmsgid"`
  16761. Infcode int64 `json:"infcode"`
  16762. Output struct {
  16763. RxTraceCode string `json:"rx_trace_code"`
  16764. HiRxno string `json:"hi_rxno"`
  16765. } `json:"output"`
  16766. RefmsgTime string `json:"refmsg_time"`
  16767. RespondTime string `json:"respond_time"`
  16768. Signtype interface{} `json:"signtype"`
  16769. WarnInfo interface{} `json:"warn_info"`
  16770. }
  16771. type ResultCFYLJG007 struct {
  16772. ErrMsg string `json:"err_msg"`
  16773. InfRefmsgid string `json:"inf_refmsgid"`
  16774. Infcode int64 `json:"infcode"`
  16775. Output struct {
  16776. HiRxno string `json:"hi_rxno"`
  16777. RxStasName string `json:"rx_stas_name"`
  16778. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16779. Seltdelts []interface{} `json:"seltdelts"`
  16780. RxUsedStasName string `json:"rx_used_stas_name"`
  16781. RxStasCodg string `json:"rx_stas_codg"`
  16782. } `json:"output"`
  16783. RefmsgTime string `json:"refmsg_time"`
  16784. RespondTime string `json:"respond_time"`
  16785. Signtype interface{} `json:"signtype"`
  16786. WarnInfo interface{} `json:"warn_info"`
  16787. }
  16788. type ResultCFYLJG002 struct {
  16789. ErrMsg string `json:"err_msg"`
  16790. InfRefmsgid string `json:"inf_refmsgid"`
  16791. Infcode int64 `json:"infcode"`
  16792. Output struct {
  16793. RxFile string `json:"rx_file"`
  16794. SignDigest string `json:"sign_digest"`
  16795. SignCertSn string `json:"sign_cert_sn"`
  16796. SignCertDn string `json:"sign_cert_dn"`
  16797. } `json:"output"`
  16798. RefmsgTime string `json:"refmsg_time"`
  16799. RespondTime string `json:"respond_time"`
  16800. Signtype interface{} `json:"signtype"`
  16801. WarnInfo interface{} `json:"warn_info"`
  16802. }
  16803. type ResultCFYLJG003 struct {
  16804. ErrMsg string `json:"err_msg"`
  16805. InfRefmsgid string `json:"inf_refmsgid"`
  16806. Infcode int64 `json:"infcode"`
  16807. Output struct {
  16808. HiRxno string `json:"hi_rxno"`
  16809. RxStasCodg string `json:"rx_stas_codg"`
  16810. RxStasName string `json:"rx_stas_name"`
  16811. } `json:"output"`
  16812. RefmsgTime string `json:"refmsg_time"`
  16813. RespondTime string `json:"respond_time"`
  16814. Signtype interface{} `json:"signtype"`
  16815. WarnInfo interface{} `json:"warn_info"`
  16816. }
  16817. type ResultCFYLJG004 struct {
  16818. ErrMsg string `json:"err_msg"`
  16819. InfRefmsgid string `json:"inf_refmsgid"`
  16820. Infcode int64 `json:"infcode"`
  16821. Output struct {
  16822. HiRxno string `json:"hi_rxno"`
  16823. RxStasCodg string `json:"rx_stas_codg"`
  16824. RxStasName string `json:"rx_stas_name"`
  16825. } `json:"output"`
  16826. RefmsgTime string `json:"refmsg_time"`
  16827. RespondTime string `json:"respond_time"`
  16828. Signtype interface{} `json:"signtype"`
  16829. WarnInfo interface{} `json:"warn_info"`
  16830. }
  16831. type ResultCFYLJG008 struct {
  16832. ErrMsg string `json:"err_msg"`
  16833. InfRefmsgid string `json:"inf_refmsgid"`
  16834. Infcode int64 `json:"infcode"`
  16835. Output struct {
  16836. PoolareaNo string `json:"poolareaNo"`
  16837. AdmdvsName string `json:"admdvsName"`
  16838. Count string `json:"count"`
  16839. } `json:"output"`
  16840. RefmsgTime string `json:"refmsg_time"`
  16841. RespondTime string `json:"respond_time"`
  16842. Signtype interface{} `json:"signtype"`
  16843. WarnInfo interface{} `json:"warn_info"`
  16844. }
  16845. type ResultCFYLJG005 struct {
  16846. ErrMsg string `json:"err_msg"`
  16847. InfRefmsgid string `json:"inf_refmsgid"`
  16848. Infcode int64 `json:"infcode"`
  16849. Output struct {
  16850. HiRxNo string `json:"hi_rxno"`
  16851. FixMedinsCode string `json:"fixmedins_code"`
  16852. FixMedinsName string `json:"fixmedins_name"`
  16853. RxStasCodg string `json:"rx_stas_codg"`
  16854. RxStasName string `json:"rx_stas_name"`
  16855. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16856. RxUserdStasName string `json:"rx_userd_stas_name"`
  16857. PrscTime string `json:"prsc_time"`
  16858. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16859. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16860. RxUsedWayName string `json:"rx_used_way_name"`
  16861. RxFrquCodg string `json:"rx_frqu_codg"`
  16862. RxFrquName string `json:"rx_frqu_name"`
  16863. RxDosunt string `json:"rx_dosunt"`
  16864. RxDoscnt float64 `json:"rx_doscnt"`
  16865. RxDrordDscr string `json:"rx_drord_dscr"`
  16866. ValiDays int64 `json:"vali_days"`
  16867. ValiEndTime string `json:"vali_end_time"`
  16868. ReptFlag string `json:"rept_flag"`
  16869. MaxReptCnt int64 `json:"max_rept_cnt"`
  16870. ReptdCnt int64 `json:"reptd_cnt"`
  16871. MinInrvDays int64 `json:"min_inrv_days"`
  16872. RxTypeCode string `json:"rx_type_code"`
  16873. RxTypeName string `json:"rx_type_name"`
  16874. LongRxFlag string `json:"long_rx_flag"`
  16875. RxDetlList []struct {
  16876. MedListCodg string `json:"med_list_codg"`
  16877. MedinsListCodg string `json:"medins_list_codg"`
  16878. HospPrepFlag string `json:"hosp_prep_flag"`
  16879. RxItemTypeCode string `json:"rx_item_type_code"`
  16880. RxItemTypeName string `json:"rx_item_type_name"`
  16881. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16882. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16883. TcmHerbFoote string `json:"tcmherb_foote"`
  16884. MednTypeCode string `json:"medn_type_code"`
  16885. MednTypeName string `json:"medn_type_name"`
  16886. MainMedcFlag string `json:"main_medc_flag"`
  16887. UrgtFlag string `json:"urgt_flag"`
  16888. BasMednFlag string `json:"bas_medn_flag"`
  16889. ImpDrugFlag string `json:"imp_drug_flag"`
  16890. ProdBarc string `json:"prod_barc"`
  16891. DrugProdname string `json:"drug_prodname"`
  16892. GennameCodg string `json:"genname_codg"`
  16893. DrugGenname string `json:"drug_genname"`
  16894. DrugDosform string `json:"drug_dosform"`
  16895. DrugSpec string `json:"drug_spec"`
  16896. PrdrName string `json:"prdr_name"`
  16897. MedcWayCodg string `json:"medc_way_codg"`
  16898. MedcWayDscr string `json:"medc_way_dscr"`
  16899. MedcBegntime string `json:"medc_begntime"`
  16900. MedcEndtime string `json:"medc_endtime"`
  16901. MedcDays float64 `json:"medc_days"`
  16902. DrugPric float64 `json:"drug_pric"`
  16903. DrugSumamt float64 `json:"drug_sumamt"`
  16904. DrugCnt float64 `json:"drug_cnt"`
  16905. DrugDosunt string `json:"drug_dosunt"`
  16906. SinDoscnt float64 `json:"sin_doscnt"`
  16907. SinDosunt string `json:"sin_dosunt"`
  16908. UsedFrquCodg string `json:"used_frqu_codg"`
  16909. UsedFrquName string `json:"used_frqu_name"`
  16910. DrugTotlcnt string `json:"drug_totlcnt"`
  16911. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16912. DiseCodg string `json:"dise_codg"`
  16913. HospApprFlag string `json:"hosp_appr_flag"`
  16914. } `json:"rx_detl_list"`
  16915. RxOtpinfo struct {
  16916. MedType string `json:"med_type"`
  16917. IptOtpNo string `json:"ipt_otp_no"`
  16918. OtpIptFlag string `json:"otp_ipt_flag"`
  16919. PatnName string `json:"patn_name"`
  16920. PatnAge float64 `json:"patn_age"`
  16921. PatnHgt float64 `json:"patn_hgt"`
  16922. PatnWt float64 `json:"patn_wt"`
  16923. Gend string `json:"gend"`
  16924. GesoVal float64 `json:"geso_val"`
  16925. NwbFlag string `json:"nwb_flag"`
  16926. NwbAge string `json:"nwb_age"`
  16927. SuckPrdFlag string `json:"suck_prd_flag"`
  16928. AlgsHis string `json:"algs_his"`
  16929. Insutype string `json:"insutype"`
  16930. PrscDeptName string `json:"prsc_dept_name"`
  16931. PrscDrName string `json:"prsc_dr_name"`
  16932. PharName string `json:"phar_name"`
  16933. PharChkTime string `json:"phar_chk_time"`
  16934. MdtrtTime string `json:"mdtrt_time"`
  16935. DiseCodg string `json:"dise_codg"`
  16936. DiseName string `json:"dise_name"`
  16937. SpDiseFlag string `json:"sp_dise_flag"`
  16938. MaindiagCode string `json:"maindiag_code"`
  16939. MaindiagName string `json:"maindiag_name"`
  16940. DiseCondDscr string `json:"dise_cond_dscr"`
  16941. FstdiagFlag string `json:"fstdiag_flag"`
  16942. } `json:"rx_otpinfo"`
  16943. RxDiseList []struct {
  16944. DiagType string `json:"diag_type"`
  16945. MaindiagFlag string `json:"maindiag_flag"`
  16946. DiagSrtNo string `json:"diag_srt_no"`
  16947. DiagCode string `json:"diag_code"`
  16948. DiagName string `json:"diag_name"`
  16949. DiagDept string `json:"diag_dept"`
  16950. DiagDrNo string `json:"diag_dr_no"`
  16951. DiagDrName string `json:"diag_dr_name"`
  16952. DiagTime string `json:"diag_time"`
  16953. TcmDiseCode string `json:"tcm_dise_code"`
  16954. TcmDiseName string `json:"tcm_dise_name"`
  16955. TcmSympCode string `json:"tcmsymp_code"`
  16956. TcmSymp string `json:"tcmsymp"`
  16957. } `json:"rx_dise_list"`
  16958. } `json:"output"`
  16959. RefmsgTime string `json:"refmsg_time"`
  16960. RespondTime string `json:"respond_time"`
  16961. Signtype interface{} `json:"signtype"`
  16962. WarnInfo interface{} `json:"warn_info"`
  16963. }
  16964. type ResultCFYLJG006 struct {
  16965. ErrMsg string `json:"err_msg"`
  16966. InfRefmsgid string `json:"inf_refmsgid"`
  16967. Infcode int64 `json:"infcode"`
  16968. Output struct {
  16969. HiRxNo string `json:"hi_rxno"`
  16970. PharCode string `json:"phar_code"`
  16971. PharName string `json:"phar_name"`
  16972. RxChkOpnn string `json:"rx_chk_opnn"`
  16973. RxChkTime string `json:"rx_chk_time"`
  16974. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16975. RxChkStasName string `json:"rx_chk_stas_name"`
  16976. RxStasCodg string `json:"rx_stas_codg"`
  16977. RxStasName string `json:"rx_stas_name"`
  16978. } `json:"output"`
  16979. RefmsgTime string `json:"refmsg_time"`
  16980. RespondTime string `json:"respond_time"`
  16981. Signtype interface{} `json:"signtype"`
  16982. WarnInfo interface{} `json:"warn_info"`
  16983. }
  16984. type ResultFourteen10265 struct {
  16985. ErrMsg string `json:"err_msg"`
  16986. InfRefmsgid string `json:"inf_refmsgid"`
  16987. Infcode string `json:"infcode"`
  16988. Output struct {
  16989. } `json:"output"`
  16990. RefmsgTime string `json:"refmsg_time"`
  16991. RespondTime string `json:"respond_time"`
  16992. Signtype interface{} `json:"signtype"`
  16993. WarnInfo interface{} `json:"warn_info"`
  16994. }
  16995. type ResultSixteen struct {
  16996. Cainfo string `json:"cainfo"`
  16997. ErrMsg string `json:"err_msg"`
  16998. InfRefmsgid string `json:"inf_refmsgid"`
  16999. Infcode int64 `json:"infcode"`
  17000. Output struct {
  17001. Setlinfo struct {
  17002. MdtrtID string `json:"mdtrt_id"`
  17003. SetlID string `json:"setl_id"`
  17004. ClrOptins string `json:"clr_optins"`
  17005. SetlTime string `json:"setl_time"`
  17006. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17007. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17008. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17009. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17010. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17011. ActPayDedc float64 `json:"act_pay_dedc"`
  17012. HifpPay float64 `json:"hifp_pay"`
  17013. PoolPropSe float64 `json:"pool_prop_selfpay"`
  17014. Lfpay float64 `json:"selfpay"`
  17015. CvlservPay float64 `json:"cvlserv_pay"`
  17016. HifesPay float64 `json:"hifes_pay"`
  17017. HifmiPay float64 `json:"hifmi_pay"`
  17018. HifobPay float64 `json:"hifob_pay"`
  17019. MafPay float64 `json:"maf_pay"`
  17020. OthPay float64 `json:"oth_pay"`
  17021. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17022. PsnPartAmt float64 `json:"psn_part_amt"`
  17023. AcctPay float64 `json:"acct_pay"`
  17024. Balc float64 `json:"balc"`
  17025. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  17026. HospPartAmt float64 `json:"hosp_part_amt"`
  17027. MedinsSetlID string `json:"medins_setl_id"`
  17028. PdnCashPay string `json:"pdn_cash_pay"`
  17029. } `json:"setlinfo"`
  17030. } `json:"output"`
  17031. RefmsgTime string `json:"refmsg_time"`
  17032. RespondTime string `json:"respond_time"`
  17033. Signtype interface{} `json:"signtype"`
  17034. WarnMsg interface{} `json:"warn_msg"`
  17035. }
  17036. type ResultSixteen10265 struct {
  17037. Cainfo string `json:"cainfo"`
  17038. ErrMsg string `json:"err_msg"`
  17039. InfRefmsgid string `json:"inf_refmsgid"`
  17040. Infcode string `json:"infcode"`
  17041. Output struct {
  17042. Setlinfo struct {
  17043. MdtrtID string `json:"mdtrt_id"`
  17044. SetlID string `json:"setl_id"`
  17045. ClrOptins string `json:"clr_optins"`
  17046. SetlTime string `json:"setl_time"`
  17047. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17048. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17049. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17050. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17051. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17052. ActPayDedc float64 `json:"act_pay_dedc"`
  17053. HifpPay float64 `json:"hifp_pay"`
  17054. PoolPropSe float64 `json:"pool_prop_selfpay"`
  17055. Lfpay float64 `json:"selfpay"`
  17056. CvlservPay float64 `json:"cvlserv_pay"`
  17057. HifesPay float64 `json:"hifes_pay"`
  17058. HifmiPay float64 `json:"hifmi_pay"`
  17059. HifobPay float64 `json:"hifob_pay"`
  17060. MafPay float64 `json:"maf_pay"`
  17061. OthPay float64 `json:"oth_pay"`
  17062. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17063. PsnPartAmt float64 `json:"psn_part_amt"`
  17064. AcctPay float64 `json:"acct_pay"`
  17065. Balc float64 `json:"balc"`
  17066. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  17067. HospPartAmt float64 `json:"hosp_part_amt"`
  17068. MedinsSetlID string `json:"medins_setl_id"`
  17069. PdnCashPay string `json:"pdn_cash_pay"`
  17070. } `json:"setlinfo"`
  17071. } `json:"output"`
  17072. RefmsgTime string `json:"refmsg_time"`
  17073. RespondTime string `json:"respond_time"`
  17074. Signtype interface{} `json:"signtype"`
  17075. WarnMsg interface{} `json:"warn_msg"`
  17076. }
  17077. type ResultSixteen10265Two struct {
  17078. Cainfo string `json:"cainfo"`
  17079. ErrMsg string `json:"err_msg"`
  17080. InfRefmsgid string `json:"inf_refmsgid"`
  17081. Infcode string `json:"infcode"`
  17082. Output struct {
  17083. Setlinfo interface{} `json:"setlinfo"`
  17084. } `json:"output"`
  17085. RefmsgTime string `json:"refmsg_time"`
  17086. RespondTime string `json:"respond_time"`
  17087. Signtype interface{} `json:"signtype"`
  17088. WarnMsg interface{} `json:"warn_msg"`
  17089. }
  17090. type ResultgzSixteen10265Two struct {
  17091. Cainfo string `json:"cainfo"`
  17092. ErrMsg string `json:"err_msg"`
  17093. InfRefmsgid string `json:"inf_refmsgid"`
  17094. Infcode int64 `json:"infcode"`
  17095. Output struct {
  17096. Setlinfo interface{} `json:"setlinfo"`
  17097. } `json:"output"`
  17098. RefmsgTime string `json:"refmsg_time"`
  17099. RespondTime string `json:"respond_time"`
  17100. Signtype interface{} `json:"signtype"`
  17101. WarnMsg interface{} `json:"warn_msg"`
  17102. }
  17103. type ResultSeventeen struct {
  17104. ErrMsg string `json:"err_msg"`
  17105. InfRefmsgid string `json:"inf_refmsgid"`
  17106. Infcode int64 `json:"infcode"`
  17107. Output struct {
  17108. SetlListId string `json:"setl_list_id"`
  17109. } `json:"output"`
  17110. RefmsgTime string `json:"refmsg_time"`
  17111. RespondTime string `json:"respond_time"`
  17112. Signtype string `json:"signtype"`
  17113. WarnInfo string `json:"warn_info"`
  17114. }
  17115. type ResultSeventeenOther struct {
  17116. ErrMsg string `json:"err_msg"`
  17117. InfRefmsgid string `json:"inf_refmsgid"`
  17118. Infcode string `json:"infcode"`
  17119. Output struct {
  17120. SetlListId string `json:"setl_list_id"`
  17121. } `json:"output"`
  17122. RefmsgTime string `json:"refmsg_time"`
  17123. RespondTime string `json:"respond_time"`
  17124. Signtype string `json:"signtype"`
  17125. WarnInfo string `json:"warn_info"`
  17126. }
  17127. type Result90991 struct {
  17128. ErrMsg string `json:"err_msg"`
  17129. InfRefmsgid string `json:"inf_refmsgid"`
  17130. Infcode int64 `json:"infcode"`
  17131. Output struct {
  17132. Result struct {
  17133. PsnNo string `json:"psn_no"`
  17134. CardStat string `json:"card_stat"`
  17135. Certno string `json:"certno"`
  17136. PsnName string `json:"psn_name"`
  17137. CheckStat string `json:"check_stat"`
  17138. SscnoCheckStat string `json:"sscno_check_stat"`
  17139. } `json:"result"`
  17140. } `json:"output"`
  17141. RefmsgTime string `json:"refmsg_time"`
  17142. RespondTime string `json:"respond_time"`
  17143. Signtype interface{} `json:"signtype"`
  17144. WarnInfo interface{} `json:"warn_info"`
  17145. }
  17146. type Result90100 struct {
  17147. ErrMsg string `json:"err_msg"`
  17148. InfRefmsgid string `json:"inf_refmsgid"`
  17149. Infcode int64 `json:"infcode"`
  17150. Output struct {
  17151. PoolareaNo string `json:"poolarea_no"`
  17152. PoolareaNoName string `json:"poolarea_no_name"`
  17153. Insutype string `json:"insutype"`
  17154. InsutypeName string `json:"insutype_name"`
  17155. ClctType string `json:"clct_type"`
  17156. ClctTypeName string `json:"clct_type_name"`
  17157. ClctFlag string `json:"clct_flag"`
  17158. ClctFlagName string `json:"clct_flag_name"`
  17159. AccrymBegn string `json:"accrym_begn"`
  17160. AccrymEnd string `json:"accrym_end"`
  17161. ClctTime string `json:"clct_time"`
  17162. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  17163. } `json:"output"`
  17164. RefmsgTime string `json:"refmsg_time"`
  17165. RespondTime string `json:"respond_time"`
  17166. Signtype interface{} `json:"signtype"`
  17167. WarnInfo interface{} `json:"warn_info"`
  17168. }
  17169. type Custom struct {
  17170. DetItemFeeSumamt string
  17171. Cut string
  17172. FeedetlSn string
  17173. Price string
  17174. MedListCodg string
  17175. Type int64
  17176. AdviceId int64
  17177. ProjectId int64
  17178. ItemId int64
  17179. }
  17180. type Result5301 struct {
  17181. ErrMsg string `json:"err_msg"`
  17182. InfRefmsgid string `json:"inf_refmsgid"`
  17183. Infcode int64 `json:"infcode"`
  17184. Output struct {
  17185. Result []struct {
  17186. OpspDiseCode string `json:"opsp_dise_code"`
  17187. OpspDiseName string `json:"opsp_dise_name"`
  17188. Begndate string `json:"begndate"`
  17189. Enddate string `json:"enddate"`
  17190. } `json:"feedetail"`
  17191. } `json:"output"`
  17192. RefmsgTime string `json:"refmsg_time"`
  17193. RespondTime string `json:"respond_time"`
  17194. Signtype interface{} `json:"signtype"`
  17195. WarnInfo interface{} `json:"warn_info"`
  17196. }
  17197. type Result5301For10265 struct {
  17198. ErrMsg string `json:"err_msg"`
  17199. InfRefmsgid string `json:"inf_refmsgid"`
  17200. Infcode string `json:"infcode"`
  17201. Output struct {
  17202. Result []struct {
  17203. OpspDiseCode string `json:"opsp_dise_code"`
  17204. OpspDiseName string `json:"opsp_dise_name"`
  17205. Begndate string `json:"begndate"`
  17206. Enddate string `json:"enddate"`
  17207. } `json:"feedetail"`
  17208. } `json:"output"`
  17209. RefmsgTime string `json:"refmsg_time"`
  17210. RespondTime string `json:"respond_time"`
  17211. Signtype interface{} `json:"signtype"`
  17212. WarnInfo interface{} `json:"warn_info"`
  17213. }
  17214. //获取个人信息----挂号-----上传就诊信息
  17215. func (c *HisApiController) GetRegisterInfo() {
  17216. id, _ := c.GetInt64("id")
  17217. record_time := c.GetString("record_time")
  17218. settlementValue, _ := c.GetInt64("settlement_value")
  17219. medical_insurance_card := c.GetString("medical_insurance_card")
  17220. name := c.GetString("name")
  17221. id_card_type, _ := c.GetInt64("id_card_type")
  17222. certificates, _ := c.GetInt64("certificates")
  17223. medical_care, _ := c.GetInt64("medical_care")
  17224. birthday := c.GetString("birthday")
  17225. id_card := c.GetString("id_card")
  17226. register_type, _ := c.GetInt64("register")
  17227. doctor, _ := c.GetInt64("doctor")
  17228. department, _ := c.GetInt64("department")
  17229. gender, _ := c.GetInt64("sex")
  17230. registration_fee, _ := c.GetFloat("registration_fee")
  17231. medical_expenses, _ := c.GetFloat("medical_expenses")
  17232. social_type, _ := c.GetInt64("social_type")
  17233. admin_user_id, _ := c.GetInt64("admin_user_id")
  17234. insuplc_admdvs := c.GetString("insuplc_admdvs")
  17235. mdtrt_type := c.GetString("mdtrt_type")
  17236. if id_card_type == 5 {
  17237. id_card_type = 4
  17238. }
  17239. timeLayout := "2006-01-02"
  17240. loc, _ := time.LoadLocation("Local")
  17241. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  17242. birthUnix := birthdays.Unix()
  17243. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17244. if err != nil {
  17245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17246. return
  17247. }
  17248. recordDateTime := theTime.Unix()
  17249. adminInfo := c.GetAdminUserInfo()
  17250. var patient service.Patients
  17251. if id == 0 {
  17252. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  17253. } else {
  17254. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  17255. }
  17256. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17257. if patientPrescription.ID == 0 {
  17258. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17259. }
  17260. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17261. if patient.ID == 0 {
  17262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17263. return
  17264. }
  17265. if len(patient.IdCardNo) == 0 {
  17266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  17267. return
  17268. }
  17269. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  17270. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  17271. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  17272. //就诊结算未完成,不能进行二次挂号
  17273. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  17274. //if len(his) >= 1 {
  17275. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  17276. // if len(his) >= 1 && order.ID == 0 {
  17277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  17278. // return
  17279. // }
  17280. //}
  17281. //var register_log string
  17282. if config.IsOpen == 1 {
  17283. var res ResultTwo
  17284. var res10265 ResultTwo10265
  17285. var PsnNo string
  17286. var PsnCertType string
  17287. var Certno string
  17288. var PsnName string
  17289. var Gend string
  17290. var Naty string
  17291. var Brdy string
  17292. var Age float64
  17293. var infoStr string
  17294. var idetinfoStr string
  17295. var infocode int64
  17296. var verify_number string
  17297. fmt.Println(verify_number)
  17298. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  17299. psn_info, _ := service.GetPsnByPatientId(id)
  17300. PsnNo = psn_info.PsnNo
  17301. PsnCertType = psn_info.PsnCertType
  17302. Certno = psn_info.Certno
  17303. PsnName = psn_info.PsnName
  17304. Gend = psn_info.Gend
  17305. Naty = psn_info.Naty
  17306. Brdy = psn_info.Brdy
  17307. Age = psn_info.Age
  17308. infoStr = psn_info.Insuinfo
  17309. idetinfoStr = psn_info.Idetinfo
  17310. infocode = 0
  17311. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17312. psn_info, _ := service.GetPsnByPatientId(id)
  17313. PsnNo = psn_info.PsnNo
  17314. PsnCertType = psn_info.PsnCertType
  17315. Certno = psn_info.Certno
  17316. PsnName = psn_info.PsnName
  17317. Gend = psn_info.Gend
  17318. Naty = psn_info.Naty
  17319. Brdy = psn_info.Brdy
  17320. Age = psn_info.Age
  17321. infoStr = psn_info.Insuinfo
  17322. idetinfoStr = psn_info.Idetinfo
  17323. infocode = 0
  17324. verify_number = psn_info.VerifyNumber
  17325. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17326. if id_card_type == 2 {
  17327. //请求内网数据
  17328. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  17329. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17330. "&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
  17331. resp, requestErr := http.Get(api)
  17332. if requestErr != nil {
  17333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17334. return
  17335. }
  17336. body, ioErr := ioutil.ReadAll(resp.Body)
  17337. if ioErr != nil {
  17338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17340. return
  17341. }
  17342. var respJSON map[string]interface{}
  17343. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17346. return
  17347. }
  17348. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17349. result_byte, _ := json.Marshal(respJSON)
  17350. result := string(result_byte)
  17351. var dat map[string]interface{}
  17352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17353. fmt.Println(dat)
  17354. } else {
  17355. fmt.Println(err)
  17356. }
  17357. userJSONBytes, _ := json.Marshal(dat)
  17358. var res ResultTwo
  17359. var resTwo10265 ResultTwo10265
  17360. if miConfig.Code == "H15049901371" {
  17361. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  17362. utils.ErrorLog("解析失败:%v", err)
  17363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17364. return
  17365. }
  17366. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  17367. res.Infcode = Infcode
  17368. res.ErrMsg = resTwo10265.ErrMsg
  17369. res.Output = resTwo10265.Output
  17370. res.InfRefmsgid = resTwo10265.InfRefmsgid
  17371. res.RespondTime = resTwo10265.RespondTime
  17372. res.WarnInfo = resTwo10265.WarnInfo
  17373. } else {
  17374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17375. utils.ErrorLog("解析失败:%v", err)
  17376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17377. return
  17378. }
  17379. }
  17380. //var insutypes []string
  17381. //var insutype string
  17382. //var is390 int = 0
  17383. //var is310 int = 0
  17384. //for _, item := range res.Output.Iinfo {
  17385. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17386. // insutypes = append(insutypes, item.Insutype)
  17387. // }
  17388. //}
  17389. //if len(insutypes) == 1 {
  17390. // insutype = insutypes[0]
  17391. //} else {
  17392. // for _, i := range insutypes {
  17393. // if i == "390" {
  17394. // is390 = 1
  17395. // }
  17396. //
  17397. // if i == "310" {
  17398. // is310 = 1
  17399. // }
  17400. // }
  17401. //}
  17402. //if is390 == 1 {
  17403. // insutype = "390"
  17404. //}
  17405. //if is310 == 1 {
  17406. // insutype = "310"
  17407. //}
  17408. //if len(insutypes) == 0 {
  17409. // insutype = "310"
  17410. //}
  17411. PsnNo = res.Output.Baseinfo.PsnNo
  17412. PsnCertType = res.Output.Baseinfo.PsnCertType
  17413. Certno = res.Output.Baseinfo.Certno
  17414. PsnName = res.Output.Baseinfo.PsnName
  17415. Gend = res.Output.Baseinfo.Gend
  17416. Naty = res.Output.Baseinfo.Naty
  17417. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17418. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17419. infoStr = string(Iinfos)
  17420. idetinfoStr = string(Idetinfos)
  17421. infocode = res.Infcode
  17422. //infocode = 0
  17423. //verify_number = psn_info.VerifyNumber
  17424. } else {
  17425. psn_info, _ := service.GetPsnByPatientId(id)
  17426. PsnNo = psn_info.PsnNo
  17427. PsnCertType = psn_info.PsnCertType
  17428. Certno = psn_info.Certno
  17429. PsnName = psn_info.PsnName
  17430. Gend = psn_info.Gend
  17431. Naty = psn_info.Naty
  17432. Brdy = psn_info.Brdy
  17433. Age = psn_info.Age
  17434. infoStr = psn_info.Insuinfo
  17435. idetinfoStr = psn_info.Idetinfo
  17436. infocode = 0
  17437. verify_number = psn_info.VerifyNumber
  17438. }
  17439. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17440. if id_card_type == 1 {
  17441. psn_info, _ := service.GetPsnByPatientId(id)
  17442. PsnNo = psn_info.PsnNo
  17443. PsnCertType = psn_info.PsnCertType
  17444. Certno = psn_info.Certno
  17445. PsnName = psn_info.PsnName
  17446. Gend = psn_info.Gend
  17447. Naty = psn_info.Naty
  17448. Brdy = psn_info.Brdy
  17449. Age = psn_info.Age
  17450. infoStr = psn_info.Insuinfo
  17451. idetinfoStr = psn_info.Idetinfo
  17452. infocode = 0
  17453. verify_number = psn_info.VerifyNumber
  17454. } else if id_card_type == 2 {
  17455. 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)
  17456. fmt.Println(errMsgLog)
  17457. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17458. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17459. utils.ErrorLog("解析失败:%v", err)
  17460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17461. return
  17462. }
  17463. PsnNo = res.Output.Baseinfo.PsnNo
  17464. PsnCertType = res.Output.Baseinfo.PsnCertType
  17465. Certno = res.Output.Baseinfo.Certno
  17466. PsnName = res.Output.Baseinfo.PsnName
  17467. Gend = res.Output.Baseinfo.Gend
  17468. Naty = res.Output.Baseinfo.Naty
  17469. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17470. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17471. infoStr = string(Iinfos)
  17472. idetinfoStr = string(Idetinfos)
  17473. infocode = res.Infcode
  17474. }
  17475. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17476. if id_card_type == 1 {
  17477. psn_info, _ := service.GetPsnByPatientId(id)
  17478. PsnNo = psn_info.PsnNo
  17479. PsnCertType = psn_info.PsnCertType
  17480. Certno = psn_info.Certno
  17481. PsnName = psn_info.PsnName
  17482. Gend = psn_info.Gend
  17483. Naty = psn_info.Naty
  17484. Brdy = psn_info.Brdy
  17485. Age = psn_info.Age
  17486. infoStr = psn_info.Insuinfo
  17487. idetinfoStr = psn_info.Idetinfo
  17488. infocode = 0
  17489. verify_number = psn_info.VerifyNumber
  17490. } else if id_card_type == 2 {
  17491. 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, "")
  17492. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17493. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17494. utils.ErrorLog("解析失败:%v", err)
  17495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17496. return
  17497. }
  17498. PsnNo = res.Output.Baseinfo.PsnNo
  17499. PsnCertType = res.Output.Baseinfo.PsnCertType
  17500. Certno = res.Output.Baseinfo.Certno
  17501. PsnName = res.Output.Baseinfo.PsnName
  17502. Gend = res.Output.Baseinfo.Gend
  17503. Naty = res.Output.Baseinfo.Naty
  17504. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17505. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17506. infoStr = string(Iinfos)
  17507. idetinfoStr = string(Idetinfos)
  17508. infocode = res.Infcode
  17509. } else {
  17510. psn_info, _ := service.GetPsnByPatientId(id)
  17511. PsnNo = psn_info.PsnNo
  17512. PsnCertType = psn_info.PsnCertType
  17513. Certno = psn_info.Certno
  17514. PsnName = psn_info.PsnName
  17515. Gend = psn_info.Gend
  17516. Naty = psn_info.Naty
  17517. Brdy = psn_info.Brdy
  17518. Age = psn_info.Age
  17519. infoStr = psn_info.Insuinfo
  17520. idetinfoStr = psn_info.Idetinfo
  17521. infocode = 0
  17522. verify_number = psn_info.VerifyNumber
  17523. }
  17524. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17525. psn_info, _ := service.GetPsnByPatientId(id)
  17526. PsnNo = psn_info.PsnNo
  17527. PsnCertType = psn_info.PsnCertType
  17528. Certno = psn_info.Certno
  17529. PsnName = psn_info.PsnName
  17530. Gend = psn_info.Gend
  17531. Naty = psn_info.Naty
  17532. Brdy = psn_info.Brdy
  17533. Age = psn_info.Age
  17534. infoStr = psn_info.Insuinfo
  17535. idetinfoStr = psn_info.Idetinfo
  17536. infocode = 0
  17537. verify_number = psn_info.VerifyNumber
  17538. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17539. if id_card_type == 1 {
  17540. psn_info, _ := service.GetPsnByPatientId(id)
  17541. PsnNo = psn_info.PsnNo
  17542. PsnCertType = psn_info.PsnCertType
  17543. Certno = psn_info.Certno
  17544. PsnName = psn_info.PsnName
  17545. Gend = psn_info.Gend
  17546. Naty = psn_info.Naty
  17547. Brdy = psn_info.Brdy
  17548. Age = psn_info.Age
  17549. infoStr = psn_info.Insuinfo
  17550. idetinfoStr = psn_info.Idetinfo
  17551. infocode = 0
  17552. verify_number = psn_info.VerifyNumber
  17553. } else if id_card_type == 2 {
  17554. 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)
  17555. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17556. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17557. utils.ErrorLog("解析失败:%v", err)
  17558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17559. return
  17560. }
  17561. PsnNo = res.Output.Baseinfo.PsnNo
  17562. PsnCertType = res.Output.Baseinfo.PsnCertType
  17563. Certno = res.Output.Baseinfo.Certno
  17564. PsnName = res.Output.Baseinfo.PsnName
  17565. Gend = res.Output.Baseinfo.Gend
  17566. Naty = res.Output.Baseinfo.Naty
  17567. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17568. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17569. infoStr = string(Iinfos)
  17570. idetinfoStr = string(Idetinfos)
  17571. infocode = res.Infcode
  17572. } else if id_card_type == 4 {
  17573. psn_info, _ := service.GetPsnByPatientId(id)
  17574. PsnNo = psn_info.PsnNo
  17575. PsnCertType = psn_info.PsnCertType
  17576. Certno = psn_info.Certno
  17577. PsnName = psn_info.PsnName
  17578. Gend = psn_info.Gend
  17579. Naty = psn_info.Naty
  17580. Brdy = psn_info.Brdy
  17581. Age = psn_info.Age
  17582. infoStr = psn_info.Insuinfo
  17583. idetinfoStr = psn_info.Idetinfo
  17584. infocode = 0
  17585. verify_number = psn_info.VerifyNumber
  17586. }
  17587. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17588. var result string
  17589. var requestLog string
  17590. 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), "")
  17591. if id_card_type == 4 {
  17592. psn_info, _ := service.GetPsnByPatientId(id)
  17593. PsnNo = psn_info.PsnNo
  17594. PsnCertType = psn_info.PsnCertType
  17595. Certno = psn_info.Certno
  17596. PsnName = psn_info.PsnName
  17597. Gend = psn_info.Gend
  17598. Naty = psn_info.Naty
  17599. Brdy = psn_info.Brdy
  17600. Age = psn_info.Age
  17601. infoStr = psn_info.Insuinfo
  17602. idetinfoStr = psn_info.Idetinfo
  17603. infocode = 0
  17604. verify_number = psn_info.VerifyNumber
  17605. } else {
  17606. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17607. if miConfig.Code == "H15049901371" {
  17608. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17609. utils.ErrorLog("解析失败:%v", err)
  17610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17611. return
  17612. }
  17613. res.ErrMsg = res10265.ErrMsg
  17614. res.Output = res10265.Output
  17615. res.InfRefmsgid = res10265.InfRefmsgid
  17616. } else {
  17617. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17618. utils.ErrorLog("解析失败:%v", err)
  17619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17620. return
  17621. }
  17622. }
  17623. PsnNo = res.Output.Baseinfo.PsnNo
  17624. PsnCertType = res.Output.Baseinfo.PsnCertType
  17625. Certno = res.Output.Baseinfo.Certno
  17626. PsnName = res.Output.Baseinfo.PsnName
  17627. Gend = res.Output.Baseinfo.Gend
  17628. Naty = res.Output.Baseinfo.Naty
  17629. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17630. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17631. infoStr = string(Iinfos)
  17632. idetinfoStr = string(Idetinfos)
  17633. if miConfig.Code == "H15049901371" {
  17634. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17635. } else {
  17636. infocode = res.Infcode
  17637. }
  17638. }
  17639. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17640. psn_info, _ := service.GetPsnByPatientId(id)
  17641. PsnNo = psn_info.PsnNo
  17642. PsnCertType = psn_info.PsnCertType
  17643. Certno = psn_info.Certno
  17644. PsnName = psn_info.PsnName
  17645. Gend = psn_info.Gend
  17646. Naty = psn_info.Naty
  17647. Brdy = psn_info.Brdy
  17648. Age = psn_info.Age
  17649. infoStr = psn_info.Insuinfo
  17650. idetinfoStr = psn_info.Idetinfo
  17651. infocode = 0
  17652. verify_number = psn_info.VerifyNumber
  17653. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17654. psn_info, _ := service.GetPsnByPatientId(id)
  17655. PsnNo = psn_info.PsnNo
  17656. PsnCertType = psn_info.PsnCertType
  17657. Certno = psn_info.Certno
  17658. PsnName = psn_info.PsnName
  17659. Gend = psn_info.Gend
  17660. Naty = psn_info.Naty
  17661. Brdy = psn_info.Brdy
  17662. Age = psn_info.Age
  17663. infoStr = psn_info.Insuinfo
  17664. idetinfoStr = psn_info.Idetinfo
  17665. infocode = 0
  17666. verify_number = psn_info.VerifyNumber
  17667. } else {
  17668. var result string
  17669. var requestLog string
  17670. //if miConfig.UserOrgId == 10138 {
  17671. if id_card_type != 4 || id_card_type != 1 {
  17672. var insa string
  17673. if len(patient.InsuplcAdmdvs) > 0 {
  17674. insa = patient.InsuplcAdmdvs
  17675. } else {
  17676. insa = miConfig.InsuplcAdmdvs
  17677. }
  17678. //psn_info, _ := service.GetPsnByPatientId(id)
  17679. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  17680. 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)
  17681. }
  17682. //}
  17683. //else {
  17684. // var insa string
  17685. // if len(patient.InsuplcAdmdvs) > 0 {
  17686. // insa = patient.InsuplcAdmdvs
  17687. // } else {
  17688. // insa = miConfig.InsuplcAdmdvs
  17689. // }
  17690. // 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)
  17691. //}
  17692. if id_card_type == 4 || id_card_type == 1 {
  17693. psn_info, _ := service.GetPsnByPatientId(id)
  17694. PsnNo = psn_info.PsnNo
  17695. PsnCertType = psn_info.PsnCertType
  17696. Certno = psn_info.Certno
  17697. PsnName = psn_info.PsnName
  17698. Gend = psn_info.Gend
  17699. Naty = psn_info.Naty
  17700. Brdy = psn_info.Brdy
  17701. Age = psn_info.Age
  17702. infoStr = psn_info.Insuinfo
  17703. idetinfoStr = psn_info.Idetinfo
  17704. infocode = 0
  17705. verify_number = psn_info.VerifyNumber
  17706. } else {
  17707. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17708. if miConfig.Code == "H15049901371" {
  17709. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17710. utils.ErrorLog("解析失败:%v", err)
  17711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17712. return
  17713. }
  17714. res.ErrMsg = res10265.ErrMsg
  17715. res.Output = res10265.Output
  17716. res.InfRefmsgid = res10265.InfRefmsgid
  17717. } else {
  17718. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17719. utils.ErrorLog("解析失败:%v", err)
  17720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17721. return
  17722. }
  17723. }
  17724. PsnNo = res.Output.Baseinfo.PsnNo
  17725. PsnCertType = res.Output.Baseinfo.PsnCertType
  17726. Certno = res.Output.Baseinfo.Certno
  17727. PsnName = res.Output.Baseinfo.PsnName
  17728. Gend = res.Output.Baseinfo.Gend
  17729. Naty = res.Output.Baseinfo.Naty
  17730. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17731. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17732. infoStr = string(Iinfos)
  17733. idetinfoStr = string(Idetinfos)
  17734. if miConfig.Code == "H15049901371" {
  17735. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17736. } else {
  17737. infocode = res.Infcode
  17738. }
  17739. }
  17740. }
  17741. if infocode == 0 {
  17742. his := models.VMHisPatient{
  17743. Name: name,
  17744. Gender: gender,
  17745. Birthday: birthUnix,
  17746. MedicalTreatmentType: medical_care,
  17747. IdType: certificates,
  17748. IdCardNo: id_card,
  17749. BalanceAccountsType: settlementValue,
  17750. SocialType: social_type,
  17751. MedicalInsuranceNumber: medical_insurance_card,
  17752. RegisterType: register_type,
  17753. RegisterCost: registration_fee,
  17754. TreatmentCost: medical_expenses,
  17755. Status: 1,
  17756. Ctime: time.Now().Unix(),
  17757. Mtime: time.Now().Unix(),
  17758. PsnNo: PsnNo,
  17759. PsnCertType: PsnCertType,
  17760. Certno: Certno,
  17761. PsnName: PsnName,
  17762. Gend: Gend,
  17763. Naty: Naty,
  17764. Brdy: Brdy,
  17765. Age: Age,
  17766. Iinfo: infoStr,
  17767. Idetinfo: idetinfoStr,
  17768. PatientId: patient.ID,
  17769. RecordDate: theTime.Unix(),
  17770. UserOrgId: adminInfo.CurrentOrgId,
  17771. AdminUserId: admin_user_id,
  17772. IsReturn: 1,
  17773. IdCardType: id_card_type,
  17774. Doctor: doctor,
  17775. Departments: department,
  17776. MdtrtGrpType: mdtrt_type,
  17777. }
  17778. timestamp := time.Now().Unix()
  17779. tempTime := time.Unix(timestamp, 0)
  17780. timeFormat := tempTime.Format("20060102150405")
  17781. chrgBchno := rand.Intn(100000) + 10000
  17782. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17783. his.Number = ipt_otp_no
  17784. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17785. department, _ := service.GetDepartMentDetail(department)
  17786. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17787. IdCardNo := ""
  17788. if id_card_type == 1 {
  17789. // IdCardNo = medical_insurance_card
  17790. IdCardNo = patient.IdCardNo
  17791. } else {
  17792. IdCardNo = patient.IdCardNo
  17793. }
  17794. var rf []*ResultFive
  17795. json.Unmarshal([]byte(his.Iinfo), &rf)
  17796. var insutypes []*ResultFive
  17797. var insutype string
  17798. var insuplc_admdvs_temp string
  17799. var is390 int = 0
  17800. var is310 int = 0
  17801. for _, item := range rf {
  17802. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17803. insutypes = append(insutypes, item)
  17804. }
  17805. }
  17806. if len(insutypes) == 1 {
  17807. insutype = insutypes[0].Insutype
  17808. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17809. if insutype == "390" {
  17810. is390 = 1
  17811. }
  17812. if insutype == "310" {
  17813. is310 = 1
  17814. }
  17815. } else {
  17816. for _, i := range insutypes {
  17817. if i.Insutype == "390" {
  17818. is390 = 1
  17819. }
  17820. if i.Insutype == "310" {
  17821. is310 = 1
  17822. }
  17823. }
  17824. }
  17825. if is390 == 1 {
  17826. insutype = "390"
  17827. }
  17828. if is310 == 1 {
  17829. insutype = "310"
  17830. }
  17831. fmt.Println(social_type)
  17832. if social_type > 0 {
  17833. insutype = strconv.FormatInt(social_type, 10)
  17834. }
  17835. var infocode int64
  17836. var resThree ResultThree
  17837. var resThree10265 ResultThree10265
  17838. if len(insuplc_admdvs) == 0 {
  17839. psn_info, _ := service.GetPsnByPatientId(id)
  17840. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17841. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17842. //}
  17843. } else {
  17844. insuplc_admdvs_temp = insuplc_admdvs
  17845. }
  17846. if miConfig.MdtrtareaAdmvs == "421300" {
  17847. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17848. psn_info, _ := service.GetPsnByPatientId(id)
  17849. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17850. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17851. "&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
  17852. resp, requestErr := http.Get(api)
  17853. if requestErr != nil {
  17854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17855. return
  17856. }
  17857. body, ioErr := ioutil.ReadAll(resp.Body)
  17858. if ioErr != nil {
  17859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17861. return
  17862. }
  17863. var respJSON map[string]interface{}
  17864. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17867. return
  17868. }
  17869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17870. result, _ := json.Marshal(respJSON)
  17871. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17872. utils.ErrorLog("解析失败:%v", err)
  17873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17874. return
  17875. }
  17876. infocode = resThree.Infcode
  17877. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17878. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17879. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17880. // insuplc_admdvs_temp =
  17881. //}
  17882. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17883. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17884. //}
  17885. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17886. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17887. "&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
  17888. resp, requestErr := http.Get(api)
  17889. if requestErr != nil {
  17890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17891. return
  17892. }
  17893. body, ioErr := ioutil.ReadAll(resp.Body)
  17894. if ioErr != nil {
  17895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17897. return
  17898. }
  17899. var respJSON map[string]interface{}
  17900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17903. return
  17904. }
  17905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17906. result, _ := json.Marshal(respJSON)
  17907. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17908. utils.ErrorLog("解析失败:%v", err)
  17909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17910. return
  17911. }
  17912. infocode = resThree.Infcode
  17913. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17914. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17915. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17916. // insuplc_admdvs_temp =
  17917. //}
  17918. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17919. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17920. //}
  17921. utils.ErrorLog("解析失败:%v", insutype)
  17922. utils.ErrorLog("解析失败:%v", PsnNo)
  17923. utils.ErrorLog("解析失败:%v", Certno)
  17924. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  17925. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  17926. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  17927. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  17928. utils.ErrorLog("解析失败:%v", PsnNo)
  17929. utils.ErrorLog("解析失败:%v", department.Number)
  17930. utils.ErrorLog("解析失败:%v", department.Name)
  17931. utils.ErrorLog("解析失败:%v", roles.UserName)
  17932. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17933. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17934. "&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
  17935. resp, requestErr := http.Get(api)
  17936. if requestErr != nil {
  17937. utils.ErrorLog("解析失败:%v", requestErr)
  17938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17939. return
  17940. }
  17941. body, ioErr := ioutil.ReadAll(resp.Body)
  17942. if ioErr != nil {
  17943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17945. return
  17946. }
  17947. var respJSON map[string]interface{}
  17948. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17951. return
  17952. }
  17953. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17954. result, _ := json.Marshal(respJSON)
  17955. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17956. utils.ErrorLog("解析失败:%v", err)
  17957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17958. return
  17959. }
  17960. infocode = resThree.Infcode
  17961. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17962. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17963. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17964. // insuplc_admdvs_temp =
  17965. //}
  17966. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17967. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17968. //}
  17969. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17970. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17971. "&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
  17972. resp, requestErr := http.Get(api)
  17973. if requestErr != nil {
  17974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17975. return
  17976. }
  17977. body, ioErr := ioutil.ReadAll(resp.Body)
  17978. if ioErr != nil {
  17979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17981. return
  17982. }
  17983. var respJSON map[string]interface{}
  17984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17987. return
  17988. }
  17989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17990. result, _ := json.Marshal(respJSON)
  17991. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17992. utils.ErrorLog("解析失败:%v", err)
  17993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17994. return
  17995. }
  17996. infocode = resThree.Infcode
  17997. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17998. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17999. psn_info, _ := service.GetPsnByPatientId(id)
  18000. var verify_number string
  18001. if id_card_type == 4 {
  18002. verify_number = psn_info.VerifyNumber
  18003. } else if id_card_type == 1 {
  18004. bas := strings.Split(psn_info.CardInfo, "|")
  18005. cardNumber := bas[2]
  18006. verify_number = cardNumber
  18007. }
  18008. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18009. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18010. "&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
  18011. resp, requestErr := http.Get(api)
  18012. if requestErr != nil {
  18013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18014. return
  18015. }
  18016. body, ioErr := ioutil.ReadAll(resp.Body)
  18017. if ioErr != nil {
  18018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18020. return
  18021. }
  18022. var respJSON map[string]interface{}
  18023. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18026. return
  18027. }
  18028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18029. result, _ := json.Marshal(respJSON)
  18030. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18031. // utils.ErrorLog("解析失败:%v", err)
  18032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18033. // return
  18034. //}
  18035. //infocode = resThree.Infcode
  18036. //result, _ := json.Marshal(respJSON)
  18037. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18038. utils.ErrorLog("解析失败:%v", err)
  18039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18040. return
  18041. }
  18042. resThree.ErrMsg = resThree10265.ErrMsg
  18043. resThree.Output = resThree10265.Output
  18044. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18045. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18046. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18047. psn_info, _ := service.GetPsnByPatientId(id)
  18048. his.PsnNo = psn_info.PsnNo
  18049. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18050. var cert_no string
  18051. if id_card_type == 3 {
  18052. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  18053. cert_no = IdCardNo
  18054. } else if id_card_type == 4 {
  18055. cert_no = IdCardNo
  18056. psn_info.VerifyNumber = psn_info.VerifyNumber
  18057. } else {
  18058. bas := strings.Split(psn_info.CardInfo, "|")
  18059. cert_no = bas[2]
  18060. }
  18061. var hisPrescription []*models.HisPrescription
  18062. for _, item := range rf {
  18063. if item.Insutype == insutype {
  18064. //insuplc_admdvs = item.InsuplcAdmdvs
  18065. his.InsuplcAdmdvs = insuplc_admdvs
  18066. }
  18067. }
  18068. his.Insutype = insutype
  18069. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18070. fmt.Println(res3101)
  18071. fmt.Println(res3101.Infcode)
  18072. if res3101.Infcode == "0" {
  18073. fmt.Println("33333333")
  18074. if len(res3101.Output.Result) > 0 {
  18075. fmt.Println("222222")
  18076. for _, item := range res3101.Output.Result {
  18077. if len(res3101.ErrMsg) == 0 {
  18078. res3101.ErrMsg = item.VolaCont
  18079. } else {
  18080. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18081. }
  18082. }
  18083. c.ServeSuccessJSON(map[string]interface{}{
  18084. "failed_code": -10,
  18085. "msg": res3101.ErrMsg,
  18086. })
  18087. return
  18088. } else {
  18089. fmt.Println("11111")
  18090. var api string
  18091. if miConfig.MdtrtareaAdmvs == "320921" {
  18092. ipt_otp_no = timeFormat
  18093. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18094. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18095. "&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
  18096. } else {
  18097. ipt_otp_no = timeFormat
  18098. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18099. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18100. "&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
  18101. }
  18102. resp, requestErr := http.Get(api)
  18103. if requestErr != nil {
  18104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18105. return
  18106. }
  18107. body, ioErr := ioutil.ReadAll(resp.Body)
  18108. if ioErr != nil {
  18109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18111. return
  18112. }
  18113. var respJSON map[string]interface{}
  18114. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18117. return
  18118. }
  18119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18120. result, _ := json.Marshal(respJSON)
  18121. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18122. utils.ErrorLog("解析失败:%v", err)
  18123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18124. return
  18125. }
  18126. resThree.ErrMsg = resThree10265.ErrMsg
  18127. resThree.Output = resThree10265.Output
  18128. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18129. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18130. }
  18131. } else if res3101.Infcode != "0" {
  18132. c.ServeSuccessJSON(map[string]interface{}{
  18133. "failed_code": -10,
  18134. "msg": res3101.ErrMsg,
  18135. })
  18136. return
  18137. }
  18138. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18139. psn_info, _ := service.GetPsnByPatientId(id)
  18140. var cert_no string
  18141. if id_card_type == 1 {
  18142. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  18143. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18144. } else if id_card_type == 4 {
  18145. cert_no = psn_info.VerifyNumber
  18146. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18147. } else {
  18148. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18149. cert_no = psn_info.VerifyNumber
  18150. }
  18151. 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)
  18152. saveLog(result, requestLog, "2201", "挂号")
  18153. if miConfig.Code == "H15049901371" {
  18154. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18155. utils.ErrorLog("解析失败:%v", err)
  18156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18157. return
  18158. }
  18159. resThree.ErrMsg = resThree10265.ErrMsg
  18160. resThree.Output = resThree10265.Output
  18161. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18162. } else {
  18163. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18164. utils.ErrorLog("解析失败:%v", err)
  18165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18166. return
  18167. }
  18168. }
  18169. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18170. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  18171. psn_info, _ := service.GetPsnByPatientId(id)
  18172. var result string
  18173. var requestLog string
  18174. if id_card_type == 1 {
  18175. bas := strings.Split(psn_info.CardInfo, "|")
  18176. basNumber := bas[2]
  18177. card_sn := bas[3]
  18178. 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)
  18179. saveLog(result, requestLog, "2201A", "挂号")
  18180. } else if id_card_type == 2 {
  18181. 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, "", "", "", "", "", "")
  18182. saveLog(result, requestLog, "2201A", "挂号")
  18183. } else {
  18184. 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)
  18185. saveLog(result, requestLog, "2201A", "挂号")
  18186. }
  18187. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18188. utils.ErrorLog("解析失败:%v", err)
  18189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18190. return
  18191. }
  18192. infocode = resThree.Infcode
  18193. } else if miConfig.MdtrtareaAdmvs == "341203" {
  18194. psn_info, _ := service.GetPsnByPatientId(id)
  18195. his.PsnNo = psn_info.PsnNo
  18196. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18197. var cert_no string
  18198. if id_card_type == 1 {
  18199. bas := strings.Split(psn_info.CardInfo, "|")
  18200. cert_no = bas[2]
  18201. } else if id_card_type == 4 {
  18202. cert_no = IdCardNo
  18203. psn_info.VerifyNumber = psn_info.VerifyNumber
  18204. } else {
  18205. cert_no = IdCardNo
  18206. psn_info.VerifyNumber = cert_no
  18207. }
  18208. for _, item := range rf {
  18209. if item.Insutype == insutype {
  18210. his.InsuplcAdmdvs = insuplc_admdvs
  18211. }
  18212. }
  18213. his.Insutype = insutype
  18214. var api string
  18215. ipt_otp_no = timeFormat
  18216. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18217. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18218. "&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
  18219. resp, requestErr := http.Get(api)
  18220. if requestErr != nil {
  18221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18222. return
  18223. }
  18224. body, ioErr := ioutil.ReadAll(resp.Body)
  18225. if ioErr != nil {
  18226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18228. return
  18229. }
  18230. var respJSON map[string]interface{}
  18231. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18234. return
  18235. }
  18236. status := respJSON["data"].(map[string]interface{})["status"].(string)
  18237. if status == "0" {
  18238. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  18239. c.ServeSuccessJSON(map[string]interface{}{
  18240. "failed_code": -10,
  18241. "msg": err_msg,
  18242. })
  18243. return
  18244. }
  18245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18246. result, _ := json.Marshal(respJSON)
  18247. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18248. utils.ErrorLog("解析失败:%v", err)
  18249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18250. return
  18251. }
  18252. infocode = resThree.Infcode
  18253. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18254. psn_info, _ := service.GetPsnByPatientId(id)
  18255. var result string
  18256. var requestLog string
  18257. if id_card_type == 1 {
  18258. bas := strings.Split(psn_info.CardInfo, "|")
  18259. basNumber := bas[2]
  18260. card_sn := bas[3]
  18261. 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)
  18262. saveLog(result, requestLog, "2201A", "挂号")
  18263. } else if id_card_type == 2 {
  18264. 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, "", "")
  18265. saveLog(result, requestLog, "2201A", "挂号")
  18266. } else {
  18267. 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, "", "")
  18268. saveLog(result, requestLog, "2201A", "挂号")
  18269. }
  18270. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18271. utils.ErrorLog("解析失败:%v", err)
  18272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18273. return
  18274. }
  18275. infocode = resThree.Infcode
  18276. } else if miConfig.MdtrtareaAdmvs == "131023" {
  18277. psn_info, _ := service.GetPsnByPatientId(id)
  18278. 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)
  18279. saveLog(result, requestLog, "2201A", "挂号")
  18280. if miConfig.Code == "H15049901371" {
  18281. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18282. utils.ErrorLog("解析失败:%v", err)
  18283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18284. return
  18285. }
  18286. resThree.ErrMsg = resThree10265.ErrMsg
  18287. resThree.Output = resThree10265.Output
  18288. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18289. } else {
  18290. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18291. utils.ErrorLog("解析失败:%v", err)
  18292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18293. return
  18294. }
  18295. }
  18296. if miConfig.Code == "H15049901371" {
  18297. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18298. } else {
  18299. infocode = resThree.Infcode
  18300. }
  18301. } else {
  18302. psn_info, _ := service.GetPsnByPatientId(id)
  18303. if id_card_type == 4 || id_card_type == 1 {
  18304. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18305. }
  18306. var rf []*ResultFive
  18307. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  18308. var insutypes []*ResultFive
  18309. var insutype string
  18310. var is390 int = 0
  18311. var is310 int = 0
  18312. for _, item := range rf {
  18313. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18314. insutypes = append(insutypes, item)
  18315. }
  18316. }
  18317. if len(insutypes) == 1 {
  18318. insutype = insutypes[0].Insutype
  18319. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18320. } else {
  18321. for _, i := range insutypes {
  18322. if i.Insutype == "390" {
  18323. is390 = 1
  18324. }
  18325. if i.Insutype == "310" {
  18326. is310 = 1
  18327. }
  18328. }
  18329. }
  18330. if is390 == 1 {
  18331. insutype = "390"
  18332. }
  18333. if is310 == 1 {
  18334. insutype = "310"
  18335. }
  18336. fmt.Println(len(insutypes))
  18337. if len(insutypes) == 0 {
  18338. for index, item := range rf {
  18339. if index == 0 {
  18340. insutype = item.Insutype
  18341. insuplc_admdvs = item.InsuplcAdmdvs
  18342. }
  18343. }
  18344. fmt.Println(insutype)
  18345. fmt.Println(insuplc_admdvs)
  18346. }
  18347. if social_type > 0 {
  18348. insutype = strconv.FormatInt(social_type, 10)
  18349. }
  18350. fmt.Println("--------")
  18351. fmt.Println(psn_info)
  18352. fmt.Println(psn_info.PsnNo)
  18353. if miConfig.MdtrtareaAdmvs == "441202" {
  18354. var hisPrescription []*models.HisPrescription
  18355. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18356. if res3101.Infcode == 0 {
  18357. fmt.Println("33333333")
  18358. if len(res3101.Output.Result) > 0 {
  18359. fmt.Println("222222")
  18360. for _, item := range res3101.Output.Result {
  18361. if len(res3101.ErrMsg) == 0 {
  18362. res3101.ErrMsg = item.VolaCont
  18363. } else {
  18364. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18365. }
  18366. }
  18367. c.ServeSuccessJSON(map[string]interface{}{
  18368. "failed_code": -10,
  18369. "msg": res3101.ErrMsg,
  18370. })
  18371. return
  18372. } else {
  18373. hour := time.Now().Format("15")
  18374. min := time.Now().Format("04")
  18375. sec := time.Now().Format("05")
  18376. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18377. fmt.Println(record_time_two)
  18378. 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)
  18379. saveLog(result, requestLog, "2201A", "挂号")
  18380. if miConfig.Code == "H15049901371" {
  18381. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18382. utils.ErrorLog("解析失败:%v", err)
  18383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18384. return
  18385. }
  18386. resThree.ErrMsg = resThree10265.ErrMsg
  18387. resThree.Output = resThree10265.Output
  18388. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18389. } else {
  18390. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18391. utils.ErrorLog("解析失败:%v", err)
  18392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18393. return
  18394. }
  18395. }
  18396. if miConfig.Code == "H15049901371" {
  18397. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18398. } else {
  18399. infocode = resThree.Infcode
  18400. }
  18401. }
  18402. } else if res3101.Infcode != 0 {
  18403. c.ServeSuccessJSON(map[string]interface{}{
  18404. "failed_code": -10,
  18405. "msg": res3101.ErrMsg,
  18406. })
  18407. return
  18408. }
  18409. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18410. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18411. psn_info, _ := service.GetPsnByPatientId(id)
  18412. var verify_number string
  18413. if id_card_type == 4 {
  18414. verify_number = psn_info.VerifyNumber
  18415. } else if id_card_type == 1 {
  18416. bas := strings.Split(psn_info.CardInfo, "|")
  18417. cardNumber := bas[2]
  18418. verify_number = cardNumber
  18419. } else {
  18420. verify_number = psn_info.Certno
  18421. }
  18422. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18423. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18424. "&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
  18425. resp, requestErr := http.Get(api)
  18426. if requestErr != nil {
  18427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18428. return
  18429. }
  18430. body, ioErr := ioutil.ReadAll(resp.Body)
  18431. if ioErr != nil {
  18432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18434. return
  18435. }
  18436. var respJSON map[string]interface{}
  18437. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18440. return
  18441. }
  18442. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18443. result, _ := json.Marshal(respJSON)
  18444. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18445. utils.ErrorLog("解析失败:%v", err)
  18446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18447. return
  18448. }
  18449. infocode = resThree.Infcode
  18450. } else {
  18451. hour := time.Now().Format("15")
  18452. min := time.Now().Format("04")
  18453. sec := time.Now().Format("05")
  18454. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18455. if id_card_type == 1 {
  18456. for _, item := range rf {
  18457. if item.Insutype == strconv.FormatInt(social_type, 10) {
  18458. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  18459. insuplc_admdvs_temp = item.InsuplcAdmdvs
  18460. } else if strconv.FormatInt(social_type, 10) == "390" {
  18461. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18462. } else {
  18463. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18464. }
  18465. }
  18466. }
  18467. }
  18468. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  18469. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18470. }
  18471. if id_card_type == 1 {
  18472. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  18473. bas := strings.Split(psn_info.CardInfo, "|")
  18474. basNumber := bas[1]
  18475. IdCardNo = basNumber
  18476. }
  18477. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  18478. IdCardNo = psn_info.VerifyNumber
  18479. }
  18480. 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)
  18481. saveLog(result, requestLog, "2201A", "挂号")
  18482. if miConfig.Code == "H15049901371" {
  18483. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18484. utils.ErrorLog("解析失败:%v", err)
  18485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18486. return
  18487. }
  18488. resThree.ErrMsg = resThree10265.ErrMsg
  18489. resThree.Output = resThree10265.Output
  18490. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18491. } else {
  18492. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18493. utils.ErrorLog("解析失败:%v", err)
  18494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18495. return
  18496. }
  18497. }
  18498. if miConfig.Code == "H15049901371" {
  18499. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18500. } else {
  18501. infocode = resThree.Infcode
  18502. }
  18503. }
  18504. }
  18505. if infocode != 0 {
  18506. adminUser := c.GetAdminUserInfo()
  18507. errlog := &models.HisOrderError{
  18508. UserOrgId: adminUser.CurrentOrgId,
  18509. Ctime: time.Now().Unix(),
  18510. Mtime: time.Now().Unix(),
  18511. ErrMsg: resThree.ErrMsg,
  18512. Status: 1,
  18513. PatientId: id,
  18514. RecordTime: recordDateTime,
  18515. Stage: 2,
  18516. }
  18517. service.CreateErrMsgLog(errlog)
  18518. c.ServeSuccessJSON(map[string]interface{}{
  18519. "failed_code": -10,
  18520. "msg": resThree.ErrMsg,
  18521. })
  18522. return
  18523. }
  18524. his.Number = resThree.Output.Data.MdtrtID
  18525. his.PsnNo = resThree.Output.Data.PsnNo
  18526. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  18527. his.IdCardNo = patient.IdCardNo
  18528. his.PhoneNumber = patient.Phone
  18529. his.UserOrgId = adminInfo.CurrentOrgId
  18530. his.Insutype = insutype
  18531. his.Ctime = time.Now().Unix()
  18532. his.Mtime = time.Now().Unix()
  18533. his.InsuplcAdmdvs = insuplc_admdvs_temp
  18534. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  18535. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18536. }
  18537. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  18538. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18539. }
  18540. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  18541. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18542. }
  18543. his.Status = 1
  18544. his.MdtrtGrpType = mdtrt_type
  18545. service.UpdateHisPatientStatus(&his)
  18546. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  18547. c.ServeSuccessJSON(map[string]interface{}{
  18548. "his_info": his,
  18549. })
  18550. } else {
  18551. adminUser := c.GetAdminUserInfo()
  18552. errlog := &models.HisOrderError{
  18553. UserOrgId: adminUser.CurrentOrgId,
  18554. Ctime: time.Now().Unix(),
  18555. Mtime: time.Now().Unix(),
  18556. ErrMsg: res.ErrMsg,
  18557. Status: 1,
  18558. PatientId: id,
  18559. RecordTime: recordDateTime,
  18560. Stage: 1,
  18561. }
  18562. service.CreateErrMsgLog(errlog)
  18563. c.ServeSuccessJSON(map[string]interface{}{
  18564. "failed_code": -10,
  18565. "msg": res.ErrMsg,
  18566. })
  18567. return
  18568. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  18569. }
  18570. }
  18571. }
  18572. func (c *HisApiController) GetUploadInfo() {
  18573. id, _ := c.GetInt64("id")
  18574. record_time := c.GetString("record_time")
  18575. his_patient_id, _ := c.GetInt64("his_patient_id")
  18576. order_id, _ := c.GetInt64("order_id")
  18577. pay_way, _ := c.GetInt64("pay_way")
  18578. pay_ways := c.GetString("pay_ways")
  18579. oth_desc := c.GetString("oth_desc")
  18580. pay_price, _ := c.GetFloat("pay_price")
  18581. pay_card_no := c.GetString("pay_card_no")
  18582. discount_price, _ := c.GetFloat("discount_price")
  18583. preferential_price, _ := c.GetFloat("preferential_price")
  18584. reality_price, _ := c.GetFloat("reality_price")
  18585. found_price, _ := c.GetFloat("found_price")
  18586. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  18587. private_price, _ := c.GetFloat("private_price")
  18588. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  18589. admin_user_id, _ := c.GetInt64("admin_user_id")
  18590. fapiao_code := c.GetString("fapiao_code")
  18591. fapiao_number := c.GetString("fapiao_number")
  18592. diagnosis_id := c.GetString("diagnosis")
  18593. sick_type, _ := c.GetInt64("sick_type")
  18594. reg_type, _ := c.GetInt64("p_type")
  18595. begin_time := c.GetString("begin_time")
  18596. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  18597. cash_pay := c.GetString("cash_pay")
  18598. band_card_pay := c.GetString("band_card_pay")
  18599. wechat_pay := c.GetString("wechat_pay")
  18600. ali_pay := c.GetString("ali_pay")
  18601. jifen_pay := c.GetString("jifen_pay")
  18602. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  18603. fmt.Println(acct_used_flag)
  18604. id_str := c.GetString("ids")
  18605. ids_arr := strings.Split(id_str, ",")
  18606. timeLayout := "2006-01-02"
  18607. loc, _ := time.LoadLocation("Local")
  18608. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  18609. if err != nil {
  18610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18611. return
  18612. }
  18613. recordDateTime := theTime.Unix()
  18614. adminUser := c.GetAdminUserInfo()
  18615. var tempOrder models.HisOrder
  18616. tempOrder, _ = service.GetHisOrderByID(order_id)
  18617. var prescriptions []*models.HisPrescription
  18618. var start_time int64
  18619. var end_time int64
  18620. //押金模块
  18621. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  18622. tmp_decimal := c.GetString("tmp_decimal")
  18623. var decimal float64 //本次使用的押金
  18624. var errmsg error
  18625. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  18626. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  18627. return
  18628. }
  18629. if len(tmp_decimal) > 0 {
  18630. if tmp_decimal[0] == 45 {
  18631. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  18632. return
  18633. }
  18634. }
  18635. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  18636. fmt.Println(errs)
  18637. decimal = tt
  18638. //if adminUser.CurrentOrgId == 10106{
  18639. // if len(fapiao_code) == 0{
  18640. // fapiao_code = "144072080589"
  18641. // }
  18642. // if len(fapiao_number) == 0{
  18643. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  18644. // if order.ID == 0{
  18645. // fapiao_number = "00001520"
  18646. // }else{
  18647. // //fapiao_code = "00001520"
  18648. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  18649. // var zero string
  18650. // if fpNumber >= 1000{
  18651. // zero = "0000" + strconv.Itoa(fpNumber)
  18652. // }else if fpNumber >= 10000{
  18653. // zero = "000" + strconv.Itoa(fpNumber)
  18654. // } else if fpNumber >= 100000{
  18655. // zero = "00" + strconv.Itoa(fpNumber)
  18656. // } else if fpNumber >= 1000000{
  18657. // zero = "0" + strconv.Itoa(fpNumber)
  18658. // }else {
  18659. // zero = strconv.Itoa(fpNumber)
  18660. // }
  18661. // fapiao_number = zero
  18662. // }
  18663. // }
  18664. //}
  18665. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18666. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18667. var patientPrescription models.HisPrescriptionInfo
  18668. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18669. if patientPrescription.ID == 0 {
  18670. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  18671. }
  18672. //if patientPrescription.Do
  18673. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18674. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  18675. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  18676. diagnosis_ids := strings.Split(diagnosis_id, ",")
  18677. var config []*models.HisXtDiagnoseConfig
  18678. for _, item := range diagnosis_ids {
  18679. id, _ := strconv.ParseInt(item, 10, 64)
  18680. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18681. config = append(config, &diagnosisConfig)
  18682. }
  18683. sickConfig, _ := service.FindSickById(sick_type)
  18684. //if tempOrder.ID == 0 {
  18685. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  18686. //}
  18687. if tempOrder.ID == 0 {
  18688. var result string
  18689. var requestLog string
  18690. var res2 ResultSix
  18691. var res3 GZResultSix
  18692. var ressix10265 ResultSix10265
  18693. if miConfig.MdtrtareaAdmvs == "421300" {
  18694. data := make(map[string]interface{})
  18695. client := &http.Client{}
  18696. data["psn_no"] = his.PsnNo
  18697. data["mdtrt_id"] = his.Number
  18698. data["opter"] = roles.UserName
  18699. data["org_name"] = miConfig.OrgName
  18700. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18701. data["doctor_id"] = doctor_info.DoctorNumber
  18702. data["doctor_name"] = doctor_info.UserName
  18703. data["department"] = department.Name
  18704. data["fixmedins_code"] = miConfig.Code
  18705. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18706. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18707. data["secret_key"] = miConfig.SecretKey
  18708. data["sick_code"] = sickConfig.CountryCode
  18709. data["sick_name"] = sickConfig.ClassName
  18710. data["dept"] = strconv.FormatInt(department.ID, 10)
  18711. data["config"] = config
  18712. data["begin_time"] = begin_time
  18713. bytesData, _ := json.Marshal(data)
  18714. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18715. resp, _ := client.Do(req)
  18716. defer resp.Body.Close()
  18717. body, ioErr := ioutil.ReadAll(resp.Body)
  18718. if ioErr != nil {
  18719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18721. return
  18722. }
  18723. var respJSON map[string]interface{}
  18724. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18727. return
  18728. }
  18729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18730. userJSONBytes, _ := json.Marshal(respJSON)
  18731. fmt.Println("log")
  18732. fmt.Println(string(userJSONBytes))
  18733. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18734. utils.ErrorLog("解析失败:%v", err)
  18735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18736. return
  18737. }
  18738. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18739. data := make(map[string]interface{})
  18740. client := &http.Client{}
  18741. data["psn_no"] = his.PsnNo
  18742. data["mdtrt_id"] = his.Number
  18743. data["opter"] = roles.UserName
  18744. data["org_name"] = miConfig.OrgName
  18745. if reg_type == 11 && his.Insutype == "390" {
  18746. data["med_type"] = "110104"
  18747. } else {
  18748. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18749. }
  18750. data["doctor_id"] = doctor_info.DoctorNumber
  18751. data["doctor_name"] = doctor_info.UserName
  18752. data["department"] = department.Name
  18753. data["fixmedins_code"] = miConfig.Code
  18754. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18755. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18756. data["secret_key"] = miConfig.SecretKey
  18757. data["sick_code"] = sickConfig.CountryCode
  18758. data["sick_name"] = sickConfig.ClassName
  18759. data["dept"] = strconv.FormatInt(department.ID, 10)
  18760. data["config"] = config
  18761. data["begin_time"] = begin_time
  18762. bytesData, _ := json.Marshal(data)
  18763. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18764. resp, _ := client.Do(req)
  18765. defer resp.Body.Close()
  18766. body, ioErr := ioutil.ReadAll(resp.Body)
  18767. if ioErr != nil {
  18768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18770. return
  18771. }
  18772. var respJSON map[string]interface{}
  18773. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18776. return
  18777. }
  18778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18779. userJSONBytes, _ := json.Marshal(respJSON)
  18780. fmt.Println("log")
  18781. fmt.Println(string(userJSONBytes))
  18782. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18783. utils.ErrorLog("解析失败:%v", err)
  18784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18785. return
  18786. }
  18787. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18788. data := make(map[string]interface{})
  18789. client := &http.Client{}
  18790. data["psn_no"] = his.PsnNo
  18791. data["mdtrt_id"] = his.Number
  18792. data["opter"] = roles.UserName
  18793. data["org_name"] = miConfig.OrgName
  18794. if reg_type == 11 && his.Insutype == "390" {
  18795. data["med_type"] = "110104"
  18796. } else {
  18797. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18798. }
  18799. data["doctor_id"] = doctor_info.DoctorNumber
  18800. data["doctor_name"] = doctor_info.UserName
  18801. data["department"] = department.Name
  18802. data["fixmedins_code"] = miConfig.Code
  18803. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18804. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18805. data["secret_key"] = miConfig.SecretKey
  18806. data["sick_code"] = sickConfig.CountryCode
  18807. data["sick_name"] = sickConfig.ClassName
  18808. data["dept"] = strconv.FormatInt(department.ID, 10)
  18809. data["config"] = config
  18810. data["begin_time"] = begin_time
  18811. bytesData, _ := json.Marshal(data)
  18812. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18813. resp, _ := client.Do(req)
  18814. defer resp.Body.Close()
  18815. body, ioErr := ioutil.ReadAll(resp.Body)
  18816. if ioErr != nil {
  18817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18819. return
  18820. }
  18821. var respJSON map[string]interface{}
  18822. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18825. return
  18826. }
  18827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18828. userJSONBytes, _ := json.Marshal(respJSON)
  18829. fmt.Println("log")
  18830. fmt.Println(string(userJSONBytes))
  18831. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18832. utils.ErrorLog("解析失败:%v", err)
  18833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18834. return
  18835. }
  18836. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18837. data := make(map[string]interface{})
  18838. client := &http.Client{}
  18839. data["psn_no"] = his.PsnNo
  18840. data["mdtrt_id"] = his.Number
  18841. data["opter"] = roles.UserName
  18842. data["org_name"] = miConfig.OrgName
  18843. if reg_type == 11 && his.Insutype == "390" {
  18844. data["med_type"] = "110104"
  18845. } else {
  18846. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18847. }
  18848. data["doctor_id"] = doctor_info.DoctorNumber
  18849. data["doctor_name"] = doctor_info.UserName
  18850. data["department"] = department.Name
  18851. data["fixmedins_code"] = miConfig.Code
  18852. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18853. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18854. data["secret_key"] = miConfig.SecretKey
  18855. data["sick_code"] = sickConfig.CountryCode
  18856. data["sick_name"] = sickConfig.ClassName
  18857. data["dept"] = strconv.FormatInt(department.ID, 10)
  18858. data["config"] = config
  18859. data["begin_time"] = begin_time
  18860. bytesData, _ := json.Marshal(data)
  18861. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18862. resp, _ := client.Do(req)
  18863. defer resp.Body.Close()
  18864. body, ioErr := ioutil.ReadAll(resp.Body)
  18865. if ioErr != nil {
  18866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18868. return
  18869. }
  18870. var respJSON map[string]interface{}
  18871. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18874. return
  18875. }
  18876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18877. userJSONBytes, _ := json.Marshal(respJSON)
  18878. fmt.Println("log")
  18879. fmt.Println(string(userJSONBytes))
  18880. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18881. utils.ErrorLog("解析失败:%v", err)
  18882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18883. return
  18884. }
  18885. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18886. data := make(map[string]interface{})
  18887. client := &http.Client{}
  18888. data["psn_no"] = his.PsnNo
  18889. data["mdtrt_id"] = his.Number
  18890. data["doctor"] = roles.UserName
  18891. data["department"] = department.Name
  18892. data["org_name"] = miConfig.OrgName
  18893. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18894. data["doctor_id"] = doctor_info.DoctorNumber
  18895. data["new_doctor_name"] = doctor_info.UserName
  18896. data["fixmedins_code"] = miConfig.Code
  18897. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18898. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18899. data["secret_key"] = miConfig.SecretKey
  18900. data["sick_code"] = sickConfig.CountryCode
  18901. data["sick_name"] = sickConfig.ClassName
  18902. data["url"] = miConfig.Url
  18903. data["ak"] = miConfig.AccessKey
  18904. data["begin_time"] = begin_time
  18905. data["cainfo"] = miConfig.Cainfo
  18906. data["dept"] = strconv.FormatInt(department.ID, 10)
  18907. data["config"] = config
  18908. bytesData, _ := json.Marshal(data)
  18909. var req *http.Request
  18910. if miConfig.MdtrtareaAdmvs == "320921" {
  18911. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18912. //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 +
  18913. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18914. } else {
  18915. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18916. }
  18917. resp, _ := client.Do(req)
  18918. defer resp.Body.Close()
  18919. body, ioErr := ioutil.ReadAll(resp.Body)
  18920. if ioErr != nil {
  18921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18923. return
  18924. }
  18925. var respJSON map[string]interface{}
  18926. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18929. return
  18930. }
  18931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18932. userJSONBytes, _ := json.Marshal(respJSON)
  18933. fmt.Println("log")
  18934. fmt.Println(string(userJSONBytes))
  18935. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18936. utils.ErrorLog("解析失败:%v", err)
  18937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18938. return
  18939. }
  18940. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18941. res2.Output = ressix10265.Output
  18942. res2.ErrMsg = ressix10265.ErrMsg
  18943. res2.Cainfo = ressix10265.Cainfo
  18944. res2.WarnMsg = ressix10265.WarnMsg
  18945. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18946. res2.Infcode = infocode
  18947. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18948. data := make(map[string]interface{})
  18949. client := &http.Client{}
  18950. data["psn_no"] = his.PsnNo
  18951. data["mdtrt_id"] = his.Number
  18952. data["doctor"] = roles.UserName
  18953. data["department"] = department.Name
  18954. data["org_name"] = miConfig.OrgName
  18955. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18956. data["doctor_id"] = doctor_info.DoctorNumber
  18957. data["new_doctor_name"] = doctor_info.UserName
  18958. data["fixmedins_code"] = miConfig.Code
  18959. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18960. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18961. data["secret_key"] = miConfig.SecretKey
  18962. data["sick_code"] = sickConfig.CountryCode
  18963. data["sick_name"] = sickConfig.ClassName
  18964. data["url"] = miConfig.Url
  18965. data["ak"] = miConfig.AccessKey
  18966. data["begin_time"] = begin_time
  18967. data["cainfo"] = miConfig.Cainfo
  18968. data["dept"] = strconv.FormatInt(department.ID, 10)
  18969. data["config"] = config
  18970. bytesData, _ := json.Marshal(data)
  18971. var req *http.Request
  18972. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18973. resp, _ := client.Do(req)
  18974. defer resp.Body.Close()
  18975. body, ioErr := ioutil.ReadAll(resp.Body)
  18976. if ioErr != nil {
  18977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18979. return
  18980. }
  18981. var respJSON map[string]interface{}
  18982. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18985. return
  18986. }
  18987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18988. userJSONBytes, _ := json.Marshal(respJSON)
  18989. fmt.Println("log")
  18990. fmt.Println(string(userJSONBytes))
  18991. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18992. utils.ErrorLog("解析失败:%v", err)
  18993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18994. return
  18995. }
  18996. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18997. res2.Output = ressix10265.Output
  18998. res2.ErrMsg = ressix10265.ErrMsg
  18999. res2.Cainfo = ressix10265.Cainfo
  19000. res2.WarnMsg = ressix10265.WarnMsg
  19001. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  19002. res2.Infcode = infocode
  19003. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19004. 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)
  19005. saveLog(result, requestLog, "2203", "上传就诊信息")
  19006. var respJSON2 map[string]interface{}
  19007. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  19008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19010. return
  19011. }
  19012. userJSONBytes2, _ := json.Marshal(respJSON2)
  19013. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  19014. utils.ErrorLog("解析失败:%v", err)
  19015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19016. return
  19017. }
  19018. 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)
  19019. fmt.Println(result2)
  19020. fmt.Println(src_request)
  19021. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19022. data := make(map[string]interface{})
  19023. client := &http.Client{}
  19024. data["psn_no"] = his.PsnNo
  19025. data["mdtrt_id"] = his.Number
  19026. data["doctor"] = roles.UserName
  19027. data["department"] = department.Name
  19028. data["org_name"] = miConfig.OrgName
  19029. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19030. data["doctor_id"] = doctor_info.DoctorNumber
  19031. data["new_doctor_name"] = doctor_info.UserName
  19032. data["fixmedins_code"] = miConfig.Code
  19033. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19034. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19035. data["secret_key"] = miConfig.SecretKey
  19036. data["sick_code"] = sickConfig.CountryCode
  19037. data["sick_name"] = sickConfig.ClassName
  19038. data["url"] = miConfig.Url
  19039. data["ak"] = miConfig.AccessKey
  19040. data["begin_time"] = begin_time
  19041. data["cainfo"] = miConfig.Cainfo
  19042. data["dept"] = strconv.FormatInt(department.ID, 10)
  19043. data["config"] = config
  19044. bytesData, _ := json.Marshal(data)
  19045. var req *http.Request
  19046. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  19047. resp, _ := client.Do(req)
  19048. defer resp.Body.Close()
  19049. body, ioErr := ioutil.ReadAll(resp.Body)
  19050. if ioErr != nil {
  19051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19053. return
  19054. }
  19055. var respJSON map[string]interface{}
  19056. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19059. return
  19060. }
  19061. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19062. userJSONBytes, _ := json.Marshal(respJSON)
  19063. fmt.Println("log")
  19064. fmt.Println(string(userJSONBytes))
  19065. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19066. utils.ErrorLog("解析失败:%v", err)
  19067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19068. return
  19069. }
  19070. } else {
  19071. if miConfig.MdtrtareaAdmvs == "440781" { //
  19072. 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)
  19073. } else {
  19074. if miConfig.Code == "H15049901371" {
  19075. //赤峰地区国家医保医疗类别
  19076. //职工透析:医疗类别选特殊情况门诊990502
  19077. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19078. var med_type string
  19079. if his.Insutype == "390" {
  19080. if reg_type == 14 {
  19081. med_type = "9933"
  19082. } else if reg_type == 11 {
  19083. med_type = "11"
  19084. }
  19085. } else if his.Insutype == "310" {
  19086. if reg_type == 14 {
  19087. med_type = "990502"
  19088. } else if reg_type == 11 {
  19089. med_type = "11"
  19090. }
  19091. }
  19092. 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)
  19093. } else {
  19094. 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)
  19095. }
  19096. }
  19097. saveLog(result, requestLog, "2203", "上传就诊信息")
  19098. var respJSON2 map[string]interface{}
  19099. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  19100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19102. return
  19103. }
  19104. userJSONBytes2, _ := json.Marshal(respJSON2)
  19105. if miConfig.Code == "H15049901371" {
  19106. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  19107. utils.ErrorLog("解析失败:%v", err)
  19108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19109. return
  19110. }
  19111. res2.InfRefmsgid = ressix10265.InfRefmsgid
  19112. res2.Output = ressix10265.Output
  19113. res2.ErrMsg = ressix10265.ErrMsg
  19114. res2.Cainfo = ressix10265.Cainfo
  19115. res2.WarnMsg = ressix10265.WarnMsg
  19116. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  19117. res2.Infcode = infocode
  19118. } else {
  19119. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19120. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  19121. utils.ErrorLog("解析失败:%v", err)
  19122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19123. return
  19124. }
  19125. res2.Infcode = res3.Infcode
  19126. } else {
  19127. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  19128. utils.ErrorLog("解析失败:%v", err)
  19129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19130. return
  19131. }
  19132. }
  19133. }
  19134. }
  19135. if res2.Infcode != 0 {
  19136. adminUser := c.GetAdminUserInfo()
  19137. errlog := &models.HisOrderError{
  19138. UserOrgId: adminUser.CurrentOrgId,
  19139. Ctime: time.Now().Unix(),
  19140. Mtime: time.Now().Unix(),
  19141. ErrMsg: res2.ErrMsg,
  19142. Status: 1,
  19143. PatientId: id,
  19144. RecordTime: recordDateTime,
  19145. Stage: 3,
  19146. }
  19147. service.CreateErrMsgLog(errlog)
  19148. c.ServeSuccessJSON(map[string]interface{}{
  19149. "failed_code": -10,
  19150. "msg": res2.ErrMsg,
  19151. })
  19152. return
  19153. } else {
  19154. his.Diagnosis = diagnosis_id
  19155. his.SickType = sickConfig.ID
  19156. //var p_type int64
  19157. //if reg_type == 1111 || reg_type == 1112 {
  19158. // p_type = 11
  19159. //
  19160. //}
  19161. his.PType = fmt.Sprintf("%d", reg_type)
  19162. service.UpdateHisPatientThree(&his)
  19163. data := make(map[string]interface{})
  19164. if settle_accounts_type == 1 { //日结
  19165. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  19166. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  19167. } else {
  19168. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  19169. }
  19170. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  19171. data["pre"] = prescriptions
  19172. } else { //月结
  19173. start_time_str := c.GetString("start_time")
  19174. end_time_str := c.GetString("end_time")
  19175. timeLayout := "2006-01-02"
  19176. loc, _ := time.LoadLocation("Local")
  19177. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  19178. if err != nil {
  19179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19180. return
  19181. }
  19182. recordStartTime := theStartTime.Unix()
  19183. start_time = recordStartTime
  19184. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  19185. if err != nil {
  19186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19187. return
  19188. }
  19189. recordEndTime := theEndTime.Unix()
  19190. end_time = recordEndTime
  19191. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  19192. data["pre"] = prescriptions
  19193. }
  19194. timestamp := time.Now().Unix()
  19195. tempTime := time.Unix(timestamp, 0)
  19196. timeFormat := tempTime.Format("20060102150405")
  19197. chrgBchno := rand.Intn(100000) + 10000
  19198. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  19199. strconv.FormatInt(his.PatientId, 10)
  19200. client := &http.Client{}
  19201. data["psn_no"] = his.PsnNo
  19202. data["mdtrt_id"] = his.Number
  19203. data["chrg_bchno"] = chrg_bchno
  19204. data["org_name"] = miConfig.OrgName
  19205. data["doctor"] = doctor_info.UserName
  19206. data["doctor_id"] = doctor_info.DoctorNumber
  19207. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  19208. data["fixmedins_code"] = miConfig.Code
  19209. data["dept_code"] = department.Number
  19210. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19211. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19212. data["secret_key"] = miConfig.SecretKey
  19213. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  19214. data["url"] = miConfig.Url
  19215. data["ak"] = miConfig.AccessKey
  19216. data["new_doctor_name"] = patientPrescription.Doctor
  19217. data["diag_code"] = sickConfig.CountryCode
  19218. data["cainfo"] = miConfig.Cainfo
  19219. data["opter"] = roles.UserName
  19220. var ids []int64
  19221. for _, item := range prescriptions {
  19222. ids = append(ids, item.ID)
  19223. }
  19224. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19225. if config.IsOpen == 1 { //对接了医保,走医保流程
  19226. var res ResultFour
  19227. var resFour10265 ResultFour10265
  19228. if miConfig.MdtrtareaAdmvs == "421300" {
  19229. bytesData, _ := json.Marshal(data)
  19230. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19231. resp, _ := client.Do(req)
  19232. defer resp.Body.Close()
  19233. body, ioErr := ioutil.ReadAll(resp.Body)
  19234. if ioErr != nil {
  19235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19237. return
  19238. }
  19239. var respJSON map[string]interface{}
  19240. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19243. return
  19244. }
  19245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19246. userJSONBytes, _ := json.Marshal(respJSON)
  19247. fmt.Println("log")
  19248. fmt.Println(string(userJSONBytes))
  19249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19250. utils.ErrorLog("解析失败:%v", err)
  19251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19252. return
  19253. }
  19254. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19255. bytesData, _ := json.Marshal(data)
  19256. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19257. resp, _ := client.Do(req)
  19258. defer resp.Body.Close()
  19259. body, ioErr := ioutil.ReadAll(resp.Body)
  19260. if ioErr != nil {
  19261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19263. return
  19264. }
  19265. var respJSON map[string]interface{}
  19266. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19269. return
  19270. }
  19271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19272. userJSONBytes, _ := json.Marshal(respJSON)
  19273. fmt.Println("log")
  19274. fmt.Println(string(userJSONBytes))
  19275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19276. utils.ErrorLog("解析失败:%v", err)
  19277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19278. return
  19279. }
  19280. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19281. bytesData, _ := json.Marshal(data)
  19282. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19283. resp, _ := client.Do(req)
  19284. defer resp.Body.Close()
  19285. body, ioErr := ioutil.ReadAll(resp.Body)
  19286. if ioErr != nil {
  19287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19289. return
  19290. }
  19291. var respJSON map[string]interface{}
  19292. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19295. return
  19296. }
  19297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19298. userJSONBytes, _ := json.Marshal(respJSON)
  19299. fmt.Println("log")
  19300. fmt.Println(string(userJSONBytes))
  19301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19302. utils.ErrorLog("解析失败:%v", err)
  19303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19304. return
  19305. }
  19306. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19307. bytesData, _ := json.Marshal(data)
  19308. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19309. resp, _ := client.Do(req)
  19310. defer resp.Body.Close()
  19311. body, ioErr := ioutil.ReadAll(resp.Body)
  19312. if ioErr != nil {
  19313. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19315. return
  19316. }
  19317. var respJSON map[string]interface{}
  19318. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19321. return
  19322. }
  19323. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19324. userJSONBytes, _ := json.Marshal(respJSON)
  19325. fmt.Println("log")
  19326. fmt.Println(string(userJSONBytes))
  19327. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19328. utils.ErrorLog("解析失败:%v", err)
  19329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19330. return
  19331. }
  19332. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19333. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  19334. if result3101.Infcode == "0" {
  19335. if len(result3101.Output.Result) > 0 {
  19336. var errMsgs []string
  19337. for _, item := range result3101.Output.Result {
  19338. errMsgs = append(errMsgs, item.VolaCont)
  19339. }
  19340. c.ServeSuccessJSON(map[string]interface{}{
  19341. "failed_code": -10,
  19342. "msg": errMsgs,
  19343. })
  19344. return
  19345. }
  19346. }
  19347. bytesData, _ := json.Marshal(data)
  19348. var req *http.Request
  19349. if miConfig.MdtrtareaAdmvs == "320921" {
  19350. data["diag_code"] = sickConfig.CountryCode
  19351. fmt.Println(data)
  19352. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19353. } else {
  19354. data["diag_code"] = sickConfig.CountryCode
  19355. fmt.Println(data)
  19356. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19357. }
  19358. resp, _ := client.Do(req)
  19359. defer resp.Body.Close()
  19360. body, ioErr := ioutil.ReadAll(resp.Body)
  19361. if ioErr != nil {
  19362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19364. return
  19365. }
  19366. var respJSON map[string]interface{}
  19367. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19370. return
  19371. }
  19372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19373. userJSONBytes, _ := json.Marshal(respJSON)
  19374. fmt.Println("log")
  19375. fmt.Println(string(userJSONBytes))
  19376. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19377. utils.ErrorLog("解析失败:%v", err)
  19378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19379. return
  19380. }
  19381. res.InfRefmsgid = resFour10265.InfRefmsgid
  19382. res.Output = resFour10265.Output
  19383. res.ErrMsg = resFour10265.ErrMsg
  19384. res.Cainfo = resFour10265.Cainfo
  19385. res.WarnMsg = resFour10265.WarnMsg
  19386. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19387. res.Infcode = infocode
  19388. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19389. var pagesize int = 2
  19390. var start int = 1
  19391. var stop int
  19392. var pagecount int
  19393. var curpage int
  19394. var isSuccess bool = true
  19395. data["doctor_id"] = doctor_info.DoctorNumber
  19396. //总页数,向上取整,注意除之前要先转换类型为float64
  19397. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  19398. for curpage = 1; curpage <= pagecount; curpage++ {
  19399. if curpage == 1 {
  19400. start = 1
  19401. } else {
  19402. start = (curpage-1)*pagesize + 1
  19403. }
  19404. stop = curpage * pagesize
  19405. if stop > len(prescriptions) {
  19406. stop = len(prescriptions)
  19407. }
  19408. //var requestLog string
  19409. data["pre"] = prescriptions[start-1 : stop]
  19410. fmt.Println(data["pre"])
  19411. bytesData, _ := json.Marshal(data)
  19412. var req *http.Request
  19413. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  19414. resp, _ := client.Do(req)
  19415. defer resp.Body.Close()
  19416. body, ioErr := ioutil.ReadAll(resp.Body)
  19417. if ioErr != nil {
  19418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19420. return
  19421. }
  19422. var respJSON map[string]interface{}
  19423. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19426. return
  19427. }
  19428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19429. userJSONBytes, _ := json.Marshal(respJSON)
  19430. fmt.Println("log")
  19431. fmt.Println(string(userJSONBytes))
  19432. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19433. utils.ErrorLog("解析失败:%v", err)
  19434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19435. return
  19436. }
  19437. res.InfRefmsgid = resFour10265.InfRefmsgid
  19438. res.Output = resFour10265.Output
  19439. res.ErrMsg = resFour10265.ErrMsg
  19440. res.Cainfo = resFour10265.Cainfo
  19441. res.WarnMsg = resFour10265.WarnMsg
  19442. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19443. res.Infcode = infocode
  19444. if infocode == 0 {
  19445. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  19446. } else {
  19447. isSuccess = false
  19448. errlog := &models.HisOrderError{
  19449. UserOrgId: adminUser.CurrentOrgId,
  19450. Ctime: time.Now().Unix(),
  19451. Mtime: time.Now().Unix(),
  19452. Number: chrg_bchno,
  19453. ErrMsg: "",
  19454. Status: 1,
  19455. PatientId: id,
  19456. RecordTime: recordDateTime,
  19457. Stage: 4,
  19458. }
  19459. service.CreateErrMsgLog(errlog)
  19460. c.ServeSuccessJSON(map[string]interface{}{
  19461. "failed_code": -10,
  19462. "msg": res.ErrMsg,
  19463. })
  19464. return
  19465. }
  19466. }
  19467. if isSuccess {
  19468. res.Infcode = 0
  19469. }
  19470. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19471. 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)
  19472. var dat map[string]interface{}
  19473. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19474. fmt.Println(dat)
  19475. } else {
  19476. fmt.Println(err)
  19477. }
  19478. saveLog(result, request_log, "2204", "上传费用明细")
  19479. userJSONBytes, _ := json.Marshal(dat)
  19480. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19481. utils.ErrorLog("解析失败:%v", err)
  19482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19483. return
  19484. }
  19485. res.InfRefmsgid = resFour10265.InfRefmsgid
  19486. res.Output = resFour10265.Output
  19487. res.ErrMsg = resFour10265.ErrMsg
  19488. res.Cainfo = resFour10265.Cainfo
  19489. res.WarnMsg = resFour10265.WarnMsg
  19490. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19491. res.Infcode = infocode
  19492. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19493. bytesData, _ := json.Marshal(data)
  19494. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  19495. resp, _ := client.Do(req)
  19496. defer resp.Body.Close()
  19497. body, ioErr := ioutil.ReadAll(resp.Body)
  19498. if ioErr != nil {
  19499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19501. return
  19502. }
  19503. var respJSON map[string]interface{}
  19504. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19507. return
  19508. }
  19509. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19510. userJSONBytes, _ := json.Marshal(respJSON)
  19511. fmt.Println("log")
  19512. fmt.Println(string(userJSONBytes))
  19513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19514. utils.ErrorLog("解析失败:%v", err)
  19515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19516. return
  19517. }
  19518. } else {
  19519. if miConfig.Code == "H15049901371" {
  19520. 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)
  19521. var dat map[string]interface{}
  19522. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19523. fmt.Println(dat)
  19524. } else {
  19525. fmt.Println(err)
  19526. }
  19527. saveLog(result, request_log, "2204", "上传费用明细")
  19528. userJSONBytes, _ := json.Marshal(dat)
  19529. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19530. utils.ErrorLog("解析失败:%v", err)
  19531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19532. return
  19533. }
  19534. res.InfRefmsgid = resFour10265.InfRefmsgid
  19535. res.Output = resFour10265.Output
  19536. res.ErrMsg = resFour10265.ErrMsg
  19537. res.Cainfo = resFour10265.Cainfo
  19538. res.WarnMsg = resFour10265.WarnMsg
  19539. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19540. res.Infcode = infocode
  19541. } else {
  19542. 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)
  19543. var dat map[string]interface{}
  19544. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19545. fmt.Println(dat)
  19546. } else {
  19547. fmt.Println(err)
  19548. }
  19549. saveLog(result, request_log, "2204", "上传费用明细")
  19550. userJSONBytes, _ := json.Marshal(dat)
  19551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19552. utils.ErrorLog("解析失败:%v", err)
  19553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19554. return
  19555. }
  19556. }
  19557. }
  19558. if res.Infcode == 0 {
  19559. order := &models.HisOrder{
  19560. UserOrgId: adminUser.CurrentOrgId,
  19561. HisPatientId: his.ID,
  19562. PatientId: his.PatientId,
  19563. SettleAccountsDate: recordDateTime,
  19564. MdtrtId: his.Number,
  19565. PsnNo: his.PsnNo,
  19566. MedType: strconv.FormatInt(reg_type, 10),
  19567. Ctime: time.Now().Unix(),
  19568. Mtime: time.Now().Unix(),
  19569. Status: 1,
  19570. Number: chrg_bchno,
  19571. Infcode: res.Infcode,
  19572. WarnMsg: res.WarnMsg,
  19573. Cainfo: res.Cainfo,
  19574. ErrMsg: res.ErrMsg,
  19575. RespondTime: res.RefmsgTime,
  19576. InfRefmsgid: res.InfRefmsgid,
  19577. OrderStatus: 1,
  19578. PayWay: pay_way,
  19579. PayWays: pay_ways,
  19580. OthDesc: oth_desc,
  19581. PayPrice: pay_price,
  19582. PayCardNo: pay_card_no,
  19583. DiscountPrice: discount_price,
  19584. PreferentialPrice: preferential_price,
  19585. RealityPrice: reality_price,
  19586. FoundPrice: found_price,
  19587. MedicalInsurancePrice: medical_insurance_price,
  19588. PrivatePrice: private_price,
  19589. IsMedicineInsurance: 1,
  19590. SettleType: settle_accounts_type,
  19591. SettleStartTime: start_time,
  19592. SettleEndTime: end_time,
  19593. Creator: roles.AdminUserId,
  19594. Modify: roles.AdminUserId,
  19595. FaPiaoNumber: fapiao_number,
  19596. FaPiaoCode: fapiao_code,
  19597. PType: 2,
  19598. Diagnosis: diagnosis_id,
  19599. CashPay: cash_pay,
  19600. WechatPay: wechat_pay,
  19601. AliPay: ali_pay,
  19602. JifenPay: jifen_pay,
  19603. BandCardPay: band_card_pay,
  19604. }
  19605. err = service.CreateOrder(order)
  19606. if err != nil {
  19607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  19608. return
  19609. }
  19610. for _, item := range res.Output.Result {
  19611. temp := strings.Split(item.FeedetlSn, "-")
  19612. var advice_id int64 = 0
  19613. var project_id int64 = 0
  19614. var types int64 = 0
  19615. id, _ := strconv.ParseInt(temp[2], 10, 64)
  19616. types, _ = strconv.ParseInt(temp[1], 10, 64)
  19617. if temp[1] == "1" {
  19618. advice_id = id
  19619. project_id = 0
  19620. } else if temp[1] == "2" {
  19621. advice_id = 0
  19622. project_id = id
  19623. }
  19624. if item.MedChrgitmType == "9" {
  19625. item.MedChrgitmType = "09"
  19626. }
  19627. info := &models.HisOrderInfo{
  19628. OrderNumber: order.Number,
  19629. FeedetlSn: item.FeedetlSn,
  19630. UploadDate: time.Now().Unix(),
  19631. AdviceId: advice_id,
  19632. DetItemFeeSumamt: item.DetItemFeeSumamt,
  19633. Cnt: item.Cnt,
  19634. Pric: float64(item.Pric),
  19635. PatientId: his.PatientId,
  19636. PricUplmtAmt: item.PricUplmtAmt,
  19637. SelfpayProp: item.SelfpayProp,
  19638. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  19639. OverlmtAmt: item.OverlmtAmt,
  19640. PreselfpayAmt: item.PreselfpayAmt,
  19641. BasMednFlag: item.BasMednFlag,
  19642. MedChrgitmType: item.MedChrgitmType,
  19643. HiNegoDrugFlag: item.HiNegoDrugFlag,
  19644. Status: 1,
  19645. Memo: item.Memo,
  19646. Mtime: time.Now().Unix(),
  19647. InscpScpAmt: item.InscpScpAmt,
  19648. DrtReimFlag: item.DrtReimFlag,
  19649. Ctime: time.Now().Unix(),
  19650. ListSpItemFlag: item.ListSpItemFlag,
  19651. ChldMedcFlag: item.ChldMedcFlag,
  19652. LmtUsedFlag: item.LmtUsedFlag,
  19653. ChrgitmLv: item.ChrgitmLv,
  19654. UserOrgId: adminUser.CurrentOrgId,
  19655. HisPatientId: his.ID,
  19656. OrderId: order.ID,
  19657. ProjectId: project_id,
  19658. Type: types,
  19659. }
  19660. service.CreateOrderInfo(info)
  19661. }
  19662. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  19663. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  19664. var total float64
  19665. for _, item := range prescriptions {
  19666. if item.Type == 1 { //药品
  19667. for _, subItem := range item.HisDoctorAdviceInfo {
  19668. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19669. total_one := price * subItem.PrescribingNumber
  19670. total = total + total_one
  19671. }
  19672. }
  19673. if item.Type == 2 { //项目
  19674. for _, subItem := range item.HisPrescriptionProject {
  19675. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  19676. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19677. total_one := price * cnt
  19678. total = total + total_one
  19679. }
  19680. }
  19681. }
  19682. allTotal := fmt.Sprintf("%.2f", total)
  19683. //if adminUser.CurrentOrgId == 9919 {
  19684. //
  19685. // allTotal = fmt.Sprintf("%.2f", total)
  19686. //
  19687. //} else {
  19688. //
  19689. // allTotal = fmt.Sprintf("%.2f", total)
  19690. //
  19691. //}
  19692. if res.Infcode == 0 {
  19693. var rf []*ResultFive
  19694. json.Unmarshal([]byte(his.Iinfo), &rf)
  19695. chrg_bchno := chrg_bchno
  19696. cert_no := his.Certno
  19697. var insutypes []string
  19698. var insutype string
  19699. var is390 int = 0
  19700. var is310 int = 0
  19701. for _, item := range rf {
  19702. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19703. insutypes = append(insutypes, item.Insutype)
  19704. }
  19705. }
  19706. if len(insutypes) == 1 {
  19707. insutype = insutypes[0]
  19708. } else {
  19709. for _, i := range insutypes {
  19710. if i == "390" {
  19711. is390 = 1
  19712. }
  19713. if i == "310" {
  19714. is310 = 1
  19715. }
  19716. }
  19717. }
  19718. if is390 == 1 {
  19719. insutype = "390"
  19720. }
  19721. if is310 == 1 {
  19722. insutype = "310"
  19723. }
  19724. if len(insutypes) == 0 {
  19725. insutype = "310"
  19726. }
  19727. if len(insutypes) == 2 {
  19728. insutype = strconv.FormatInt(his.SocialType, 10)
  19729. }
  19730. insutype = strconv.FormatInt(his.SocialType, 10)
  19731. //insutype = "390"
  19732. if his.IdCardType == 1 {
  19733. // cert_no = his.MedicalInsuranceNumber
  19734. cert_no = his.Certno
  19735. } else {
  19736. cert_no = his.Certno
  19737. }
  19738. var res ResultSeven
  19739. var resSeven10265 ResultSeven10265
  19740. var gzresSeven10265Two GZResultSeven10265Two
  19741. var src_resquest string
  19742. var result2 string
  19743. if miConfig.MdtrtareaAdmvs == "421300" {
  19744. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19745. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19746. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19747. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19748. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19749. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19750. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19751. resp, requestErr := http.Get(api)
  19752. if requestErr != nil {
  19753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19754. return
  19755. }
  19756. body, ioErr := ioutil.ReadAll(resp.Body)
  19757. if ioErr != nil {
  19758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19760. return
  19761. }
  19762. var respJSON map[string]interface{}
  19763. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19766. return
  19767. }
  19768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19769. result, _ := json.Marshal(respJSON)
  19770. if miConfig.Code == "H15049901371" {
  19771. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19772. utils.ErrorLog("解析失败:%v", err)
  19773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19774. return
  19775. }
  19776. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19777. res.Output = resSeven10265.Output
  19778. res.ErrMsg = resSeven10265.ErrMsg
  19779. res.Cainfo = resSeven10265.Cainfo
  19780. res.WarnMsg = resSeven10265.WarnMsg
  19781. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19782. res.Infcode = infocode
  19783. } else {
  19784. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19785. utils.ErrorLog("解析失败:%v", err)
  19786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19787. return
  19788. }
  19789. }
  19790. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19791. if reg_type == 11 && his.Insutype == "390" {
  19792. reg_type = 110104
  19793. }
  19794. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19795. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19796. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19797. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19798. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19799. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19800. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19801. resp, requestErr := http.Get(api)
  19802. if requestErr != nil {
  19803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19804. return
  19805. }
  19806. body, ioErr := ioutil.ReadAll(resp.Body)
  19807. if ioErr != nil {
  19808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19810. return
  19811. }
  19812. var respJSON map[string]interface{}
  19813. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19816. return
  19817. }
  19818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19819. result, _ := json.Marshal(respJSON)
  19820. if miConfig.Code == "H15049901371" {
  19821. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19822. utils.ErrorLog("解析失败:%v", err)
  19823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19824. return
  19825. }
  19826. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19827. res.Output = resSeven10265.Output
  19828. res.ErrMsg = resSeven10265.ErrMsg
  19829. res.Cainfo = resSeven10265.Cainfo
  19830. res.WarnMsg = resSeven10265.WarnMsg
  19831. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19832. res.Infcode = infocode
  19833. } else {
  19834. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19835. utils.ErrorLog("解析失败:%v", err)
  19836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19837. return
  19838. }
  19839. }
  19840. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19841. if reg_type == 11 && his.Insutype == "390" {
  19842. reg_type = 110104
  19843. }
  19844. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19845. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19846. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19847. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19848. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19849. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19850. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19851. resp, requestErr := http.Get(api)
  19852. if requestErr != nil {
  19853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19854. return
  19855. }
  19856. body, ioErr := ioutil.ReadAll(resp.Body)
  19857. if ioErr != nil {
  19858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19860. return
  19861. }
  19862. var respJSON map[string]interface{}
  19863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19866. return
  19867. }
  19868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19869. result, _ := json.Marshal(respJSON)
  19870. if miConfig.Code == "H15049901371" {
  19871. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19872. utils.ErrorLog("解析失败:%v", err)
  19873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19874. return
  19875. }
  19876. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19877. res.Output = resSeven10265.Output
  19878. res.ErrMsg = resSeven10265.ErrMsg
  19879. res.Cainfo = resSeven10265.Cainfo
  19880. res.WarnMsg = resSeven10265.WarnMsg
  19881. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19882. res.Infcode = infocode
  19883. } else {
  19884. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19885. utils.ErrorLog("解析失败:%v", err)
  19886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19887. return
  19888. }
  19889. }
  19890. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19891. if reg_type == 11 && his.Insutype == "390" {
  19892. reg_type = 110104
  19893. }
  19894. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19895. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19896. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19898. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19899. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19900. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19901. resp, requestErr := http.Get(api)
  19902. if requestErr != nil {
  19903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19904. return
  19905. }
  19906. body, ioErr := ioutil.ReadAll(resp.Body)
  19907. if ioErr != nil {
  19908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19910. return
  19911. }
  19912. var respJSON map[string]interface{}
  19913. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19916. return
  19917. }
  19918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19919. result, _ := json.Marshal(respJSON)
  19920. if miConfig.Code == "H15049901371" {
  19921. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19922. utils.ErrorLog("解析失败:%v", err)
  19923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19924. return
  19925. }
  19926. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19927. res.Output = resSeven10265.Output
  19928. res.ErrMsg = resSeven10265.ErrMsg
  19929. res.Cainfo = resSeven10265.Cainfo
  19930. res.WarnMsg = resSeven10265.WarnMsg
  19931. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19932. res.Infcode = infocode
  19933. } else {
  19934. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19935. utils.ErrorLog("解析失败:%v", err)
  19936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19937. return
  19938. }
  19939. }
  19940. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19941. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19942. if result3101.Infcode == "0" {
  19943. if len(result3101.Output.Result) > 0 {
  19944. var errMsgs []string
  19945. for _, item := range result3101.Output.Result {
  19946. errMsgs = append(errMsgs, item.VolaCont)
  19947. }
  19948. c.ServeSuccessJSON(map[string]interface{}{
  19949. "failed_code": -10,
  19950. "msg": errMsgs,
  19951. })
  19952. return
  19953. } else {
  19954. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19955. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19956. bas := strings.Split(psn_info.CardInfo, "|")
  19957. if his.IdCardType == 1 {
  19958. cert_no = bas[2]
  19959. } else if his.IdCardType == 3 {
  19960. cert_no = his.Certno
  19961. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19962. } else if his.IdCardType == 4 {
  19963. cert_no = his.Certno
  19964. psn_info.VerifyNumber = psn_info.VerifyNumber
  19965. }
  19966. var api string
  19967. if miConfig.MdtrtareaAdmvs == "320921" {
  19968. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19969. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19970. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19971. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19972. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19973. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19974. "&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
  19975. } else {
  19976. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19977. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19978. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19979. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19980. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19981. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19982. "&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
  19983. }
  19984. resp, requestErr := http.Get(api)
  19985. if requestErr != nil {
  19986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19987. return
  19988. }
  19989. body, ioErr := ioutil.ReadAll(resp.Body)
  19990. if ioErr != nil {
  19991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19993. return
  19994. }
  19995. var respJSON map[string]interface{}
  19996. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19999. return
  20000. }
  20001. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20002. result, _ := json.Marshal(respJSON)
  20003. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20004. utils.ErrorLog("解析失败:%v", err)
  20005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20006. return
  20007. }
  20008. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20009. res.Output = resSeven10265.Output
  20010. res.ErrMsg = resSeven10265.ErrMsg
  20011. res.Cainfo = resSeven10265.Cainfo
  20012. res.WarnMsg = resSeven10265.WarnMsg
  20013. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20014. res.Infcode = infocode
  20015. }
  20016. }
  20017. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20018. psn_info, _ := service.GetPsnByPatientId(id)
  20019. var verify_number string
  20020. if psn_info.IdCardType == 4 {
  20021. verify_number = psn_info.VerifyNumber
  20022. } else if psn_info.IdCardType == 1 {
  20023. bas := strings.Split(psn_info.CardInfo, "|")
  20024. cardNumber := bas[2]
  20025. verify_number = cardNumber
  20026. } else {
  20027. psn_info.IdCardType = 2
  20028. verify_number = psn_info.Certno
  20029. }
  20030. var api string
  20031. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20032. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20033. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20034. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20035. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20036. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20037. "&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
  20038. resp, requestErr := http.Get(api)
  20039. if requestErr != nil {
  20040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20041. return
  20042. }
  20043. body, ioErr := ioutil.ReadAll(resp.Body)
  20044. if ioErr != nil {
  20045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20047. return
  20048. }
  20049. var respJSON map[string]interface{}
  20050. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20053. return
  20054. }
  20055. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20056. result, _ := json.Marshal(respJSON)
  20057. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20058. utils.ErrorLog("解析失败:%v", err)
  20059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20060. return
  20061. }
  20062. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20063. res.Output = resSeven10265.Output
  20064. res.ErrMsg = resSeven10265.ErrMsg
  20065. res.Cainfo = resSeven10265.Cainfo
  20066. res.WarnMsg = resSeven10265.WarnMsg
  20067. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20068. res.Infcode = infocode
  20069. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20070. var cert_no string
  20071. if his.IdCardType == 4 {
  20072. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20073. cert_no = psn_info.VerifyNumber
  20074. 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)
  20075. } else if his.IdCardType == 1 {
  20076. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20077. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20078. 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)
  20079. }
  20080. //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)
  20081. var dat map[string]interface{}
  20082. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20083. fmt.Println(dat)
  20084. } else {
  20085. fmt.Println(err)
  20086. }
  20087. saveLog(result2, src_resquest, "2207", "结算")
  20088. userJSONBytes, _ := json.Marshal(dat)
  20089. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20090. utils.ErrorLog("解析失败:%v", err)
  20091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20092. return
  20093. }
  20094. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20095. res.Output = resSeven10265.Output
  20096. res.ErrMsg = resSeven10265.ErrMsg
  20097. res.Cainfo = resSeven10265.Cainfo
  20098. res.WarnMsg = resSeven10265.WarnMsg
  20099. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20100. res.Infcode = infocode
  20101. } else if miConfig.MdtrtareaAdmvs == "450721" {
  20102. res2 := c.GetoleInfo()
  20103. if res2.Infcode == 0 {
  20104. var result string
  20105. var request_log string
  20106. var result_log string
  20107. if res2.Output.MdtrtCertType == "02" {
  20108. 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)
  20109. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20110. } else if res2.Output.MdtrtCertType == "01" {
  20111. 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)
  20112. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20113. } else {
  20114. 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)
  20115. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20116. }
  20117. var dat map[string]interface{}
  20118. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20119. fmt.Println(dat)
  20120. } else {
  20121. fmt.Println(err)
  20122. }
  20123. userJSONBytes, _ := json.Marshal(dat)
  20124. var res5 ResultTwo
  20125. //var resTwo10265 ResultTwo10265
  20126. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20127. utils.ErrorLog("解析失败:%v", err)
  20128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20129. return
  20130. }
  20131. if res5.Infcode == -1 {
  20132. c.ServeSuccessJSON(map[string]interface{}{
  20133. "failed_code": -10,
  20134. "msg": res5.ErrMsg,
  20135. })
  20136. return
  20137. }
  20138. var insutypes []string
  20139. var insutype string
  20140. var is390 int = 0
  20141. var is310 int = 0
  20142. for _, item := range res5.Output.Iinfo {
  20143. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20144. insutypes = append(insutypes, item.Insutype)
  20145. }
  20146. }
  20147. if len(insutypes) == 1 {
  20148. insutype = insutypes[0]
  20149. } else {
  20150. for _, i := range insutypes {
  20151. if i == "390" {
  20152. is390 = 1
  20153. }
  20154. if i == "310" {
  20155. is310 = 1
  20156. }
  20157. }
  20158. }
  20159. if is390 == 1 {
  20160. insutype = "390"
  20161. }
  20162. if is310 == 1 {
  20163. insutype = "310"
  20164. }
  20165. if len(insutypes) == 0 {
  20166. insutype = "310"
  20167. }
  20168. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20169. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20170. infoStr := string(Iinfos)
  20171. idetinfoStr := string(Idetinfos)
  20172. psn := &models.HisPsn{
  20173. PsnNo: res5.Output.Baseinfo.PsnNo,
  20174. PatientId: id,
  20175. Certno: res5.Output.Baseinfo.Certno,
  20176. Gend: res5.Output.Baseinfo.Gend,
  20177. Naty: res5.Output.Baseinfo.Naty,
  20178. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20179. PsnName: res5.Output.Baseinfo.PsnName,
  20180. Idetinfo: idetinfoStr,
  20181. Insuinfo: infoStr,
  20182. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20183. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20184. VerifyNumber: res2.Output.EcToken,
  20185. }
  20186. if res2.Output.MdtrtCertType == "01" {
  20187. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20188. psn.VerifyNumber = res2.Output.EcToken
  20189. } else if res2.Output.MdtrtCertType == "02" {
  20190. psn.VerifyNumber = res2.Output.CardNo
  20191. } else {
  20192. psn.VerifyNumber = res2.Output.MdtrtCertNo
  20193. }
  20194. service.CreateHisPsn(psn)
  20195. if res2.Output.MdtrtCertType == "01" {
  20196. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20197. token := res2.Output.EcToken
  20198. 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)
  20199. } else if res2.Output.MdtrtCertType == "02" {
  20200. 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)
  20201. } else {
  20202. 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)
  20203. }
  20204. var dat2 map[string]interface{}
  20205. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20206. fmt.Println(dat2)
  20207. } else {
  20208. fmt.Println(err)
  20209. }
  20210. userJSONBytes3, _ := json.Marshal(dat2)
  20211. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20212. utils.ErrorLog("解析失败:%v", err)
  20213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20214. return
  20215. }
  20216. saveLog(result2, src_resquest, "2207", "结算")
  20217. } else {
  20218. c.ServeSuccessJSON(map[string]interface{}{
  20219. "failed_code": -10,
  20220. "msg": res2.ErrMsg,
  20221. })
  20222. return
  20223. }
  20224. } else {
  20225. if miConfig.Code == "H15049901371" {
  20226. //赤峰地区国家医保医疗类别
  20227. //职工透析:医疗类别选特殊情况门诊990502
  20228. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20229. var med_type string
  20230. if his.Insutype == "390" {
  20231. if reg_type == 14 {
  20232. med_type = "9933"
  20233. } else if reg_type == 11 {
  20234. med_type = "11"
  20235. }
  20236. } else if his.Insutype == "310" {
  20237. if reg_type == 14 {
  20238. med_type = "990502"
  20239. } else if reg_type == 11 {
  20240. med_type = "11"
  20241. }
  20242. }
  20243. 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)
  20244. } else {
  20245. if his.IdCardType == 4 {
  20246. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20247. var token string
  20248. token = psn_info.VerifyNumber
  20249. 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)
  20250. } else {
  20251. if his.IdCardType == 1 {
  20252. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20253. bas := strings.Split(psn_info.CardInfo, "|")
  20254. basNumber := bas[2]
  20255. cert_no = basNumber
  20256. }
  20257. 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)
  20258. }
  20259. }
  20260. //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)
  20261. var dat map[string]interface{}
  20262. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20263. fmt.Println(dat)
  20264. } else {
  20265. fmt.Println(err)
  20266. }
  20267. saveLog(result2, src_resquest, "2207", "结算")
  20268. userJSONBytes, _ := json.Marshal(dat)
  20269. if miConfig.Code == "H15049901371" {
  20270. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20271. utils.ErrorLog("解析失败:%v", err)
  20272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20273. return
  20274. }
  20275. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20276. res.Output = resSeven10265.Output
  20277. res.ErrMsg = resSeven10265.ErrMsg
  20278. res.Cainfo = resSeven10265.Cainfo
  20279. res.WarnMsg = resSeven10265.WarnMsg
  20280. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20281. res.Infcode = infocode
  20282. } else {
  20283. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20284. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20285. utils.ErrorLog("解析失败:%v", err)
  20286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20287. return
  20288. }
  20289. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20290. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20291. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20292. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20293. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20294. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20295. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20296. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20297. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20298. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20299. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20300. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20301. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20302. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20303. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20304. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20305. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20306. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20307. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20308. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20309. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20310. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20311. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20312. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20313. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20314. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20315. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20316. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20317. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20318. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20319. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20320. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20321. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20322. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20323. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20324. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20325. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20326. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20327. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20328. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20329. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20330. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20331. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20332. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20333. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20334. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20335. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20336. res.Cainfo = gzresSeven10265Two.Cainfo
  20337. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20338. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20339. //res.Infcode = infocode
  20340. } else {
  20341. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20342. utils.ErrorLog("解析失败:%v", err)
  20343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20344. return
  20345. }
  20346. }
  20347. }
  20348. }
  20349. if res.Infcode == -1 {
  20350. errlog := &models.HisOrderError{
  20351. UserOrgId: adminUser.CurrentOrgId,
  20352. Ctime: time.Now().Unix(),
  20353. Mtime: time.Now().Unix(),
  20354. Number: chrg_bchno,
  20355. ErrMsg: res.ErrMsg,
  20356. Status: 1,
  20357. PatientId: id,
  20358. RecordTime: recordDateTime,
  20359. Stage: 6,
  20360. }
  20361. service.CreateErrMsgLog(errlog)
  20362. c.ServeSuccessJSON(map[string]interface{}{
  20363. "failed_code": -10,
  20364. "msg": res.ErrMsg,
  20365. })
  20366. return
  20367. } else {
  20368. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20369. order.OrderStatus = 2
  20370. order.Status = 1
  20371. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20372. order.SetlId = res.Output.Setlinfo.SetlID
  20373. order.PsnNo = res.Output.Setlinfo.PsnNo
  20374. order.PsnName = res.Output.Setlinfo.PsnName
  20375. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20376. order.Certno = res.Output.Setlinfo.Certno
  20377. order.Gend = res.Output.Setlinfo.Gend
  20378. order.Naty = res.Output.Setlinfo.Naty
  20379. order.Age = res.Output.Setlinfo.Age
  20380. order.Insutype = res.Output.Setlinfo.Insutype
  20381. order.PsnType = res.Output.Setlinfo.PsnType
  20382. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20383. order.SetlTime = res.Output.Setlinfo.SetlTime
  20384. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20385. if res.Output.Setlinfo.MedType == "140101" {
  20386. order.MedType = "14"
  20387. } else {
  20388. if res.Output.Setlinfo.MedType == "110104" {
  20389. order.MedType = "11"
  20390. } else {
  20391. order.MedType = res.Output.Setlinfo.MedType
  20392. }
  20393. }
  20394. if reg_type == 1112 {
  20395. order.MedType = "1112"
  20396. }
  20397. if reg_type == 1111 {
  20398. order.MedType = "1111"
  20399. }
  20400. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20401. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20402. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20403. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20404. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20405. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20406. order.HifpPay = res.Output.Setlinfo.HifpPay
  20407. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20408. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20409. order.HifesPay = res.Output.Setlinfo.HifesPay
  20410. order.HifobPay = res.Output.Setlinfo.HifobPay
  20411. order.MafPay = res.Output.Setlinfo.MafPay
  20412. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20413. order.OthPay = res.Output.Setlinfo.OthPay
  20414. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20415. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20416. order.AcctPay = res.Output.Setlinfo.AcctPay
  20417. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20418. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20419. order.Balc = res.Output.Setlinfo.Balc
  20420. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20421. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20422. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20423. order.ClrType = res.Output.Setlinfo.ClrType
  20424. order.ClrWay = res.Output.Setlinfo.ClrWay
  20425. order.Creator = order.Creator
  20426. order.Modify = roles.AdminUserId
  20427. order.RequestLog = src_resquest
  20428. order.FaPiaoNumber = fapiao_number
  20429. order.FaPiaoCode = fapiao_code
  20430. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20431. //detailStr := string(setlDetail)
  20432. //order.SetlDetail = detailStr
  20433. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20434. err = service.UpDateOrder(order)
  20435. if err == nil {
  20436. //判断是否使用了押金
  20437. if dec_way == "true" {
  20438. tmpstring := strconv.FormatInt(order.ID, 10)
  20439. order.Decimal = decimal
  20440. service.UpDateOrder(order)
  20441. //扣押金
  20442. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20443. if errmsg != nil {
  20444. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20445. return
  20446. }
  20447. }
  20448. c.ServeSuccessJSON(map[string]interface{}{
  20449. "msg": "结算成功",
  20450. })
  20451. } else {
  20452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20453. return
  20454. }
  20455. }
  20456. } else {
  20457. adminUser := c.GetAdminUserInfo()
  20458. errlog := &models.HisOrderError{
  20459. UserOrgId: adminUser.CurrentOrgId,
  20460. Ctime: time.Now().Unix(),
  20461. Mtime: time.Now().Unix(),
  20462. ErrMsg: res.ErrMsg,
  20463. Status: 1,
  20464. PatientId: id,
  20465. RecordTime: recordDateTime,
  20466. Stage: 4,
  20467. }
  20468. service.CreateErrMsgLog(errlog)
  20469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  20470. return
  20471. }
  20472. } else {
  20473. adminUser := c.GetAdminUserInfo()
  20474. errlog := &models.HisOrderError{
  20475. UserOrgId: adminUser.CurrentOrgId,
  20476. Ctime: time.Now().Unix(),
  20477. Mtime: time.Now().Unix(),
  20478. ErrMsg: res.ErrMsg,
  20479. Status: 1,
  20480. PatientId: id,
  20481. RecordTime: recordDateTime,
  20482. Stage: 4,
  20483. }
  20484. service.CreateErrMsgLog(errlog)
  20485. c.ServeSuccessJSON(map[string]interface{}{
  20486. "failed_code": -10,
  20487. "msg": res.ErrMsg,
  20488. })
  20489. return
  20490. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  20491. //return
  20492. }
  20493. }
  20494. }
  20495. } else if tempOrder.ID > 0 {
  20496. if tempOrder.IsPre == 1 {
  20497. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  20498. var rf []*ResultFive
  20499. json.Unmarshal([]byte(his.Iinfo), &rf)
  20500. chrg_bchno := tempOrder.Number
  20501. cert_no := his.Certno
  20502. var insutypes []string
  20503. var insutype string
  20504. var is390 int = 0
  20505. var is310 int = 0
  20506. for _, item := range rf {
  20507. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20508. insutypes = append(insutypes, item.Insutype)
  20509. }
  20510. }
  20511. if len(insutypes) == 1 {
  20512. insutype = insutypes[0]
  20513. } else {
  20514. for _, i := range insutypes {
  20515. if i == "390" {
  20516. is390 = 1
  20517. }
  20518. if i == "310" {
  20519. is310 = 1
  20520. }
  20521. }
  20522. }
  20523. if is390 == 1 {
  20524. insutype = "390"
  20525. }
  20526. if is310 == 1 {
  20527. insutype = "310"
  20528. }
  20529. if len(insutypes) == 0 {
  20530. insutype = "310"
  20531. }
  20532. if len(insutypes) == 2 {
  20533. insutype = strconv.FormatInt(his.SocialType, 10)
  20534. }
  20535. //insutype = "390"
  20536. if his.IdCardType == 1 {
  20537. // cert_no = his.MedicalInsuranceNumber
  20538. cert_no = his.Certno
  20539. } else {
  20540. cert_no = his.Certno
  20541. }
  20542. var res ResultSeven
  20543. var ahres ResultSevenAH
  20544. var resSeven10265 ResultSeven10265
  20545. var gzresSeven10265Two GZResultSeven10265Two
  20546. var src_resquest string
  20547. var result2 string
  20548. if miConfig.MdtrtareaAdmvs == "450721" {
  20549. res2 := c.GetoleInfo()
  20550. if res2.Infcode == 0 {
  20551. var result string
  20552. var request_log string
  20553. var result_log string
  20554. if res2.Output.MdtrtCertType == "02" {
  20555. 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)
  20556. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20557. } else if res2.Output.MdtrtCertType == "01" {
  20558. 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)
  20559. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20560. } else {
  20561. 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)
  20562. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20563. }
  20564. var dat map[string]interface{}
  20565. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20566. fmt.Println(dat)
  20567. } else {
  20568. fmt.Println(err)
  20569. }
  20570. userJSONBytes, _ := json.Marshal(dat)
  20571. var res5 ResultTwo
  20572. //var resTwo10265 ResultTwo10265
  20573. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20574. utils.ErrorLog("解析失败:%v", err)
  20575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20576. return
  20577. }
  20578. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  20579. if res5.Infcode == -1 {
  20580. c.ServeSuccessJSON(map[string]interface{}{
  20581. "failed_code": -10,
  20582. "msg": res5.ErrMsg,
  20583. })
  20584. return
  20585. }
  20586. var insutypes []string
  20587. var insutype string
  20588. var is390 int = 0
  20589. var is310 int = 0
  20590. for _, item := range res5.Output.Iinfo {
  20591. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20592. insutypes = append(insutypes, item.Insutype)
  20593. }
  20594. }
  20595. if len(insutypes) == 1 {
  20596. insutype = insutypes[0]
  20597. } else {
  20598. for _, i := range insutypes {
  20599. if i == "390" {
  20600. is390 = 1
  20601. }
  20602. if i == "310" {
  20603. is310 = 1
  20604. }
  20605. }
  20606. }
  20607. if is390 == 1 {
  20608. insutype = "390"
  20609. }
  20610. if is310 == 1 {
  20611. insutype = "310"
  20612. }
  20613. if len(insutypes) == 0 {
  20614. insutype = "310"
  20615. }
  20616. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20617. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20618. infoStr := string(Iinfos)
  20619. idetinfoStr := string(Idetinfos)
  20620. psn := &models.HisPsn{
  20621. PsnNo: res5.Output.Baseinfo.PsnNo,
  20622. PatientId: id,
  20623. Certno: res5.Output.Baseinfo.Certno,
  20624. Gend: res5.Output.Baseinfo.Gend,
  20625. Naty: res5.Output.Baseinfo.Naty,
  20626. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20627. PsnName: res5.Output.Baseinfo.PsnName,
  20628. Idetinfo: idetinfoStr,
  20629. Insuinfo: infoStr,
  20630. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20632. VerifyNumber: res2.Output.EcToken,
  20633. }
  20634. service.CreateHisPsn(psn)
  20635. if res2.Output.MdtrtCertType == "01" {
  20636. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20637. token := res2.Output.EcToken
  20638. 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)
  20639. } else if res2.Output.MdtrtCertType == "02" {
  20640. 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)
  20641. } else {
  20642. 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)
  20643. }
  20644. var dat2 map[string]interface{}
  20645. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20646. fmt.Println(dat2)
  20647. } else {
  20648. fmt.Println(err)
  20649. }
  20650. userJSONBytes3, _ := json.Marshal(dat2)
  20651. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20652. utils.ErrorLog("解析失败:%v", err)
  20653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20654. return
  20655. }
  20656. saveLog(result2, src_resquest, "2207", "结算")
  20657. } else {
  20658. c.ServeSuccessJSON(map[string]interface{}{
  20659. "failed_code": -10,
  20660. "msg": res2.ErrMsg,
  20661. })
  20662. return
  20663. }
  20664. } else if miConfig.MdtrtareaAdmvs == "421300" {
  20665. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20666. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20667. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20668. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20669. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20670. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20671. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20672. resp, requestErr := http.Get(api)
  20673. if requestErr != nil {
  20674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20675. return
  20676. }
  20677. body, ioErr := ioutil.ReadAll(resp.Body)
  20678. if ioErr != nil {
  20679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20681. return
  20682. }
  20683. var respJSON map[string]interface{}
  20684. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20687. return
  20688. }
  20689. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20690. result, _ := json.Marshal(respJSON)
  20691. fmt.Println("log")
  20692. fmt.Println(string(result))
  20693. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20694. utils.ErrorLog("解析失败:%v", err)
  20695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20696. return
  20697. }
  20698. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20699. if reg_type == 11 && his.Insutype == "390" {
  20700. reg_type = 110104
  20701. }
  20702. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20703. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20704. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20705. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20706. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20707. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20708. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20709. resp, requestErr := http.Get(api)
  20710. if requestErr != nil {
  20711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20712. return
  20713. }
  20714. body, ioErr := ioutil.ReadAll(resp.Body)
  20715. if ioErr != nil {
  20716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20718. return
  20719. }
  20720. var respJSON map[string]interface{}
  20721. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20724. return
  20725. }
  20726. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20727. result, _ := json.Marshal(respJSON)
  20728. fmt.Println("log")
  20729. fmt.Println(string(result))
  20730. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20731. utils.ErrorLog("解析失败:%v", err)
  20732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20733. return
  20734. }
  20735. } else if miConfig.MdtrtareaAdmvs == "420902" {
  20736. if reg_type == 11 && his.Insutype == "390" {
  20737. reg_type = 110104
  20738. }
  20739. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20740. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20741. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20742. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20743. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20744. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20745. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20746. resp, requestErr := http.Get(api)
  20747. if requestErr != nil {
  20748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20749. return
  20750. }
  20751. body, ioErr := ioutil.ReadAll(resp.Body)
  20752. if ioErr != nil {
  20753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20755. return
  20756. }
  20757. var respJSON map[string]interface{}
  20758. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20761. return
  20762. }
  20763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20764. result, _ := json.Marshal(respJSON)
  20765. fmt.Println("log")
  20766. fmt.Println(string(result))
  20767. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20768. utils.ErrorLog("解析失败:%v", err)
  20769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20770. return
  20771. }
  20772. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20773. if reg_type == 11 && his.Insutype == "390" {
  20774. reg_type = 110104
  20775. }
  20776. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20777. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20778. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20779. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20780. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20781. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20782. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20783. resp, requestErr := http.Get(api)
  20784. if requestErr != nil {
  20785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20786. return
  20787. }
  20788. body, ioErr := ioutil.ReadAll(resp.Body)
  20789. if ioErr != nil {
  20790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20792. return
  20793. }
  20794. var respJSON map[string]interface{}
  20795. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20798. return
  20799. }
  20800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20801. result, _ := json.Marshal(respJSON)
  20802. fmt.Println("log")
  20803. fmt.Println(string(result))
  20804. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20805. utils.ErrorLog("解析失败:%v", err)
  20806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20807. return
  20808. }
  20809. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20810. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  20811. if result3101.Infcode == "0" {
  20812. if len(result3101.Output.Result) > 0 {
  20813. var errMsgs []string
  20814. for _, item := range result3101.Output.Result {
  20815. errMsgs = append(errMsgs, item.VolaCont)
  20816. }
  20817. c.ServeSuccessJSON(map[string]interface{}{
  20818. "failed_code": -10,
  20819. "msg": errMsgs,
  20820. })
  20821. return
  20822. } else {
  20823. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20824. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20825. bas := strings.Split(psn_info.CardInfo, "|")
  20826. if his.IdCardType == 1 {
  20827. cert_no = bas[2]
  20828. } else if his.IdCardType == 3 {
  20829. cert_no = his.Certno
  20830. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20831. } else if his.IdCardType == 4 {
  20832. cert_no = his.Certno
  20833. psn_info.VerifyNumber = psn_info.VerifyNumber
  20834. }
  20835. //江苏地区国家医保医疗类别
  20836. //职工透析:医疗类别选特殊情况门诊9933
  20837. //居民血透门慢: 医疗类别选门诊慢病1402
  20838. //var med_type string
  20839. //if his.Insutype == "310" {
  20840. // if reg_type == 14 {
  20841. // med_type = "9933"
  20842. // } else if reg_type == 11 {
  20843. // med_type = "11"
  20844. //
  20845. // }
  20846. //} else if his.Insutype == "390" {
  20847. // if reg_type == 14 {
  20848. // med_type = "1402"
  20849. // } else if reg_type == 11 {
  20850. // med_type = "11"
  20851. // }
  20852. //}
  20853. var api string
  20854. if miConfig.MdtrtareaAdmvs == "320921" {
  20855. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20856. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20857. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20858. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20859. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20860. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20861. "&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
  20862. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20863. } else {
  20864. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20865. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20866. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20867. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20868. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20869. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20870. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20871. "&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
  20872. }
  20873. resp, requestErr := http.Get(api)
  20874. if requestErr != nil {
  20875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20876. return
  20877. }
  20878. body, ioErr := ioutil.ReadAll(resp.Body)
  20879. if ioErr != nil {
  20880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20882. return
  20883. }
  20884. var respJSON map[string]interface{}
  20885. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20888. return
  20889. }
  20890. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20891. result, _ := json.Marshal(respJSON)
  20892. fmt.Println("log")
  20893. fmt.Println(string(result))
  20894. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20895. utils.ErrorLog("解析失败:%v", err)
  20896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20897. return
  20898. }
  20899. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20900. res.Output = resSeven10265.Output
  20901. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20902. res.ErrMsg = resSeven10265.ErrMsg
  20903. res.Cainfo = resSeven10265.Cainfo
  20904. res.WarnMsg = resSeven10265.WarnMsg
  20905. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20906. res.Infcode = infocode
  20907. }
  20908. }
  20909. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20910. psn_info, _ := service.GetPsnByPatientId(id)
  20911. var verify_number string
  20912. if psn_info.IdCardType == 4 {
  20913. verify_number = psn_info.VerifyNumber
  20914. } else if psn_info.IdCardType == 1 {
  20915. bas := strings.Split(psn_info.CardInfo, "|")
  20916. cardNumber := bas[2]
  20917. verify_number = cardNumber
  20918. } else {
  20919. verify_number = psn_info.Certno
  20920. psn_info.IdCardType = 2
  20921. }
  20922. var api string
  20923. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20924. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20925. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20926. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20927. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20928. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20929. "&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
  20930. resp, requestErr := http.Get(api)
  20931. if requestErr != nil {
  20932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20933. return
  20934. }
  20935. body, ioErr := ioutil.ReadAll(resp.Body)
  20936. if ioErr != nil {
  20937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20939. return
  20940. }
  20941. var respJSON map[string]interface{}
  20942. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20945. return
  20946. }
  20947. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20948. result, _ := json.Marshal(respJSON)
  20949. fmt.Println("log")
  20950. fmt.Println(string(result))
  20951. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20952. utils.ErrorLog("解析失败:%v", err)
  20953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20954. return
  20955. }
  20956. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20957. res.Output = resSeven10265.Output
  20958. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20959. res.ErrMsg = resSeven10265.ErrMsg
  20960. res.Cainfo = resSeven10265.Cainfo
  20961. res.WarnMsg = resSeven10265.WarnMsg
  20962. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20963. res.Infcode = infocode
  20964. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20965. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20966. var cert_no string
  20967. if his.IdCardType == 1 {
  20968. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20969. } else {
  20970. cert_no = psn_info.VerifyNumber
  20971. }
  20972. 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)
  20973. var dat map[string]interface{}
  20974. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20975. fmt.Println(dat)
  20976. } else {
  20977. fmt.Println(err)
  20978. }
  20979. saveLog(result2, src_resquest, "2207", "结算")
  20980. userJSONBytes, _ := json.Marshal(dat)
  20981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20982. utils.ErrorLog("解析失败:%v", err)
  20983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20984. return
  20985. }
  20986. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20987. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20988. var cert_no string
  20989. var card_sn string
  20990. if his.IdCardType == 1 {
  20991. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20992. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20993. bas := strings.Split(psn_info.CardInfo, "|")
  20994. card_sn = bas[3]
  20995. } else if his.IdCardType == 2 {
  20996. cert_no = his.IdCardNo
  20997. } else {
  20998. cert_no = psn_info.VerifyNumber
  20999. }
  21000. var rf []*ResultFive
  21001. json.Unmarshal([]byte(his.Iinfo), &rf)
  21002. var psn_type string
  21003. for _, item := range rf {
  21004. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  21005. psn_type = item.PsnType
  21006. }
  21007. }
  21008. 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)
  21009. var dat map[string]interface{}
  21010. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21011. fmt.Println(dat)
  21012. } else {
  21013. fmt.Println(err)
  21014. }
  21015. saveLog(result2, src_resquest, "2207", "结算")
  21016. userJSONBytes, _ := json.Marshal(dat)
  21017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21018. utils.ErrorLog("解析失败:%v", err)
  21019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21020. return
  21021. }
  21022. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21023. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21024. if his.IdCardType == 1 {
  21025. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21026. bas := strings.Split(psn_info.CardInfo, "|")
  21027. cert_no = bas[2]
  21028. } else if his.IdCardType == 3 {
  21029. cert_no = his.Certno
  21030. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  21031. } else if his.IdCardType == 4 {
  21032. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21033. cert_no = his.Certno
  21034. psn_info.VerifyNumber = psn_info.VerifyNumber
  21035. } else {
  21036. cert_no = his.Certno
  21037. psn_info.VerifyNumber = his.Certno
  21038. }
  21039. var api string
  21040. var med_type string
  21041. if his.Insutype == "390" {
  21042. if reg_type == 992102 {
  21043. med_type = "992102"
  21044. }
  21045. if reg_type == 140104 {
  21046. med_type = "140104"
  21047. }
  21048. if reg_type == 14 {
  21049. med_type = "14"
  21050. }
  21051. } else if his.Insutype == "310" {
  21052. if reg_type == 992102 {
  21053. med_type = "992102"
  21054. }
  21055. if reg_type == 14 {
  21056. med_type = "14"
  21057. }
  21058. }
  21059. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21060. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21061. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21062. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21063. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21064. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21065. "&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
  21066. resp, requestErr := http.Get(api)
  21067. if requestErr != nil {
  21068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21069. return
  21070. }
  21071. body, ioErr := ioutil.ReadAll(resp.Body)
  21072. if ioErr != nil {
  21073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21075. return
  21076. }
  21077. var respJSON map[string]interface{}
  21078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21081. return
  21082. }
  21083. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21084. if status == "0" {
  21085. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21086. c.ServeSuccessJSON(map[string]interface{}{
  21087. "failed_code": -10,
  21088. "msg": err_msg,
  21089. })
  21090. return
  21091. }
  21092. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21093. result, _ := json.Marshal(respJSON)
  21094. fmt.Println("log")
  21095. fmt.Println(string(result))
  21096. if err := json.Unmarshal(result, &ahres); err != nil {
  21097. utils.ErrorLog("解析失败:%v", err)
  21098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21099. return
  21100. }
  21101. res.InfRefmsgid = ahres.InfRefmsgid
  21102. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  21103. // 创建对应的Time类型
  21104. t := time.UnixMilli(timestamp)
  21105. // 格式化成指定的日期字符串
  21106. str := t.Format("2006-01-02 15:04:05")
  21107. res.Output.Setlinfo.SetlTime = str
  21108. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  21109. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  21110. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21111. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  21112. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  21113. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  21114. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21115. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  21116. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  21117. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  21118. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  21119. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  21120. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21121. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  21122. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  21123. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  21124. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  21125. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  21126. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  21127. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21128. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  21129. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  21130. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  21131. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  21132. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  21133. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  21134. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  21135. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  21136. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  21137. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  21138. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  21139. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  21140. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  21141. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  21142. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  21143. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  21144. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  21145. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  21146. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  21147. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  21148. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  21149. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  21150. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  21151. res.Output.Setldetail = ahres.Output.Setldetail
  21152. res.ErrMsg = ahres.ErrMsg
  21153. res.Cainfo = ahres.Cainfo
  21154. res.WarnMsg = ahres.WarnMsg
  21155. res.Infcode = ahres.Infcode
  21156. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21157. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21158. var cert_no string
  21159. if his.IdCardType == 1 {
  21160. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  21161. } else if his.IdCardType == 2 {
  21162. cert_no = his.IdCardNo
  21163. } else {
  21164. cert_no = psn_info.VerifyNumber
  21165. }
  21166. 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, "")
  21167. var dat map[string]interface{}
  21168. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21169. fmt.Println(dat)
  21170. } else {
  21171. fmt.Println(err)
  21172. }
  21173. saveLog(result2, src_resquest, "2207", "结算")
  21174. userJSONBytes, _ := json.Marshal(dat)
  21175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21176. utils.ErrorLog("解析失败:%v", err)
  21177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21178. return
  21179. }
  21180. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21181. psn_info, _ := service.GetPsnByPatientId(id)
  21182. var verify_number string
  21183. if psn_info.IdCardType == 4 {
  21184. verify_number = psn_info.VerifyNumber
  21185. } else if psn_info.IdCardType == 1 {
  21186. bas := strings.Split(psn_info.CardInfo, "|")
  21187. cardNumber := bas[2]
  21188. verify_number = cardNumber
  21189. } else {
  21190. verify_number = psn_info.Certno
  21191. psn_info.IdCardType = 2
  21192. }
  21193. var api string
  21194. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21195. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21196. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21197. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21198. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21199. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21200. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  21201. resp, requestErr := http.Get(api)
  21202. if requestErr != nil {
  21203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21204. return
  21205. }
  21206. body, ioErr := ioutil.ReadAll(resp.Body)
  21207. if ioErr != nil {
  21208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21210. return
  21211. }
  21212. var respJSON map[string]interface{}
  21213. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21216. return
  21217. }
  21218. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21219. result, _ := json.Marshal(respJSON)
  21220. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21221. utils.ErrorLog("解析失败:%v", err)
  21222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21223. return
  21224. }
  21225. } else {
  21226. var src_resquest string
  21227. if miConfig.Code == "H15049901371" {
  21228. //赤峰地区国家医保医疗类别
  21229. //职工透析:医疗类别选特殊情况门诊990502
  21230. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21231. var med_type string
  21232. if his.Insutype == "390" {
  21233. if reg_type == 14 {
  21234. med_type = "9933"
  21235. } else if reg_type == 11 {
  21236. med_type = "11"
  21237. }
  21238. } else if his.Insutype == "310" {
  21239. if reg_type == 14 {
  21240. med_type = "990502"
  21241. } else if reg_type == 11 {
  21242. med_type = "11"
  21243. }
  21244. }
  21245. 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)
  21246. } else {
  21247. if his.IdCardType == 4 {
  21248. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21249. token := psn_info.VerifyNumber
  21250. 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)
  21251. } else {
  21252. 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)
  21253. }
  21254. }
  21255. var dat map[string]interface{}
  21256. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21257. fmt.Println(dat)
  21258. } else {
  21259. fmt.Println(err)
  21260. }
  21261. saveLog(result2, src_resquest, "2207", "结算")
  21262. userJSONBytes, _ := json.Marshal(dat)
  21263. if miConfig.Code == "H15049901371" {
  21264. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  21265. utils.ErrorLog("解析失败:%v", err)
  21266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21267. return
  21268. }
  21269. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21270. res.Output = resSeven10265.Output
  21271. res.ErrMsg = resSeven10265.ErrMsg
  21272. res.Cainfo = resSeven10265.Cainfo
  21273. res.WarnMsg = resSeven10265.WarnMsg
  21274. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21275. res.Infcode = infocode
  21276. } else {
  21277. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21278. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  21279. utils.ErrorLog("解析失败:%v", err)
  21280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21281. return
  21282. }
  21283. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  21284. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  21285. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  21286. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21287. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  21288. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  21289. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  21290. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21291. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  21292. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21293. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21294. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21295. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21296. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21297. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  21298. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  21299. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  21300. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  21301. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  21302. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  21303. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21304. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  21305. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  21306. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  21307. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  21308. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  21309. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  21310. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  21311. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  21312. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  21313. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  21314. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  21315. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  21316. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  21317. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21318. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  21319. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  21320. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  21321. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21322. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  21323. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  21324. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  21325. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  21326. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  21327. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  21328. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  21329. res.ErrMsg = gzresSeven10265Two.ErrMsg
  21330. res.Cainfo = gzresSeven10265Two.Cainfo
  21331. res.WarnMsg = gzresSeven10265Two.WarnMsg
  21332. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21333. //res.Infcode = infocode
  21334. } else {
  21335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21336. utils.ErrorLog("解析失败:%v", err)
  21337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21338. return
  21339. }
  21340. }
  21341. }
  21342. }
  21343. if res.Infcode != 0 {
  21344. errlog := &models.HisOrderError{
  21345. UserOrgId: adminUser.CurrentOrgId,
  21346. Ctime: time.Now().Unix(),
  21347. Mtime: time.Now().Unix(),
  21348. Number: chrg_bchno,
  21349. ErrMsg: res.ErrMsg,
  21350. Status: 1,
  21351. PatientId: id,
  21352. RecordTime: recordDateTime,
  21353. Stage: 6,
  21354. }
  21355. service.CreateErrMsgLog(errlog)
  21356. c.ServeSuccessJSON(map[string]interface{}{
  21357. "failed_code": -10,
  21358. "msg": res.ErrMsg,
  21359. })
  21360. return
  21361. } else {
  21362. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  21363. order.OrderStatus = 2
  21364. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  21365. order.SetlId = res.Output.Setlinfo.SetlID
  21366. order.PsnNo = res.Output.Setlinfo.PsnNo
  21367. order.PsnName = res.Output.Setlinfo.PsnName
  21368. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  21369. order.Certno = res.Output.Setlinfo.Certno
  21370. order.Gend = res.Output.Setlinfo.Gend
  21371. order.Naty = res.Output.Setlinfo.Naty
  21372. order.Age = res.Output.Setlinfo.Age
  21373. order.Insutype = res.Output.Setlinfo.Insutype
  21374. order.PsnType = res.Output.Setlinfo.PsnType
  21375. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  21376. order.SetlTime = res.Output.Setlinfo.SetlTime
  21377. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  21378. order.PayWays = pay_ways
  21379. order.AcctUsedFlag = acct_used_flag
  21380. order.WechatPay = wechat_pay
  21381. order.AliPay = ali_pay
  21382. order.JifenPay = jifen_pay
  21383. order.BandCardPay = band_card_pay
  21384. order.CashPay = cash_pay
  21385. order.OthDesc = oth_desc
  21386. //order.MedType = res.Output.Setlinfo.MedType
  21387. if reg_type == 1112 {
  21388. order.MedType = "1112"
  21389. }
  21390. if reg_type == 1111 {
  21391. order.MedType = "1111"
  21392. }
  21393. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  21394. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  21395. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  21396. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  21397. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  21398. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  21399. order.HifpPay = res.Output.Setlinfo.HifpPay
  21400. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  21401. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  21402. order.HifesPay = res.Output.Setlinfo.HifesPay
  21403. order.HifobPay = res.Output.Setlinfo.HifobPay
  21404. order.MafPay = res.Output.Setlinfo.MafPay
  21405. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  21406. order.OthPay = res.Output.Setlinfo.OthPay
  21407. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  21408. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  21409. order.AcctPay = res.Output.Setlinfo.AcctPay
  21410. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  21411. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  21412. order.Balc = res.Output.Setlinfo.Balc
  21413. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  21414. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  21415. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  21416. order.ClrWay = res.Output.Setlinfo.ClrWay
  21417. order.Creator = order.Creator
  21418. order.ClrType = res.Output.Setlinfo.ClrType
  21419. order.Modify = roles.AdminUserId
  21420. order.RequestLog = src_resquest
  21421. order.Diagnosis = diagnosis_id
  21422. order.FaPiaoNumber = fapiao_number
  21423. order.FaPiaoCode = fapiao_code
  21424. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21425. detailStr := string(setlDetail)
  21426. order.SetlDetail = detailStr
  21427. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21428. err = service.UpDateOrder(order)
  21429. if err == nil {
  21430. //判断是否使用了押金
  21431. if dec_way == "true" {
  21432. tmpstring := strconv.FormatInt(order.ID, 10)
  21433. //扣押金
  21434. order.Decimal = decimal
  21435. service.UpDateOrder(order)
  21436. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21437. if errmsg != nil {
  21438. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21439. return
  21440. }
  21441. }
  21442. c.ServeSuccessJSON(map[string]interface{}{
  21443. "msg": "结算成功",
  21444. })
  21445. } else {
  21446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21447. return
  21448. }
  21449. }
  21450. }
  21451. }
  21452. }
  21453. // 上传明细-预结算-
  21454. func (c *HisApiController) GetPreUploadInfo() {
  21455. id, _ := c.GetInt64("id")
  21456. record_time := c.GetString("record_time")
  21457. his_patient_id, _ := c.GetInt64("his_patient_id")
  21458. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  21459. admin_user_id, _ := c.GetInt64("admin_user_id")
  21460. diagnosis_id := c.GetString("diagnosis")
  21461. sick_type, _ := c.GetInt64("sick_type")
  21462. reg_type, _ := c.GetInt64("p_type")
  21463. begin_time := c.GetString("begin_time")
  21464. acct_used_flag := c.GetString("acct_used_flag")
  21465. id_str := c.GetString("ids")
  21466. ids_arr := strings.Split(id_str, ",")
  21467. timeLayout := "2006-01-02"
  21468. loc, _ := time.LoadLocation("Local")
  21469. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21470. if err != nil {
  21471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21472. return
  21473. }
  21474. recordDateTime := theTime.Unix()
  21475. adminUser := c.GetAdminUserInfo()
  21476. diagnosis_ids := strings.Split(diagnosis_id, ",")
  21477. var config []*models.HisXtDiagnoseConfig
  21478. for _, item := range diagnosis_ids {
  21479. id, _ := strconv.ParseInt(item, 10, 64)
  21480. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21481. config = append(config, &diagnosisConfig)
  21482. }
  21483. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  21484. sickConfig, _ := service.FindSickById(sick_type)
  21485. var prescriptions []*models.HisPrescription
  21486. var start_time int64
  21487. var end_time int64
  21488. var isSuccess bool = true
  21489. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21490. fmt.Println(his_patient_id)
  21491. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21492. timestamp := time.Now().Unix()
  21493. tempTime := time.Unix(timestamp, 0)
  21494. timeFormat := tempTime.Format("20060102150405")
  21495. chrgBchno := rand.Intn(100000) + 10000
  21496. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  21497. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21498. var patientPrescription models.HisPrescriptionInfo
  21499. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21500. if patientPrescription.ID == 0 {
  21501. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  21502. }
  21503. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21504. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  21505. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  21506. strconv.FormatInt(his.PatientId, 10)
  21507. var res2406 Result2406
  21508. //安徽单病种处理
  21509. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  21510. data := make(map[string]interface{})
  21511. client := &http.Client{}
  21512. data["psn_no"] = his.PsnNo
  21513. data["mdtrt_id"] = his.Number
  21514. data["operator"] = roles.UserName
  21515. data["cert_no"] = his.IdCardNo
  21516. data["org_name"] = miConfig.OrgName
  21517. data["psn_name"] = his.Name
  21518. data["ipt_otp_no"] = his.IptOtpNo
  21519. data["ipt_psn_sp_flag_type"] = "0901"
  21520. data["ipt_psn_sp_flag"] = "1"
  21521. data["fixmedins_code"] = miConfig.Code
  21522. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21523. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21524. data["url"] = miConfig.Url
  21525. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  21526. bytesData, _ := json.Marshal(data)
  21527. var req *http.Request
  21528. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  21529. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  21530. resp, _ := client.Do(req)
  21531. defer resp.Body.Close()
  21532. body, ioErr := ioutil.ReadAll(resp.Body)
  21533. if ioErr != nil {
  21534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21536. return
  21537. }
  21538. var respJSON map[string]interface{}
  21539. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21542. return
  21543. }
  21544. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21545. if status == "0" {
  21546. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21547. c.ServeSuccessJSON(map[string]interface{}{
  21548. "failed_code": -10,
  21549. "msg": err_msg,
  21550. })
  21551. return
  21552. }
  21553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21554. userJSONBytes, _ := json.Marshal(respJSON)
  21555. fmt.Println("log")
  21556. fmt.Println(string(userJSONBytes))
  21557. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  21558. utils.ErrorLog("解析失败:%v", err)
  21559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21560. return
  21561. }
  21562. }
  21563. if res2406.Infcode != 0 {
  21564. adminUser := c.GetAdminUserInfo()
  21565. errlog := &models.HisOrderError{
  21566. UserOrgId: adminUser.CurrentOrgId,
  21567. Ctime: time.Now().Unix(),
  21568. Mtime: time.Now().Unix(),
  21569. ErrMsg: res2406.ErrMsg,
  21570. Status: 1,
  21571. PatientId: id,
  21572. RecordTime: recordDateTime,
  21573. Stage: 3,
  21574. }
  21575. service.CreateErrMsgLog(errlog)
  21576. c.ServeSuccessJSON(map[string]interface{}{
  21577. "failed_code": -10,
  21578. "msg": res2406.ErrMsg,
  21579. })
  21580. return
  21581. }
  21582. var res2 ResultSix
  21583. var res3 GZResultSix
  21584. var resSix10265 ResultSix10265
  21585. //var time_stamp string
  21586. if miConfig.MdtrtareaAdmvs == "421300" {
  21587. data := make(map[string]interface{})
  21588. client := &http.Client{}
  21589. data["psn_no"] = his.PsnNo
  21590. data["mdtrt_id"] = his.Number
  21591. data["department"] = department.Name
  21592. data["org_name"] = miConfig.OrgName
  21593. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21594. data["doctor_id"] = doctor_info.DoctorNumber
  21595. data["doctor_name"] = roles.UserName
  21596. data["fixmedins_code"] = miConfig.Code
  21597. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21598. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21599. data["secret_key"] = miConfig.SecretKey
  21600. data["sick_code"] = sickConfig.CountryCode
  21601. data["sick_name"] = sickConfig.ClassName
  21602. data["begin_time"] = begin_time
  21603. data["dept"] = strconv.FormatInt(department.ID, 10)
  21604. data["config"] = config
  21605. data["opter"] = roles.UserName
  21606. fmt.Println(data)
  21607. bytesData, _ := json.Marshal(data)
  21608. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21609. resp, _ := client.Do(req)
  21610. defer resp.Body.Close()
  21611. body, ioErr := ioutil.ReadAll(resp.Body)
  21612. if ioErr != nil {
  21613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21615. return
  21616. }
  21617. var respJSON map[string]interface{}
  21618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21621. return
  21622. }
  21623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21624. userJSONBytes, _ := json.Marshal(respJSON)
  21625. fmt.Println("log")
  21626. fmt.Println(string(userJSONBytes))
  21627. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21628. utils.ErrorLog("解析失败:%v", err)
  21629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21630. return
  21631. }
  21632. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21633. data := make(map[string]interface{})
  21634. client := &http.Client{}
  21635. data["psn_no"] = his.PsnNo
  21636. data["mdtrt_id"] = his.Number
  21637. data["department"] = department.Name
  21638. data["org_name"] = miConfig.OrgName
  21639. if reg_type == 11 && his.Insutype == "390" {
  21640. data["med_type"] = "110104"
  21641. } else {
  21642. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21643. }
  21644. data["doctor_id"] = doctor_info.DoctorNumber
  21645. data["doctor_name"] = roles.UserName
  21646. data["fixmedins_code"] = miConfig.Code
  21647. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21648. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21649. data["secret_key"] = miConfig.SecretKey
  21650. data["sick_code"] = sickConfig.CountryCode
  21651. data["sick_name"] = sickConfig.ClassName
  21652. data["begin_time"] = begin_time
  21653. data["dept"] = strconv.FormatInt(department.ID, 10)
  21654. data["config"] = config
  21655. data["opter"] = roles.UserName
  21656. fmt.Println(data)
  21657. bytesData, _ := json.Marshal(data)
  21658. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21659. resp, _ := client.Do(req)
  21660. defer resp.Body.Close()
  21661. body, ioErr := ioutil.ReadAll(resp.Body)
  21662. if ioErr != nil {
  21663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21665. return
  21666. }
  21667. var respJSON map[string]interface{}
  21668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21671. return
  21672. }
  21673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21674. userJSONBytes, _ := json.Marshal(respJSON)
  21675. fmt.Println("log")
  21676. fmt.Println(string(userJSONBytes))
  21677. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21678. utils.ErrorLog("解析失败:%v", err)
  21679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21680. return
  21681. }
  21682. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21683. data := make(map[string]interface{})
  21684. client := &http.Client{}
  21685. data["psn_no"] = his.PsnNo
  21686. data["mdtrt_id"] = his.Number
  21687. data["department"] = department.Name
  21688. data["org_name"] = miConfig.OrgName
  21689. if reg_type == 11 && his.Insutype == "390" {
  21690. data["med_type"] = "110104"
  21691. } else {
  21692. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21693. }
  21694. data["doctor_id"] = doctor_info.DoctorNumber
  21695. data["doctor_name"] = roles.UserName
  21696. data["fixmedins_code"] = miConfig.Code
  21697. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21698. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21699. data["secret_key"] = miConfig.SecretKey
  21700. data["sick_code"] = sickConfig.CountryCode
  21701. data["sick_name"] = sickConfig.ClassName
  21702. data["begin_time"] = begin_time
  21703. data["dept"] = strconv.FormatInt(department.ID, 10)
  21704. data["config"] = config
  21705. data["opter"] = roles.UserName
  21706. fmt.Println(data)
  21707. bytesData, _ := json.Marshal(data)
  21708. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21709. resp, _ := client.Do(req)
  21710. defer resp.Body.Close()
  21711. body, ioErr := ioutil.ReadAll(resp.Body)
  21712. if ioErr != nil {
  21713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21715. return
  21716. }
  21717. var respJSON map[string]interface{}
  21718. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21721. return
  21722. }
  21723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21724. userJSONBytes, _ := json.Marshal(respJSON)
  21725. fmt.Println("log")
  21726. fmt.Println(string(userJSONBytes))
  21727. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21728. utils.ErrorLog("解析失败:%v", err)
  21729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21730. return
  21731. }
  21732. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21733. data := make(map[string]interface{})
  21734. client := &http.Client{}
  21735. data["psn_no"] = his.PsnNo
  21736. data["mdtrt_id"] = his.Number
  21737. data["department"] = department.Name
  21738. data["org_name"] = miConfig.OrgName
  21739. if reg_type == 11 && his.Insutype == "390" {
  21740. data["med_type"] = "110104"
  21741. } else {
  21742. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21743. }
  21744. data["doctor_id"] = doctor_info.DoctorNumber
  21745. data["doctor_name"] = roles.UserName
  21746. data["fixmedins_code"] = miConfig.Code
  21747. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21748. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21749. data["secret_key"] = miConfig.SecretKey
  21750. data["sick_code"] = sickConfig.CountryCode
  21751. data["sick_name"] = sickConfig.ClassName
  21752. data["begin_time"] = begin_time
  21753. data["dept"] = strconv.FormatInt(department.ID, 10)
  21754. data["config"] = config
  21755. data["opter"] = roles.UserName
  21756. fmt.Println(data)
  21757. bytesData, _ := json.Marshal(data)
  21758. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21759. resp, _ := client.Do(req)
  21760. defer resp.Body.Close()
  21761. body, ioErr := ioutil.ReadAll(resp.Body)
  21762. if ioErr != nil {
  21763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21765. return
  21766. }
  21767. var respJSON map[string]interface{}
  21768. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21771. return
  21772. }
  21773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21774. userJSONBytes, _ := json.Marshal(respJSON)
  21775. fmt.Println("log")
  21776. fmt.Println(string(userJSONBytes))
  21777. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21778. utils.ErrorLog("解析失败:%v", err)
  21779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21780. return
  21781. }
  21782. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21783. data := make(map[string]interface{})
  21784. client := &http.Client{}
  21785. data["psn_no"] = his.PsnNo
  21786. data["mdtrt_id"] = his.Number
  21787. data["doctor"] = roles.UserName
  21788. data["department"] = department.Name
  21789. data["org_name"] = miConfig.OrgName
  21790. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21791. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21792. data["fixmedins_code"] = miConfig.Code
  21793. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21794. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21795. data["secret_key"] = miConfig.SecretKey
  21796. data["sick_code"] = sickConfig.CountryCode
  21797. data["sick_name"] = sickConfig.ClassName
  21798. data["begin_time"] = begin_time
  21799. data["dept"] = strconv.FormatInt(department.ID, 10)
  21800. data["config"] = config
  21801. data["url"] = miConfig.Url
  21802. data["ak"] = miConfig.AccessKey
  21803. data["cainfo"] = miConfig.Cainfo
  21804. bytesData, _ := json.Marshal(data)
  21805. var req *http.Request
  21806. if miConfig.MdtrtareaAdmvs == "320921" {
  21807. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21808. } else {
  21809. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21810. }
  21811. resp, _ := client.Do(req)
  21812. defer resp.Body.Close()
  21813. body, ioErr := ioutil.ReadAll(resp.Body)
  21814. if ioErr != nil {
  21815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21817. return
  21818. }
  21819. var respJSON map[string]interface{}
  21820. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21823. return
  21824. }
  21825. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21826. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21827. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21829. userJSONBytes, _ := json.Marshal(respJSON)
  21830. fmt.Println("log")
  21831. fmt.Println(string(userJSONBytes))
  21832. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21833. utils.ErrorLog("解析失败:%v", err)
  21834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21835. return
  21836. }
  21837. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21838. res2.Output = resSix10265.Output
  21839. res2.ErrMsg = resSix10265.ErrMsg
  21840. res2.Cainfo = resSix10265.Cainfo
  21841. res2.WarnMsg = resSix10265.WarnMsg
  21842. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21843. res2.Infcode = infocode
  21844. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21845. data := make(map[string]interface{})
  21846. client := &http.Client{}
  21847. data["psn_no"] = his.PsnNo
  21848. data["mdtrt_id"] = his.Number
  21849. data["doctor"] = roles.UserName
  21850. data["department"] = department.Name
  21851. data["org_name"] = miConfig.OrgName
  21852. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21853. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21854. data["fixmedins_code"] = miConfig.Code
  21855. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21856. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21857. data["secret_key"] = miConfig.SecretKey
  21858. data["sick_code"] = sickConfig.CountryCode
  21859. data["sick_name"] = sickConfig.ClassName
  21860. data["begin_time"] = begin_time
  21861. data["dept"] = strconv.FormatInt(department.ID, 10)
  21862. data["config"] = config
  21863. //data["url"] = miConfig.Url
  21864. //data["ak"] = miConfig.AccessKey
  21865. data["cainfo"] = miConfig.Cainfo
  21866. fmt.Println(data)
  21867. bytesData, _ := json.Marshal(data)
  21868. var req *http.Request
  21869. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  21870. resp, _ := client.Do(req)
  21871. defer resp.Body.Close()
  21872. body, ioErr := ioutil.ReadAll(resp.Body)
  21873. if ioErr != nil {
  21874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21876. return
  21877. }
  21878. var respJSON map[string]interface{}
  21879. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21882. return
  21883. }
  21884. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21885. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21886. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21888. userJSONBytes, _ := json.Marshal(respJSON)
  21889. fmt.Println("log")
  21890. fmt.Println(string(userJSONBytes))
  21891. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21892. utils.ErrorLog("解析失败:%v", err)
  21893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21894. return
  21895. }
  21896. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21897. res2.Output = resSix10265.Output
  21898. res2.ErrMsg = resSix10265.ErrMsg
  21899. res2.Cainfo = resSix10265.Cainfo
  21900. res2.WarnMsg = resSix10265.WarnMsg
  21901. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21902. res2.Infcode = infocode
  21903. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21904. 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)
  21905. saveLog(result, requestLog, "2203", "上传就诊信息")
  21906. var respJSON2 map[string]interface{}
  21907. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21910. return
  21911. }
  21912. userJSONBytes2, _ := json.Marshal(respJSON2)
  21913. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21914. utils.ErrorLog("解析失败:%v", err)
  21915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21916. return
  21917. }
  21918. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21919. var result string
  21920. var requestLog string
  21921. 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, "")
  21922. saveLog(result, requestLog, "2203", "上传就诊信息")
  21923. var respJSON2 map[string]interface{}
  21924. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21927. return
  21928. }
  21929. userJSONBytes2, _ := json.Marshal(respJSON2)
  21930. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21931. utils.ErrorLog("解析失败:%v", err)
  21932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21933. return
  21934. }
  21935. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21936. data := make(map[string]interface{})
  21937. client := &http.Client{}
  21938. data["psn_no"] = his.PsnNo
  21939. data["mdtrt_id"] = his.Number
  21940. data["operator"] = roles.UserName
  21941. data["department"] = department.Name
  21942. data["org_name"] = miConfig.OrgName
  21943. var med_type string
  21944. if his.Insutype == "390" {
  21945. if reg_type == 992102 {
  21946. med_type = "992102"
  21947. data["sick_code"] = "ZDZ940"
  21948. data["sick_name"] = "慢性肾衰竭"
  21949. }
  21950. if reg_type == 140104 {
  21951. med_type = "140104"
  21952. data["sick_code"] = sickConfig.CountryCode
  21953. data["sick_name"] = sickConfig.ClassName
  21954. }
  21955. if reg_type == 14 {
  21956. med_type = "140104"
  21957. data["sick_code"] = sickConfig.CountryCode
  21958. data["sick_name"] = sickConfig.ClassName
  21959. }
  21960. } else if his.Insutype == "310" {
  21961. if reg_type == 992102 {
  21962. med_type = "992102"
  21963. data["sick_code"] = "ZDZ940"
  21964. data["sick_name"] = "慢性肾衰竭"
  21965. }
  21966. if reg_type == 140104 {
  21967. med_type = "140104"
  21968. data["sick_code"] = sickConfig.CountryCode
  21969. data["sick_name"] = sickConfig.ClassName
  21970. }
  21971. if reg_type == 14 {
  21972. med_type = "14"
  21973. data["sick_code"] = sickConfig.CountryCode
  21974. data["sick_name"] = sickConfig.ClassName
  21975. }
  21976. }
  21977. data["med_type"] = med_type
  21978. data["doctor_number"] = doctor_info.DoctorNumber
  21979. data["doctor_name"] = doctor_info.UserName
  21980. data["fixmedins_code"] = miConfig.Code
  21981. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21982. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21983. data["secret_key"] = miConfig.SecretKey
  21984. data["begin_time"] = begin_time
  21985. data["dept"] = strconv.FormatInt(department.ID, 10)
  21986. data["config"] = config
  21987. data["url"] = miConfig.Url
  21988. data["ak"] = miConfig.AccessKey
  21989. data["cainfo"] = miConfig.Cainfo
  21990. bytesData, _ := json.Marshal(data)
  21991. var req *http.Request
  21992. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  21993. resp, _ := client.Do(req)
  21994. defer resp.Body.Close()
  21995. body, ioErr := ioutil.ReadAll(resp.Body)
  21996. if ioErr != nil {
  21997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21999. return
  22000. }
  22001. var respJSON map[string]interface{}
  22002. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22005. return
  22006. }
  22007. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22008. if status == "0" {
  22009. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22010. c.ServeSuccessJSON(map[string]interface{}{
  22011. "failed_code": -10,
  22012. "msg": err_msg,
  22013. })
  22014. return
  22015. }
  22016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22017. userJSONBytes, _ := json.Marshal(respJSON)
  22018. fmt.Println("log")
  22019. fmt.Println(string(userJSONBytes))
  22020. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22021. utils.ErrorLog("解析失败:%v", err)
  22022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22023. return
  22024. }
  22025. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22026. var result string
  22027. var requestLog string
  22028. 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, "")
  22029. saveLog(result, requestLog, "2203", "上传就诊信息")
  22030. var respJSON2 map[string]interface{}
  22031. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22034. return
  22035. }
  22036. userJSONBytes2, _ := json.Marshal(respJSON2)
  22037. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22038. utils.ErrorLog("解析失败:%v", err)
  22039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22040. return
  22041. }
  22042. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22043. data := make(map[string]interface{})
  22044. client := &http.Client{}
  22045. data["psn_no"] = his.PsnNo
  22046. data["mdtrt_id"] = his.Number
  22047. data["doctor"] = roles.UserName
  22048. data["department"] = department.Name
  22049. data["org_name"] = miConfig.OrgName
  22050. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22051. data["doctor_id"] = doctor_info.DoctorNumber
  22052. data["fixmedins_code"] = miConfig.Code
  22053. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22054. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22055. data["secret_key"] = miConfig.SecretKey
  22056. data["sick_code"] = sickConfig.CountryCode
  22057. data["sick_name"] = sickConfig.ClassName
  22058. data["begin_time"] = begin_time
  22059. data["new_doctor_name"] = doctor_info.UserName
  22060. data["dept"] = strconv.FormatInt(department.ID, 10)
  22061. data["config"] = config
  22062. bytesData, _ := json.Marshal(data)
  22063. var req *http.Request
  22064. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  22065. resp, _ := client.Do(req)
  22066. defer resp.Body.Close()
  22067. body, ioErr := ioutil.ReadAll(resp.Body)
  22068. if ioErr != nil {
  22069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22071. return
  22072. }
  22073. var respJSON map[string]interface{}
  22074. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22077. return
  22078. }
  22079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22080. userJSONBytes, _ := json.Marshal(respJSON)
  22081. fmt.Println("log")
  22082. fmt.Println(string(userJSONBytes))
  22083. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22084. utils.ErrorLog("解析失败:%v", err)
  22085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22086. return
  22087. }
  22088. } else {
  22089. var result string
  22090. var requestLog string
  22091. if miConfig.MdtrtareaAdmvs == "440781" { //
  22092. 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)
  22093. } else {
  22094. if miConfig.Code == "H15049901371" {
  22095. //赤峰地区国家医保医疗类别
  22096. //职工透析:医疗类别选特殊情况门诊990502
  22097. //居民定额血透门慢: 医疗类别选门诊慢病140104
  22098. var med_type string
  22099. if his.Insutype == "390" {
  22100. if reg_type == 14 {
  22101. med_type = "9933"
  22102. } else if reg_type == 11 {
  22103. med_type = "11"
  22104. }
  22105. } else if his.Insutype == "310" {
  22106. if reg_type == 14 {
  22107. med_type = "990502"
  22108. } else if reg_type == 11 {
  22109. med_type = "11"
  22110. }
  22111. }
  22112. 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)
  22113. } else {
  22114. 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)
  22115. }
  22116. saveLog(result, requestLog, "2203", "上传就诊信息")
  22117. var respJSON2 map[string]interface{}
  22118. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22121. return
  22122. }
  22123. userJSONBytes2, _ := json.Marshal(respJSON2)
  22124. if miConfig.Code == "H15049901371" {
  22125. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  22126. utils.ErrorLog("解析失败:%v", err)
  22127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22128. return
  22129. }
  22130. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22131. res2.Output = resSix10265.Output
  22132. res2.ErrMsg = resSix10265.ErrMsg
  22133. res2.Cainfo = resSix10265.Cainfo
  22134. res2.WarnMsg = resSix10265.WarnMsg
  22135. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22136. res2.Infcode = infocode
  22137. } else {
  22138. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22139. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  22140. utils.ErrorLog("解析失败:%v", err)
  22141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22142. return
  22143. }
  22144. res2.Infcode = res3.Infcode
  22145. } else {
  22146. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22147. utils.ErrorLog("解析失败:%v", err)
  22148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22149. return
  22150. }
  22151. }
  22152. }
  22153. }
  22154. }
  22155. if res2.Infcode == -1 {
  22156. adminUser := c.GetAdminUserInfo()
  22157. errlog := &models.HisOrderError{
  22158. UserOrgId: adminUser.CurrentOrgId,
  22159. Ctime: time.Now().Unix(),
  22160. Mtime: time.Now().Unix(),
  22161. ErrMsg: res2.ErrMsg,
  22162. Status: 1,
  22163. PatientId: id,
  22164. RecordTime: recordDateTime,
  22165. Stage: 3,
  22166. }
  22167. service.CreateErrMsgLog(errlog)
  22168. c.ServeSuccessJSON(map[string]interface{}{
  22169. "failed_code": -10,
  22170. "msg": res2.ErrMsg,
  22171. })
  22172. return
  22173. }
  22174. if res2.Infcode != 0 {
  22175. adminUser := c.GetAdminUserInfo()
  22176. errlog := &models.HisOrderError{
  22177. UserOrgId: adminUser.CurrentOrgId,
  22178. Ctime: time.Now().Unix(),
  22179. Mtime: time.Now().Unix(),
  22180. ErrMsg: res2.ErrMsg,
  22181. Status: 1,
  22182. PatientId: id,
  22183. RecordTime: recordDateTime,
  22184. Stage: 3,
  22185. }
  22186. service.CreateErrMsgLog(errlog)
  22187. c.ServeSuccessJSON(map[string]interface{}{
  22188. "failed_code": -10,
  22189. "msg": res2.ErrMsg,
  22190. })
  22191. return
  22192. } else {
  22193. his.Diagnosis = diagnosis_id
  22194. his.SickType = sickConfig.ID
  22195. his.PType = fmt.Sprintf("%d", reg_type)
  22196. service.UpdateHisPatientThree(&his)
  22197. data := make(map[string]interface{})
  22198. if settle_accounts_type == 1 { //日结
  22199. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  22200. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  22201. } else {
  22202. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  22203. }
  22204. data["pre"] = prescriptions
  22205. } else { //月结
  22206. start_time_str := c.GetString("start_time")
  22207. end_time_str := c.GetString("end_time")
  22208. timeLayout := "2006-01-02"
  22209. loc, _ := time.LoadLocation("Local")
  22210. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  22211. if err != nil {
  22212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22213. return
  22214. }
  22215. recordStartTime := theStartTime.Unix()
  22216. start_time = recordStartTime
  22217. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  22218. if err != nil {
  22219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22220. return
  22221. }
  22222. recordEndTime := theEndTime.Unix()
  22223. end_time = recordEndTime
  22224. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  22225. data["pre"] = prescriptions
  22226. }
  22227. client := &http.Client{}
  22228. data["psn_no"] = his.PsnNo
  22229. data["mdtrt_id"] = his.Number
  22230. data["chrg_bchno"] = chrg_bchno
  22231. data["org_name"] = miConfig.OrgName
  22232. data["doctor"] = doctor_info.UserName
  22233. data["doctor_id"] = doctor_info.DoctorNumber
  22234. data["dept"] = department.Name
  22235. data["fixmedins_code"] = miConfig.Code
  22236. data["opter"] = roles.UserName
  22237. data["dept_code"] = department.Number
  22238. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22239. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22240. data["secret_key"] = miConfig.SecretKey
  22241. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  22242. data["url"] = miConfig.Url
  22243. data["ak"] = miConfig.AccessKey
  22244. data["new_doctor_name"] = patientPrescription.Doctor
  22245. if his.Insutype == "390" {
  22246. if reg_type == 992102 {
  22247. data["diag_code"] = "ZDZ940"
  22248. }
  22249. if reg_type == 140104 {
  22250. data["diag_code"] = sickConfig.CountryCode
  22251. }
  22252. if reg_type == 14 {
  22253. data["diag_code"] = sickConfig.CountryCode
  22254. }
  22255. } else if his.Insutype == "310" {
  22256. if reg_type == 992102 {
  22257. data["diag_code"] = "ZDZ940"
  22258. }
  22259. if reg_type == 14 {
  22260. data["diag_code"] = sickConfig.CountryCode
  22261. }
  22262. }
  22263. data["cainfo"] = miConfig.Cainfo
  22264. data["opter"] = roles.UserName
  22265. var ids []int64
  22266. for _, item := range prescriptions {
  22267. ids = append(ids, item.ID)
  22268. }
  22269. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22270. if config.IsOpen == 1 { //对接了医保,走医保流程
  22271. var res ResultFour
  22272. var resFour10265 ResultFour10265
  22273. if miConfig.MdtrtareaAdmvs == "421300" {
  22274. bytesData, _ := json.Marshal(data)
  22275. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22276. resp, _ := client.Do(req)
  22277. defer resp.Body.Close()
  22278. body, ioErr := ioutil.ReadAll(resp.Body)
  22279. if ioErr != nil {
  22280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22282. return
  22283. }
  22284. var respJSON map[string]interface{}
  22285. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22288. return
  22289. }
  22290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22291. userJSONBytes, _ := json.Marshal(respJSON)
  22292. fmt.Println("log")
  22293. fmt.Println(string(userJSONBytes))
  22294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22295. utils.ErrorLog("解析失败:%v", err)
  22296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22297. return
  22298. }
  22299. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22300. bytesData, _ := json.Marshal(data)
  22301. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22302. resp, _ := client.Do(req)
  22303. defer resp.Body.Close()
  22304. body, ioErr := ioutil.ReadAll(resp.Body)
  22305. if ioErr != nil {
  22306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22308. return
  22309. }
  22310. var respJSON map[string]interface{}
  22311. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22314. return
  22315. }
  22316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22317. userJSONBytes, _ := json.Marshal(respJSON)
  22318. fmt.Println("log")
  22319. fmt.Println(string(userJSONBytes))
  22320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22321. utils.ErrorLog("解析失败:%v", err)
  22322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22323. return
  22324. }
  22325. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22326. bytesData, _ := json.Marshal(data)
  22327. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22328. resp, _ := client.Do(req)
  22329. defer resp.Body.Close()
  22330. body, ioErr := ioutil.ReadAll(resp.Body)
  22331. if ioErr != nil {
  22332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22334. return
  22335. }
  22336. var respJSON map[string]interface{}
  22337. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22340. return
  22341. }
  22342. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22343. userJSONBytes, _ := json.Marshal(respJSON)
  22344. fmt.Println("log")
  22345. fmt.Println(string(userJSONBytes))
  22346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22347. utils.ErrorLog("解析失败:%v", err)
  22348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22349. return
  22350. }
  22351. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22352. bytesData, _ := json.Marshal(data)
  22353. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22354. resp, _ := client.Do(req)
  22355. defer resp.Body.Close()
  22356. body, ioErr := ioutil.ReadAll(resp.Body)
  22357. if ioErr != nil {
  22358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22360. return
  22361. }
  22362. var respJSON map[string]interface{}
  22363. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22366. return
  22367. }
  22368. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22369. userJSONBytes, _ := json.Marshal(respJSON)
  22370. fmt.Println("log")
  22371. fmt.Println(string(userJSONBytes))
  22372. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22373. utils.ErrorLog("解析失败:%v", err)
  22374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22375. return
  22376. }
  22377. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22378. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22379. if result3101.Infcode == "0" {
  22380. if len(result3101.Output.Result) > 0 {
  22381. var errMsgs []string
  22382. for _, item := range result3101.Output.Result {
  22383. errMsgs = append(errMsgs, item.VolaCont)
  22384. }
  22385. c.ServeSuccessJSON(map[string]interface{}{
  22386. "failed_code": -10,
  22387. "msg": errMsgs,
  22388. })
  22389. return
  22390. } else {
  22391. if miConfig.MdtrtareaAdmvs == "320921" {
  22392. data["doctor_id"] = "D320923012139"
  22393. } else {
  22394. data["doctor_id"] = "D371621008686"
  22395. }
  22396. bytesData, _ := json.Marshal(data)
  22397. var req *http.Request
  22398. if miConfig.MdtrtareaAdmvs == "320921" {
  22399. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22400. } else {
  22401. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22402. }
  22403. resp, _ := client.Do(req)
  22404. defer resp.Body.Close()
  22405. body, ioErr := ioutil.ReadAll(resp.Body)
  22406. if ioErr != nil {
  22407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22409. return
  22410. }
  22411. var respJSON map[string]interface{}
  22412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22415. return
  22416. }
  22417. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22418. userJSONBytes, _ := json.Marshal(respJSON)
  22419. fmt.Println("log")
  22420. fmt.Println(string(userJSONBytes))
  22421. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22422. utils.ErrorLog("解析失败:%v", err)
  22423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22424. return
  22425. }
  22426. res.InfRefmsgid = resFour10265.InfRefmsgid
  22427. res.Output = resFour10265.Output
  22428. res.ErrMsg = resFour10265.ErrMsg
  22429. res.Cainfo = resFour10265.Cainfo
  22430. res.WarnMsg = resFour10265.WarnMsg
  22431. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22432. res.Infcode = infocode
  22433. }
  22434. }
  22435. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22436. var pagesize int = 5
  22437. var start int = 1
  22438. var stop int
  22439. var pagecount int
  22440. var curpage int
  22441. data["doctor_id"] = doctor_info.DoctorNumber
  22442. var res2 ResultFour
  22443. //var result res.
  22444. //总页数,向上取整,注意除之前要先转换类型为float64
  22445. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  22446. for curpage = 1; curpage <= pagecount; curpage++ {
  22447. if curpage == 1 {
  22448. start = 1
  22449. } else {
  22450. start = (curpage-1)*pagesize + 1
  22451. }
  22452. stop = curpage * pagesize
  22453. if stop > len(prescriptions) {
  22454. stop = len(prescriptions)
  22455. }
  22456. //var requestLog string
  22457. data["pre"] = prescriptions[start-1 : stop]
  22458. fmt.Println(data["pre"])
  22459. bytesData, _ := json.Marshal(data)
  22460. var req *http.Request
  22461. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  22462. resp, _ := client.Do(req)
  22463. defer resp.Body.Close()
  22464. body, ioErr := ioutil.ReadAll(resp.Body)
  22465. if ioErr != nil {
  22466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22468. return
  22469. }
  22470. var respJSON map[string]interface{}
  22471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22474. return
  22475. }
  22476. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22477. userJSONBytes, _ := json.Marshal(respJSON)
  22478. fmt.Println("log")
  22479. fmt.Println(string(userJSONBytes))
  22480. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22481. utils.ErrorLog("解析失败:%v", err)
  22482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22483. return
  22484. }
  22485. res.InfRefmsgid = resFour10265.InfRefmsgid
  22486. res.Output = resFour10265.Output
  22487. res.ErrMsg = resFour10265.ErrMsg
  22488. res.Cainfo = resFour10265.Cainfo
  22489. res.WarnMsg = resFour10265.WarnMsg
  22490. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22491. res.Infcode = infocode
  22492. if infocode == 0 {
  22493. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  22494. } else {
  22495. isSuccess = false
  22496. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  22497. res.Infcode = -1
  22498. res.ErrMsg = resFour10265.ErrMsg
  22499. errlog := &models.HisOrderError{
  22500. UserOrgId: adminUser.CurrentOrgId,
  22501. Ctime: time.Now().Unix(),
  22502. Mtime: time.Now().Unix(),
  22503. Number: chrg_bchno,
  22504. ErrMsg: "",
  22505. Status: 1,
  22506. PatientId: id,
  22507. RecordTime: recordDateTime,
  22508. Stage: 4,
  22509. }
  22510. service.CreateErrMsgLog(errlog)
  22511. }
  22512. }
  22513. if isSuccess {
  22514. res.Infcode = 0
  22515. res.Output.Result = res2.Output.Result
  22516. } else {
  22517. order := &models.HisOrder{
  22518. UserOrgId: adminUser.CurrentOrgId,
  22519. HisPatientId: his.ID,
  22520. PatientId: his.PatientId,
  22521. SettleAccountsDate: recordDateTime,
  22522. Ctime: time.Now().Unix(),
  22523. Mtime: time.Now().Unix(),
  22524. MdtrtId: his.Number,
  22525. PsnNo: his.PsnNo,
  22526. MedType: strconv.FormatInt(reg_type, 10),
  22527. Status: 1,
  22528. Number: chrg_bchno,
  22529. Infcode: res.Infcode,
  22530. WarnMsg: res.WarnMsg,
  22531. Cainfo: res.Cainfo,
  22532. ErrMsg: res.ErrMsg,
  22533. RespondTime: res.RefmsgTime,
  22534. InfRefmsgid: res.InfRefmsgid,
  22535. OrderStatus: 1,
  22536. IsMedicineInsurance: 1,
  22537. SettleType: settle_accounts_type,
  22538. SettleStartTime: start_time,
  22539. SettleEndTime: end_time,
  22540. Creator: roles.AdminUserId,
  22541. Modify: roles.AdminUserId,
  22542. PType: 2,
  22543. Diagnosis: diagnosis_id,
  22544. }
  22545. err = service.CreateOrder(order)
  22546. if err != nil {
  22547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22548. return
  22549. }
  22550. c.ServeSuccessJSON(map[string]interface{}{
  22551. "failed_code": -10,
  22552. "msg": res2.ErrMsg,
  22553. })
  22554. return
  22555. }
  22556. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22557. 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)
  22558. var dat map[string]interface{}
  22559. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22560. fmt.Println(dat)
  22561. } else {
  22562. fmt.Println(err)
  22563. }
  22564. saveLog(result, request_log, "2204", "上传费用明细")
  22565. userJSONBytes, _ := json.Marshal(dat)
  22566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22567. utils.ErrorLog("解析失败:%v", err)
  22568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22569. return
  22570. }
  22571. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22572. 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, "", "")
  22573. var dat map[string]interface{}
  22574. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22575. fmt.Println(dat)
  22576. } else {
  22577. fmt.Println(err)
  22578. }
  22579. saveLog(result, request_log, "2204", "上传费用明细")
  22580. userJSONBytes, _ := json.Marshal(dat)
  22581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22582. utils.ErrorLog("解析失败:%v", err)
  22583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22584. return
  22585. }
  22586. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22587. bytesData, _ := json.Marshal(data)
  22588. var req *http.Request
  22589. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  22590. resp, _ := client.Do(req)
  22591. defer resp.Body.Close()
  22592. body, ioErr := ioutil.ReadAll(resp.Body)
  22593. if ioErr != nil {
  22594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22596. return
  22597. }
  22598. var respJSON map[string]interface{}
  22599. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22602. return
  22603. }
  22604. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22605. if status == "0" {
  22606. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22607. c.ServeSuccessJSON(map[string]interface{}{
  22608. "failed_code": -10,
  22609. "msg": err_msg,
  22610. })
  22611. return
  22612. }
  22613. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22614. userJSONBytes, _ := json.Marshal(respJSON)
  22615. fmt.Println("log")
  22616. fmt.Println(string(userJSONBytes))
  22617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22618. utils.ErrorLog("解析失败:%v", err)
  22619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22620. return
  22621. }
  22622. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22623. 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, "", "")
  22624. var dat map[string]interface{}
  22625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22626. fmt.Println(dat)
  22627. } else {
  22628. fmt.Println(err)
  22629. }
  22630. saveLog(result, request_log, "2204", "上传费用明细")
  22631. userJSONBytes, _ := json.Marshal(dat)
  22632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22633. utils.ErrorLog("解析失败:%v", err)
  22634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22635. return
  22636. }
  22637. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22638. bytesData, _ := json.Marshal(data)
  22639. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  22640. resp, _ := client.Do(req)
  22641. defer resp.Body.Close()
  22642. body, ioErr := ioutil.ReadAll(resp.Body)
  22643. if ioErr != nil {
  22644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22646. return
  22647. }
  22648. var respJSON map[string]interface{}
  22649. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22652. return
  22653. }
  22654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22655. userJSONBytes, _ := json.Marshal(respJSON)
  22656. fmt.Println("log")
  22657. fmt.Println(string(userJSONBytes))
  22658. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22659. utils.ErrorLog("解析失败:%v", err)
  22660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22661. return
  22662. }
  22663. } else {
  22664. if miConfig.MdtrtareaAdmvs == "441202" {
  22665. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22666. if result3101.Infcode == 0 {
  22667. if len(result3101.Output.Result) > 0 {
  22668. var errMsgs []string
  22669. for _, item := range result3101.Output.Result {
  22670. errMsgs = append(errMsgs, item.VolaCont)
  22671. }
  22672. c.ServeSuccessJSON(map[string]interface{}{
  22673. "failed_code": -10,
  22674. "msg": errMsgs,
  22675. })
  22676. return
  22677. } else {
  22678. 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)
  22679. var dat map[string]interface{}
  22680. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22681. fmt.Println(dat)
  22682. } else {
  22683. fmt.Println(err)
  22684. }
  22685. saveLog(result, request_log, "2204", "上传费用明细")
  22686. userJSONBytes, _ := json.Marshal(dat)
  22687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22688. utils.ErrorLog("解析失败:%v", err)
  22689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22690. return
  22691. }
  22692. }
  22693. } else {
  22694. c.ServeSuccessJSON(map[string]interface{}{
  22695. "failed_code": -10,
  22696. "msg": result3101.ErrMsg,
  22697. })
  22698. return
  22699. }
  22700. } else {
  22701. if miConfig.Code == "H15049901371" {
  22702. 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)
  22703. var dat map[string]interface{}
  22704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22705. fmt.Println(dat)
  22706. } else {
  22707. fmt.Println(err)
  22708. }
  22709. saveLog(result, request_log, "2204", "上传费用明细")
  22710. userJSONBytes, _ := json.Marshal(dat)
  22711. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22712. utils.ErrorLog("解析失败:%v", err)
  22713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22714. return
  22715. }
  22716. res.InfRefmsgid = resFour10265.InfRefmsgid
  22717. res.Output = resFour10265.Output
  22718. res.ErrMsg = resFour10265.ErrMsg
  22719. res.Cainfo = resFour10265.Cainfo
  22720. res.WarnMsg = resFour10265.WarnMsg
  22721. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22722. res.Infcode = infocode
  22723. } else {
  22724. 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)
  22725. var dat map[string]interface{}
  22726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22727. fmt.Println(dat)
  22728. } else {
  22729. fmt.Println(err)
  22730. }
  22731. saveLog(result, request_log, "2204", "上传费用明细")
  22732. userJSONBytes, _ := json.Marshal(dat)
  22733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22734. utils.ErrorLog("解析失败:%v", err)
  22735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22736. return
  22737. }
  22738. }
  22739. }
  22740. }
  22741. var total_two float64
  22742. if res.Infcode == 0 {
  22743. order := &models.HisOrder{
  22744. UserOrgId: adminUser.CurrentOrgId,
  22745. HisPatientId: his.ID,
  22746. PatientId: his.PatientId,
  22747. SettleAccountsDate: recordDateTime,
  22748. Ctime: time.Now().Unix(),
  22749. Mtime: time.Now().Unix(),
  22750. MdtrtId: his.Number,
  22751. PsnNo: his.PsnNo,
  22752. MedType: strconv.FormatInt(reg_type, 10),
  22753. Status: 1,
  22754. Number: chrg_bchno,
  22755. Infcode: res.Infcode,
  22756. WarnMsg: res.WarnMsg,
  22757. Cainfo: res.Cainfo,
  22758. ErrMsg: res.ErrMsg,
  22759. RespondTime: res.RefmsgTime,
  22760. InfRefmsgid: res.InfRefmsgid,
  22761. OrderStatus: 1,
  22762. IsMedicineInsurance: 1,
  22763. SettleType: settle_accounts_type,
  22764. SettleStartTime: start_time,
  22765. SettleEndTime: end_time,
  22766. Creator: roles.AdminUserId,
  22767. Modify: roles.AdminUserId,
  22768. PType: 2,
  22769. Diagnosis: diagnosis_id,
  22770. }
  22771. err = service.CreateOrder(order)
  22772. if err != nil {
  22773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22774. return
  22775. }
  22776. for _, item := range res.Output.Result {
  22777. temp := strings.Split(item.FeedetlSn, "-")
  22778. var advice_id int64 = 0
  22779. var project_id int64 = 0
  22780. var types int64 = 0
  22781. id, _ := strconv.ParseInt(temp[2], 10, 64)
  22782. types, _ = strconv.ParseInt(temp[1], 10, 64)
  22783. if temp[1] == "1" {
  22784. advice_id = id
  22785. project_id = 0
  22786. } else if temp[1] == "2" {
  22787. advice_id = 0
  22788. project_id = id
  22789. }
  22790. total_two = total_two + item.DetItemFeeSumamt
  22791. info := &models.HisOrderInfo{
  22792. OrderNumber: order.Number,
  22793. FeedetlSn: item.FeedetlSn,
  22794. UploadDate: time.Now().Unix(),
  22795. AdviceId: advice_id,
  22796. DetItemFeeSumamt: item.DetItemFeeSumamt,
  22797. Cnt: item.Cnt,
  22798. Pric: float64(item.Pric),
  22799. PatientId: his.PatientId,
  22800. PricUplmtAmt: item.PricUplmtAmt,
  22801. SelfpayProp: item.SelfpayProp,
  22802. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  22803. OverlmtAmt: item.OverlmtAmt,
  22804. PreselfpayAmt: item.PreselfpayAmt,
  22805. BasMednFlag: item.BasMednFlag,
  22806. MedChrgitmType: item.MedChrgitmType,
  22807. HiNegoDrugFlag: item.HiNegoDrugFlag,
  22808. Status: 1,
  22809. Memo: item.Memo,
  22810. Mtime: time.Now().Unix(),
  22811. InscpScpAmt: item.InscpScpAmt,
  22812. DrtReimFlag: item.DrtReimFlag,
  22813. Ctime: time.Now().Unix(),
  22814. ListSpItemFlag: item.ListSpItemFlag,
  22815. ChldMedcFlag: item.ChldMedcFlag,
  22816. LmtUsedFlag: item.LmtUsedFlag,
  22817. ChrgitmLv: item.ChrgitmLv,
  22818. UserOrgId: adminUser.CurrentOrgId,
  22819. HisPatientId: his.ID,
  22820. OrderId: order.ID,
  22821. ProjectId: project_id,
  22822. Type: types,
  22823. }
  22824. service.CreateOrderInfo(info)
  22825. }
  22826. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  22827. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  22828. var total float64
  22829. for _, item := range prescriptions {
  22830. if item.Type == 1 { //药品
  22831. for _, subItem := range item.HisDoctorAdviceInfo {
  22832. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22833. total_one := price * subItem.PrescribingNumber
  22834. fmt.Println("subItem")
  22835. fmt.Println(subItem.Price)
  22836. fmt.Println("price")
  22837. fmt.Println(price)
  22838. fmt.Println("total_one")
  22839. fmt.Println(total_one)
  22840. total = total + total_one
  22841. fmt.Println(total)
  22842. }
  22843. }
  22844. if item.Type == 2 { //项目
  22845. for _, subItem := range item.HisPrescriptionProject {
  22846. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  22847. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22848. total_one := price * cnt
  22849. total = total + total_one
  22850. }
  22851. }
  22852. }
  22853. allTotal := fmt.Sprintf("%.2f", total)
  22854. if res.Infcode == 0 {
  22855. var rf []*ResultFive
  22856. json.Unmarshal([]byte(his.Iinfo), &rf)
  22857. chrg_bchno := chrg_bchno
  22858. cert_no := his.Certno
  22859. var insutypes []string
  22860. var insutype string
  22861. var is390 int = 0
  22862. var is310 int = 0
  22863. for _, item := range rf {
  22864. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22865. insutypes = append(insutypes, item.Insutype)
  22866. }
  22867. }
  22868. if len(insutypes) == 1 {
  22869. insutype = insutypes[0]
  22870. } else {
  22871. for _, i := range insutypes {
  22872. if i == "390" {
  22873. is390 = 1
  22874. }
  22875. if i == "310" {
  22876. is310 = 1
  22877. }
  22878. }
  22879. }
  22880. if is390 == 1 {
  22881. insutype = "390"
  22882. }
  22883. if is310 == 1 {
  22884. insutype = "310"
  22885. }
  22886. if len(insutypes) == 0 {
  22887. insutype = "390"
  22888. }
  22889. if len(insutypes) == 2 {
  22890. insutype = strconv.FormatInt(his.SocialType, 10)
  22891. }
  22892. //insutype = "390"
  22893. if his.IdCardType == 1 {
  22894. cert_no = his.MedicalInsuranceNumber
  22895. } else {
  22896. cert_no = his.Certno
  22897. }
  22898. var res ResultSeven
  22899. var ahres ResultSevenAH
  22900. var resSeven10265 ResultSeven10265
  22901. var resSeven10265Two ResultSeven10265Two
  22902. var gzresSeven10265Two GZResultSeven10265Two
  22903. if miConfig.MdtrtareaAdmvs == "421300" {
  22904. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  22905. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22906. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22907. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22908. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22909. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22910. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22911. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22912. resp, requestErr := http.Get(api)
  22913. if requestErr != nil {
  22914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22915. return
  22916. }
  22917. body, ioErr := ioutil.ReadAll(resp.Body)
  22918. if ioErr != nil {
  22919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22921. return
  22922. }
  22923. var respJSON map[string]interface{}
  22924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22927. return
  22928. }
  22929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22930. result, _ := json.Marshal(respJSON)
  22931. fmt.Println("log")
  22932. fmt.Println(string(result))
  22933. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22934. utils.ErrorLog("解析失败:%v", err)
  22935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22936. return
  22937. }
  22938. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22939. if reg_type == 11 && his.Insutype == "390" {
  22940. reg_type = 110104
  22941. }
  22942. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22943. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22944. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22945. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22946. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22947. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22948. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22949. resp, requestErr := http.Get(api)
  22950. if requestErr != nil {
  22951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22952. return
  22953. }
  22954. body, ioErr := ioutil.ReadAll(resp.Body)
  22955. if ioErr != nil {
  22956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22958. return
  22959. }
  22960. var respJSON map[string]interface{}
  22961. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22964. return
  22965. }
  22966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22967. result, _ := json.Marshal(respJSON)
  22968. fmt.Println("log")
  22969. fmt.Println(string(result))
  22970. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22971. utils.ErrorLog("解析失败:%v", err)
  22972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22973. return
  22974. }
  22975. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22976. if reg_type == 11 && his.Insutype == "390" {
  22977. reg_type = 110104
  22978. }
  22979. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22980. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22981. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22982. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22983. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22984. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22985. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22986. resp, requestErr := http.Get(api)
  22987. if requestErr != nil {
  22988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22989. return
  22990. }
  22991. body, ioErr := ioutil.ReadAll(resp.Body)
  22992. if ioErr != nil {
  22993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22995. return
  22996. }
  22997. var respJSON map[string]interface{}
  22998. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23001. return
  23002. }
  23003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23004. result, _ := json.Marshal(respJSON)
  23005. fmt.Println("log")
  23006. fmt.Println(string(result))
  23007. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23008. utils.ErrorLog("解析失败:%v", err)
  23009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23010. return
  23011. }
  23012. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23013. if reg_type == 11 && his.Insutype == "390" {
  23014. reg_type = 110104
  23015. }
  23016. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23017. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23018. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23019. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23020. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23021. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23022. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23023. resp, requestErr := http.Get(api)
  23024. if requestErr != nil {
  23025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23026. return
  23027. }
  23028. body, ioErr := ioutil.ReadAll(resp.Body)
  23029. if ioErr != nil {
  23030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23032. return
  23033. }
  23034. var respJSON map[string]interface{}
  23035. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23038. return
  23039. }
  23040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23041. result, _ := json.Marshal(respJSON)
  23042. fmt.Println("log")
  23043. fmt.Println(string(result))
  23044. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23045. utils.ErrorLog("解析失败:%v", err)
  23046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23047. return
  23048. }
  23049. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23050. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23051. if result3101.Infcode == "0" {
  23052. if len(result3101.Output.Result) > 0 {
  23053. var errMsgs []string
  23054. for _, item := range result3101.Output.Result {
  23055. errMsgs = append(errMsgs, item.VolaCont)
  23056. }
  23057. c.ServeSuccessJSON(map[string]interface{}{
  23058. "failed_code": -10,
  23059. "msg": errMsgs,
  23060. })
  23061. return
  23062. } else {
  23063. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23064. if his.IdCardType != 4 {
  23065. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23066. bas := strings.Split(psn_info.CardInfo, "|")
  23067. if his.IdCardType == 1 {
  23068. cert_no = bas[2]
  23069. } else {
  23070. cert_no = bas[1]
  23071. }
  23072. } else {
  23073. cert_no = his.Certno
  23074. }
  23075. //江苏地区国家医保医疗类别
  23076. //职工透析:医疗类别选特殊情况门诊9933
  23077. //居民血透门慢: 医疗类别选门诊慢病1402
  23078. //var med_type string
  23079. //if his.Insutype == "310" {
  23080. // if reg_type == 14 {
  23081. // med_type = "9933"
  23082. // } else if reg_type == 11 {
  23083. // med_type = "11"
  23084. //
  23085. // }
  23086. //} else if his.Insutype == "390" {
  23087. // if reg_type == 14 {
  23088. // med_type = "1402"
  23089. // } else if reg_type == 11 {
  23090. // med_type = "11"
  23091. // }
  23092. //}
  23093. var api string
  23094. if miConfig.MdtrtareaAdmvs == "320921" {
  23095. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23096. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23097. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23098. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23099. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23100. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23101. "&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
  23102. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23103. } else {
  23104. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23105. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23106. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23107. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23108. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23109. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23110. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23111. "&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
  23112. }
  23113. resp, requestErr := http.Get(api)
  23114. if requestErr != nil {
  23115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23116. return
  23117. }
  23118. body, ioErr := ioutil.ReadAll(resp.Body)
  23119. if ioErr != nil {
  23120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23122. return
  23123. }
  23124. var respJSON map[string]interface{}
  23125. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23128. return
  23129. }
  23130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23131. result, _ := json.Marshal(respJSON)
  23132. fmt.Println("log")
  23133. fmt.Println(string(result))
  23134. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  23135. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23136. utils.ErrorLog("解析失败:%v", err)
  23137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23138. return
  23139. }
  23140. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23141. res.Output = resSeven10265.Output
  23142. res.ErrMsg = resSeven10265.ErrMsg
  23143. res.Cainfo = resSeven10265.Cainfo
  23144. res.WarnMsg = resSeven10265.WarnMsg
  23145. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23146. res.Infcode = infocode
  23147. } else {
  23148. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  23149. utils.ErrorLog("解析失败:%v", err)
  23150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23151. return
  23152. }
  23153. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  23154. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  23155. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  23156. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  23157. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23158. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  23159. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  23160. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  23161. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  23162. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  23163. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  23164. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23165. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  23166. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  23167. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23168. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23169. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  23170. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  23171. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  23172. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  23173. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  23174. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23175. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  23176. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  23177. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  23178. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  23179. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  23180. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  23181. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  23182. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  23183. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23184. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  23185. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  23186. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  23187. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23188. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23189. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23190. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23191. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  23192. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23193. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  23194. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  23195. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  23196. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  23197. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  23198. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  23199. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  23200. res.ErrMsg = resSeven10265Two.ErrMsg
  23201. res.Cainfo = resSeven10265Two.Cainfo
  23202. res.WarnMsg = resSeven10265Two.WarnMsg
  23203. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23204. res.Infcode = infocode
  23205. }
  23206. }
  23207. }
  23208. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23209. psn_info, _ := service.GetPsnByPatientId(id)
  23210. var verify_number string
  23211. if psn_info.IdCardType == 4 {
  23212. verify_number = psn_info.VerifyNumber
  23213. } else if psn_info.IdCardType == 1 {
  23214. bas := strings.Split(psn_info.CardInfo, "|")
  23215. cardNumber := bas[2]
  23216. verify_number = cardNumber
  23217. } else {
  23218. psn_info.IdCardType = 2
  23219. verify_number = psn_info.Certno
  23220. }
  23221. var api string
  23222. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23223. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23224. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23225. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23226. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  23227. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23228. "&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
  23229. resp, requestErr := http.Get(api)
  23230. if requestErr != nil {
  23231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23232. return
  23233. }
  23234. body, ioErr := ioutil.ReadAll(resp.Body)
  23235. if ioErr != nil {
  23236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23238. return
  23239. }
  23240. var respJSON map[string]interface{}
  23241. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23244. return
  23245. }
  23246. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23247. result, _ := json.Marshal(respJSON)
  23248. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23249. utils.ErrorLog("解析失败:%v", err)
  23250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23251. return
  23252. }
  23253. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23254. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  23255. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  23256. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23257. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  23258. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  23259. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  23260. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  23261. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  23262. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  23263. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  23264. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  23265. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  23266. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23267. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  23268. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  23269. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  23270. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  23271. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  23272. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  23273. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23274. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  23275. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  23276. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  23277. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  23278. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  23279. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  23280. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  23281. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  23282. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  23283. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  23284. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  23285. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  23286. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  23287. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23288. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  23289. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  23290. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  23291. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  23292. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  23293. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  23294. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  23295. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  23296. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  23297. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  23298. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  23299. res.ErrMsg = resSeven10265.ErrMsg
  23300. res.Cainfo = resSeven10265.Cainfo
  23301. res.WarnMsg = resSeven10265.WarnMsg
  23302. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23303. res.Infcode = infocode
  23304. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23305. acct_used_flag := "1"
  23306. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  23307. var result string
  23308. var request_log string
  23309. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  23310. 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)
  23311. } else {
  23312. 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)
  23313. }
  23314. var dat map[string]interface{}
  23315. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23316. fmt.Println(dat)
  23317. } else {
  23318. fmt.Println(err)
  23319. }
  23320. saveLog(result, request_log, "2206", "预结算")
  23321. userJSONBytes, _ := json.Marshal(dat)
  23322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23323. utils.ErrorLog("解析失败:%v", err)
  23324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23325. return
  23326. }
  23327. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23328. var result string
  23329. var request_log string
  23330. if his.IdCardType == 2 {
  23331. 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, "")
  23332. } else if his.IdCardType == 1 {
  23333. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23334. bas := strings.Split(psn_info.CardInfo, "|")
  23335. basNumber := bas[2]
  23336. card_sn := bas[3]
  23337. var rf []*ResultFive
  23338. json.Unmarshal([]byte(his.Iinfo), &rf)
  23339. var psn_type string
  23340. for _, item := range rf {
  23341. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  23342. psn_type = item.PsnType
  23343. }
  23344. }
  23345. 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)
  23346. } else {
  23347. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23348. 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, "")
  23349. }
  23350. var dat map[string]interface{}
  23351. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23352. fmt.Println(dat)
  23353. } else {
  23354. fmt.Println(err)
  23355. }
  23356. saveLog(result, request_log, "2206", "预结算")
  23357. userJSONBytes, _ := json.Marshal(dat)
  23358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23359. utils.ErrorLog("解析失败:%v", err)
  23360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23361. return
  23362. }
  23363. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23364. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23365. if his.IdCardType == 4 {
  23366. psn_info.VerifyNumber = psn_info.VerifyNumber
  23367. cert_no = psn_info.Certno
  23368. } else if his.IdCardType == 2 {
  23369. cert_no = psn_info.Certno
  23370. psn_info.VerifyNumber = psn_info.Certno
  23371. } else {
  23372. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23373. bas := strings.Split(psn_info.CardInfo, "|")
  23374. if his.IdCardType == 1 {
  23375. cert_no = bas[2]
  23376. } else {
  23377. cert_no = bas[1]
  23378. }
  23379. }
  23380. var api string
  23381. var med_type string
  23382. if his.Insutype == "390" {
  23383. if reg_type == 992102 {
  23384. med_type = "992102"
  23385. }
  23386. if reg_type == 140104 {
  23387. med_type = "140104"
  23388. }
  23389. if reg_type == 14 {
  23390. med_type = "140104"
  23391. }
  23392. } else if his.Insutype == "310" {
  23393. if reg_type == 992102 {
  23394. med_type = "992102"
  23395. }
  23396. if reg_type == 14 {
  23397. med_type = "14"
  23398. }
  23399. }
  23400. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23401. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23402. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23403. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23404. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23405. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23406. "&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
  23407. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23408. resp, requestErr := http.Get(api)
  23409. if requestErr != nil {
  23410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23411. return
  23412. }
  23413. body, ioErr := ioutil.ReadAll(resp.Body)
  23414. if ioErr != nil {
  23415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23417. return
  23418. }
  23419. var respJSON map[string]interface{}
  23420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23423. return
  23424. }
  23425. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23426. if status == "0" {
  23427. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23428. c.ServeSuccessJSON(map[string]interface{}{
  23429. "failed_code": -10,
  23430. "msg": err_msg,
  23431. })
  23432. return
  23433. }
  23434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23435. result, _ := json.Marshal(respJSON)
  23436. fmt.Println("log")
  23437. fmt.Println(string(result))
  23438. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  23439. utils.ErrorLog("解析失败:%v", err)
  23440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23441. return
  23442. }
  23443. res.InfRefmsgid = ahres.InfRefmsgid
  23444. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23445. // 创建对应的Time类型
  23446. t := time.UnixMilli(timestamp)
  23447. // 格式化成指定的日期字符串
  23448. str := t.Format("2006-01-02 15:04:05")
  23449. res.Output.Setlinfo.SetlTime = str
  23450. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23451. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23452. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23453. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23454. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23455. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23456. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23457. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23458. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23459. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23460. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23461. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23462. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23463. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23464. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23465. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23466. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23467. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23468. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23469. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23470. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23471. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23472. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23473. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23474. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23475. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23476. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23477. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23478. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23479. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23480. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23481. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23482. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23483. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  23484. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23485. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  23486. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  23487. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  23488. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  23489. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23490. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  23491. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23492. //res.Output.Setldetail = ahres.Output.Setldetail
  23493. res.ErrMsg = ahres.ErrMsg
  23494. res.Cainfo = ahres.Cainfo
  23495. res.WarnMsg = ahres.WarnMsg
  23496. res.Infcode = ahres.Infcode
  23497. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23498. var result string
  23499. var request_log string
  23500. if his.IdCardType == 2 {
  23501. 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")
  23502. } else if his.IdCardType == 1 {
  23503. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23504. bas := strings.Split(psn_info.CardInfo, "|")
  23505. basNumber := bas[2]
  23506. card_sn := bas[3]
  23507. 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")
  23508. } else {
  23509. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23510. 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")
  23511. }
  23512. var dat map[string]interface{}
  23513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23514. fmt.Println(dat)
  23515. } else {
  23516. fmt.Println(err)
  23517. }
  23518. saveLog(result, request_log, "2206", "预结算")
  23519. userJSONBytes, _ := json.Marshal(dat)
  23520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23521. utils.ErrorLog("解析失败:%v", err)
  23522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23523. return
  23524. }
  23525. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23526. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23527. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23528. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23529. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23530. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23531. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23532. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23533. resp, requestErr := http.Get(api)
  23534. if requestErr != nil {
  23535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23536. return
  23537. }
  23538. body, ioErr := ioutil.ReadAll(resp.Body)
  23539. if ioErr != nil {
  23540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23542. return
  23543. }
  23544. var respJSON map[string]interface{}
  23545. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23548. return
  23549. }
  23550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23551. result, _ := json.Marshal(respJSON)
  23552. fmt.Println("log")
  23553. fmt.Println(string(result))
  23554. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23555. utils.ErrorLog("解析失败:%v", err)
  23556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23557. return
  23558. }
  23559. } else {
  23560. if miConfig.MdtrtareaAdmvs == "441202" {
  23561. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23562. if result3101.Infcode == 0 {
  23563. if len(result3101.Output.Result) > 0 {
  23564. var errMsgs []string
  23565. for _, item := range result3101.Output.Result {
  23566. errMsgs = append(errMsgs, item.VolaCont)
  23567. }
  23568. c.ServeSuccessJSON(map[string]interface{}{
  23569. "failed_code": -10,
  23570. "msg": errMsgs,
  23571. })
  23572. return
  23573. } else {
  23574. var result string
  23575. var request_log string
  23576. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23577. allTotal = fmt.Sprintf("%.2f", total_two)
  23578. if his.IdCardType == 4 {
  23579. 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)
  23580. } else {
  23581. 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)
  23582. }
  23583. var dat map[string]interface{}
  23584. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23585. fmt.Println(dat)
  23586. } else {
  23587. fmt.Println(err)
  23588. }
  23589. saveLog(result, request_log, "2206", "预结算")
  23590. //userJSONBytes, _ := json.Marshal(dat)
  23591. //
  23592. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23593. // utils.ErrorLog("解析失败:%v", err)
  23594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23595. // return
  23596. //}
  23597. userJSONBytes, _ := json.Marshal(dat)
  23598. if miConfig.Code == "H15049901371" {
  23599. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23600. utils.ErrorLog("解析失败:%v", err)
  23601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23602. return
  23603. }
  23604. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23605. res.Output = resSeven10265.Output
  23606. res.ErrMsg = resSeven10265.ErrMsg
  23607. res.Cainfo = resSeven10265.Cainfo
  23608. res.WarnMsg = resSeven10265.WarnMsg
  23609. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23610. res.Infcode = infocode
  23611. } else {
  23612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23613. utils.ErrorLog("解析失败:%v", err)
  23614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23615. return
  23616. }
  23617. }
  23618. }
  23619. } else {
  23620. c.ServeSuccessJSON(map[string]interface{}{
  23621. "failed_code": -10,
  23622. "msg": result3101.ErrMsg,
  23623. })
  23624. return
  23625. }
  23626. } else {
  23627. var result string
  23628. var request_log string
  23629. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23630. allTotal = fmt.Sprintf("%.2f", total_two)
  23631. if his.IdCardType == 4 {
  23632. 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)
  23633. } else {
  23634. 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)
  23635. }
  23636. var dat map[string]interface{}
  23637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23638. fmt.Println(dat)
  23639. } else {
  23640. fmt.Println(err)
  23641. }
  23642. saveLog(result, request_log, "2206", "预结算")
  23643. //userJSONBytes, _ := json.Marshal(dat)
  23644. //
  23645. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23646. // utils.ErrorLog("解析失败:%v", err)
  23647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23648. // return
  23649. //}
  23650. userJSONBytes, _ := json.Marshal(dat)
  23651. if miConfig.Code == "H15049901371" {
  23652. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23653. utils.ErrorLog("解析失败:%v", err)
  23654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23655. return
  23656. }
  23657. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23658. res.Output = resSeven10265.Output
  23659. res.ErrMsg = resSeven10265.ErrMsg
  23660. res.Cainfo = resSeven10265.Cainfo
  23661. res.WarnMsg = resSeven10265.WarnMsg
  23662. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23663. res.Infcode = infocode
  23664. } else {
  23665. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23666. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  23667. utils.ErrorLog("解析失败:%v", err)
  23668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23669. return
  23670. }
  23671. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  23672. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  23673. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  23674. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23675. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  23676. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  23677. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  23678. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23679. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  23680. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23681. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23682. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23683. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23684. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23685. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23686. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  23687. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  23688. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  23689. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  23690. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  23691. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23692. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  23693. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  23694. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  23695. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  23696. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  23697. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  23698. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  23699. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  23700. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23701. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  23702. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  23703. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  23704. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23705. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23706. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23707. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23708. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  23709. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23710. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  23711. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  23712. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  23713. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  23714. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  23715. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  23716. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  23717. res.ErrMsg = gzresSeven10265Two.ErrMsg
  23718. res.Cainfo = gzresSeven10265Two.Cainfo
  23719. res.WarnMsg = gzresSeven10265Two.WarnMsg
  23720. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23721. //res.Infcode = infocode
  23722. } else {
  23723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23724. utils.ErrorLog("解析失败:%v", err)
  23725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23726. return
  23727. }
  23728. }
  23729. }
  23730. }
  23731. }
  23732. utils.ErrorLog("解析失败:%v", res.Infcode)
  23733. if res.Infcode == -1 {
  23734. errlog := &models.HisOrderError{
  23735. UserOrgId: adminUser.CurrentOrgId,
  23736. Ctime: time.Now().Unix(),
  23737. Mtime: time.Now().Unix(),
  23738. Number: chrg_bchno,
  23739. ErrMsg: res.ErrMsg,
  23740. Status: 1,
  23741. PatientId: id,
  23742. RecordTime: recordDateTime,
  23743. Stage: 20,
  23744. }
  23745. service.CreateErrMsgLog(errlog)
  23746. c.ServeSuccessJSON(map[string]interface{}{
  23747. "failed_code": -10,
  23748. "msg": res.ErrMsg,
  23749. })
  23750. return
  23751. }
  23752. if res.Infcode != 0 {
  23753. errlog := &models.HisOrderError{
  23754. UserOrgId: adminUser.CurrentOrgId,
  23755. Ctime: time.Now().Unix(),
  23756. Mtime: time.Now().Unix(),
  23757. Number: chrg_bchno,
  23758. ErrMsg: res.ErrMsg,
  23759. Status: 1,
  23760. PatientId: id,
  23761. RecordTime: recordDateTime,
  23762. Stage: 20,
  23763. }
  23764. service.CreateErrMsgLog(errlog)
  23765. c.ServeSuccessJSON(map[string]interface{}{
  23766. "failed_code": -10,
  23767. "msg": res.ErrMsg,
  23768. })
  23769. return
  23770. } else {
  23771. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  23772. order.OrderStatus = 1
  23773. order.IsPre = 1
  23774. order.Status = 1
  23775. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  23776. order.SetlId = res.Output.Setlinfo.SetlID
  23777. order.PsnNo = res.Output.Setlinfo.PsnNo
  23778. order.PsnName = res.Output.Setlinfo.PsnName
  23779. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  23780. order.Certno = res.Output.Setlinfo.Certno
  23781. order.Gend = res.Output.Setlinfo.Gend
  23782. order.Naty = res.Output.Setlinfo.Naty
  23783. order.Age = res.Output.Setlinfo.Age
  23784. order.Insutype = res.Output.Setlinfo.Insutype
  23785. order.PsnType = res.Output.Setlinfo.PsnType
  23786. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  23787. order.SetlTime = res.Output.Setlinfo.SetlTime
  23788. order.AcctUsedFlag = acct_used_flag
  23789. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  23790. if res.Output.Setlinfo.MedType == "140101" {
  23791. order.MedType = "14"
  23792. } else {
  23793. if res.Output.Setlinfo.MedType == "110104" {
  23794. order.MedType = "11"
  23795. } else {
  23796. order.MedType = res.Output.Setlinfo.MedType
  23797. }
  23798. }
  23799. if res.Output.Setlinfo.MedType == "992102" {
  23800. order.MedType = "992102"
  23801. }
  23802. if res.Output.Setlinfo.MedType == "140104" {
  23803. order.MedType = "140104"
  23804. }
  23805. if res.Output.Setlinfo.MedType == "14" {
  23806. order.MedType = "14"
  23807. }
  23808. if reg_type == 1112 {
  23809. order.MedType = "1112"
  23810. }
  23811. if reg_type == 1111 {
  23812. order.MedType = "1111"
  23813. }
  23814. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  23815. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  23816. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  23817. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  23818. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  23819. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  23820. order.HifpPay = res.Output.Setlinfo.HifpPay
  23821. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  23822. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  23823. order.HifesPay = res.Output.Setlinfo.HifesPay
  23824. order.HifobPay = res.Output.Setlinfo.HifobPay
  23825. order.MafPay = res.Output.Setlinfo.MafPay
  23826. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  23827. order.OthPay = res.Output.Setlinfo.OthPay
  23828. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  23829. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  23830. order.AcctPay = res.Output.Setlinfo.AcctPay
  23831. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  23832. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  23833. order.Balc = res.Output.Setlinfo.Balc
  23834. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  23835. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  23836. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  23837. order.ClrWay = res.Output.Setlinfo.ClrWay
  23838. order.Creator = order.Creator
  23839. order.Modify = roles.AdminUserId
  23840. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  23841. //detailStr := string(setlDetail)
  23842. //order.SetlDetail = detailStr
  23843. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  23844. err = service.UpDateOrder(order)
  23845. if err == nil {
  23846. c.ServeSuccessJSON(map[string]interface{}{
  23847. "msg": "预结算成功",
  23848. })
  23849. } else {
  23850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  23851. return
  23852. }
  23853. }
  23854. } else {
  23855. adminUser := c.GetAdminUserInfo()
  23856. errlog := &models.HisOrderError{
  23857. UserOrgId: adminUser.CurrentOrgId,
  23858. Ctime: time.Now().Unix(),
  23859. Mtime: time.Now().Unix(),
  23860. ErrMsg: res.ErrMsg,
  23861. Status: 1,
  23862. PatientId: id,
  23863. RecordTime: recordDateTime,
  23864. Stage: 4,
  23865. }
  23866. service.CreateErrMsgLog(errlog)
  23867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  23868. return
  23869. }
  23870. } else {
  23871. if miConfig.MdtrtareaAdmvs == "150499" {
  23872. order := &models.HisOrder{
  23873. UserOrgId: adminUser.CurrentOrgId,
  23874. HisPatientId: his.ID,
  23875. PatientId: his.PatientId,
  23876. SettleAccountsDate: recordDateTime,
  23877. Ctime: time.Now().Unix(),
  23878. Mtime: time.Now().Unix(),
  23879. MdtrtId: his.Number,
  23880. PsnNo: his.PsnNo,
  23881. MedType: strconv.FormatInt(reg_type, 10),
  23882. Status: 1,
  23883. Number: chrg_bchno,
  23884. Infcode: res.Infcode,
  23885. WarnMsg: res.WarnMsg,
  23886. Cainfo: res.Cainfo,
  23887. ErrMsg: res.ErrMsg,
  23888. RespondTime: res.RefmsgTime,
  23889. InfRefmsgid: res.InfRefmsgid,
  23890. OrderStatus: 1,
  23891. IsMedicineInsurance: 1,
  23892. SettleType: settle_accounts_type,
  23893. SettleStartTime: start_time,
  23894. SettleEndTime: end_time,
  23895. Creator: roles.AdminUserId,
  23896. Modify: roles.AdminUserId,
  23897. PType: 2,
  23898. Diagnosis: diagnosis_id,
  23899. }
  23900. err = service.CreateOrder(order)
  23901. if err != nil {
  23902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23903. return
  23904. }
  23905. }
  23906. adminUser := c.GetAdminUserInfo()
  23907. errlog := &models.HisOrderError{
  23908. UserOrgId: adminUser.CurrentOrgId,
  23909. Ctime: time.Now().Unix(),
  23910. Mtime: time.Now().Unix(),
  23911. ErrMsg: res.ErrMsg,
  23912. Status: 1,
  23913. PatientId: id,
  23914. RecordTime: recordDateTime,
  23915. Stage: 4,
  23916. }
  23917. service.CreateErrMsgLog(errlog)
  23918. c.ServeSuccessJSON(map[string]interface{}{
  23919. "failed_code": -10,
  23920. "msg": res.ErrMsg,
  23921. })
  23922. return
  23923. }
  23924. }
  23925. }
  23926. }
  23927. // 退款
  23928. func (c *HisApiController) Refund() {
  23929. order_id, _ := c.GetInt64("order_id")
  23930. admin_user_id, _ := c.GetInt64("admin_user_id")
  23931. adminUser := c.GetAdminUserInfo()
  23932. var order models.HisOrder
  23933. order, _ = service.GetHisOrderByID(order_id)
  23934. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23935. if order.ID == 0 {
  23936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23937. return
  23938. }
  23939. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23940. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23941. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23942. if config.IsOpen == 1 { //对接了医保,走医保流程
  23943. var res ResultSixteen
  23944. var ahres ResultSevenAH
  23945. var resSixteen10265 ResultSixteen10265
  23946. var resSixteen10265Two ResultSixteen10265Two
  23947. var gz ResultgzSixteen10265Two
  23948. var src_resquest string
  23949. var result string
  23950. if miConfig.MdtrtareaAdmvs == "421300" {
  23951. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23952. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23953. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23954. resp3, requestErr3 := http.Get(api3)
  23955. if requestErr3 != nil {
  23956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23957. return
  23958. }
  23959. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23960. if ioErr3 != nil {
  23961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23963. return
  23964. }
  23965. var respJSON3 map[string]interface{}
  23966. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23969. return
  23970. }
  23971. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23972. userJSONBytes3, _ := json.Marshal(respJSON3)
  23973. fmt.Println("log")
  23974. fmt.Println(string(userJSONBytes3))
  23975. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23976. utils.ErrorLog("解析失败:%v", err)
  23977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23978. return
  23979. }
  23980. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23981. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23982. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23983. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23984. resp3, requestErr3 := http.Get(api3)
  23985. if requestErr3 != nil {
  23986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23987. return
  23988. }
  23989. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23990. if ioErr3 != nil {
  23991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23993. return
  23994. }
  23995. var respJSON3 map[string]interface{}
  23996. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23999. return
  24000. }
  24001. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24002. userJSONBytes3, _ := json.Marshal(respJSON3)
  24003. fmt.Println("log")
  24004. fmt.Println(string(userJSONBytes3))
  24005. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24006. utils.ErrorLog("解析失败:%v", err)
  24007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24008. return
  24009. }
  24010. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24011. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  24012. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24013. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24014. resp3, requestErr3 := http.Get(api3)
  24015. if requestErr3 != nil {
  24016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24017. return
  24018. }
  24019. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24020. if ioErr3 != nil {
  24021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24023. return
  24024. }
  24025. var respJSON3 map[string]interface{}
  24026. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24029. return
  24030. }
  24031. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24032. userJSONBytes3, _ := json.Marshal(respJSON3)
  24033. fmt.Println("log")
  24034. fmt.Println(string(userJSONBytes3))
  24035. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24036. utils.ErrorLog("解析失败:%v", err)
  24037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24038. return
  24039. }
  24040. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24041. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  24042. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24043. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24044. resp3, requestErr3 := http.Get(api3)
  24045. if requestErr3 != nil {
  24046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24047. return
  24048. }
  24049. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24050. if ioErr3 != nil {
  24051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24053. return
  24054. }
  24055. var respJSON3 map[string]interface{}
  24056. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24059. return
  24060. }
  24061. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24062. userJSONBytes3, _ := json.Marshal(respJSON3)
  24063. fmt.Println("log")
  24064. fmt.Println(string(userJSONBytes3))
  24065. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24066. utils.ErrorLog("解析失败:%v", err)
  24067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24068. return
  24069. }
  24070. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24071. var api3 string
  24072. if miConfig.MdtrtareaAdmvs == "320921" {
  24073. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  24074. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24075. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24076. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24077. } else {
  24078. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24079. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  24080. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24081. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24082. }
  24083. resp3, requestErr3 := http.Get(api3)
  24084. if requestErr3 != nil {
  24085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24086. return
  24087. }
  24088. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24089. if ioErr3 != nil {
  24090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24092. return
  24093. }
  24094. var respJSON3 map[string]interface{}
  24095. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24098. return
  24099. }
  24100. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24101. userJSONBytes3, _ := json.Marshal(respJSON3)
  24102. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  24103. utils.ErrorLog("解析失败:%v", err)
  24104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24105. return
  24106. }
  24107. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24108. res.Output = resSixteen10265.Output
  24109. res.ErrMsg = resSixteen10265.ErrMsg
  24110. res.Cainfo = resSixteen10265.Cainfo
  24111. res.WarnMsg = resSixteen10265.WarnMsg
  24112. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24113. res.Infcode = infocode
  24114. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24115. var api3 string
  24116. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  24117. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24118. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24119. resp3, requestErr3 := http.Get(api3)
  24120. if requestErr3 != nil {
  24121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24122. return
  24123. }
  24124. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24125. if ioErr3 != nil {
  24126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24128. return
  24129. }
  24130. var respJSON3 map[string]interface{}
  24131. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24134. return
  24135. }
  24136. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24137. userJSONBytes3, _ := json.Marshal(respJSON3)
  24138. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  24139. utils.ErrorLog("解析失败:%v", err)
  24140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24141. return
  24142. }
  24143. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24144. res.Output = resSixteen10265.Output
  24145. res.ErrMsg = resSixteen10265.ErrMsg
  24146. res.Cainfo = resSixteen10265.Cainfo
  24147. res.WarnMsg = resSixteen10265.WarnMsg
  24148. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24149. res.Infcode = infocode
  24150. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24151. 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)
  24152. var dat map[string]interface{}
  24153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24154. fmt.Println(dat)
  24155. } else {
  24156. fmt.Println(err)
  24157. }
  24158. saveLog(result, src_resquest, "2208", "退费")
  24159. userJSONBytes, _ := json.Marshal(dat)
  24160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24161. utils.ErrorLog("解析失败:%v", err)
  24162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24163. return
  24164. }
  24165. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24166. 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, "")
  24167. var dat map[string]interface{}
  24168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24169. fmt.Println(dat)
  24170. } else {
  24171. fmt.Println(err)
  24172. }
  24173. saveLog(result, src_resquest, "2208", "退费")
  24174. userJSONBytes, _ := json.Marshal(dat)
  24175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24176. utils.ErrorLog("解析失败:%v", err)
  24177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24178. return
  24179. }
  24180. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24181. var api3 string
  24182. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  24183. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24184. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24185. resp3, requestErr3 := http.Get(api3)
  24186. if requestErr3 != nil {
  24187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24188. return
  24189. }
  24190. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24191. if ioErr3 != nil {
  24192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24194. return
  24195. }
  24196. var respJSON3 map[string]interface{}
  24197. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24200. return
  24201. }
  24202. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24203. if status == "0" {
  24204. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24205. c.ServeSuccessJSON(map[string]interface{}{
  24206. "failed_code": -10,
  24207. "msg": err_msg,
  24208. })
  24209. return
  24210. }
  24211. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24212. userJSONBytes3, _ := json.Marshal(respJSON3)
  24213. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24214. // utils.ErrorLog("解析失败:%v", err)
  24215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24216. // return
  24217. //}
  24218. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  24219. utils.ErrorLog("解析失败:%v", err)
  24220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24221. return
  24222. }
  24223. res.InfRefmsgid = ahres.InfRefmsgid
  24224. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  24225. // 创建对应的Time类型
  24226. t := time.UnixMilli(timestamp)
  24227. // 格式化成指定的日期字符串
  24228. str := t.Format("2006-01-02 15:04:05")
  24229. res.Output.Setlinfo.SetlTime = str
  24230. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  24231. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  24232. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24233. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  24234. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  24235. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  24236. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24237. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  24238. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  24239. //
  24240. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  24241. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  24242. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  24243. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24244. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  24245. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  24246. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  24247. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  24248. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  24249. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  24250. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24251. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  24252. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  24253. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  24254. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  24255. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  24256. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  24257. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  24258. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  24259. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  24260. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  24261. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  24262. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  24263. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  24264. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  24265. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  24266. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  24267. //res.Output.Setldetail = ahres.Output.Setldetail
  24268. res.ErrMsg = ahres.ErrMsg
  24269. res.Cainfo = ahres.Cainfo
  24270. res.WarnMsg = ahres.WarnMsg
  24271. res.Infcode = ahres.Infcode
  24272. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24273. 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, "")
  24274. var dat map[string]interface{}
  24275. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24276. fmt.Println(dat)
  24277. } else {
  24278. fmt.Println(err)
  24279. }
  24280. saveLog(result, src_resquest, "2208", "退费")
  24281. userJSONBytes, _ := json.Marshal(dat)
  24282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24283. utils.ErrorLog("解析失败:%v", err)
  24284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24285. return
  24286. }
  24287. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24288. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  24289. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24290. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24291. resp3, requestErr3 := http.Get(api3)
  24292. if requestErr3 != nil {
  24293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24294. return
  24295. }
  24296. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24297. if ioErr3 != nil {
  24298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24300. return
  24301. }
  24302. var respJSON3 map[string]interface{}
  24303. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24306. return
  24307. }
  24308. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24309. userJSONBytes3, _ := json.Marshal(respJSON3)
  24310. fmt.Println("log")
  24311. fmt.Println(string(userJSONBytes3))
  24312. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24313. utils.ErrorLog("解析失败:%v", err)
  24314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24315. return
  24316. }
  24317. } else {
  24318. if miConfig.Code == "H15049901371" {
  24319. 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)
  24320. var dat map[string]interface{}
  24321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24322. fmt.Println(dat)
  24323. } else {
  24324. fmt.Println(err)
  24325. }
  24326. saveLog(result, src_resquest, "2208", "退费")
  24327. userJSONBytes, _ := json.Marshal(dat)
  24328. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  24329. utils.ErrorLog("解析失败:%v", err)
  24330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24331. return
  24332. }
  24333. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24334. res.Output = resSixteen10265.Output
  24335. res.ErrMsg = resSixteen10265.ErrMsg
  24336. res.Cainfo = resSixteen10265.Cainfo
  24337. res.WarnMsg = resSixteen10265.WarnMsg
  24338. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24339. res.Infcode = infocode
  24340. } else {
  24341. 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)
  24342. var dat map[string]interface{}
  24343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24344. fmt.Println(dat)
  24345. } else {
  24346. fmt.Println(err)
  24347. }
  24348. saveLog(result, src_resquest, "2208", "退费")
  24349. userJSONBytes, _ := json.Marshal(dat)
  24350. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24351. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  24352. utils.ErrorLog("解析失败:%v", err)
  24353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24354. return
  24355. }
  24356. res.Infcode = gz.Infcode
  24357. } else {
  24358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24359. utils.ErrorLog("解析失败:%v", err)
  24360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24361. return
  24362. }
  24363. }
  24364. }
  24365. }
  24366. if res.Infcode == 0 {
  24367. var res2 ResultSix
  24368. var resSix10265 ResultSix10265
  24369. if miConfig.MdtrtareaAdmvs == "421300" {
  24370. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24371. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24372. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24373. resp3, requestErr3 := http.Get(api3)
  24374. if requestErr3 != nil {
  24375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24376. return
  24377. }
  24378. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24379. if ioErr3 != nil {
  24380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24382. return
  24383. }
  24384. var respJSON3 map[string]interface{}
  24385. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24388. return
  24389. }
  24390. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24391. userJSONBytes3, _ := json.Marshal(respJSON3)
  24392. fmt.Println("log")
  24393. fmt.Println(string(userJSONBytes3))
  24394. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24395. utils.ErrorLog("解析失败:%v", err)
  24396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24397. return
  24398. }
  24399. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24400. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24401. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24402. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24403. resp3, requestErr3 := http.Get(api3)
  24404. if requestErr3 != nil {
  24405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24406. return
  24407. }
  24408. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24409. if ioErr3 != nil {
  24410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24412. return
  24413. }
  24414. var respJSON3 map[string]interface{}
  24415. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24418. return
  24419. }
  24420. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24421. userJSONBytes3, _ := json.Marshal(respJSON3)
  24422. fmt.Println("log")
  24423. fmt.Println(string(userJSONBytes3))
  24424. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24425. utils.ErrorLog("解析失败:%v", err)
  24426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24427. return
  24428. }
  24429. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24430. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24431. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24432. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24433. resp3, requestErr3 := http.Get(api3)
  24434. if requestErr3 != nil {
  24435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24436. return
  24437. }
  24438. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24439. if ioErr3 != nil {
  24440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24442. return
  24443. }
  24444. var respJSON3 map[string]interface{}
  24445. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24448. return
  24449. }
  24450. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24451. userJSONBytes3, _ := json.Marshal(respJSON3)
  24452. fmt.Println("log")
  24453. fmt.Println(string(userJSONBytes3))
  24454. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24455. utils.ErrorLog("解析失败:%v", err)
  24456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24457. return
  24458. }
  24459. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24460. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24461. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24462. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24463. resp3, requestErr3 := http.Get(api3)
  24464. if requestErr3 != nil {
  24465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24466. return
  24467. }
  24468. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24469. if ioErr3 != nil {
  24470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24472. return
  24473. }
  24474. var respJSON3 map[string]interface{}
  24475. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24478. return
  24479. }
  24480. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24481. userJSONBytes3, _ := json.Marshal(respJSON3)
  24482. fmt.Println("log")
  24483. fmt.Println(string(userJSONBytes3))
  24484. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24485. utils.ErrorLog("解析失败:%v", err)
  24486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24487. return
  24488. }
  24489. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24490. var api3 string
  24491. if miConfig.MdtrtareaAdmvs == "320921" {
  24492. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24493. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24495. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24496. } else {
  24497. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24498. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24499. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24500. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24501. }
  24502. resp3, requestErr3 := http.Get(api3)
  24503. if requestErr3 != nil {
  24504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24505. return
  24506. }
  24507. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24508. if ioErr3 != nil {
  24509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24511. return
  24512. }
  24513. var respJSON3 map[string]interface{}
  24514. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24517. return
  24518. }
  24519. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24520. userJSONBytes3, _ := json.Marshal(respJSON3)
  24521. fmt.Println("log")
  24522. fmt.Println(string(userJSONBytes3))
  24523. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24524. utils.ErrorLog("解析失败:%v", err)
  24525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24526. return
  24527. }
  24528. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24529. res2.Output = resSix10265.Output
  24530. res2.ErrMsg = resSix10265.ErrMsg
  24531. res2.Cainfo = resSix10265.Cainfo
  24532. res2.WarnMsg = resSix10265.WarnMsg
  24533. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24534. res2.Infcode = infocode
  24535. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24536. var api3 string
  24537. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24538. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24539. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24540. resp3, requestErr3 := http.Get(api3)
  24541. if requestErr3 != nil {
  24542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24543. return
  24544. }
  24545. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24546. if ioErr3 != nil {
  24547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24549. return
  24550. }
  24551. var respJSON3 map[string]interface{}
  24552. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24555. return
  24556. }
  24557. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24558. userJSONBytes3, _ := json.Marshal(respJSON3)
  24559. fmt.Println("log")
  24560. fmt.Println(string(userJSONBytes3))
  24561. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24562. utils.ErrorLog("解析失败:%v", err)
  24563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24564. return
  24565. }
  24566. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24567. res2.Output = resSix10265.Output
  24568. res2.ErrMsg = resSix10265.ErrMsg
  24569. res2.Cainfo = resSix10265.Cainfo
  24570. res2.WarnMsg = resSix10265.WarnMsg
  24571. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24572. res2.Infcode = infocode
  24573. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24574. 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)
  24575. var dat map[string]interface{}
  24576. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24577. fmt.Println(dat)
  24578. } else {
  24579. fmt.Println(err)
  24580. }
  24581. saveLog(result2, src_request, "2205", "撤销明细")
  24582. userJSONBytes, _ := json.Marshal(dat)
  24583. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24584. utils.ErrorLog("解析失败:%v", err)
  24585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24586. return
  24587. }
  24588. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24589. 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, "")
  24590. var dat map[string]interface{}
  24591. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24592. fmt.Println(dat)
  24593. } else {
  24594. fmt.Println(err)
  24595. }
  24596. saveLog(result2, src_request, "2205", "撤销明细")
  24597. userJSONBytes, _ := json.Marshal(dat)
  24598. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24599. utils.ErrorLog("解析失败:%v", err)
  24600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24601. return
  24602. }
  24603. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24604. var api3 string
  24605. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24606. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24607. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24608. resp3, requestErr3 := http.Get(api3)
  24609. if requestErr3 != nil {
  24610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24611. return
  24612. }
  24613. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24614. if ioErr3 != nil {
  24615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24617. return
  24618. }
  24619. var respJSON3 map[string]interface{}
  24620. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24623. return
  24624. }
  24625. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24626. if status == "0" {
  24627. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24628. c.ServeSuccessJSON(map[string]interface{}{
  24629. "failed_code": -10,
  24630. "msg": err_msg,
  24631. })
  24632. return
  24633. }
  24634. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24635. userJSONBytes3, _ := json.Marshal(respJSON3)
  24636. fmt.Println("log")
  24637. fmt.Println(string(userJSONBytes3))
  24638. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24639. utils.ErrorLog("解析失败:%v", err)
  24640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24641. return
  24642. }
  24643. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24644. 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, "")
  24645. var dat map[string]interface{}
  24646. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24647. fmt.Println(dat)
  24648. } else {
  24649. fmt.Println(err)
  24650. }
  24651. saveLog(result2, src_request, "2205", "撤销明细")
  24652. userJSONBytes, _ := json.Marshal(dat)
  24653. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24654. utils.ErrorLog("解析失败:%v", err)
  24655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24656. return
  24657. }
  24658. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24659. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  24660. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24661. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24662. resp3, requestErr3 := http.Get(api3)
  24663. if requestErr3 != nil {
  24664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24665. return
  24666. }
  24667. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24668. if ioErr3 != nil {
  24669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24671. return
  24672. }
  24673. var respJSON3 map[string]interface{}
  24674. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24677. return
  24678. }
  24679. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24680. userJSONBytes3, _ := json.Marshal(respJSON3)
  24681. fmt.Println("log")
  24682. fmt.Println(string(userJSONBytes3))
  24683. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24684. utils.ErrorLog("解析失败:%v", err)
  24685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24686. return
  24687. }
  24688. } else {
  24689. if miConfig.Code == "H15049901371" {
  24690. 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)
  24691. var dat map[string]interface{}
  24692. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24693. fmt.Println(dat)
  24694. } else {
  24695. fmt.Println(err)
  24696. }
  24697. saveLog(result2, src_request, "2205", "撤销明细")
  24698. userJSONBytes, _ := json.Marshal(dat)
  24699. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24700. utils.ErrorLog("解析失败:%v", err)
  24701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24702. return
  24703. }
  24704. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24705. res2.Output = resSix10265.Output
  24706. res2.ErrMsg = resSix10265.ErrMsg
  24707. res2.Cainfo = resSix10265.Cainfo
  24708. res2.WarnMsg = resSix10265.WarnMsg
  24709. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24710. res2.Infcode = infocode
  24711. } else {
  24712. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24713. res2.Infcode = 0
  24714. } else {
  24715. 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)
  24716. var dat map[string]interface{}
  24717. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24718. fmt.Println(dat)
  24719. } else {
  24720. fmt.Println(err)
  24721. }
  24722. saveLog(result2, src_request, "2205", "撤销明细")
  24723. userJSONBytes, _ := json.Marshal(dat)
  24724. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24725. utils.ErrorLog("解析失败:%v", err)
  24726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24727. return
  24728. }
  24729. }
  24730. }
  24731. }
  24732. if res2.Infcode == -1 {
  24733. c.ServeSuccessJSON(map[string]interface{}{
  24734. "failed_code": -10,
  24735. "msg": res2.ErrMsg,
  24736. })
  24737. return
  24738. }
  24739. if res2.Infcode == 0 {
  24740. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  24741. if err == nil {
  24742. //当押金不为零时产生退费记录
  24743. if order.Decimal != 0 {
  24744. tmp := strconv.FormatInt(order.ID, 10)
  24745. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  24746. if err != nil {
  24747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24748. return
  24749. }
  24750. }
  24751. c.ServeSuccessJSON(map[string]interface{}{
  24752. "msg": "退费成功",
  24753. })
  24754. } else {
  24755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24756. return
  24757. }
  24758. } else {
  24759. c.ServeSuccessJSON(map[string]interface{}{
  24760. "failed_code": -10,
  24761. "msg": res2.ErrMsg,
  24762. })
  24763. }
  24764. } else {
  24765. c.ServeSuccessJSON(map[string]interface{}{
  24766. "failed_code": -10,
  24767. "msg": res.ErrMsg,
  24768. })
  24769. }
  24770. }
  24771. }
  24772. func (c *HisApiController) RefundNumber() {
  24773. record_time := c.GetString("record_time")
  24774. //patient_id, _ := c.GetInt64("patient_id")
  24775. admin_user_id, _ := c.GetInt64("admin_user_id")
  24776. his_patient_id, _ := c.GetInt64("id")
  24777. timeLayout := "2006-01-02"
  24778. loc, _ := time.LoadLocation("Local")
  24779. adminUser := c.GetAdminUserInfo()
  24780. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24781. fmt.Println(err)
  24782. if err != nil {
  24783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24784. return
  24785. }
  24786. recordDateTime := theTime.Unix()
  24787. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24788. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  24789. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24790. //order, _ := service.GetHisOrderByID(order_id)
  24791. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24792. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24793. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24794. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  24795. if count > 0 {
  24796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  24797. return
  24798. }
  24799. if config.IsOpen == 1 { //对接了医保,走医保流程
  24800. var res2 ResultSix
  24801. var res3 GZResultSix
  24802. var resSix10265 ResultSix10265
  24803. if miConfig.MdtrtareaAdmvs == "421300" {
  24804. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24805. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24806. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24807. resp3, requestErr3 := http.Get(api3)
  24808. if requestErr3 != nil {
  24809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24810. return
  24811. }
  24812. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24813. if ioErr3 != nil {
  24814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24816. return
  24817. }
  24818. var respJSON3 map[string]interface{}
  24819. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24822. return
  24823. }
  24824. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24825. userJSONBytes3, _ := json.Marshal(respJSON3)
  24826. fmt.Println("log")
  24827. fmt.Println(string(userJSONBytes3))
  24828. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24829. utils.ErrorLog("解析失败:%v", err)
  24830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24831. return
  24832. }
  24833. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24834. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24835. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24836. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24837. resp3, requestErr3 := http.Get(api3)
  24838. if requestErr3 != nil {
  24839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24840. return
  24841. }
  24842. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24843. if ioErr3 != nil {
  24844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24846. return
  24847. }
  24848. var respJSON3 map[string]interface{}
  24849. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24852. return
  24853. }
  24854. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24855. userJSONBytes3, _ := json.Marshal(respJSON3)
  24856. fmt.Println("log")
  24857. fmt.Println(string(userJSONBytes3))
  24858. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24859. utils.ErrorLog("解析失败:%v", err)
  24860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24861. return
  24862. }
  24863. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24864. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24865. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24866. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24867. resp3, requestErr3 := http.Get(api3)
  24868. if requestErr3 != nil {
  24869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24870. return
  24871. }
  24872. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24873. if ioErr3 != nil {
  24874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24876. return
  24877. }
  24878. var respJSON3 map[string]interface{}
  24879. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24882. return
  24883. }
  24884. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24885. userJSONBytes3, _ := json.Marshal(respJSON3)
  24886. fmt.Println("log")
  24887. fmt.Println(string(userJSONBytes3))
  24888. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24889. utils.ErrorLog("解析失败:%v", err)
  24890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24891. return
  24892. }
  24893. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24894. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24895. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24896. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24897. resp3, requestErr3 := http.Get(api3)
  24898. if requestErr3 != nil {
  24899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24900. return
  24901. }
  24902. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24903. if ioErr3 != nil {
  24904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24906. return
  24907. }
  24908. var respJSON3 map[string]interface{}
  24909. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24912. return
  24913. }
  24914. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24915. userJSONBytes3, _ := json.Marshal(respJSON3)
  24916. fmt.Println("log")
  24917. fmt.Println(string(userJSONBytes3))
  24918. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24919. utils.ErrorLog("解析失败:%v", err)
  24920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24921. return
  24922. }
  24923. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24924. var api3 string
  24925. if miConfig.MdtrtareaAdmvs == "320921" {
  24926. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24927. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24928. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24929. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24930. } else {
  24931. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24932. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24933. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24934. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24935. }
  24936. resp3, requestErr3 := http.Get(api3)
  24937. if requestErr3 != nil {
  24938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24939. return
  24940. }
  24941. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24942. if ioErr3 != nil {
  24943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24945. return
  24946. }
  24947. var respJSON3 map[string]interface{}
  24948. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24951. return
  24952. }
  24953. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24954. userJSONBytes3, _ := json.Marshal(respJSON3)
  24955. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24956. utils.ErrorLog("解析失败:%v", err)
  24957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24958. return
  24959. }
  24960. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24961. res2.Output = resSix10265.Output
  24962. res2.ErrMsg = resSix10265.ErrMsg
  24963. res2.Cainfo = resSix10265.Cainfo
  24964. res2.WarnMsg = resSix10265.WarnMsg
  24965. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24966. res2.Infcode = infocode
  24967. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24968. var api3 string
  24969. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  24970. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24971. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24972. resp3, requestErr3 := http.Get(api3)
  24973. if requestErr3 != nil {
  24974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24975. return
  24976. }
  24977. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24978. if ioErr3 != nil {
  24979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24981. return
  24982. }
  24983. var respJSON3 map[string]interface{}
  24984. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24987. return
  24988. }
  24989. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24990. userJSONBytes3, _ := json.Marshal(respJSON3)
  24991. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24992. utils.ErrorLog("解析失败:%v", err)
  24993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24994. return
  24995. }
  24996. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24997. res2.Output = resSix10265.Output
  24998. res2.ErrMsg = resSix10265.ErrMsg
  24999. res2.Cainfo = resSix10265.Cainfo
  25000. res2.WarnMsg = resSix10265.WarnMsg
  25001. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25002. res2.Infcode = infocode
  25003. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25004. 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)
  25005. var dat map[string]interface{}
  25006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25007. fmt.Println(dat)
  25008. } else {
  25009. fmt.Println(err)
  25010. }
  25011. saveLog(result, request, "2202", "退号")
  25012. userJSONBytes, _ := json.Marshal(dat)
  25013. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25014. utils.ErrorLog("解析失败:%v", err)
  25015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25016. return
  25017. }
  25018. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25019. 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, "")
  25020. var dat map[string]interface{}
  25021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25022. fmt.Println(dat)
  25023. } else {
  25024. fmt.Println(err)
  25025. }
  25026. saveLog(result, request, "2202", "退号")
  25027. userJSONBytes, _ := json.Marshal(dat)
  25028. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25029. utils.ErrorLog("解析失败:%v", err)
  25030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25031. return
  25032. }
  25033. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25034. var api3 string
  25035. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  25036. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25037. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25038. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25039. resp3, requestErr3 := http.Get(api3)
  25040. if requestErr3 != nil {
  25041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25042. return
  25043. }
  25044. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25045. if ioErr3 != nil {
  25046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25048. return
  25049. }
  25050. var respJSON3 map[string]interface{}
  25051. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25054. return
  25055. }
  25056. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25057. if status == "0" {
  25058. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25059. c.ServeSuccessJSON(map[string]interface{}{
  25060. "failed_code": -10,
  25061. "msg": err_msg,
  25062. })
  25063. return
  25064. }
  25065. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25066. userJSONBytes3, _ := json.Marshal(respJSON3)
  25067. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25068. utils.ErrorLog("解析失败:%v", err)
  25069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25070. return
  25071. }
  25072. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  25073. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25074. 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, "")
  25075. var dat map[string]interface{}
  25076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25077. fmt.Println(dat)
  25078. } else {
  25079. fmt.Println(err)
  25080. }
  25081. saveLog(result, request, "2202", "退号")
  25082. userJSONBytes, _ := json.Marshal(dat)
  25083. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25084. utils.ErrorLog("解析失败:%v", err)
  25085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25086. return
  25087. }
  25088. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25089. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  25090. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25091. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25092. resp3, requestErr3 := http.Get(api3)
  25093. if requestErr3 != nil {
  25094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25095. return
  25096. }
  25097. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25098. if ioErr3 != nil {
  25099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25101. return
  25102. }
  25103. var respJSON3 map[string]interface{}
  25104. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25107. return
  25108. }
  25109. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25110. userJSONBytes3, _ := json.Marshal(respJSON3)
  25111. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25112. utils.ErrorLog("解析失败:%v", err)
  25113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25114. return
  25115. }
  25116. } else {
  25117. var api3 string
  25118. if miConfig.Code == "H15049901371" {
  25119. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  25120. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25121. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25122. } else {
  25123. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  25124. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25125. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25126. }
  25127. resp3, requestErr3 := http.Get(api3)
  25128. if requestErr3 != nil {
  25129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25130. return
  25131. }
  25132. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25133. if ioErr3 != nil {
  25134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25136. return
  25137. }
  25138. var respJSON3 map[string]interface{}
  25139. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25142. return
  25143. }
  25144. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25145. userJSONBytes3, _ := json.Marshal(respJSON3)
  25146. if miConfig.Code == "H15049901371" {
  25147. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25148. utils.ErrorLog("解析失败:%v", err)
  25149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25150. return
  25151. }
  25152. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25153. res2.Output = resSix10265.Output
  25154. res2.ErrMsg = resSix10265.ErrMsg
  25155. res2.Cainfo = resSix10265.Cainfo
  25156. res2.WarnMsg = resSix10265.WarnMsg
  25157. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25158. res2.Infcode = infocode
  25159. } else {
  25160. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25161. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  25162. utils.ErrorLog("解析失败:%v", err)
  25163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25164. return
  25165. }
  25166. res2.Infcode = res3.Infcode
  25167. } else {
  25168. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25169. utils.ErrorLog("解析失败:%v", err)
  25170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25171. return
  25172. }
  25173. }
  25174. }
  25175. }
  25176. if res2.Infcode == -1 {
  25177. utils.ErrorLog("解析失败:%v", res2.Infcode)
  25178. c.ServeSuccessJSON(map[string]interface{}{
  25179. "failed_code": -10,
  25180. "msg": res2.ErrMsg,
  25181. })
  25182. return
  25183. }
  25184. if res2.Infcode == 0 {
  25185. if err == nil {
  25186. c.ServeSuccessJSON(map[string]interface{}{
  25187. "msg": "退号成功",
  25188. })
  25189. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  25190. } else {
  25191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25192. return
  25193. }
  25194. }
  25195. } else {
  25196. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  25197. //if err == nil {
  25198. // c.ServeSuccessJSON(map[string]interface{}{
  25199. // "msg": "退费成功",
  25200. // })
  25201. //} else {
  25202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25203. // return
  25204. //}
  25205. }
  25206. }
  25207. func (c *HisApiController) RefundDetail() {
  25208. order_id, _ := c.GetInt64("order_id")
  25209. admin_user_id, _ := c.GetInt64("admin_user_id")
  25210. //his_patient_id, _ := c.GetInt64("his_patient_id")
  25211. number := c.GetString("number")
  25212. record_time := c.GetString("record_time")
  25213. patient_id, _ := c.GetInt64("patient_id")
  25214. //med_type, _ := c.GetInt64("med_type")
  25215. timeLayout := "2006-01-02"
  25216. loc, _ := time.LoadLocation("Local")
  25217. adminUser := c.GetAdminUserInfo()
  25218. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25219. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25220. fmt.Println(err)
  25221. if err != nil {
  25222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25223. return
  25224. }
  25225. recordDateTime := theTime.Unix()
  25226. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25227. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25228. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25229. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25230. var order models.HisOrder
  25231. order, _ = service.GetHisOrderByID(order_id)
  25232. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25233. if config.IsOpen == 1 { //对接了医保,走医保流程
  25234. var res2 ResultSix
  25235. if miConfig.MdtrtareaAdmvs == "421300" {
  25236. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25237. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25239. resp3, requestErr3 := http.Get(api3)
  25240. if requestErr3 != nil {
  25241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25242. return
  25243. }
  25244. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25245. if ioErr3 != nil {
  25246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25248. return
  25249. }
  25250. var respJSON3 map[string]interface{}
  25251. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25254. return
  25255. }
  25256. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25257. userJSONBytes3, _ := json.Marshal(respJSON3)
  25258. fmt.Println("log")
  25259. fmt.Println(string(userJSONBytes3))
  25260. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25261. utils.ErrorLog("解析失败:%v", err)
  25262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25263. return
  25264. }
  25265. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25266. if err == nil {
  25267. c.ServeSuccessJSON(map[string]interface{}{
  25268. "msg": "撤销明细成功",
  25269. })
  25270. return
  25271. } else {
  25272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25273. return
  25274. }
  25275. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25276. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25277. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25278. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25279. resp3, requestErr3 := http.Get(api3)
  25280. if requestErr3 != nil {
  25281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25282. return
  25283. }
  25284. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25285. if ioErr3 != nil {
  25286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25288. return
  25289. }
  25290. var respJSON3 map[string]interface{}
  25291. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25294. return
  25295. }
  25296. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25297. userJSONBytes3, _ := json.Marshal(respJSON3)
  25298. fmt.Println("log")
  25299. fmt.Println(string(userJSONBytes3))
  25300. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25301. utils.ErrorLog("解析失败:%v", err)
  25302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25303. return
  25304. }
  25305. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25306. if err == nil {
  25307. c.ServeSuccessJSON(map[string]interface{}{
  25308. "msg": "撤销明细成功",
  25309. })
  25310. return
  25311. } else {
  25312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25313. return
  25314. }
  25315. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25316. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25317. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25318. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25319. resp3, requestErr3 := http.Get(api3)
  25320. if requestErr3 != nil {
  25321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25322. return
  25323. }
  25324. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25325. if ioErr3 != nil {
  25326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25328. return
  25329. }
  25330. var respJSON3 map[string]interface{}
  25331. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25334. return
  25335. }
  25336. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25337. userJSONBytes3, _ := json.Marshal(respJSON3)
  25338. fmt.Println("log")
  25339. fmt.Println(string(userJSONBytes3))
  25340. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25341. utils.ErrorLog("解析失败:%v", err)
  25342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25343. return
  25344. }
  25345. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25346. if err == nil {
  25347. c.ServeSuccessJSON(map[string]interface{}{
  25348. "msg": "撤销明细成功",
  25349. })
  25350. return
  25351. } else {
  25352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25353. return
  25354. }
  25355. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25356. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25357. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25358. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25359. resp3, requestErr3 := http.Get(api3)
  25360. if requestErr3 != nil {
  25361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25362. return
  25363. }
  25364. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25365. if ioErr3 != nil {
  25366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25368. return
  25369. }
  25370. var respJSON3 map[string]interface{}
  25371. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25374. return
  25375. }
  25376. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25377. userJSONBytes3, _ := json.Marshal(respJSON3)
  25378. fmt.Println("log")
  25379. fmt.Println(string(userJSONBytes3))
  25380. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25381. utils.ErrorLog("解析失败:%v", err)
  25382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25383. return
  25384. }
  25385. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25386. if err == nil {
  25387. c.ServeSuccessJSON(map[string]interface{}{
  25388. "msg": "撤销明细成功",
  25389. })
  25390. return
  25391. } else {
  25392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25393. return
  25394. }
  25395. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25396. var resSix10265 ResultSix10265
  25397. var api3 string
  25398. if miConfig.MdtrtareaAdmvs == "320921" {
  25399. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25400. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25401. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25402. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25403. } else {
  25404. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25405. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25406. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25407. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25408. }
  25409. resp3, requestErr3 := http.Get(api3)
  25410. utils.ErrorLog("接口: %v", requestErr3)
  25411. if requestErr3 != nil {
  25412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25413. return
  25414. }
  25415. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25416. if ioErr3 != nil {
  25417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25419. return
  25420. }
  25421. var respJSON3 map[string]interface{}
  25422. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25425. return
  25426. }
  25427. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25428. userJSONBytes3, _ := json.Marshal(respJSON3)
  25429. fmt.Println("log")
  25430. fmt.Println(string(userJSONBytes3))
  25431. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25432. utils.ErrorLog("解析失败:%v", err)
  25433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25434. return
  25435. }
  25436. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25437. res2.Output = resSix10265.Output
  25438. res2.ErrMsg = resSix10265.ErrMsg
  25439. res2.Cainfo = resSix10265.Cainfo
  25440. res2.WarnMsg = resSix10265.WarnMsg
  25441. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25442. res2.Infcode = infocode
  25443. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25444. if err == nil {
  25445. c.ServeSuccessJSON(map[string]interface{}{
  25446. "msg": "撤销明细成功",
  25447. })
  25448. return
  25449. } else {
  25450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25451. return
  25452. }
  25453. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25454. var api3 string
  25455. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  25456. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25457. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25458. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25459. resp3, requestErr3 := http.Get(api3)
  25460. utils.ErrorLog("接口: %v", requestErr3)
  25461. if requestErr3 != nil {
  25462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25463. return
  25464. }
  25465. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25466. if ioErr3 != nil {
  25467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25469. return
  25470. }
  25471. var respJSON3 map[string]interface{}
  25472. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25475. return
  25476. }
  25477. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25478. if status == "0" {
  25479. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25480. c.ServeSuccessJSON(map[string]interface{}{
  25481. "failed_code": -10,
  25482. "msg": err_msg,
  25483. })
  25484. return
  25485. }
  25486. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25487. userJSONBytes3, _ := json.Marshal(respJSON3)
  25488. fmt.Println("log")
  25489. fmt.Println(string(userJSONBytes3))
  25490. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25491. utils.ErrorLog("解析失败:%v", err)
  25492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25493. return
  25494. }
  25495. fmt.Println(res2.Infcode)
  25496. if res2.Infcode == -1 {
  25497. c.ServeSuccessJSON(map[string]interface{}{
  25498. "failed_code": -10,
  25499. "msg": res2.ErrMsg,
  25500. })
  25501. return
  25502. }
  25503. if res2.Infcode == 0 {
  25504. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25505. if err == nil {
  25506. c.ServeSuccessJSON(map[string]interface{}{
  25507. "msg": "撤销明细成功",
  25508. })
  25509. return
  25510. } else {
  25511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25512. return
  25513. }
  25514. } else {
  25515. c.ServeSuccessJSON(map[string]interface{}{
  25516. "failed_code": -10,
  25517. "msg": res2.ErrMsg,
  25518. })
  25519. }
  25520. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25521. if err == nil {
  25522. c.ServeSuccessJSON(map[string]interface{}{
  25523. "msg": "撤销明细成功",
  25524. })
  25525. return
  25526. } else {
  25527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25528. return
  25529. }
  25530. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25531. var resSix10265 ResultSix10265
  25532. var api3 string
  25533. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25534. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25535. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25536. resp3, requestErr3 := http.Get(api3)
  25537. if requestErr3 != nil {
  25538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25539. return
  25540. }
  25541. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25542. if ioErr3 != nil {
  25543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25545. return
  25546. }
  25547. var respJSON3 map[string]interface{}
  25548. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25551. return
  25552. }
  25553. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25554. userJSONBytes3, _ := json.Marshal(respJSON3)
  25555. fmt.Println("log")
  25556. fmt.Println(string(userJSONBytes3))
  25557. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25558. utils.ErrorLog("解析失败:%v", err)
  25559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25560. return
  25561. }
  25562. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25563. res2.Output = resSix10265.Output
  25564. res2.ErrMsg = resSix10265.ErrMsg
  25565. res2.Cainfo = resSix10265.Cainfo
  25566. res2.WarnMsg = resSix10265.WarnMsg
  25567. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25568. res2.Infcode = infocode
  25569. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25570. if err == nil {
  25571. c.ServeSuccessJSON(map[string]interface{}{
  25572. "msg": "撤销明细成功",
  25573. })
  25574. return
  25575. } else {
  25576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25577. return
  25578. }
  25579. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25580. 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)
  25581. var dat map[string]interface{}
  25582. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25583. fmt.Println(dat)
  25584. } else {
  25585. fmt.Println(err)
  25586. }
  25587. saveLog(result2, src_request, "2205", "撤销明细")
  25588. userJSONBytes, _ := json.Marshal(dat)
  25589. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25590. utils.ErrorLog("解析失败:%v", err)
  25591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25592. return
  25593. }
  25594. if res2.Infcode == 0 {
  25595. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25596. if err == nil {
  25597. c.ServeSuccessJSON(map[string]interface{}{
  25598. "msg": "撤销明细成功",
  25599. })
  25600. return
  25601. } else {
  25602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25603. return
  25604. }
  25605. } else {
  25606. c.ServeSuccessJSON(map[string]interface{}{
  25607. "failed_code": -10,
  25608. "msg": res2.ErrMsg,
  25609. })
  25610. }
  25611. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25612. 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, "")
  25613. var dat map[string]interface{}
  25614. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25615. fmt.Println(dat)
  25616. } else {
  25617. fmt.Println(err)
  25618. }
  25619. saveLog(result2, src_request, "2205", "撤销明细")
  25620. userJSONBytes, _ := json.Marshal(dat)
  25621. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25622. utils.ErrorLog("解析失败:%v", err)
  25623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25624. return
  25625. }
  25626. if res2.Infcode == 0 {
  25627. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25628. if err == nil {
  25629. c.ServeSuccessJSON(map[string]interface{}{
  25630. "msg": "撤销明细成功",
  25631. })
  25632. return
  25633. } else {
  25634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25635. return
  25636. }
  25637. } else {
  25638. c.ServeSuccessJSON(map[string]interface{}{
  25639. "failed_code": -10,
  25640. "msg": res2.ErrMsg,
  25641. })
  25642. }
  25643. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25644. 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, "")
  25645. var dat map[string]interface{}
  25646. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25647. fmt.Println(dat)
  25648. } else {
  25649. fmt.Println(err)
  25650. }
  25651. saveLog(result2, src_request, "2205", "撤销明细")
  25652. userJSONBytes, _ := json.Marshal(dat)
  25653. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25654. utils.ErrorLog("解析失败:%v", err)
  25655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25656. return
  25657. }
  25658. if res2.Infcode == 0 {
  25659. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25660. if err == nil {
  25661. c.ServeSuccessJSON(map[string]interface{}{
  25662. "msg": "撤销明细成功",
  25663. })
  25664. return
  25665. } else {
  25666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25667. return
  25668. }
  25669. } else {
  25670. c.ServeSuccessJSON(map[string]interface{}{
  25671. "failed_code": -10,
  25672. "msg": res2.ErrMsg,
  25673. })
  25674. }
  25675. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25676. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  25677. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25678. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25679. resp2, requestErr2 := http.Get(api2)
  25680. if requestErr2 != nil {
  25681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25682. return
  25683. }
  25684. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25685. if ioErr2 != nil {
  25686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25688. return
  25689. }
  25690. var respJSON2 map[string]interface{}
  25691. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25694. return
  25695. }
  25696. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25697. userJSONBytes3, _ := json.Marshal(respJSON2)
  25698. fmt.Println("log")
  25699. fmt.Println(string(userJSONBytes3))
  25700. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25701. utils.ErrorLog("解析失败:%v", err)
  25702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25703. return
  25704. }
  25705. if res2.Infcode == 0 {
  25706. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25707. if err == nil {
  25708. c.ServeSuccessJSON(map[string]interface{}{
  25709. "msg": "撤销明细成功",
  25710. })
  25711. return
  25712. } else {
  25713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25714. return
  25715. }
  25716. } else {
  25717. c.ServeSuccessJSON(map[string]interface{}{
  25718. "failed_code": -10,
  25719. "msg": res2.ErrMsg,
  25720. })
  25721. }
  25722. } else {
  25723. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  25724. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25725. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25726. resp2, requestErr2 := http.Get(api2)
  25727. if requestErr2 != nil {
  25728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25729. return
  25730. }
  25731. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25732. if ioErr2 != nil {
  25733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25735. return
  25736. }
  25737. var respJSON2 map[string]interface{}
  25738. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25741. return
  25742. }
  25743. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25744. if err == nil {
  25745. c.ServeSuccessJSON(map[string]interface{}{
  25746. "msg": "撤销明细成功",
  25747. })
  25748. return
  25749. } else {
  25750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25751. return
  25752. }
  25753. }
  25754. } else {
  25755. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25756. if err == nil {
  25757. c.ServeSuccessJSON(map[string]interface{}{
  25758. "msg": "退费成功",
  25759. })
  25760. } else {
  25761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25762. return
  25763. }
  25764. }
  25765. }
  25766. // 对账
  25767. func (c *HisApiController) GetCheckAccount() {
  25768. start_time := c.GetString("start_time")
  25769. end_time := c.GetString("end_time")
  25770. insutype := c.GetString("insutype")
  25771. clr_type := c.GetString("clr_type")
  25772. clr_org := c.GetString("clr_optins")
  25773. admin_user_id, _ := c.GetInt64("admin_user_id")
  25774. adminUser := c.GetAdminUserInfo()
  25775. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25776. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25777. if len(clr_org) == 0 {
  25778. clr_org = miConfig.InsuplcAdmdvs
  25779. }
  25780. timeLayout := "2006-01-02"
  25781. loc, _ := time.LoadLocation("Local")
  25782. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25783. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25784. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25785. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25786. fixmedins_setl_cnt := int64(len(orders))
  25787. var medfee_sumamt float64
  25788. var acct_pay float64
  25789. var fund_pay_sumamt float64
  25790. for _, item := range orders {
  25791. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25792. acct_pay = acct_pay + item.AcctPay
  25793. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25794. }
  25795. var user_name string
  25796. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25797. if role.ID == 0 {
  25798. user_name = "xxx"
  25799. } else {
  25800. user_name = role.UserName
  25801. }
  25802. var res ResultEight
  25803. var res10188 ResultEightFor10188
  25804. if config.IsOpen == 1 {
  25805. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25806. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  25807. "insutype=" + insutype +
  25808. "&clr_type=" + clr_type +
  25809. "&setl_optins=" + clr_org +
  25810. "&stmt_begndate=" + start_time +
  25811. "&stm_enddate=" + end_time +
  25812. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25813. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25814. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25815. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25816. "&fixmedins_code=" + miConfig.Code +
  25817. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25818. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25819. "&secret_key=" + miConfig.SecretKey +
  25820. "&org_name=" + miConfig.OrgName +
  25821. "&doctor=" + user_name +
  25822. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25823. fmt.Println(api)
  25824. resp, requestErr := http.Get(api)
  25825. if requestErr != nil {
  25826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25827. return
  25828. }
  25829. body, ioErr := ioutil.ReadAll(resp.Body)
  25830. fmt.Println(body)
  25831. if ioErr != nil {
  25832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25834. return
  25835. }
  25836. var respJSON map[string]interface{}
  25837. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25840. return
  25841. }
  25842. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25843. userJSONBytes, _ := json.Marshal(respJSON)
  25844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25845. utils.ErrorLog("解析失败:%v", err)
  25846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25847. return
  25848. }
  25849. res.InfRefmsgid = res10188.InfRefmsgid
  25850. res.Output = res10188.Output
  25851. res.ErrMsg = res10188.ErrMsg
  25852. res.Cainfo = res10188.Cainfo
  25853. res.WarnMsg = res10188.WarnMsg
  25854. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25855. res.Infcode = infocode
  25856. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25857. if clr_type != "9903" {
  25858. clr_type = "99" // 就诊 ID(来自2201接口返回)
  25859. }
  25860. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  25861. "insutype=" + insutype +
  25862. "&clr_type=" + clr_type +
  25863. "&setl_optins=" + clr_org +
  25864. "&stmt_begndate=" + start_time +
  25865. "&stm_enddate=" + end_time +
  25866. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25867. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25868. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25869. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25870. "&fixmedins_code=" + miConfig.Code +
  25871. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25872. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25873. "&secret_key=" + miConfig.SecretKey +
  25874. "&org_name=" + miConfig.OrgName +
  25875. "&doctor=" + user_name
  25876. resp, requestErr := http.Get(api)
  25877. if requestErr != nil {
  25878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25879. return
  25880. }
  25881. body, ioErr := ioutil.ReadAll(resp.Body)
  25882. if ioErr != nil {
  25883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25885. return
  25886. }
  25887. var respJSON map[string]interface{}
  25888. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25891. return
  25892. }
  25893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25894. result, _ := json.Marshal(respJSON)
  25895. fmt.Println("log")
  25896. fmt.Println(string(result))
  25897. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  25898. utils.ErrorLog("解析失败:%v", err)
  25899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25900. return
  25901. }
  25902. res.InfRefmsgid = res10188.InfRefmsgid
  25903. res.Output = res10188.Output
  25904. res.ErrMsg = res10188.ErrMsg
  25905. res.Cainfo = res10188.Cainfo
  25906. res.WarnMsg = res10188.WarnMsg
  25907. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25908. res.Infcode = infocode
  25909. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25910. var baseParams models.BaseParams
  25911. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25912. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25913. baseParams.SecretKey = miConfig.SecretKey
  25914. baseParams.OrgName = miConfig.OrgName
  25915. baseParams.FixmedinsCode = miConfig.Code
  25916. baseParams.EncKey = miConfig.EncKey
  25917. baseParams.AppSecret = miConfig.AppSecret
  25918. baseParams.SignKey = miConfig.SignKey
  25919. baseParams.AppID = miConfig.Code
  25920. baseParams.Doctor = role.UserName
  25921. baseParams.RequestUrl = miConfig.Url
  25922. businessParams := models.BusinessParams{
  25923. Insutype: insutype,
  25924. ClrType: clr_type,
  25925. SetlOptins: clr_org,
  25926. StmtBegndate: start_time,
  25927. StmtEnddate: end_time,
  25928. MedfeeSumamt: medfee_sumamt,
  25929. FundPaySumamt: fund_pay_sumamt,
  25930. AcctPay: acct_pay,
  25931. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25932. }
  25933. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  25934. fmt.Println(requestLog)
  25935. fmt.Println(result)
  25936. fmt.Println(err_msg)
  25937. var dat map[string]interface{}
  25938. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25939. fmt.Println(dat)
  25940. } else {
  25941. fmt.Println(err)
  25942. }
  25943. userJSONBytes, _ := json.Marshal(dat)
  25944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25945. utils.ErrorLog("解析失败:%v", err)
  25946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25947. return
  25948. }
  25949. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25950. var baseParams models.BaseParams
  25951. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25952. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25953. baseParams.SecretKey = miConfig.SecretKey
  25954. baseParams.OrgName = miConfig.OrgName
  25955. baseParams.FixmedinsCode = miConfig.Code
  25956. baseParams.EncKey = miConfig.EncKey
  25957. baseParams.AppSecret = miConfig.AppSecret
  25958. baseParams.SignKey = miConfig.SignKey
  25959. baseParams.AppID = miConfig.Code
  25960. baseParams.Doctor = role.UserName
  25961. baseParams.RequestUrl = miConfig.Url
  25962. baseParams.AccessKey = miConfig.AccessKey
  25963. businessParams := models.BusinessParams{
  25964. Insutype: insutype,
  25965. ClrType: clr_type,
  25966. SetlOptins: "430822",
  25967. StmtBegndate: start_time,
  25968. StmtEnddate: end_time,
  25969. MedfeeSumamt: medfee_sumamt,
  25970. FundPaySumamt: fund_pay_sumamt,
  25971. AcctPay: acct_pay,
  25972. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25973. }
  25974. 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)
  25975. fmt.Println(requestLog)
  25976. fmt.Println(result)
  25977. var dat map[string]interface{}
  25978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25979. fmt.Println(dat)
  25980. } else {
  25981. fmt.Println(err)
  25982. }
  25983. userJSONBytes, _ := json.Marshal(dat)
  25984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25985. utils.ErrorLog("解析失败:%v", err)
  25986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25987. return
  25988. }
  25989. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25990. var baseParams models.BaseParams
  25991. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25992. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25993. baseParams.SecretKey = miConfig.SecretKey
  25994. baseParams.OrgName = miConfig.OrgName
  25995. baseParams.FixmedinsCode = miConfig.Code
  25996. baseParams.EncKey = miConfig.EncKey
  25997. baseParams.AppSecret = miConfig.AppSecret
  25998. baseParams.SignKey = miConfig.SignKey
  25999. baseParams.AppID = miConfig.Code
  26000. baseParams.Doctor = role.UserName
  26001. baseParams.RequestUrl = miConfig.Url
  26002. businessParams := models.BusinessParams{
  26003. Insutype: insutype,
  26004. ClrType: clr_type,
  26005. SetlOptins: clr_org,
  26006. StmtBegndate: start_time,
  26007. StmtEnddate: end_time,
  26008. MedfeeSumamt: medfee_sumamt,
  26009. FundPaySumamt: fund_pay_sumamt,
  26010. AcctPay: acct_pay,
  26011. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26012. }
  26013. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  26014. fmt.Println(requestLog)
  26015. fmt.Println(result)
  26016. fmt.Println(err_msg)
  26017. var dat map[string]interface{}
  26018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26019. fmt.Println(dat)
  26020. } else {
  26021. fmt.Println(err)
  26022. }
  26023. userJSONBytes, _ := json.Marshal(dat)
  26024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26025. utils.ErrorLog("解析失败:%v", err)
  26026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26027. return
  26028. }
  26029. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26030. if len(clr_type) == 0 {
  26031. clr_type = "11"
  26032. }
  26033. api := miConfig.Url + "gdyb/ten?" +
  26034. "insutype=" + insutype +
  26035. "&clr_type=" + clr_type +
  26036. "&setl_optins=" + clr_org +
  26037. "&stmt_begndate=" + start_time +
  26038. "&stm_enddate=" + end_time +
  26039. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26040. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26041. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26042. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26043. "&fixmedins_code=" + miConfig.Code +
  26044. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26045. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26046. "&secret_key=" + miConfig.SecretKey +
  26047. "&org_name=" + miConfig.OrgName +
  26048. "&doctor=" + user_name
  26049. fmt.Println(api)
  26050. resp, requestErr := http.Get(api)
  26051. if requestErr != nil {
  26052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26053. return
  26054. }
  26055. body, ioErr := ioutil.ReadAll(resp.Body)
  26056. fmt.Println(body)
  26057. if ioErr != nil {
  26058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26060. return
  26061. }
  26062. var respJSON map[string]interface{}
  26063. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26066. return
  26067. }
  26068. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26069. userJSONBytes, _ := json.Marshal(respJSON)
  26070. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26071. utils.ErrorLog("解析失败:%v", err)
  26072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26073. return
  26074. }
  26075. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26076. var baseParams models.BaseParams
  26077. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26078. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  26079. baseParams.SecretKey = miConfig.SecretKey
  26080. baseParams.OrgName = miConfig.OrgName
  26081. baseParams.FixmedinsCode = miConfig.Code
  26082. baseParams.EncKey = miConfig.EncKey
  26083. baseParams.AppSecret = miConfig.AppSecret
  26084. baseParams.SignKey = miConfig.SignKey
  26085. baseParams.AppID = miConfig.Code
  26086. baseParams.Doctor = role.UserName
  26087. baseParams.RequestUrl = miConfig.Url
  26088. if clr_type == "9903" {
  26089. clr_type = "9901"
  26090. }
  26091. businessParams := models.BusinessParams{
  26092. Insutype: insutype,
  26093. ClrType: clr_type,
  26094. SetlOptins: "360302",
  26095. StmtBegndate: start_time,
  26096. StmtEnddate: end_time,
  26097. MedfeeSumamt: 0,
  26098. FundPaySumamt: 0,
  26099. AcctPay: 0,
  26100. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26101. }
  26102. 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))
  26103. fmt.Println(requestLog)
  26104. fmt.Println(result)
  26105. var dat map[string]interface{}
  26106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26107. fmt.Println(dat)
  26108. } else {
  26109. fmt.Println(err)
  26110. }
  26111. userJSONBytes, _ := json.Marshal(dat)
  26112. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26113. utils.ErrorLog("解析失败:%v", err)
  26114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26115. return
  26116. }
  26117. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26118. var api string
  26119. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  26120. "&clr_type=" + clr_type +
  26121. "&setl_optins=" + clr_org +
  26122. "&stmt_begndate=" + start_time +
  26123. "&stm_enddate=" + end_time +
  26124. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26125. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26126. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26127. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  26128. "&fixmedins_code=" + miConfig.Code +
  26129. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26130. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26131. "&secret_key=" + miConfig.SecretKey +
  26132. "&org_name=" + miConfig.OrgName +
  26133. "&doctor=" + user_name + "&url=" + miConfig.Url
  26134. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26135. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26136. resp, requestErr := http.Get(api)
  26137. if requestErr != nil {
  26138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26139. return
  26140. }
  26141. body, ioErr := ioutil.ReadAll(resp.Body)
  26142. if ioErr != nil {
  26143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26145. return
  26146. }
  26147. var respJSON map[string]interface{}
  26148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26151. return
  26152. }
  26153. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26154. if status == "0" {
  26155. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26156. c.ServeSuccessJSON(map[string]interface{}{
  26157. "failed_code": -10,
  26158. "msg": err_msg,
  26159. })
  26160. return
  26161. }
  26162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26163. userJSONBytes, _ := json.Marshal(respJSON)
  26164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26165. utils.ErrorLog("解析失败:%v", err)
  26166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26167. return
  26168. }
  26169. } else {
  26170. if len(clr_type) == 0 {
  26171. clr_type = "11"
  26172. }
  26173. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26174. "insutype=" + insutype +
  26175. "&clr_type=" + clr_type +
  26176. "&setl_optins=" + clr_org +
  26177. "&stmt_begndate=" + start_time +
  26178. "&stm_enddate=" + end_time +
  26179. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26180. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26181. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26182. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26183. "&fixmedins_code=" + miConfig.Code +
  26184. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26185. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26186. "&secret_key=" + miConfig.SecretKey +
  26187. "&org_name=" + miConfig.OrgName +
  26188. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  26189. fmt.Println(api)
  26190. resp, requestErr := http.Get(api)
  26191. if requestErr != nil {
  26192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26193. return
  26194. }
  26195. body, ioErr := ioutil.ReadAll(resp.Body)
  26196. fmt.Println(body)
  26197. if ioErr != nil {
  26198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26200. return
  26201. }
  26202. var respJSON map[string]interface{}
  26203. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26206. return
  26207. }
  26208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26209. userJSONBytes, _ := json.Marshal(respJSON)
  26210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26211. utils.ErrorLog("解析失败:%v", err)
  26212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26213. return
  26214. }
  26215. }
  26216. if res.Infcode == 0 {
  26217. if res.Output.Stmtinfo.StmtRslt == "0" {
  26218. micc := &models.MedicalInsuranceCostCompare{
  26219. StartTime: startime.Unix(),
  26220. EndTime: endtime.Unix(),
  26221. Insutype: insutype,
  26222. CheckType: 1,
  26223. Num: fixmedins_setl_cnt,
  26224. Mtime: time.Now().Unix(),
  26225. Status: 1,
  26226. UserOrgId: adminUser.CurrentOrgId,
  26227. CostTotal: medfee_sumamt,
  26228. FuncTotal: fund_pay_sumamt,
  26229. PsnPay: acct_pay,
  26230. Creator: admin_user_id,
  26231. Ctime: time.Now().Unix(),
  26232. ClrType: clr_type,
  26233. }
  26234. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  26235. if err == nil {
  26236. c.ServeSuccessJSON(map[string]interface{}{
  26237. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26238. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26239. })
  26240. } else {
  26241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26242. }
  26243. } else {
  26244. c.ServeSuccessJSON(map[string]interface{}{
  26245. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26246. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26247. })
  26248. }
  26249. } else {
  26250. c.ServeSuccessJSON(map[string]interface{}{
  26251. "failed_code": -10,
  26252. "msg": res.ErrMsg,
  26253. })
  26254. }
  26255. }
  26256. }
  26257. func (c *HisApiController) Check310() {
  26258. adminUser := c.GetAdminUserInfo()
  26259. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26260. var user_name string
  26261. user_name = "高慧裕"
  26262. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26263. "insutype=" + "310" +
  26264. "&clr_type=" + "" +
  26265. "&setl_optins=" + "441202" +
  26266. "&stmt_begndate=" + "2022-03-01" +
  26267. "&stm_enddate=" + "2022-03-31" +
  26268. "&medfee_sumamt=" + "194930.12" +
  26269. "&fund_pay_sumamt=" + "188741.46" +
  26270. "&acct_pay=" + "0" +
  26271. "&fixmedins_setl_cnt=" + "452" +
  26272. "&fixmedins_code=" + miConfig.Code +
  26273. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26274. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26275. "&secret_key=" + miConfig.SecretKey +
  26276. "&org_name=" + miConfig.OrgName +
  26277. "&doctor=" + user_name
  26278. fmt.Println(api)
  26279. resp, requestErr := http.Get(api)
  26280. if requestErr != nil {
  26281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26282. return
  26283. }
  26284. body, ioErr := ioutil.ReadAll(resp.Body)
  26285. fmt.Println(body)
  26286. if ioErr != nil {
  26287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26289. return
  26290. }
  26291. var respJSON map[string]interface{}
  26292. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26295. return
  26296. }
  26297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26298. userJSONBytes, _ := json.Marshal(respJSON)
  26299. var res ResultEight
  26300. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26301. utils.ErrorLog("解析失败:%v", err)
  26302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26303. return
  26304. }
  26305. }
  26306. func (c *HisApiController) Check390() {
  26307. adminUser := c.GetAdminUserInfo()
  26308. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26309. var user_name string
  26310. user_name = "高慧裕"
  26311. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26312. "insutype=" + "390" +
  26313. "&clr_type=" + "" +
  26314. "&setl_optins=" + "441202" +
  26315. "&stmt_begndate=" + "2022-03-01" +
  26316. "&stm_enddate=" + "2022-03-31" +
  26317. "&medfee_sumamt=" + "1068448.89" +
  26318. "&fund_pay_sumamt=" + "1014677.62" +
  26319. "&acct_pay=" + "0" +
  26320. "&fixmedins_setl_cnt=" + "1950" +
  26321. "&fixmedins_code=" + miConfig.Code +
  26322. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26323. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26324. "&secret_key=" + miConfig.SecretKey +
  26325. "&org_name=" + miConfig.OrgName +
  26326. "&doctor=" + user_name
  26327. fmt.Println(api)
  26328. resp, requestErr := http.Get(api)
  26329. if requestErr != nil {
  26330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26331. return
  26332. }
  26333. body, ioErr := ioutil.ReadAll(resp.Body)
  26334. fmt.Println(body)
  26335. if ioErr != nil {
  26336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26338. return
  26339. }
  26340. var respJSON map[string]interface{}
  26341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26344. return
  26345. }
  26346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26347. userJSONBytes, _ := json.Marshal(respJSON)
  26348. var res ResultEight
  26349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26350. utils.ErrorLog("解析失败:%v", err)
  26351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26352. return
  26353. }
  26354. }
  26355. // 对账明细
  26356. func (c *HisApiController) GetCheckDetailAccount() {
  26357. start_time := c.GetString("start_time")
  26358. end_time := c.GetString("end_time")
  26359. admin_user_id, _ := c.GetInt64("admin_user_id")
  26360. adminUser := c.GetAdminUserInfo()
  26361. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26362. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26363. timeLayout := "2006-01-02"
  26364. loc, _ := time.LoadLocation("Local")
  26365. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26366. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  26367. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  26368. rand.Seed(time.Now().UnixNano())
  26369. num := rand.Intn(30000)
  26370. Mkdir(miConfig.OrgName)
  26371. file := strconv.FormatInt(int64(num), 10)
  26372. file_name := file + ".txt"
  26373. zip_name := file + ".zip"
  26374. zip_path := miConfig.OrgName + "/" + zip_name
  26375. file_path := miConfig.OrgName + "/" + file_name
  26376. decimal.DivisionPrecision = 2
  26377. var medfee_sumamt float64
  26378. var psn_cash_pay float64
  26379. var fund_pay_sumamt float64
  26380. fixmedins_setl_cnt := int64(len(orders))
  26381. for _, item := range orders {
  26382. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  26383. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  26384. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  26385. }
  26386. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  26387. defer f.Close()
  26388. if err != nil {
  26389. fmt.Println(err.Error())
  26390. } else {
  26391. for _, item := range orders {
  26392. var refd_setl_flag string
  26393. if item.OrderStatus == 2 {
  26394. refd_setl_flag = "0"
  26395. var str string
  26396. str = item.SetlId + " " +
  26397. item.MdtrtId + " " +
  26398. item.PsnNo + " " +
  26399. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26400. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26401. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  26402. _, err = f.Write([]byte(str))
  26403. }
  26404. if item.OrderStatus == 3 {
  26405. var str string
  26406. str = item.SetlId + " " +
  26407. item.MdtrtId + " " +
  26408. item.PsnNo + " " +
  26409. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26410. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26411. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  26412. _, err = f.Write([]byte(str))
  26413. var str2 string
  26414. str2 = item.SetlId + " " +
  26415. item.MdtrtId + " " +
  26416. item.PsnNo + " " +
  26417. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  26418. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  26419. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  26420. _, err = f.Write([]byte(str2))
  26421. }
  26422. }
  26423. }
  26424. Zip(file_path, zip_path)
  26425. fmt.Println(ReadFile(zip_path))
  26426. fmt.Println(string(ReadFile(zip_path)))
  26427. if config.IsOpen == 1 {
  26428. var user_name string
  26429. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26430. if role.ID == 0 {
  26431. user_name = "管理员"
  26432. } else {
  26433. user_name = role.UserName
  26434. }
  26435. baseParams := models.BaseParams{
  26436. SecretKey: miConfig.SecretKey,
  26437. FixmedinsCode: miConfig.Code,
  26438. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26439. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26440. OrgName: miConfig.OrgName,
  26441. Doctor: user_name,
  26442. }
  26443. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  26444. var dat map[string]interface{}
  26445. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26446. fmt.Println(dat)
  26447. } else {
  26448. fmt.Println(err)
  26449. }
  26450. userJSONBytes, _ := json.Marshal(dat)
  26451. var res ResultNine
  26452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26453. utils.ErrorLog("解析失败:%v", err)
  26454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26455. return
  26456. }
  26457. if res.Infcode == 0 {
  26458. fileNo := res.Output.FileQuryNo
  26459. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  26460. "file_qury_no=" + fileNo +
  26461. "&setl_optins=" + "定点医保中心" +
  26462. "&stmt_begndate=" + start_time +
  26463. "&stm_enddate=" + end_time +
  26464. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26465. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26466. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  26467. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26468. "&fixmedins_code=" + miConfig.Code +
  26469. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26470. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26471. "&secret_key=" + miConfig.SecretKey +
  26472. "&org_name=" + miConfig.OrgName +
  26473. "&doctor=" + user_name
  26474. resp, requestErr := http.Get(api)
  26475. if requestErr != nil {
  26476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26477. return
  26478. }
  26479. body, ioErr := ioutil.ReadAll(resp.Body)
  26480. if ioErr != nil {
  26481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26483. return
  26484. }
  26485. var respJSON map[string]interface{}
  26486. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26489. return
  26490. }
  26491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26492. userJSONBytes, _ := json.Marshal(respJSON)
  26493. var res ResultTen
  26494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26495. utils.ErrorLog("解析失败:%v", err)
  26496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26497. return
  26498. }
  26499. if res.Infcode == 0 {
  26500. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  26501. micc := &models.MedicalInsuranceCostCompare{
  26502. StartTime: startime.Unix(),
  26503. EndTime: endtime.Unix(),
  26504. Insutype: "0",
  26505. CheckType: 2,
  26506. Num: fixmedins_setl_cnt,
  26507. Mtime: time.Now().Unix(),
  26508. Status: 1,
  26509. UserOrgId: adminUser.CurrentOrgId,
  26510. CostTotal: medfee_sumamt,
  26511. FuncTotal: fund_pay_sumamt,
  26512. PsnPay: psn_cash_pay,
  26513. Creator: admin_user_id,
  26514. Ctime: time.Now().Unix(),
  26515. }
  26516. service.CreateMedicalInsuranceCostCompareRecord(micc)
  26517. c.ServeSuccessJSON(map[string]interface{}{
  26518. "msg": "明细对账成功",
  26519. })
  26520. }
  26521. } else {
  26522. }
  26523. }
  26524. }
  26525. type CustomOrderInfo struct {
  26526. Name string
  26527. Spec string
  26528. Unit string
  26529. Count float64
  26530. Price float64
  26531. Total float64
  26532. }
  26533. func (c *HisApiController) GetBatchSettleAccounts() {
  26534. admin_user_id, _ := c.GetInt64("admin_user_id")
  26535. order_ids := c.GetString("order_ids")
  26536. order_ids_arr := strings.Split(order_ids, ",")
  26537. data3 := []map[string]interface{}{}
  26538. for _, item := range order_ids_arr {
  26539. id, _ := strconv.ParseInt(item, 10, 64)
  26540. order_id := id
  26541. adminUser := c.GetAdminUserInfo()
  26542. order, _ := service.GetHisOrderByID(order_id)
  26543. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26544. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26545. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26546. orderInfos = append(orderInfos, orderInfos_two...)
  26547. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26548. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26549. var diagnosis_ids []string
  26550. if his.ID > 0 {
  26551. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26552. } else {
  26553. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26554. }
  26555. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26556. var dia_config []*models.HisXtDiagnoseConfig
  26557. var name string
  26558. for _, item := range diagnosis_ids {
  26559. id, _ := strconv.ParseInt(item, 10, 64)
  26560. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26561. dia_config = append(dia_config, &diagnosisConfig)
  26562. if len(name) == 0 {
  26563. name = diagnosisConfig.ClassName
  26564. }
  26565. //} else {
  26566. // name = name + "," + diagnosisConfig.ClassName
  26567. //}
  26568. }
  26569. var bedCostTotal float64 = 0 //床位总费
  26570. var bedCostSelfTotal float64 = 0 //床位自费
  26571. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26572. var bedSelfTotal float64 = 0 //床位部分项目自费
  26573. var bedInscpTotal float64 = 0 //床位部分项目自费
  26574. var operationCostTotal float64 = 0 //手术费
  26575. var operationCostSelfTotal float64 = 0 //手术费
  26576. var operationCostPartSelfTotal float64 = 0 //手术费
  26577. var operationSelfTotal float64 = 0 //床位部分项目自费
  26578. var operationInscpTotal float64 = 0 //床位部分项目自费
  26579. var otherCostTotal float64 = 0 //其他费用
  26580. var otherCostSelfTotal float64 = 0 //其他费用
  26581. var otherCostPartSelfTotal float64 = 0 //其他费用
  26582. var otherSelfTotal float64 = 0 //床位部分项目自费
  26583. var otherInscpTotal float64 = 0 //床位部分项目自费
  26584. var materialCostTotal float64 = 0 //材料费
  26585. var materialCostSelfTotal float64 = 0 //材料费
  26586. var materialCostPartSelfTotal float64 = 0 //材料费
  26587. var materialSelfTotal float64 = 0 //床位部分项目自费
  26588. var materialInscpTotal float64 = 0 //床位部分项目自费
  26589. var westernMedicineCostTotal float64 = 0 //西药费
  26590. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26591. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26592. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26593. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26594. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26595. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26596. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26597. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26598. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26599. var checkCostTotal float64 = 0 //检查费
  26600. var checkCostSelfTotal float64 = 0 //检查费
  26601. var checkCostPartSelfTotal float64 = 0 //检查费
  26602. var checkSelfTotal float64 = 0 //床位部分项目自费
  26603. var checkInscpTotal float64 = 0 //床位部分项目自费
  26604. var laboratoryCostTotal float64 = 0 //化验费
  26605. var laboratoryCostSelfTotal float64 = 0 //化验费
  26606. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26607. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26608. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26609. var treatCostTotal float64 = 0 //治疗费用
  26610. var treatCostSelfTotal float64 = 0 //治疗费用
  26611. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26612. var treatSelfTotal float64 = 0 //床位部分项目自费
  26613. var treatInscpTotal float64 = 0 //床位部分项目自费
  26614. decimal.DivisionPrecision = 2
  26615. for _, item := range orderInfos {
  26616. if item.MedChrgitmType == "01" { //床位费
  26617. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26618. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26619. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26620. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26621. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26622. }
  26623. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26624. if item.MedChrgitmType == "03" { //检查费
  26625. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26626. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26627. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26628. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26629. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26630. }
  26631. } else {
  26632. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26633. fmt.Println("------------")
  26634. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26635. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26636. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26637. }
  26638. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26639. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26640. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26641. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26642. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26643. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26644. }
  26645. }
  26646. if item.MedChrgitmType == "04" { //化验费
  26647. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26648. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26649. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26650. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26651. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26652. }
  26653. if item.MedChrgitmType == "05" { //治疗费
  26654. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26655. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26656. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26657. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26658. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26659. }
  26660. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26661. fmt.Println("------------")
  26662. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26663. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26664. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26665. }
  26666. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26667. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26668. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26669. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26670. }
  26671. //if item.MedChrgitmType == "06" { //手术费
  26672. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26673. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26674. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26675. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26676. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26677. //
  26678. //}
  26679. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26680. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26681. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26682. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26683. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26684. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26685. }
  26686. if item.MedChrgitmType == "09" { //西药费
  26687. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26688. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26689. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26690. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26691. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26692. }
  26693. if item.MedChrgitmType == "11" { //中成费
  26694. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26695. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26696. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26697. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26698. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26699. }
  26700. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26701. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26702. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26703. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26704. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26705. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26706. }
  26707. }
  26708. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26709. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26710. var user_name string
  26711. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26712. if role.ID == 0 {
  26713. user_name = "管理员"
  26714. } else {
  26715. user_name = role.UserName
  26716. }
  26717. baseParams := models.BaseParams{
  26718. SecretKey: miConfig.SecretKey,
  26719. FixmedinsCode: miConfig.Code,
  26720. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26721. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26722. OrgName: miConfig.OrgName,
  26723. Doctor: user_name,
  26724. RequestUrl: miConfig.Url,
  26725. AccessKey: miConfig.AccessKey,
  26726. }
  26727. businessParams := models.BusinessParams{
  26728. PsnNo: order.PsnNo,
  26729. MdtrtId: order.MdtrtId,
  26730. SetlId: order.SetlId,
  26731. }
  26732. var res ResultEleven
  26733. var resEleven10265 ResultEleven10265
  26734. if config.IsOpen == 1 {
  26735. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26736. result := service.Gdyb5203(baseParams, businessParams)
  26737. service.Gdyb5204(baseParams, businessParams)
  26738. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26739. var dat map[string]interface{}
  26740. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26741. fmt.Println(dat)
  26742. } else {
  26743. fmt.Println(err)
  26744. }
  26745. userJSONBytes, _ := json.Marshal(dat)
  26746. if miConfig.Code == "H15049901371" {
  26747. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26748. utils.ErrorLog("解析失败:%v", err)
  26749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26750. return
  26751. }
  26752. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26753. res.Output = resEleven10265.Output
  26754. res.ErrMsg = resEleven10265.ErrMsg
  26755. res.Cainfo = resEleven10265.Cainfo
  26756. res.WarnMsg = resEleven10265.WarnMsg
  26757. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26758. res.Infcode = infocode
  26759. } else {
  26760. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26761. utils.ErrorLog("解析失败:%v", err)
  26762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26763. return
  26764. }
  26765. }
  26766. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26767. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26768. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26769. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26770. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26771. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26772. var doctor_name string
  26773. if roles.ID == 0 {
  26774. doctor_name = "管理员"
  26775. } else {
  26776. doctor_name = roles.UserName
  26777. }
  26778. yiliao_leibie := ""
  26779. switch order.MedType {
  26780. case "11":
  26781. yiliao_leibie = "普通门诊"
  26782. break
  26783. case "12":
  26784. yiliao_leibie = "门诊挂号"
  26785. break
  26786. case "13":
  26787. yiliao_leibie = "急诊"
  26788. break
  26789. case "14":
  26790. yiliao_leibie = "门诊特殊病"
  26791. break
  26792. case "15":
  26793. yiliao_leibie = "门诊统筹"
  26794. break
  26795. case "16":
  26796. yiliao_leibie = "门诊慢性病"
  26797. break
  26798. case "21":
  26799. yiliao_leibie = "普通住院"
  26800. break
  26801. }
  26802. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26803. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  26804. if res.Infcode == 0 {
  26805. data2 := map[string]interface{}{
  26806. "diagnosis": name,
  26807. "order_infos": orderInfos,
  26808. "number": order.MdtrtId,
  26809. "date": order.SettleAccountsDate,
  26810. "charge_admin": charge_admin,
  26811. "printor_admin": printor_admin,
  26812. "info": res.Output.Setlinfo,
  26813. "order": order,
  26814. "bedCostTotal": bedCostTotal,
  26815. "bedCostSelfTotal": bedCostSelfTotal,
  26816. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26817. "bedSelfTotal": bedSelfTotal,
  26818. "bedInscpTotal": bedInscpTotal,
  26819. "operationCostTotal": operationCostTotal,
  26820. "operationCostSelfTotal": operationCostSelfTotal,
  26821. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26822. "operationSelfTotal": operationSelfTotal,
  26823. "operationInscpTotal": operationInscpTotal,
  26824. "otherCostTotal": otherCostTotal,
  26825. "otherCostSelfTotal": otherCostSelfTotal,
  26826. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26827. "otherSelfTotal": otherSelfTotal,
  26828. "otherInscpTotal": otherInscpTotal,
  26829. "materialCostTotal": materialCostTotal,
  26830. "materialCostSelfTotal": materialCostSelfTotal,
  26831. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26832. "materialSelfTotal": materialSelfTotal,
  26833. "materialInscpTotal": materialInscpTotal,
  26834. "westernMedicineCostTotal": westernMedicineCostTotal,
  26835. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26836. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26837. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26838. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26839. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26840. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26841. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26842. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26843. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26844. "checkCostTotal": checkCostTotal,
  26845. "checkCostSelfTotal": checkCostSelfTotal,
  26846. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26847. "checkSelfTotal": checkSelfTotal,
  26848. "checkInscpTotal": checkInscpTotal,
  26849. "laboratoryCostTotal": laboratoryCostTotal,
  26850. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26851. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26852. "laboratorySelfTotal": laboratorySelfTotal,
  26853. "laboratoryInscpTotal": laboratoryInscpTotal,
  26854. "treatCostTotal": treatCostTotal,
  26855. "treatCostSelfTotal": treatCostSelfTotal,
  26856. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26857. "treatSelfTotal": treatSelfTotal,
  26858. "treatInscpTotal": treatInscpTotal,
  26859. "doctor_info": doctor_info,
  26860. "doctor_code": adminRole_two.DoctorCode,
  26861. "doctor_name": doctor_name,
  26862. "health_card_no": order.PsnNo,
  26863. "department": departments.Name,
  26864. "yiliao_leibie": yiliao_leibie,
  26865. "after_money": order.AccountPrice,
  26866. "patient": patient,
  26867. "org_name": miConfig.OrgName,
  26868. "org_code": miConfig.Code,
  26869. "order_number": order.Number,
  26870. "his_hospital": his_hospital,
  26871. "his": his,
  26872. "dia_config": dia_config,
  26873. "psn_cash_pay": order.PsnCashPay,
  26874. //"check_order_info": cus_slice,
  26875. }
  26876. data3 = append(data3, data2)
  26877. }
  26878. }
  26879. }
  26880. c.ServeSuccessJSON(map[string]interface{}{
  26881. "infos": data3,
  26882. })
  26883. }
  26884. func (c *HisApiController) GetSettleAccounts() {
  26885. //id, _ := c.GetInt64("id")
  26886. //record_time := c.GetString("record_time")
  26887. order_id, _ := c.GetInt64("order_id")
  26888. admin_user_id, _ := c.GetInt64("admin_user_id")
  26889. //timeLayout := "2006-01-02"
  26890. //loc, _ := time.LoadLocation("Local")
  26891. //
  26892. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26893. //if err != nil {
  26894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26895. // return
  26896. //}Hbyb5203
  26897. //recordDateTime := theTime.Unix()
  26898. adminUser := c.GetAdminUserInfo()
  26899. order, _ := service.GetHisOrderByID(order_id)
  26900. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26901. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26902. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26903. orderInfos = append(orderInfos, orderInfos_two...)
  26904. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26905. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26906. var diagnosis_ids []string
  26907. if his.ID > 0 {
  26908. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26909. } else {
  26910. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26911. }
  26912. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26913. var dia_config []*models.HisXtDiagnoseConfig
  26914. var name string
  26915. for _, item := range diagnosis_ids {
  26916. id, _ := strconv.ParseInt(item, 10, 64)
  26917. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26918. dia_config = append(dia_config, &diagnosisConfig)
  26919. if len(name) == 0 {
  26920. name = diagnosisConfig.ClassName
  26921. } else {
  26922. name = name + "," + diagnosisConfig.ClassName
  26923. }
  26924. }
  26925. if patient.UserOrgId == 10215 {
  26926. name = "慢性肾功能不全(血透治疗)"
  26927. }
  26928. var bedCostTotal float64 = 0 //床位总费
  26929. var bedCostSelfTotal float64 = 0 //床位自费
  26930. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26931. var bedSelfTotal float64 = 0 //床位部分项目自费
  26932. var bedInscpTotal float64 = 0 //床位部分项目自费
  26933. var operationCostTotal float64 = 0 //手术费
  26934. var operationCostSelfTotal float64 = 0 //手术费
  26935. var operationCostPartSelfTotal float64 = 0 //手术费
  26936. var operationSelfTotal float64 = 0 //床位部分项目自费
  26937. var operationInscpTotal float64 = 0 //床位部分项目自费
  26938. var otherCostTotal float64 = 0 //其他费用
  26939. var otherCostSelfTotal float64 = 0 //其他费用
  26940. var otherCostPartSelfTotal float64 = 0 //其他费用
  26941. var otherSelfTotal float64 = 0 //床位部分项目自费
  26942. var otherInscpTotal float64 = 0 //床位部分项目自费
  26943. var materialCostTotal float64 = 0 //材料费
  26944. var materialCostSelfTotal float64 = 0 //材料费
  26945. var materialCostPartSelfTotal float64 = 0 //材料费
  26946. var materialSelfTotal float64 = 0 //床位部分项目自费
  26947. var materialInscpTotal float64 = 0 //床位部分项目自费
  26948. var westernMedicineCostTotal float64 = 0 //西药费
  26949. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26950. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26951. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26952. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26953. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26954. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26955. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26956. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26957. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26958. var checkCostTotal float64 = 0 //检查费
  26959. var checkCostSelfTotal float64 = 0 //检查费
  26960. var checkCostPartSelfTotal float64 = 0 //检查费
  26961. var checkSelfTotal float64 = 0 //床位部分项目自费
  26962. var checkInscpTotal float64 = 0 //床位部分项目自费
  26963. var laboratoryCostTotal float64 = 0 //化验费
  26964. var laboratoryCostSelfTotal float64 = 0 //化验费
  26965. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26966. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26967. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26968. var treatCostTotal float64 = 0 //治疗费用
  26969. var treatCostSelfTotal float64 = 0 //治疗费用
  26970. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26971. var treatSelfTotal float64 = 0 //床位部分项目自费
  26972. var treatInscpTotal float64 = 0 //床位部分项目自费
  26973. decimal.DivisionPrecision = 2
  26974. for _, item := range orderInfos {
  26975. if item.MedChrgitmType == "01" { //床位费
  26976. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26977. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26978. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26979. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26980. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26981. }
  26982. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26983. if item.MedChrgitmType == "03" { //检查费
  26984. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26985. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26986. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26987. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26988. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26989. }
  26990. } else {
  26991. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26992. fmt.Println("------------")
  26993. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26994. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26995. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26996. }
  26997. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26998. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26999. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27000. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27001. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27002. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27003. }
  27004. }
  27005. if item.MedChrgitmType == "04" { //化验费
  27006. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27007. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27008. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27009. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27010. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27011. }
  27012. if item.MedChrgitmType == "05" { //治疗费
  27013. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27014. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27015. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27016. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27017. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27018. }
  27019. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  27020. fmt.Println("------------")
  27021. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27022. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27023. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27024. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27025. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27026. }
  27027. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  27028. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27029. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27030. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27031. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27032. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27033. }
  27034. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  27035. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27036. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27037. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27038. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27039. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27040. }
  27041. if item.MedChrgitmType == "09" { //西药费
  27042. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27043. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27044. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27045. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27046. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27047. }
  27048. if item.MedChrgitmType == "11" { //中成费
  27049. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27050. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27051. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27052. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27053. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27054. }
  27055. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  27056. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27057. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27058. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27059. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27060. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27061. }
  27062. }
  27063. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27064. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27065. var user_name string
  27066. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27067. if role.ID == 0 {
  27068. user_name = "管理员"
  27069. } else {
  27070. user_name = role.UserName
  27071. }
  27072. baseParams := models.BaseParams{
  27073. SecretKey: miConfig.SecretKey,
  27074. FixmedinsCode: miConfig.Code,
  27075. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27076. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27077. OrgName: miConfig.OrgName,
  27078. Doctor: user_name,
  27079. RequestUrl: miConfig.Url,
  27080. AccessKey: miConfig.AccessKey,
  27081. }
  27082. businessParams := models.BusinessParams{
  27083. PsnNo: order.PsnNo,
  27084. MdtrtId: order.MdtrtId,
  27085. SetlId: order.SetlId,
  27086. }
  27087. var res ResultEleven
  27088. var resah ResultElevenah
  27089. var resEleven10265 ResultEleven10265
  27090. if config.IsOpen == 1 {
  27091. if miConfig.MdtrtareaAdmvs == "421300" {
  27092. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27093. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27094. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27095. resp, requestErr := http.Get(api)
  27096. if requestErr != nil {
  27097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27098. return
  27099. }
  27100. body, ioErr := ioutil.ReadAll(resp.Body)
  27101. if ioErr != nil {
  27102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27104. return
  27105. }
  27106. var respJSON map[string]interface{}
  27107. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27110. return
  27111. }
  27112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27113. result, _ := json.Marshal(respJSON)
  27114. fmt.Println("log")
  27115. fmt.Println(string(result))
  27116. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27117. utils.ErrorLog("解析失败:%v", err)
  27118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27119. return
  27120. }
  27121. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27122. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27123. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27124. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27125. resp, requestErr := http.Get(api)
  27126. if requestErr != nil {
  27127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27128. return
  27129. }
  27130. body, ioErr := ioutil.ReadAll(resp.Body)
  27131. if ioErr != nil {
  27132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27134. return
  27135. }
  27136. var respJSON map[string]interface{}
  27137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27140. return
  27141. }
  27142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27143. result, _ := json.Marshal(respJSON)
  27144. fmt.Println("log")
  27145. fmt.Println(string(result))
  27146. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27147. utils.ErrorLog("解析失败:%v", err)
  27148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27149. return
  27150. }
  27151. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27152. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27153. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27154. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27155. resp, requestErr := http.Get(api)
  27156. if requestErr != nil {
  27157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27158. return
  27159. }
  27160. body, ioErr := ioutil.ReadAll(resp.Body)
  27161. if ioErr != nil {
  27162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27164. return
  27165. }
  27166. var respJSON map[string]interface{}
  27167. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27170. return
  27171. }
  27172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27173. result, _ := json.Marshal(respJSON)
  27174. fmt.Println("log")
  27175. fmt.Println(string(result))
  27176. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27177. utils.ErrorLog("解析失败:%v", err)
  27178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27179. return
  27180. }
  27181. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27182. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27183. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27184. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  27185. resp, requestErr := http.Get(api)
  27186. if requestErr != nil {
  27187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27188. return
  27189. }
  27190. body, ioErr := ioutil.ReadAll(resp.Body)
  27191. if ioErr != nil {
  27192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27194. return
  27195. }
  27196. var respJSON map[string]interface{}
  27197. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27200. return
  27201. }
  27202. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27203. result, _ := json.Marshal(respJSON)
  27204. fmt.Println("log")
  27205. fmt.Println(string(result))
  27206. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27207. utils.ErrorLog("解析失败:%v", err)
  27208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27209. return
  27210. }
  27211. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27212. var api string
  27213. if miConfig.MdtrtareaAdmvs == "320921" {
  27214. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27215. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27216. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27217. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27218. } else {
  27219. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27220. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27221. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27222. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27223. }
  27224. resp, requestErr := http.Get(api)
  27225. if requestErr != nil {
  27226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27227. return
  27228. }
  27229. body, ioErr := ioutil.ReadAll(resp.Body)
  27230. if ioErr != nil {
  27231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27233. return
  27234. }
  27235. var respJSON map[string]interface{}
  27236. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27239. return
  27240. }
  27241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27242. result, _ := json.Marshal(respJSON)
  27243. fmt.Println("log")
  27244. fmt.Println(string(result))
  27245. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27246. utils.ErrorLog("解析失败:%v", err)
  27247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27248. return
  27249. }
  27250. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27251. res.Output = resEleven10265.Output
  27252. res.ErrMsg = resEleven10265.ErrMsg
  27253. res.Cainfo = resEleven10265.Cainfo
  27254. res.WarnMsg = resEleven10265.WarnMsg
  27255. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27256. res.Infcode = infocode
  27257. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27258. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  27259. saveLog(result, requestLog, "5203", "结算单")
  27260. var dat map[string]interface{}
  27261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27262. fmt.Println(dat)
  27263. } else {
  27264. fmt.Println(err)
  27265. }
  27266. userJSONBytes, _ := json.Marshal(dat)
  27267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27268. utils.ErrorLog("解析失败:%v", err)
  27269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27270. return
  27271. }
  27272. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27273. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  27274. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  27275. fmt.Println(result3)
  27276. fmt.Println(requestLog3)
  27277. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  27278. fmt.Println(result2)
  27279. fmt.Println(requestLog2)
  27280. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  27281. saveLog(result, requestLog, "5203", "结算单")
  27282. var dat map[string]interface{}
  27283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27284. fmt.Println(dat)
  27285. } else {
  27286. fmt.Println(err)
  27287. }
  27288. userJSONBytes, _ := json.Marshal(dat)
  27289. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27290. utils.ErrorLog("解析失败:%v", err)
  27291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27292. return
  27293. }
  27294. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27295. var api string
  27296. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27297. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27298. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27299. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27300. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27301. resp, requestErr := http.Get(api)
  27302. if requestErr != nil {
  27303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27304. return
  27305. }
  27306. body, ioErr := ioutil.ReadAll(resp.Body)
  27307. if ioErr != nil {
  27308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27310. return
  27311. }
  27312. var respJSON map[string]interface{}
  27313. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27316. return
  27317. }
  27318. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27319. if status == "0" {
  27320. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27321. c.ServeSuccessJSON(map[string]interface{}{
  27322. "failed_code": -10,
  27323. "msg": err_msg,
  27324. })
  27325. return
  27326. }
  27327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27328. result, _ := json.Marshal(respJSON)
  27329. fmt.Println("log")
  27330. fmt.Println(string(result))
  27331. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  27332. utils.ErrorLog("解析失败:%v", err)
  27333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27334. return
  27335. }
  27336. res.InfRefmsgid = resah.InfRefmsgid
  27337. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27338. // 创建对应的Time类型
  27339. t := time.UnixMilli(timestamp)
  27340. // 格式化成指定的日期字符串
  27341. str := t.Format("2006-01-02 15:04:05")
  27342. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27343. // 创建对应的Time类型
  27344. t3 := time.UnixMilli(timestamp2)
  27345. // 格式化成指定的日期字符串
  27346. str2 := t3.Format("2006-01-02 15:04:05")
  27347. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  27348. // 创建对应的Time类型
  27349. t4 := time.UnixMilli(timestamp3)
  27350. // 格式化成指定的日期字符串
  27351. str3 := t4.Format("2006-01-02 15:04:05")
  27352. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  27353. // 创建对应的Time类型
  27354. t5 := time.UnixMilli(timestamp4)
  27355. // 格式化成指定的日期字符串
  27356. str5 := t5.Format("2006-01-02 15:04:05")
  27357. res.Output.Setlinfo.Brdy = str2
  27358. res.Output.Setlinfo.SetlTime = str
  27359. res.Output.Setlinfo.Begndate = str3
  27360. res.Output.Setlinfo.Enddate = str5
  27361. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  27362. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  27363. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  27364. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  27365. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27366. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27367. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  27368. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  27369. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27370. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  27371. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  27372. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  27373. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27374. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  27375. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  27376. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  27377. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  27378. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  27379. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27380. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  27381. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  27382. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27383. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  27384. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  27385. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  27386. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27387. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  27388. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  27389. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  27390. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  27391. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27392. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  27393. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27394. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  27395. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  27396. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  27397. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  27398. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  27399. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  27400. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  27401. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  27402. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  27403. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  27404. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  27405. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  27406. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27407. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  27408. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  27409. //res.Output.Setldetail = resah.Output.Setldetail
  27410. res.ErrMsg = resah.ErrMsg
  27411. res.Cainfo = resah.Cainfo
  27412. res.WarnMsg = resah.WarnMsg
  27413. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27414. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  27415. saveLog(result, requestLog, "5203", "结算单")
  27416. var dat map[string]interface{}
  27417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27418. fmt.Println(dat)
  27419. } else {
  27420. fmt.Println(err)
  27421. }
  27422. userJSONBytes, _ := json.Marshal(dat)
  27423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27424. utils.ErrorLog("解析失败:%v", err)
  27425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27426. return
  27427. }
  27428. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27429. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27430. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27431. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27432. resp, requestErr := http.Get(api)
  27433. if requestErr != nil {
  27434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27435. return
  27436. }
  27437. body, ioErr := ioutil.ReadAll(resp.Body)
  27438. if ioErr != nil {
  27439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27441. return
  27442. }
  27443. var respJSON map[string]interface{}
  27444. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27447. return
  27448. }
  27449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27450. result, _ := json.Marshal(respJSON)
  27451. fmt.Println("log")
  27452. fmt.Println(string(result))
  27453. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27454. utils.ErrorLog("解析失败:%v", err)
  27455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27456. return
  27457. }
  27458. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27459. res.Output = resEleven10265.Output
  27460. res.ErrMsg = resEleven10265.ErrMsg
  27461. res.Cainfo = resEleven10265.Cainfo
  27462. res.WarnMsg = resEleven10265.WarnMsg
  27463. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27464. res.Infcode = infocode
  27465. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27466. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27467. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27468. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27469. resp, requestErr := http.Get(api)
  27470. if requestErr != nil {
  27471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27472. return
  27473. }
  27474. body, ioErr := ioutil.ReadAll(resp.Body)
  27475. if ioErr != nil {
  27476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27478. return
  27479. }
  27480. var respJSON map[string]interface{}
  27481. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27484. return
  27485. }
  27486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27487. result, _ := json.Marshal(respJSON)
  27488. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27489. utils.ErrorLog("解析失败:%v", err)
  27490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27491. return
  27492. }
  27493. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27494. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  27495. //return
  27496. } else {
  27497. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27498. if len(his.InsuplcAdmdvs) == 0 {
  27499. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  27500. } else {
  27501. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27502. }
  27503. result := service.Gdyb5203(baseParams, businessParams)
  27504. //service.Gdyb5204(baseParams, businessParams)
  27505. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27506. var dat map[string]interface{}
  27507. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27508. fmt.Println(dat)
  27509. } else {
  27510. fmt.Println(err)
  27511. }
  27512. userJSONBytes, _ := json.Marshal(dat)
  27513. if miConfig.Code == "H15049901371" {
  27514. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27515. utils.ErrorLog("解析失败:%v", err)
  27516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27517. return
  27518. }
  27519. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27520. res.Output = resEleven10265.Output
  27521. res.ErrMsg = resEleven10265.ErrMsg
  27522. res.Cainfo = resEleven10265.Cainfo
  27523. res.WarnMsg = resEleven10265.WarnMsg
  27524. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27525. res.Infcode = infocode
  27526. } else {
  27527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27528. utils.ErrorLog("解析失败:%v", err)
  27529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27530. return
  27531. }
  27532. }
  27533. }
  27534. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27535. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27536. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27537. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27538. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27539. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27540. var doctor_name string
  27541. if roles.ID == 0 {
  27542. doctor_name = "管理员"
  27543. } else {
  27544. doctor_name = roles.UserName
  27545. }
  27546. yiliao_leibie := ""
  27547. switch order.MedType {
  27548. case "11":
  27549. yiliao_leibie = "普通门诊"
  27550. break
  27551. case "12":
  27552. yiliao_leibie = "门诊挂号"
  27553. break
  27554. case "13":
  27555. yiliao_leibie = "急诊"
  27556. break
  27557. case "14":
  27558. yiliao_leibie = "门诊特殊病"
  27559. break
  27560. case "15":
  27561. yiliao_leibie = "门诊统筹"
  27562. break
  27563. case "16":
  27564. yiliao_leibie = "门诊慢性病"
  27565. break
  27566. case "21":
  27567. yiliao_leibie = "普通住院"
  27568. break
  27569. }
  27570. //var rf []CustomFundPay
  27571. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  27572. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27573. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  27574. if res.Infcode == 0 {
  27575. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  27576. c.ServeSuccessJSON(map[string]interface{}{
  27577. "diagnosis": name,
  27578. "order_infos": orderInfos,
  27579. "number": order.MdtrtId,
  27580. "date": order.SettleAccountsDate,
  27581. "charge_admin": charge_admin,
  27582. "printor_admin": printor_admin,
  27583. "info": res.Output.Setlinfo,
  27584. "order": order,
  27585. "bedCostTotal": bedCostTotal,
  27586. "bedCostSelfTotal": bedCostSelfTotal,
  27587. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27588. "bedSelfTotal": bedSelfTotal,
  27589. "bedInscpTotal": bedInscpTotal,
  27590. "operationCostTotal": operationCostTotal,
  27591. "operationCostSelfTotal": operationCostSelfTotal,
  27592. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27593. "operationSelfTotal": operationSelfTotal,
  27594. "operationInscpTotal": operationInscpTotal,
  27595. "otherCostTotal": otherCostTotal,
  27596. "otherCostSelfTotal": otherCostSelfTotal,
  27597. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27598. "otherSelfTotal": otherSelfTotal,
  27599. "otherInscpTotal": otherInscpTotal,
  27600. "materialCostTotal": materialCostTotal,
  27601. "materialCostSelfTotal": materialCostSelfTotal,
  27602. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27603. "materialSelfTotal": materialSelfTotal,
  27604. "materialInscpTotal": materialInscpTotal,
  27605. "westernMedicineCostTotal": westernMedicineCostTotal,
  27606. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27607. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27608. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27609. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27610. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27611. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27612. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27613. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27614. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27615. "checkCostTotal": checkCostTotal,
  27616. "checkCostSelfTotal": checkCostSelfTotal,
  27617. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27618. "checkSelfTotal": checkSelfTotal,
  27619. "checkInscpTotal": checkInscpTotal,
  27620. "laboratoryCostTotal": laboratoryCostTotal,
  27621. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27622. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27623. "laboratorySelfTotal": laboratorySelfTotal,
  27624. "laboratoryInscpTotal": laboratoryInscpTotal,
  27625. "treatCostTotal": treatCostTotal,
  27626. "treatCostSelfTotal": treatCostSelfTotal,
  27627. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27628. "treatSelfTotal": treatSelfTotal,
  27629. "treatInscpTotal": treatInscpTotal,
  27630. "doctor_info": doctor_info,
  27631. "doctor_code": adminRole_two.DoctorCode,
  27632. "doctor_name": doctor_name,
  27633. "health_card_no": order.PsnNo,
  27634. "department": departments.Name,
  27635. "yiliao_leibie": yiliao_leibie,
  27636. "after_money": order.AccountPrice,
  27637. "patient": patient,
  27638. "org_name": miConfig.OrgName,
  27639. "org_code": miConfig.Code,
  27640. "order_number": order.Number,
  27641. "his_hospital": his_hospital,
  27642. "his": his,
  27643. "dia_config": dia_config,
  27644. "psn_cash_pay": order.PsnCashPay,
  27645. //"funds": rf,
  27646. //"check_order_info": cus_slice,
  27647. })
  27648. } else {
  27649. c.ServeSuccessJSON(map[string]interface{}{
  27650. "diagnosis": name,
  27651. "order_infos": orderInfos,
  27652. "number": order.MdtrtId,
  27653. "date": order.SettleAccountsDate,
  27654. "charge_admin": charge_admin,
  27655. "printor_admin": printor_admin,
  27656. "info": order,
  27657. "order": order,
  27658. "bedCostTotal": bedCostTotal,
  27659. "bedCostSelfTotal": bedCostSelfTotal,
  27660. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27661. "bedSelfTotal": bedSelfTotal,
  27662. "bedInscpTotal": bedInscpTotal,
  27663. "operationCostTotal": operationCostTotal,
  27664. "operationCostSelfTotal": operationCostSelfTotal,
  27665. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27666. "operationSelfTotal": operationSelfTotal,
  27667. "operationInscpTotal": operationInscpTotal,
  27668. "otherCostTotal": otherCostTotal,
  27669. "otherCostSelfTotal": otherCostSelfTotal,
  27670. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27671. "otherSelfTotal": otherSelfTotal,
  27672. "otherInscpTotal": otherInscpTotal,
  27673. "materialCostTotal": materialCostTotal,
  27674. "materialCostSelfTotal": materialCostSelfTotal,
  27675. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27676. "materialSelfTotal": materialSelfTotal,
  27677. "materialInscpTotal": materialInscpTotal,
  27678. "westernMedicineCostTotal": westernMedicineCostTotal,
  27679. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27680. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27681. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27682. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27683. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27684. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27685. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27686. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27687. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27688. "checkCostTotal": checkCostTotal,
  27689. "checkCostSelfTotal": checkCostSelfTotal,
  27690. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27691. "checkSelfTotal": checkSelfTotal,
  27692. "checkInscpTotal": checkInscpTotal,
  27693. "laboratoryCostTotal": laboratoryCostTotal,
  27694. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27695. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27696. "laboratorySelfTotal": laboratorySelfTotal,
  27697. "laboratoryInscpTotal": laboratoryInscpTotal,
  27698. "treatCostTotal": treatCostTotal,
  27699. "treatCostSelfTotal": treatCostSelfTotal,
  27700. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27701. "treatSelfTotal": treatSelfTotal,
  27702. "treatInscpTotal": treatInscpTotal,
  27703. "doctor_info": doctor_info,
  27704. "doctor_code": adminRole_two.DoctorCode,
  27705. "doctor_name": doctor_name,
  27706. "health_card_no": order.PsnNo,
  27707. "department": departments.Name,
  27708. "yiliao_leibie": yiliao_leibie,
  27709. "after_money": order.AccountPrice,
  27710. "patient": patient,
  27711. "org_name": miConfig.OrgName,
  27712. "org_code": miConfig.Code,
  27713. "order_number": order.Number,
  27714. "his_hospital": his_hospital,
  27715. "his": his,
  27716. "dia_config": dia_config,
  27717. "psn_cash_pay": order.PsnCashPay,
  27718. //"funds": rf,
  27719. //"check_order_info": cus_slice,
  27720. })
  27721. }
  27722. }
  27723. }
  27724. }
  27725. //func (c *HisApiController) CheckTreatment() {
  27726. // patient_id, _ := c.GetInt64("patient_id")
  27727. // id_card_no := c.GetString("id_card_no")
  27728. // insutype := c.GetString("insutype")
  27729. // med_type := c.GetString("med_type")
  27730. // admin_user_id, _ := c.GetInt64("admin_user_id")
  27731. //
  27732. // adminUser := c.GetAdminUserInfo()
  27733. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27734. //
  27735. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27736. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27737. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27738. //
  27739. // if miConfig.MdtrtareaAdmvs == "421300" {
  27740. // var res ResultTwo
  27741. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  27742. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27743. // "&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)
  27744. // resp, requestErr := http.Get(api)
  27745. // if requestErr != nil {
  27746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27747. // return
  27748. // }
  27749. //
  27750. // body, ioErr := ioutil.ReadAll(resp.Body)
  27751. // if ioErr != nil {
  27752. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27754. // return
  27755. // }
  27756. // var respJSON map[string]interface{}
  27757. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27758. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27760. // return
  27761. // }
  27762. //
  27763. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27764. // result, _ := json.Marshal(respJSON)
  27765. //
  27766. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27767. // utils.ErrorLog("解析失败:%v", err)
  27768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27769. // return
  27770. // }
  27771. //
  27772. // if res.Infcode == 0 {
  27773. //
  27774. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  27775. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27776. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  27777. // resp, requestErr := http.Get(api)
  27778. // if requestErr != nil {
  27779. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27780. // return
  27781. // }
  27782. //
  27783. // body, ioErr := ioutil.ReadAll(resp.Body)
  27784. // if ioErr != nil {
  27785. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27787. // return
  27788. // }
  27789. // var respJSON map[string]interface{}
  27790. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27791. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27793. // return
  27794. // }
  27795. // var res Result2001
  27796. //
  27797. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27798. // result2, _ := json.Marshal(respJSON)
  27799. //
  27800. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  27801. // utils.ErrorLog("解析失败:%v", err)
  27802. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27803. // return
  27804. // }
  27805. //
  27806. // if res.Infcode == 0 {
  27807. // c.ServeSuccessJSON(map[string]interface{}{
  27808. // "msg": res.Output.Trtinfo,
  27809. // })
  27810. // }
  27811. //
  27812. // } else {
  27813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27814. // return
  27815. // }
  27816. //
  27817. // } else {
  27818. //
  27819. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27820. // var dat map[string]interface{}
  27821. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27822. // fmt.Println(dat)
  27823. // } else {
  27824. // fmt.Println(err)
  27825. // }
  27826. // userJSONBytes, _ := json.Marshal(dat)
  27827. // var res ResultTwo
  27828. // var res10265 ResultTwo10265
  27829. // if miConfig.Code == "H15049901371" {
  27830. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27831. // utils.ErrorLog("解析失败:%v", err)
  27832. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27833. // return
  27834. // }
  27835. // res.ErrMsg = res10265.ErrMsg
  27836. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27837. // res.Infcode = infocode
  27838. // res.Output = res10265.Output
  27839. // res.InfRefmsgid = res10265.InfRefmsgid
  27840. // } else {
  27841. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27842. // utils.ErrorLog("解析失败:%v", err)
  27843. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27844. // return
  27845. // }
  27846. // }
  27847. //
  27848. // var user_name string
  27849. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  27850. // if role.ID == 0 {
  27851. // user_name = "xxx"
  27852. // } else {
  27853. // user_name = role.UserName
  27854. // }
  27855. //
  27856. // baseParams := models.BaseParams{
  27857. // SecretKey: miConfig.SecretKey,
  27858. // FixmedinsCode: miConfig.Code,
  27859. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27860. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27861. // OrgName: miConfig.OrgName,
  27862. // Doctor: user_name,
  27863. // }
  27864. //
  27865. // if config.IsOpen == 1 {
  27866. // if miConfig.Code == "H15049901371" {
  27867. // if med_type == "14" {
  27868. // if insutype == "390" {
  27869. // med_type = "9933"
  27870. // } else if insutype == "310" {
  27871. // med_type = "990502"
  27872. // }
  27873. // } else if med_type == "11" {
  27874. // med_type = "11"
  27875. // }
  27876. // }
  27877. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  27878. // var dat map[string]interface{}
  27879. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27880. // fmt.Println(dat)
  27881. // } else {
  27882. // fmt.Println(err)
  27883. // }
  27884. // var res Result2001
  27885. // var res10265 Result2001Org10265
  27886. // if miConfig.Code == "H15049901371" {
  27887. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27888. // utils.ErrorLog("解析失败:%v", err)
  27889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27890. // return
  27891. // }
  27892. // res.ErrMsg = res10265.ErrMsg
  27893. // res.Output = res10265.Output
  27894. // res.InfRefmsgid = res10265.InfRefmsgid
  27895. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27896. // res.Infcode = infocode
  27897. // } else {
  27898. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27899. // utils.ErrorLog("解析失败:%v", err)
  27900. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27901. // return
  27902. // }
  27903. // }
  27904. // if res.Infcode == 0 {
  27905. // c.ServeSuccessJSON(map[string]interface{}{
  27906. // "msg": res.Output.Trtinfo,
  27907. // })
  27908. // }
  27909. // }
  27910. // }
  27911. //}
  27912. //func (c *HisApiController) PutRecord() {
  27913. // id, _ := c.GetInt64("id")
  27914. // record_time := c.GetString("record_time")
  27915. // timeLayout := "2006-01-02"
  27916. // loc, _ := time.LoadLocation("Local")
  27917. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27918. // if err != nil {
  27919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27920. // return
  27921. // }
  27922. // recordDateTime := theTime.Unix()
  27923. //
  27924. // adminInfo := c.GetAdminUserInfo()
  27925. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  27926. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27927. //
  27928. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27929. //
  27930. // fmt.Println(miConfig.SecretKey)
  27931. //
  27932. // if patient == nil {
  27933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27934. // return
  27935. // }
  27936. // if len(patient.IdCardNo) == 0 {
  27937. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  27938. // return
  27939. // }
  27940. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  27941. // if config.IsOpen == 1 {
  27942. // 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
  27943. // resp, requestErr := http.Get(api)
  27944. // if requestErr != nil {
  27945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27946. // return
  27947. // }
  27948. // defer resp.Body.Close()
  27949. // body, ioErr := ioutil.ReadAll(resp.Body)
  27950. // if ioErr != nil {
  27951. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27952. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27953. // return
  27954. // }
  27955. // var respJSON map[string]interface{}
  27956. //
  27957. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27958. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27959. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27960. // return
  27961. // }
  27962. //
  27963. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27964. // userJSONBytes, _ := json.Marshal(userJSON)
  27965. // var res ResultTwo
  27966. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27967. // utils.ErrorLog("解析失败:%v", err)
  27968. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27969. // return
  27970. // }
  27971. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27972. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27973. // infoStr := string(Iinfos)
  27974. // idetinfoStr := string(Idetinfos)
  27975. //
  27976. // if res.Infcode == 0 {
  27977. // his := models.VMHisPatient{
  27978. // Status: 1,
  27979. // Ctime: time.Now().Unix(),
  27980. // Mtime: time.Now().Unix(),
  27981. // PsnNo: res.Output.Baseinfo.PsnNo,
  27982. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  27983. // Certno: res.Output.Baseinfo.Certno,
  27984. // PsnName: res.Output.Baseinfo.PsnName,
  27985. // Gend: res.Output.Baseinfo.Gend,
  27986. // Naty: res.Output.Baseinfo.Naty,
  27987. // Brdy: res.Output.Baseinfo.Brdy,
  27988. // Age: res.Output.Baseinfo.Age,
  27989. // Iinfo: infoStr,
  27990. // Idetinfo: idetinfoStr,
  27991. // PatientId: patient.ID,
  27992. // RecordDate: theTime.Unix(),
  27993. // UserOrgId: adminInfo.CurrentOrgId,
  27994. // AdminUserId: adminInfo.AdminUser.Id,
  27995. // IsReturn: 1,
  27996. // }
  27997. //
  27998. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  27999. // //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")
  28000. // //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")
  28001. //
  28002. // //var dat map[string]interface{}
  28003. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28004. // // fmt.Println(dat)
  28005. // //} else {
  28006. // // fmt.Println(err)
  28007. // //}
  28008. //
  28009. // var dat2 map[string]interface{}
  28010. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28011. // fmt.Println(dat2)
  28012. // } else {
  28013. // fmt.Println(err)
  28014. // }
  28015. //
  28016. // } else {
  28017. // adminUser := c.GetAdminUserInfo()
  28018. // errlog := &models.HisOrderError{
  28019. // UserOrgId: adminUser.CurrentOrgId,
  28020. // Ctime: time.Now().Unix(),
  28021. // Mtime: time.Now().Unix(),
  28022. // ErrMsg: res.ErrMsg,
  28023. // Status: 1,
  28024. // PatientId: id,
  28025. // RecordTime: recordDateTime,
  28026. // Stage: 1,
  28027. // }
  28028. // service.CreateErrMsgLog(errlog)
  28029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  28030. // return
  28031. // }
  28032. // }
  28033. //
  28034. //}
  28035. //func (c *HisApiController) GetUploadDiag() {
  28036. // id, _ := c.GetInt64("id")
  28037. // record_time := c.GetString("record_time")
  28038. //
  28039. // diagnosis_id, _ := c.GetInt64("diagnosis")
  28040. // sick_type, _ := c.GetInt64("sick_type")
  28041. // reg_type, _ := c.GetInt64("reg_type")
  28042. //
  28043. // timeLayout := "2006-01-02"
  28044. // loc, _ := time.LoadLocation("Local")
  28045. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28046. // if err != nil {
  28047. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28048. // return
  28049. // }
  28050. //
  28051. // var patientPrescription models.HisPrescriptionInfo
  28052. // recordDateTime := theTime.Unix()
  28053. // adminInfo := c.GetAdminUserInfo()
  28054. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28055. //
  28056. // if patientPrescription.ID == 0 {
  28057. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28058. // }
  28059. //
  28060. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  28061. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28062. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28063. // sickConfig, _ := service.FindSickById(sick_type)
  28064. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28065. //
  28066. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  28067. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  28068. // "&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 +
  28069. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  28070. // resp2, requestErr2 := http.Get(api2)
  28071. // if requestErr2 != nil {
  28072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28073. // return
  28074. // }
  28075. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  28076. // if ioErr2 != nil {
  28077. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  28078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28079. // return
  28080. // }
  28081. // var respJSON2 map[string]interface{}
  28082. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  28083. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28085. // return
  28086. // }
  28087. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28088. // userJSONBytes2, _ := json.Marshal(respJSON2)
  28089. //
  28090. // var res2 ResultSix
  28091. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28092. // utils.ErrorLog("解析失败:%v", err)
  28093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28094. // return
  28095. // }
  28096. // if res2.Infcode != 0 {
  28097. // adminUser := c.GetAdminUserInfo()
  28098. // errlog := &models.HisOrderError{
  28099. // UserOrgId: adminUser.CurrentOrgId,
  28100. // Ctime: time.Now().Unix(),
  28101. // Mtime: time.Now().Unix(),
  28102. // ErrMsg: res2.ErrMsg,
  28103. // Status: 1,
  28104. // PatientId: id,
  28105. // RecordTime: recordDateTime,
  28106. // Stage: 3,
  28107. // }
  28108. // service.CreateErrMsgLog(errlog)
  28109. //
  28110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  28111. // return
  28112. // }
  28113. //
  28114. // c.ServeSuccessJSON(map[string]interface{}{
  28115. // "msg": "上传成功",
  28116. // })
  28117. //
  28118. //}
  28119. type QueryResult struct {
  28120. ID int64
  28121. Name string
  28122. Code string
  28123. List_type_code string
  28124. }
  28125. func (c *HisApiController) GetCheckCode() {
  28126. ids_str := c.GetString("ids")
  28127. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  28128. ids_arr := strings.Split(ids_str, ",")
  28129. var queryResult []QueryResult
  28130. ids := make([]int64, 0)
  28131. for _, item := range ids_arr {
  28132. id, _ := strconv.ParseInt(item, 10, 64)
  28133. ids = append(ids, id)
  28134. }
  28135. if record_type == 1 {
  28136. drugs, _ := service.GetBatchDrugList(ids)
  28137. for _, item := range drugs {
  28138. result := QueryResult{
  28139. ID: item.ID,
  28140. Name: item.DrugName,
  28141. Code: item.MedicalInsuranceNumber,
  28142. List_type_code: "101",
  28143. }
  28144. queryResult = append(queryResult, result)
  28145. }
  28146. } else if record_type == 2 {
  28147. goods, _ := service.GetBatchGoodInformationList(ids)
  28148. fmt.Println(goods)
  28149. for _, item := range goods {
  28150. result := QueryResult{
  28151. ID: item.ID,
  28152. Name: item.GoodName,
  28153. Code: item.SocialSecurityDirectoryCode,
  28154. List_type_code: "301",
  28155. }
  28156. queryResult = append(queryResult, result)
  28157. }
  28158. } else if record_type == 3 {
  28159. projects, _ := service.GetBathchMyPorjecgList(ids)
  28160. for _, item := range projects {
  28161. result := QueryResult{
  28162. ID: item.ID,
  28163. Name: item.ProjectName,
  28164. Code: item.MedicalCode,
  28165. List_type_code: "201",
  28166. }
  28167. queryResult = append(queryResult, result)
  28168. }
  28169. }
  28170. admin_user_id, _ := c.GetInt64("admin_user_id")
  28171. adminUser := c.GetAdminUserInfo()
  28172. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28173. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28174. var user_name string
  28175. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28176. if role.ID == 0 {
  28177. user_name = "管理员"
  28178. } else {
  28179. user_name = role.UserName
  28180. }
  28181. baseParams := models.BaseParams{
  28182. SecretKey: miConfig.SecretKey,
  28183. FixmedinsCode: miConfig.Code,
  28184. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28185. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28186. OrgName: miConfig.OrgName,
  28187. Doctor: user_name,
  28188. }
  28189. var result string
  28190. if miConfig.MdtrtareaAdmvs == "430800" {
  28191. for _, item := range queryResult {
  28192. if record_type == 1 {
  28193. 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)
  28194. } else if record_type == 2 {
  28195. fmt.Println(item.Code)
  28196. 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)
  28197. } else if record_type == 3 {
  28198. 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)
  28199. }
  28200. var dat map[string]interface{}
  28201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28202. fmt.Println(dat)
  28203. } else {
  28204. fmt.Println(err)
  28205. }
  28206. userJSONBytes, _ := json.Marshal(dat)
  28207. var res ResultSix
  28208. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28209. utils.ErrorLog("解析失败:%v", err)
  28210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28211. return
  28212. }
  28213. if res.Infcode == 0 {
  28214. if record_type == 1 {
  28215. service.UpdateBaseDrugById(item.ID)
  28216. } else if record_type == 2 {
  28217. service.UpdateGoodInformaitonByDetail(item.ID)
  28218. } else if record_type == 3 {
  28219. service.UpdateProjectById(item.ID)
  28220. }
  28221. c.ServeSuccessJSON(map[string]interface{}{
  28222. "failed_code": 0,
  28223. "msg": "目录对照成功",
  28224. })
  28225. } else {
  28226. c.ServeSuccessJSON(map[string]interface{}{
  28227. "failed_code": -10,
  28228. "msg": res.ErrMsg,
  28229. })
  28230. }
  28231. }
  28232. } else {
  28233. for _, item := range queryResult {
  28234. var result string
  28235. if record_type == 1 {
  28236. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28237. } else if record_type == 2 {
  28238. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28239. } else if record_type == 3 {
  28240. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28241. }
  28242. var dat map[string]interface{}
  28243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28244. fmt.Println(dat)
  28245. } else {
  28246. fmt.Println(err)
  28247. }
  28248. userJSONBytes, _ := json.Marshal(dat)
  28249. var res ResultSix
  28250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28251. utils.ErrorLog("解析失败:%v", err)
  28252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28253. return
  28254. }
  28255. if res.Infcode == 0 {
  28256. if record_type == 1 {
  28257. service.UpdateBaseDrugById(item.ID)
  28258. } else if record_type == 2 {
  28259. service.UpdateGoodInformaitonByDetail(item.ID)
  28260. } else if record_type == 3 {
  28261. service.UpdateProjectById(item.ID)
  28262. }
  28263. c.ServeSuccessJSON(map[string]interface{}{
  28264. "failed_code": 0,
  28265. "msg": "目录对照成功",
  28266. })
  28267. } else {
  28268. c.ServeSuccessJSON(map[string]interface{}{
  28269. "failed_code": -10,
  28270. "msg": res.ErrMsg,
  28271. })
  28272. }
  28273. }
  28274. }
  28275. }
  28276. func (c *HisApiController) UnCheckCode() {
  28277. ids_str := c.GetString("ids")
  28278. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  28279. admin_user_id, _ := c.GetInt64("admin_user_id")
  28280. ids_arr := strings.Split(ids_str, ",")
  28281. var queryResult []QueryResult
  28282. ids := make([]int64, 0)
  28283. for _, item := range ids_arr {
  28284. id, _ := strconv.ParseInt(item, 10, 64)
  28285. ids = append(ids, id)
  28286. }
  28287. if record_type == 1 {
  28288. drugs, _ := service.GetBatchDrugList(ids)
  28289. for _, item := range drugs {
  28290. result := QueryResult{
  28291. ID: item.ID,
  28292. Name: item.DrugName,
  28293. Code: item.MedicalInsuranceNumber,
  28294. List_type_code: "101",
  28295. }
  28296. queryResult = append(queryResult, result)
  28297. }
  28298. } else if record_type == 2 {
  28299. goods, _ := service.GetBatchGoodInformationList(ids)
  28300. for _, item := range goods {
  28301. result := QueryResult{
  28302. ID: item.ID,
  28303. Name: item.GoodName,
  28304. Code: item.SocialSecurityDirectoryCode,
  28305. List_type_code: "301",
  28306. }
  28307. queryResult = append(queryResult, result)
  28308. }
  28309. } else if record_type == 3 {
  28310. projects, _ := service.GetBathchMyPorjecgList(ids)
  28311. for _, item := range projects {
  28312. result := QueryResult{
  28313. ID: item.ID,
  28314. Name: item.ProjectName,
  28315. Code: item.MedicalCode,
  28316. List_type_code: "201",
  28317. }
  28318. queryResult = append(queryResult, result)
  28319. }
  28320. }
  28321. adminUser := c.GetAdminUserInfo()
  28322. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28323. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28324. var user_name string
  28325. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28326. if role.ID == 0 {
  28327. user_name = "xxx"
  28328. } else {
  28329. user_name = role.UserName
  28330. }
  28331. baseParams := &models.BaseParams{
  28332. SecretKey: miConfig.SecretKey,
  28333. FixmedinsCode: miConfig.Code,
  28334. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28335. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28336. OrgName: miConfig.OrgName,
  28337. Doctor: user_name,
  28338. }
  28339. if config.IsOpen == 1 {
  28340. if miConfig.MdtrtareaAdmvs == "430800" {
  28341. for _, item := range queryResult {
  28342. var result string
  28343. if record_type == 1 {
  28344. 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)
  28345. } else if record_type == 2 {
  28346. fmt.Println(item.Code)
  28347. 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)
  28348. } else if record_type == 3 {
  28349. 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)
  28350. }
  28351. var dat map[string]interface{}
  28352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28353. fmt.Println(dat)
  28354. } else {
  28355. fmt.Println(err)
  28356. }
  28357. userJSONBytes, _ := json.Marshal(dat)
  28358. var res ResultSix
  28359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28360. utils.ErrorLog("解析失败:%v", err)
  28361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28362. return
  28363. }
  28364. if res.Infcode == 0 {
  28365. if record_type == 1 {
  28366. service.UpdateBaseDrugById(item.ID)
  28367. } else if record_type == 2 {
  28368. service.UpdateGoodInformaitonByDetail(item.ID)
  28369. } else if record_type == 3 {
  28370. service.UpdateProjectById(item.ID)
  28371. }
  28372. c.ServeSuccessJSON(map[string]interface{}{
  28373. "failed_code": 0,
  28374. "msg": "目录对照成功",
  28375. })
  28376. } else {
  28377. c.ServeSuccessJSON(map[string]interface{}{
  28378. "failed_code": -10,
  28379. "msg": res.ErrMsg,
  28380. })
  28381. }
  28382. }
  28383. } else {
  28384. for _, item := range queryResult {
  28385. var result string
  28386. if record_type == 1 {
  28387. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28388. } else if record_type == 2 {
  28389. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28390. } else if record_type == 3 {
  28391. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28392. }
  28393. var dat2 map[string]interface{}
  28394. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28395. fmt.Println(dat2)
  28396. } else {
  28397. fmt.Println(err)
  28398. }
  28399. userJSONBytes, _ := json.Marshal(dat2)
  28400. var res ResultSix
  28401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28402. utils.ErrorLog("解析失败:%v", err)
  28403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28404. return
  28405. }
  28406. if res.Infcode == 0 {
  28407. if record_type == 1 {
  28408. service.UpdateDrugByIdDetail(item.ID)
  28409. } else if record_type == 2 {
  28410. service.UpdateGoodInfoById(item.ID)
  28411. } else if record_type == 3 {
  28412. service.UpdateMyProjectById(item.ID)
  28413. }
  28414. c.ServeSuccessJSON(map[string]interface{}{
  28415. "failed_code": 0,
  28416. "msg": "撤销目录对照成功",
  28417. })
  28418. } else {
  28419. c.ServeSuccessJSON(map[string]interface{}{
  28420. "failed_code": -10,
  28421. "msg": res.ErrMsg,
  28422. })
  28423. }
  28424. }
  28425. }
  28426. }
  28427. }
  28428. func (c *HisApiController) GetPatientInfo() {
  28429. id_card_no := c.GetString("id_card_no")
  28430. admin_user_id, _ := c.GetInt64("admin_user_id")
  28431. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  28432. if patient.ID == 0 {
  28433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28434. return
  28435. }
  28436. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  28437. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28438. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  28439. var res ResultTwo
  28440. var res10265 ResultTwo10265
  28441. if config.IsOpen == 1 {
  28442. if miConfig.MdtrtareaAdmvs == "150499" {
  28443. //请求内网数据
  28444. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  28445. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28446. "&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
  28447. resp, requestErr := http.Get(api)
  28448. if requestErr != nil {
  28449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28450. return
  28451. }
  28452. body, ioErr := ioutil.ReadAll(resp.Body)
  28453. if ioErr != nil {
  28454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28456. return
  28457. }
  28458. var respJSON map[string]interface{}
  28459. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28462. return
  28463. }
  28464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28465. result_byte, _ := json.Marshal(respJSON)
  28466. result := string(result_byte)
  28467. var dat map[string]interface{}
  28468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28469. fmt.Println(dat)
  28470. } else {
  28471. fmt.Println(err)
  28472. }
  28473. userJSONBytes, _ := json.Marshal(dat)
  28474. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28475. utils.ErrorLog("解析失败:%v", err)
  28476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28477. return
  28478. }
  28479. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28480. res.Infcode = Infcode
  28481. res.ErrMsg = res10265.ErrMsg
  28482. res.Output = res10265.Output
  28483. res.InfRefmsgid = res10265.InfRefmsgid
  28484. res.RespondTime = res10265.RespondTime
  28485. res.WarnInfo = res10265.WarnInfo
  28486. } else {
  28487. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28488. var dat map[string]interface{}
  28489. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28490. fmt.Println(dat)
  28491. } else {
  28492. fmt.Println(err)
  28493. }
  28494. userJSONBytes, _ := json.Marshal(dat)
  28495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28496. utils.ErrorLog("解析失败:%v", err)
  28497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28498. return
  28499. }
  28500. }
  28501. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28502. // utils.ErrorLog("解析失败:%v", err)
  28503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28504. // return
  28505. //}
  28506. for index, item := range res.Output.Iinfo {
  28507. if item.PsnInsuStas == "2" {
  28508. fmt.Println("--------")
  28509. res.Output.Iinfo[index].Insutype = "300"
  28510. res.Output.Iinfo[index].PsnInsuStas = "1"
  28511. }
  28512. }
  28513. fmt.Println(res.Output.Iinfo)
  28514. if res.Infcode != 0 {
  28515. c.ServeSuccessJSON(map[string]interface{}{
  28516. "failed_code": -10,
  28517. "msg": res.ErrMsg,
  28518. })
  28519. } else {
  28520. c.ServeSuccessJSON(map[string]interface{}{
  28521. "failed_code": 0,
  28522. "info": res,
  28523. })
  28524. }
  28525. }
  28526. }
  28527. func (c *HisApiController) PsnPutOnRecord() {
  28528. record_type, _ := c.GetInt64("type")
  28529. patient_id, _ := c.GetInt64("patient_id")
  28530. admin_user_id, _ := c.GetInt64("admin_user_id")
  28531. start_time := c.GetString("start_time")
  28532. end_time := c.GetString("end_time")
  28533. adminUser := c.GetAdminUserInfo()
  28534. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28535. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28536. var patients []*models.Patients
  28537. if record_type == 1 { //全部备案
  28538. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  28539. patients = append(patients, patient...)
  28540. } else { //单个备案
  28541. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28542. patients = append(patients, patient)
  28543. }
  28544. var user_name string
  28545. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28546. if role.ID == 0 {
  28547. user_name = "xxx"
  28548. } else {
  28549. user_name = role.UserName
  28550. }
  28551. if config.IsOpen == 1 {
  28552. for _, item := range patients {
  28553. 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
  28554. resp, requestErr := http.Get(api)
  28555. if requestErr != nil {
  28556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28557. return
  28558. }
  28559. defer resp.Body.Close()
  28560. body, ioErr := ioutil.ReadAll(resp.Body)
  28561. if ioErr != nil {
  28562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28564. return
  28565. }
  28566. var respJSON map[string]interface{}
  28567. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28570. return
  28571. }
  28572. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28573. userJSONBytes, _ := json.Marshal(userJSON)
  28574. var res ResultTwo
  28575. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28576. utils.ErrorLog("解析失败:%v", err)
  28577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28578. return
  28579. }
  28580. if res.Infcode == 0 {
  28581. 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)
  28582. var dat map[string]interface{}
  28583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28584. fmt.Println(dat)
  28585. } else {
  28586. fmt.Println(err)
  28587. }
  28588. userJSONBytes, _ := json.Marshal(dat)
  28589. var res2 ResultThirteen
  28590. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28591. utils.ErrorLog("解析失败:%v", err)
  28592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28593. return
  28594. }
  28595. if res2.Infcode == 0 {
  28596. psnResult := &models.GdybPsnRecord{
  28597. UserOrgId: adminUser.CurrentOrgId,
  28598. PatientId: item.ID,
  28599. PsnNo: res.Output.Baseinfo.PsnNo,
  28600. Ctime: time.Now().Unix(),
  28601. Mtime: time.Now().Unix(),
  28602. Status: 1,
  28603. IsCancel: 1,
  28604. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28605. }
  28606. service.CreatePsnRecord(psnResult)
  28607. } else {
  28608. c.ServeSuccessJSON(map[string]interface{}{
  28609. "failed_code": -10,
  28610. "msg": res2.ErrMsg,
  28611. })
  28612. return
  28613. }
  28614. }
  28615. }
  28616. }
  28617. }
  28618. func (c *HisApiController) PsnUnPutOnRecord() {
  28619. id, _ := c.GetInt64("id")
  28620. //record_type, _ := c.GetInt64("type")
  28621. admin_user_id, _ := c.GetInt64("admin_user_id")
  28622. adminUser := c.GetAdminUserInfo()
  28623. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28624. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28625. var user_name string
  28626. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28627. if role.ID == 0 {
  28628. user_name = "xxx"
  28629. } else {
  28630. user_name = role.UserName
  28631. }
  28632. psn_record, _ := service.GetPsnRecordById(id)
  28633. if psn_record.ID == 0 {
  28634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28635. return
  28636. }
  28637. if config.IsOpen == 1 {
  28638. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28639. var dat map[string]interface{}
  28640. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28641. fmt.Println(dat)
  28642. } else {
  28643. fmt.Println(err)
  28644. }
  28645. userJSONBytes, _ := json.Marshal(dat)
  28646. var res ResultFourteen
  28647. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28648. utils.ErrorLog("解析失败:%v", err)
  28649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28650. return
  28651. }
  28652. if res.Infcode == 0 {
  28653. psn_record.IsCancel = 2
  28654. service.CreatePsnRecord(&psn_record)
  28655. } else {
  28656. c.ServeSuccessJSON(map[string]interface{}{
  28657. "failed_code": -10,
  28658. "msg": res.ErrMsg,
  28659. })
  28660. return
  28661. }
  28662. }
  28663. }
  28664. func (c *HisApiController) PsnPutNCDSOnRecord() {
  28665. patient_id, _ := c.GetInt64("patient_id")
  28666. insutype_two := c.GetString("insutype")
  28667. psn_no := c.GetString("psn_no")
  28668. doctor_id, _ := c.GetInt64("doctor_id")
  28669. sick_id, _ := c.GetInt64("sick_id")
  28670. department_id, _ := c.GetInt64("department_id")
  28671. start_time := c.GetString("start_time")
  28672. end_time := c.GetString("end_time")
  28673. check_time := c.GetString("check_time")
  28674. hospital_code := c.GetString("hospital_code")
  28675. hospital_name := c.GetString("hospital_name")
  28676. adminUser := c.GetAdminUserInfo()
  28677. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28678. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28679. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28680. sick, _ := service.FindSickById(sick_id)
  28681. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28682. if len(hospital_code) == 0 {
  28683. hospital_code = miConfig.Code
  28684. }
  28685. if len(hospital_name) == 0 {
  28686. hospital_name = miConfig.OrgName
  28687. }
  28688. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28689. var res ResultTwo
  28690. var res10265 ResultTwo10265
  28691. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28692. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  28693. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  28694. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28695. "&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
  28696. resp, requestErr := http.Get(api)
  28697. if requestErr != nil {
  28698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28699. return
  28700. }
  28701. body, ioErr := ioutil.ReadAll(resp.Body)
  28702. if ioErr != nil {
  28703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28705. return
  28706. }
  28707. var respJSON map[string]interface{}
  28708. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28711. return
  28712. }
  28713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28714. result, _ := json.Marshal(respJSON)
  28715. fmt.Println("log")
  28716. fmt.Println(string(result))
  28717. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28718. utils.ErrorLog("解析失败:%v", err)
  28719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28720. return
  28721. }
  28722. res.ErrMsg = res10265.ErrMsg
  28723. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28724. res.Infcode = infocode
  28725. res.Output = res10265.Output
  28726. res.InfRefmsgid = res10265.InfRefmsgid
  28727. } else {
  28728. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28729. if miConfig.Code == "H15049901371" {
  28730. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28731. utils.ErrorLog("解析失败:%v", err)
  28732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28733. return
  28734. }
  28735. res.ErrMsg = res10265.ErrMsg
  28736. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28737. res.Infcode = infocode
  28738. res.Output = res10265.Output
  28739. res.InfRefmsgid = res10265.InfRefmsgid
  28740. } else {
  28741. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28742. utils.ErrorLog("解析失败:%v", err)
  28743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28744. return
  28745. }
  28746. }
  28747. }
  28748. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28749. infoStr := string(Iinfos)
  28750. var rf []*ResultFive
  28751. json.Unmarshal([]byte(infoStr), &rf)
  28752. var insuplc_admdvs string
  28753. var insutype string
  28754. var is390 int = 0
  28755. var is310 int = 0
  28756. var insutypes []*ResultFive
  28757. for _, item := range rf {
  28758. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28759. insutypes = append(insutypes, item)
  28760. }
  28761. }
  28762. if len(insutypes) == 1 {
  28763. insutype = insutypes[0].Insutype
  28764. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28765. } else {
  28766. for _, i := range insutypes {
  28767. if i.Insutype == "390" {
  28768. is390 = 1
  28769. }
  28770. if i.Insutype == "310" {
  28771. is310 = 1
  28772. }
  28773. }
  28774. }
  28775. if is390 == 1 {
  28776. insutype = "390"
  28777. }
  28778. if is310 == 1 {
  28779. insutype = "310"
  28780. }
  28781. if len(insutypes) == 2 {
  28782. insutype = insutype_two
  28783. }
  28784. if len(insutypes) == 0 {
  28785. insutype = "310"
  28786. }
  28787. insutype = insutype_two
  28788. fmt.Println(insutype)
  28789. for _, item := range rf {
  28790. fmt.Println(item.Insutype)
  28791. fmt.Println(insutype)
  28792. if item.Insutype == insutype {
  28793. fmt.Println(item.Insutype)
  28794. fmt.Println(insutype)
  28795. insuplc_admdvs = item.InsuplcAdmdvs
  28796. }
  28797. }
  28798. fmt.Println(insuplc_admdvs)
  28799. var res2 ResultThirteen
  28800. var res10265_2 ResultThirteen10265
  28801. if config.IsOpen == 1 {
  28802. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28803. } else {
  28804. if miConfig.MdtrtareaAdmvs == "150499" {
  28805. //
  28806. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  28807. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28808. // "&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
  28809. //resp, requestErr := http.Get(api)
  28810. //if requestErr != nil {
  28811. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28812. // return
  28813. //}
  28814. //
  28815. //body, ioErr := ioutil.ReadAll(resp.Body)
  28816. //if ioErr != nil {
  28817. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28819. // return
  28820. //}
  28821. //var respJSON map[string]interface{}
  28822. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28823. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28825. // return
  28826. //}
  28827. //
  28828. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28829. //result, _ := json.Marshal(respJSON)
  28830. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  28831. // utils.ErrorLog("解析失败:%v", err)
  28832. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28833. // return
  28834. //}
  28835. //infocode = resThree.Infcode
  28836. //result, _ := json.Marshal(respJSON)
  28837. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  28838. // utils.ErrorLog("解析失败:%v", err)
  28839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28840. // return
  28841. //}
  28842. //
  28843. //resThree.ErrMsg = resThree10265.ErrMsg
  28844. //
  28845. //resThree.Output = resThree10265.Output
  28846. //
  28847. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  28848. //
  28849. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  28850. //
  28851. } else {
  28852. 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)
  28853. var dat map[string]interface{}
  28854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28855. fmt.Println(dat)
  28856. } else {
  28857. fmt.Println(err)
  28858. }
  28859. userJSONBytes, _ := json.Marshal(dat)
  28860. if miConfig.Code == "H15049901371" {
  28861. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  28862. utils.ErrorLog("解析失败:%v", err)
  28863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28864. return
  28865. }
  28866. res2.ErrMsg = res10265_2.ErrMsg
  28867. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  28868. res2.Infcode = infocode
  28869. res2.Output = res10265_2.Output
  28870. res2.InfRefmsgid = res10265_2.InfRefmsgid
  28871. } else {
  28872. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28873. utils.ErrorLog("解析失败:%v", err)
  28874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28875. return
  28876. }
  28877. }
  28878. }
  28879. }
  28880. if res2.Infcode == 0 {
  28881. psnResult := &models.GdybPsnNcdsRecord{
  28882. UserOrgId: adminUser.CurrentOrgId,
  28883. PatientId: patient.ID,
  28884. PsnNo: psn_no,
  28885. DoctorId: doctor.AdminUserId,
  28886. DepartmentId: department_id,
  28887. SickType: sick_id,
  28888. Insutype: insutype,
  28889. Ctime: time.Now().Unix(),
  28890. Mtime: time.Now().Unix(),
  28891. Status: 1,
  28892. IsCancel: 1,
  28893. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28894. }
  28895. service.CreatePsnNCDSRecord(psnResult)
  28896. c.ServeSuccessJSON(map[string]interface{}{
  28897. "failed_code": 0,
  28898. "msg": "备案成功",
  28899. "result": psnResult,
  28900. })
  28901. } else {
  28902. c.ServeSuccessJSON(map[string]interface{}{
  28903. "failed_code": -10,
  28904. "msg": res2.ErrMsg,
  28905. })
  28906. return
  28907. }
  28908. }
  28909. }
  28910. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  28911. id, _ := c.GetInt64("id")
  28912. admin_user_id, _ := c.GetInt64("admin_user_id")
  28913. adminUser := c.GetAdminUserInfo()
  28914. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28915. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28916. //config, _ := service.Ge(adminUser.CurrentOrgId)
  28917. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  28918. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28919. //var user_name string
  28920. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28921. //if role.ID == 0 {
  28922. // user_name = "xxx"
  28923. //} else {
  28924. // user_name = role.UserName
  28925. //}
  28926. psn_record, _ := service.GetPsnNCDSRecordById(id)
  28927. if psn_record.ID == 0 {
  28928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28929. return
  28930. }
  28931. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28932. var res ResultTwo
  28933. var res10265 ResultTwo10265
  28934. if miConfig.Code == "H15049901371" {
  28935. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28936. utils.ErrorLog("解析失败:%v", err)
  28937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28938. return
  28939. }
  28940. res.ErrMsg = res10265.ErrMsg
  28941. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28942. res.Infcode = infocode
  28943. res.Output = res10265.Output
  28944. res.InfRefmsgid = res10265.InfRefmsgid
  28945. } else {
  28946. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28947. utils.ErrorLog("解析失败:%v", err)
  28948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28949. return
  28950. }
  28951. }
  28952. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28953. infoStr := string(Iinfos)
  28954. var rf []*ResultFive
  28955. json.Unmarshal([]byte(infoStr), &rf)
  28956. var insuplc_admdvs string
  28957. var insutype string
  28958. var is390 int = 0
  28959. var is310 int = 0
  28960. var insutypes []*ResultFive
  28961. for _, item := range rf {
  28962. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28963. insutypes = append(insutypes, item)
  28964. }
  28965. }
  28966. if len(insutypes) == 1 {
  28967. insutype = insutypes[0].Insutype
  28968. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28969. } else {
  28970. for _, i := range insutypes {
  28971. if i.Insutype == "390" {
  28972. is390 = 1
  28973. }
  28974. if i.Insutype == "310" {
  28975. is310 = 1
  28976. }
  28977. }
  28978. }
  28979. if is390 == 1 {
  28980. insutype = "390"
  28981. }
  28982. if is310 == 1 {
  28983. insutype = "310"
  28984. }
  28985. if len(insutypes) == 0 {
  28986. insutype = "310"
  28987. }
  28988. insutype = psn_record.Insutype
  28989. for _, item := range rf {
  28990. if item.Insutype == insutype {
  28991. insuplc_admdvs = item.InsuplcAdmdvs
  28992. }
  28993. }
  28994. if config.IsOpen == 1 {
  28995. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28996. var dat map[string]interface{}
  28997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28998. fmt.Println(dat)
  28999. } else {
  29000. fmt.Println(err)
  29001. }
  29002. userJSONBytes, _ := json.Marshal(dat)
  29003. var res ResultFourteen
  29004. var res10265 ResultFourteen10265
  29005. if miConfig.Code == "H15049901371" {
  29006. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  29007. utils.ErrorLog("解析失败:%v", err)
  29008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29009. return
  29010. }
  29011. res.ErrMsg = res10265.ErrMsg
  29012. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29013. res.Infcode = infocode
  29014. res.Output = res10265.Output
  29015. res.InfRefmsgid = res10265.InfRefmsgid
  29016. } else {
  29017. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29018. utils.ErrorLog("解析失败:%v", err)
  29019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29020. return
  29021. }
  29022. }
  29023. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29024. // utils.ErrorLog("解析失败:%v", err)
  29025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29026. // return
  29027. //}
  29028. if res.Infcode == 0 {
  29029. psn_record.IsCancel = 2
  29030. service.CreatePsnNCDSRecord(&psn_record)
  29031. c.ServeSuccessJSON(map[string]interface{}{
  29032. "failed_code": 0,
  29033. "msg": "撤销备案成功",
  29034. })
  29035. } else {
  29036. c.ServeSuccessJSON(map[string]interface{}{
  29037. "failed_code": -10,
  29038. "msg": res.ErrMsg,
  29039. })
  29040. return
  29041. }
  29042. }
  29043. }
  29044. func (c *HisApiController) TestTest() {
  29045. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  29046. fmt.Println(patient.Iinfo)
  29047. }
  29048. type CustomData struct {
  29049. MsgId string
  29050. PsnNo string
  29051. Info string
  29052. }
  29053. func (c *HisApiController) ReversalData() {
  29054. var customData []*CustomData
  29055. custom := &CustomData{
  29056. MsgId: "H44022900158202103301714472004",
  29057. PsnNo: "44020000001101329945",
  29058. Info: "2207",
  29059. }
  29060. customData = append(customData, custom)
  29061. custom1 := &CustomData{
  29062. MsgId: "H4402290015820210330172057803",
  29063. PsnNo: "44020000001101161813",
  29064. Info: "2207",
  29065. }
  29066. customData = append(customData, custom1)
  29067. custom2 := &CustomData{
  29068. MsgId: "H44022900158202103301705198813",
  29069. PsnNo: "44190000133097375417",
  29070. Info: "2207",
  29071. }
  29072. customData = append(customData, custom2)
  29073. custom3 := &CustomData{
  29074. MsgId: "H44022900158202103301715524756",
  29075. PsnNo: "44020000001100187221",
  29076. Info: "2207",
  29077. }
  29078. customData = append(customData, custom3)
  29079. custom4 := &CustomData{
  29080. MsgId: "H44022900158202103301730376224",
  29081. PsnNo: "44020000001101959155",
  29082. Info: "2207",
  29083. }
  29084. customData = append(customData, custom4)
  29085. custom5 := &CustomData{
  29086. MsgId: "H44022900158202103301748008725",
  29087. PsnNo: "44020000001104246641",
  29088. Info: "2207",
  29089. }
  29090. customData = append(customData, custom5)
  29091. custom6 := &CustomData{
  29092. MsgId: "H44022900158202103301718096755",
  29093. PsnNo: "44020000001102211860",
  29094. Info: "2207",
  29095. }
  29096. customData = append(customData, custom6)
  29097. custom7 := &CustomData{
  29098. MsgId: "H44022900158202103301736551640",
  29099. PsnNo: "44020000001102687718",
  29100. Info: "2207",
  29101. }
  29102. customData = append(customData, custom7)
  29103. custom8 := &CustomData{
  29104. MsgId: "H44022900158202103301743097676",
  29105. PsnNo: "44020000001102127785",
  29106. Info: "2207",
  29107. }
  29108. customData = append(customData, custom8)
  29109. custom9 := &CustomData{
  29110. MsgId: "H44022900158202103301712304203",
  29111. PsnNo: "44020000001101518097",
  29112. Info: "2207",
  29113. }
  29114. customData = append(customData, custom9)
  29115. custom10 := &CustomData{
  29116. MsgId: "H44022900158202103301738448785",
  29117. PsnNo: "44020000001100500813",
  29118. Info: "2207",
  29119. }
  29120. customData = append(customData, custom10)
  29121. custom11 := &CustomData{
  29122. MsgId: "H44022900158202103301732455843",
  29123. PsnNo: "44020000001102690557",
  29124. Info: "2207",
  29125. }
  29126. customData = append(customData, custom11)
  29127. custom12 := &CustomData{
  29128. MsgId: "H44022900158202103301745421708",
  29129. PsnNo: "44020000001102211928",
  29130. Info: "2207",
  29131. }
  29132. customData = append(customData, custom12)
  29133. custom1212 := &CustomData{
  29134. MsgId: "H440229001582021033017351627",
  29135. PsnNo: "44020000001102481733",
  29136. Info: "2207",
  29137. }
  29138. customData = append(customData, custom1212)
  29139. custom13 := &CustomData{
  29140. MsgId: "H44022900158202103301740327951",
  29141. PsnNo: "44020000001103174866",
  29142. Info: "2207",
  29143. }
  29144. customData = append(customData, custom13)
  29145. custom14 := &CustomData{
  29146. MsgId: "H4402290015820210330174922668",
  29147. PsnNo: "44020000001102927272",
  29148. Info: "2207",
  29149. }
  29150. customData = append(customData, custom14)
  29151. custom15 := &CustomData{
  29152. MsgId: "H44022900158202103301752362273",
  29153. PsnNo: "44020000001102942890",
  29154. Info: "2207",
  29155. }
  29156. customData = append(customData, custom15)
  29157. custom16 := &CustomData{
  29158. MsgId: "H44022900158202103301751082917",
  29159. PsnNo: "44020000001101662162",
  29160. Info: "2207",
  29161. }
  29162. customData = append(customData, custom16)
  29163. custom17 := &CustomData{
  29164. MsgId: "H44022900158202103301754147728",
  29165. PsnNo: "44020000000229014511",
  29166. Info: "2207",
  29167. }
  29168. customData = append(customData, custom17)
  29169. adminUser := c.GetAdminUserInfo()
  29170. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29171. for _, item := range customData {
  29172. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29173. fmt.Println(result)
  29174. }
  29175. }
  29176. func (c *HisApiController) GetAllopatry() {
  29177. year := c.GetString("year")
  29178. month := c.GetString("month")
  29179. admin_user_id, _ := c.GetInt64("admin_user_id")
  29180. adminUser := c.GetAdminUserInfo()
  29181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29182. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29183. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29184. var dat map[string]interface{}
  29185. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29186. fmt.Println(dat)
  29187. } else {
  29188. fmt.Println(err)
  29189. }
  29190. userJSONBytes, _ := json.Marshal(dat)
  29191. var res models.Result9001
  29192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29193. utils.ErrorLog("解析失败:%v", err)
  29194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29195. return
  29196. }
  29197. fmt.Println(res.Output.Signinoutb)
  29198. fmt.Println(res.Output.Signinoutb.SignNo)
  29199. fmt.Println(string(userJSONBytes))
  29200. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29201. var dat3 map[string]interface{}
  29202. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  29203. fmt.Println(dat3)
  29204. } else {
  29205. fmt.Println(err)
  29206. }
  29207. userJSONBytes3, _ := json.Marshal(dat3)
  29208. var res3 models.Result3260
  29209. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29210. utils.ErrorLog("解析失败:%v", err)
  29211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29212. return
  29213. }
  29214. var curpage int
  29215. var pagesize int = 100
  29216. var start int = 1
  29217. //var stop int
  29218. //pagecount := 10
  29219. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  29220. var res22 []models.Result3260
  29221. for curpage = 1; curpage <= pagecount; curpage++ {
  29222. if curpage == 1 {
  29223. start = 0
  29224. } else {
  29225. start = (curpage-1)*pagesize + 1
  29226. }
  29227. fmt.Println(start)
  29228. //stop = curpage * pagesize
  29229. //if stop > int(res3.Output.Totalrow) {
  29230. // stop =int(res3.Output.Totalrow)
  29231. //}
  29232. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  29233. var dat2 map[string]interface{}
  29234. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29235. fmt.Println(dat)
  29236. } else {
  29237. fmt.Println(err)
  29238. }
  29239. userJSONBytes2, _ := json.Marshal(dat2)
  29240. var res2 models.Result3260
  29241. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29242. utils.ErrorLog("解析失败:%v", err)
  29243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29244. return
  29245. }
  29246. if res2.Infcode == 0 {
  29247. res22 = append(res22, res2)
  29248. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29249. //var dat2 map[string]interface{}
  29250. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29251. // fmt.Println(dat)
  29252. //} else {
  29253. // fmt.Println(err)
  29254. //}
  29255. //c.ServeSuccessJSON(map[string]interface{}{
  29256. // "list": res2.Output.Data,
  29257. //})
  29258. //continue
  29259. }
  29260. }
  29261. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29262. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29263. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  29264. //var dat2 map[string]interface{}
  29265. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29266. // fmt.Println(dat)
  29267. //} else {
  29268. // fmt.Println(err)
  29269. //}
  29270. //userJSONBytes2, _ := json.Marshal(dat2)
  29271. //var res2 models.Result3260
  29272. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29273. // utils.ErrorLog("解析失败:%v", err)
  29274. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29275. // return
  29276. //}
  29277. //if res2.Infcode == 0 {
  29278. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29279. // var dat2 map[string]interface{}
  29280. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29281. // fmt.Println(dat)
  29282. // } else {
  29283. // fmt.Println(err)
  29284. // }
  29285. // c.ServeSuccessJSON(map[string]interface{}{
  29286. // "list": res2.Output.Data,
  29287. // })
  29288. //}
  29289. }
  29290. func (c *HisApiController) ComfirmAllopatry() {
  29291. year := c.GetString("year")
  29292. month := c.GetString("month")
  29293. admin_user_id, _ := c.GetInt64("admin_user_id")
  29294. adminUser := c.GetAdminUserInfo()
  29295. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29296. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29297. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29298. var dat map[string]interface{}
  29299. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29300. fmt.Println(dat)
  29301. } else {
  29302. fmt.Println(err)
  29303. }
  29304. userJSONBytes, _ := json.Marshal(dat)
  29305. var res models.Result9001
  29306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29307. utils.ErrorLog("解析失败:%v", err)
  29308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29309. return
  29310. }
  29311. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29312. var dat2 map[string]interface{}
  29313. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29314. fmt.Println(dat)
  29315. } else {
  29316. fmt.Println(err)
  29317. }
  29318. userJSONBytes2, _ := json.Marshal(dat2)
  29319. var res2 models.Result3260
  29320. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29321. utils.ErrorLog("解析失败:%v", err)
  29322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29323. return
  29324. }
  29325. //if res2.Infcode == 0 {
  29326. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29327. // var dat map[string]interface{}
  29328. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29329. // fmt.Println(dat)
  29330. // } else {
  29331. // fmt.Println(err)
  29332. // }
  29333. // userJSONBytes, _ := json.Marshal(dat)
  29334. // var res3 models.Result3261
  29335. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  29336. // utils.ErrorLog("解析失败:%v", err)
  29337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29338. // return
  29339. // }
  29340. //
  29341. // if res3.Infcode == 0 {
  29342. // record := &models.HisYidiClearRecord{
  29343. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29344. // Ctime: time.Now().Unix(),
  29345. // Mtime: time.Now().Unix(),
  29346. // Status: 1,
  29347. // MsgId: msgId,
  29348. // }
  29349. // service.SaveClearRecord(record)
  29350. // c.ServeSuccessJSON(map[string]interface{}{
  29351. // "msg": "提取成功",
  29352. // })
  29353. // }
  29354. //}
  29355. }
  29356. func (c *HisApiController) RefundAllopatry() {
  29357. year := c.GetString("year")
  29358. month := c.GetString("month")
  29359. //id, _ := c.GetInt64("id")
  29360. admin_user_id, _ := c.GetInt64("admin_user_id")
  29361. adminUser := c.GetAdminUserInfo()
  29362. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29363. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29364. //record, _ := service.GetClearRecordById(id)
  29365. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29366. var dat map[string]interface{}
  29367. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29368. fmt.Println(dat)
  29369. } else {
  29370. fmt.Println(err)
  29371. }
  29372. userJSONBytes, _ := json.Marshal(dat)
  29373. var res models.Result9001
  29374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29375. utils.ErrorLog("解析失败:%v", err)
  29376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29377. return
  29378. }
  29379. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  29380. var dat2 map[string]interface{}
  29381. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  29382. fmt.Println(dat)
  29383. } else {
  29384. fmt.Println(err)
  29385. }
  29386. userJSONBytes2, _ := json.Marshal(dat2)
  29387. var empty ResultFourteen
  29388. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  29389. utils.ErrorLog("解析失败:%v", err)
  29390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29391. return
  29392. }
  29393. if empty.Infcode == 0 {
  29394. c.ServeSuccessJSON(map[string]interface{}{
  29395. "msg": "撤销成功",
  29396. })
  29397. return
  29398. }
  29399. }
  29400. func (c *HisApiController) ReversalOtherData() {
  29401. var customData []*CustomData
  29402. custom := &CustomData{
  29403. MsgId: "H44022900158202103301714472004",
  29404. PsnNo: "44020000001101329945",
  29405. Info: "2208",
  29406. }
  29407. customData = append(customData, custom)
  29408. custom1 := &CustomData{
  29409. MsgId: "H4402290015820210330172057803",
  29410. PsnNo: "44020000001101161813",
  29411. Info: "2208",
  29412. }
  29413. customData = append(customData, custom1)
  29414. custom2 := &CustomData{
  29415. MsgId: "H44022900158202103301705198813",
  29416. PsnNo: "44190000133097375417",
  29417. Info: "2208",
  29418. }
  29419. customData = append(customData, custom2)
  29420. custom3 := &CustomData{
  29421. MsgId: "H44022900158202103301715524756",
  29422. PsnNo: "44020000001100187221",
  29423. Info: "2208",
  29424. }
  29425. customData = append(customData, custom3)
  29426. custom4 := &CustomData{
  29427. MsgId: "H44022900158202103301730376224",
  29428. PsnNo: "44020000001101959155",
  29429. Info: "2208",
  29430. }
  29431. customData = append(customData, custom4)
  29432. custom5 := &CustomData{
  29433. MsgId: "H44022900158202103301748008725",
  29434. PsnNo: "44020000001104246641",
  29435. Info: "2208",
  29436. }
  29437. customData = append(customData, custom5)
  29438. custom6 := &CustomData{
  29439. MsgId: "H44022900158202103301718096755",
  29440. PsnNo: "44020000001102211860",
  29441. Info: "2208",
  29442. }
  29443. customData = append(customData, custom6)
  29444. custom7 := &CustomData{
  29445. MsgId: "H44022900158202103301736551640",
  29446. PsnNo: "44020000001102687718",
  29447. Info: "2208",
  29448. }
  29449. customData = append(customData, custom7)
  29450. custom8 := &CustomData{
  29451. MsgId: "H44022900158202103301743097676",
  29452. PsnNo: "44020000001102127785",
  29453. Info: "2208",
  29454. }
  29455. customData = append(customData, custom8)
  29456. custom9 := &CustomData{
  29457. MsgId: "H44022900158202103301712304203",
  29458. PsnNo: "44020000001101518097",
  29459. Info: "2208",
  29460. }
  29461. customData = append(customData, custom9)
  29462. custom10 := &CustomData{
  29463. MsgId: "H44022900158202103301738448785",
  29464. PsnNo: "44020000001100500813",
  29465. Info: "2208",
  29466. }
  29467. customData = append(customData, custom10)
  29468. custom11 := &CustomData{
  29469. MsgId: "H44022900158202103301732455843",
  29470. PsnNo: "44020000001102690557",
  29471. Info: "2208",
  29472. }
  29473. customData = append(customData, custom11)
  29474. custom12 := &CustomData{
  29475. MsgId: "H44022900158202103301745421708",
  29476. PsnNo: "44020000001102211928",
  29477. Info: "2208",
  29478. }
  29479. customData = append(customData, custom12)
  29480. custom1212 := &CustomData{
  29481. MsgId: "H440229001582021033017351627",
  29482. PsnNo: "44020000001102481733",
  29483. Info: "2208",
  29484. }
  29485. customData = append(customData, custom1212)
  29486. custom13 := &CustomData{
  29487. MsgId: "H44022900158202103301740327951",
  29488. PsnNo: "44020000001103174866",
  29489. Info: "2208",
  29490. }
  29491. customData = append(customData, custom13)
  29492. custom14 := &CustomData{
  29493. MsgId: "H4402290015820210330174922668",
  29494. PsnNo: "44020000001102927272",
  29495. Info: "2208",
  29496. }
  29497. customData = append(customData, custom14)
  29498. custom15 := &CustomData{
  29499. MsgId: "H44022900158202103301752362273",
  29500. PsnNo: "44020000001102942890",
  29501. Info: "2208",
  29502. }
  29503. customData = append(customData, custom15)
  29504. custom16 := &CustomData{
  29505. MsgId: "H44022900158202103301751082917",
  29506. PsnNo: "44020000001101662162",
  29507. Info: "2208",
  29508. }
  29509. customData = append(customData, custom16)
  29510. custom17 := &CustomData{
  29511. MsgId: "H44022900158202103301754147728",
  29512. PsnNo: "44020000000229014511",
  29513. Info: "2208",
  29514. }
  29515. customData = append(customData, custom17)
  29516. adminUser := c.GetAdminUserInfo()
  29517. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29518. for _, item := range customData {
  29519. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29520. fmt.Println(result)
  29521. }
  29522. }
  29523. func PathExists(path string) (bool, error) {
  29524. _, err := os.Stat(path)
  29525. if err == nil {
  29526. return true, nil
  29527. }
  29528. if os.IsNotExist(err) {
  29529. return false, nil
  29530. }
  29531. return false, err
  29532. }
  29533. // 创建文件夹
  29534. func Mkdir(dir string) {
  29535. // 创建文件夹
  29536. exist, err := PathExists(dir)
  29537. if err != nil {
  29538. fmt.Println(err.Error())
  29539. } else {
  29540. if exist {
  29541. fmt.Println(dir + "文件夹已存在!")
  29542. } else {
  29543. // 文件夹名称,权限
  29544. err := os.Mkdir(dir, os.ModePerm)
  29545. if err != nil {
  29546. fmt.Println(dir+"文件夹创建失败:", err.Error())
  29547. } else {
  29548. fmt.Println(dir + "文件夹创建成功!")
  29549. }
  29550. }
  29551. }
  29552. }
  29553. // 压缩文件
  29554. func Zip(srcFile string, destZip string) error {
  29555. zipfile, err := os.Create(destZip)
  29556. if err != nil {
  29557. return err
  29558. }
  29559. defer zipfile.Close()
  29560. archive := zip.NewWriter(zipfile)
  29561. defer archive.Close()
  29562. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  29563. if err != nil {
  29564. return err
  29565. }
  29566. header, err := zip.FileInfoHeader(info)
  29567. if err != nil {
  29568. return err
  29569. }
  29570. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  29571. // header.Name = path
  29572. if info.IsDir() {
  29573. header.Name += "/"
  29574. } else {
  29575. header.Method = zip.Deflate
  29576. }
  29577. writer, err := archive.CreateHeader(header)
  29578. if err != nil {
  29579. return err
  29580. }
  29581. if !info.IsDir() {
  29582. file, err := os.Open(path)
  29583. if err != nil {
  29584. return err
  29585. }
  29586. defer file.Close()
  29587. _, err = io.Copy(writer, file)
  29588. }
  29589. return err
  29590. })
  29591. return err
  29592. }
  29593. func ReadFile(filePath string) []byte {
  29594. f, err := os.Open(filePath)
  29595. if err != nil {
  29596. fmt.Println("read file fail", err)
  29597. return nil
  29598. }
  29599. defer f.Close()
  29600. fd, err := ioutil.ReadAll(f)
  29601. if err != nil {
  29602. fmt.Println("read to fd fail", err)
  29603. return nil
  29604. }
  29605. return fd
  29606. }
  29607. func saveLogq(result string, request string, infno string, desc string) {
  29608. dir := "日志"
  29609. utils.Mkdir(dir)
  29610. month := time.Unix(1557042972, 0).Format("1")
  29611. year := time.Now().Format("2006")
  29612. month = time.Now().Format("01")
  29613. day := time.Now().Format("02")
  29614. hour := time.Now().Format("15")
  29615. min := time.Now().Format("04")
  29616. sec := time.Now().Format("05")
  29617. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29618. file := year + month + day + "_log"
  29619. file_name := file + ".txt"
  29620. file_path := "日志" + "/" + file_name
  29621. exist, _ := utils.PathExists(file_path)
  29622. if exist { //存在
  29623. fmt.Println("存在")
  29624. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29625. if err != nil {
  29626. fmt.Println("read fail")
  29627. }
  29628. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29629. n, _ := f.Seek(0, 2)
  29630. _, err = f.WriteAt([]byte(content), n)
  29631. } else { //不存在
  29632. fmt.Println("文件不存在,创建文件")
  29633. f, err := os.Create("日志" + "/" + file_name)
  29634. defer f.Close()
  29635. if err != nil {
  29636. } else {
  29637. _, err = f.Write([]byte("记录日志"))
  29638. }
  29639. }
  29640. }
  29641. func saveLog(result string, request string, infno string, desc string) {
  29642. org_id, _ := beego.AppConfig.Int64("org_id")
  29643. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29644. dir := miConfig.OrgName + "日志"
  29645. utils.Mkdir(dir)
  29646. month := time.Unix(1557042972, 0).Format("1")
  29647. year := time.Now().Format("2006")
  29648. month = time.Now().Format("01")
  29649. day := time.Now().Format("02")
  29650. hour := time.Now().Format("15")
  29651. min := time.Now().Format("04")
  29652. sec := time.Now().Format("05")
  29653. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29654. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  29655. file_name := file + ".txt"
  29656. file_path := miConfig.OrgName + "日志" + "/" + file_name
  29657. exist, _ := utils.PathExists(file_path)
  29658. if exist { //存在
  29659. fmt.Println("存在")
  29660. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29661. if err != nil {
  29662. fmt.Println("read fail")
  29663. }
  29664. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29665. n, _ := f.Seek(0, 2)
  29666. _, err = f.WriteAt([]byte(content), n)
  29667. } else { //不存在
  29668. fmt.Println("文件不存在,创建文件")
  29669. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  29670. defer f.Close()
  29671. if err != nil {
  29672. } else {
  29673. _, err = f.Write([]byte("记录日志"))
  29674. }
  29675. }
  29676. }
  29677. type Charset string
  29678. const (
  29679. UTF8 = Charset("UTF-8")
  29680. GB18030 = Charset("GB18030")
  29681. )
  29682. func ConvertToString(src string, srcCode string, tagCode string) string {
  29683. srcCoder := mahonia.NewDecoder(srcCode)
  29684. srcResult := srcCoder.ConvertString(src)
  29685. tagCoder := mahonia.NewDecoder(tagCode)
  29686. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  29687. result := string(cdata)
  29688. return result
  29689. }
  29690. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  29691. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29692. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29693. var token string
  29694. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29695. var api string
  29696. if miConfig.MdtrtareaAdmvs == "320921" {
  29697. 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 +
  29698. "&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
  29699. fmt.Println(api)
  29700. } else {
  29701. 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 +
  29702. "&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
  29703. }
  29704. resp, requestErr := http.Get(api)
  29705. if requestErr != nil {
  29706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29707. return ""
  29708. }
  29709. body, ioErr := ioutil.ReadAll(resp.Body)
  29710. if ioErr != nil {
  29711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29713. return ""
  29714. }
  29715. var respJSON map[string]interface{}
  29716. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29719. return ""
  29720. }
  29721. var status string
  29722. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29723. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29724. var res ResultTwo //1101结果
  29725. var res10265 ResultTwo10265 //1101结果
  29726. if status == "0" { //读卡成功
  29727. var card_info string //卡信息
  29728. var busi_card_info string
  29729. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29730. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29731. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29732. fmt.Println(card_info)
  29733. fmt.Println(busi_card_info)
  29734. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29735. result, _ := json.Marshal(respJSON)
  29736. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29737. utils.ErrorLog("解析失败:%v", err)
  29738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29739. return ""
  29740. }
  29741. res.ErrMsg = res10265.ErrMsg
  29742. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29743. res.Infcode = infocode
  29744. res.Output = res10265.Output
  29745. res.InfRefmsgid = res10265.InfRefmsgid
  29746. if res.Infcode == 0 {
  29747. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29748. if err == gorm.ErrRecordNotFound {
  29749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29750. return ""
  29751. } else if err != nil {
  29752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29753. return ""
  29754. } else {
  29755. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29756. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29757. infoStr := string(Iinfos)
  29758. idetinfoStr := string(Idetinfos)
  29759. psn := &models.HisPsn{
  29760. PsnNo: res.Output.Baseinfo.PsnNo,
  29761. PatientId: patient.ID,
  29762. Certno: res.Output.Baseinfo.Certno,
  29763. Gend: res.Output.Baseinfo.Gend,
  29764. Naty: res.Output.Baseinfo.Naty,
  29765. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29766. PsnName: res.Output.Baseinfo.PsnName,
  29767. Idetinfo: idetinfoStr,
  29768. Insuinfo: infoStr,
  29769. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29770. CardInfo: card_info,
  29771. VerifyNumber: token,
  29772. }
  29773. service.CreateHisPsn(psn)
  29774. return token
  29775. }
  29776. }
  29777. } else {
  29778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29779. return ""
  29780. }
  29781. } else { //读卡失败
  29782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29783. return ""
  29784. }
  29785. return token
  29786. }
  29787. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  29788. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29789. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29790. var token string
  29791. var api string
  29792. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29793. "&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
  29794. fmt.Println(api)
  29795. resp, requestErr := http.Get(api)
  29796. if requestErr != nil {
  29797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29798. return ""
  29799. }
  29800. body, ioErr := ioutil.ReadAll(resp.Body)
  29801. if ioErr != nil {
  29802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29804. return ""
  29805. }
  29806. var respJSON map[string]interface{}
  29807. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29810. return ""
  29811. }
  29812. var status string
  29813. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29814. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29815. var res ResultTwo //1101结果
  29816. if status == "1" { //读卡成功
  29817. var card_info string //卡信息
  29818. var busi_card_info string
  29819. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29820. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29821. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29822. fmt.Println(card_info)
  29823. fmt.Println(busi_card_info)
  29824. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29825. result, _ := json.Marshal(respJSON)
  29826. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29827. utils.ErrorLog("解析失败:%v", err)
  29828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29829. return ""
  29830. }
  29831. if res.Infcode == 0 {
  29832. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29833. if err == gorm.ErrRecordNotFound {
  29834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29835. return ""
  29836. } else if err != nil {
  29837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29838. return ""
  29839. } else {
  29840. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29841. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29842. infoStr := string(Iinfos)
  29843. idetinfoStr := string(Idetinfos)
  29844. psn := &models.HisPsn{
  29845. PsnNo: res.Output.Baseinfo.PsnNo,
  29846. PatientId: patient.ID,
  29847. Certno: res.Output.Baseinfo.Certno,
  29848. Gend: res.Output.Baseinfo.Gend,
  29849. Naty: res.Output.Baseinfo.Naty,
  29850. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29851. PsnName: res.Output.Baseinfo.PsnName,
  29852. Idetinfo: idetinfoStr,
  29853. Insuinfo: infoStr,
  29854. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29855. CardInfo: card_info,
  29856. VerifyNumber: token,
  29857. }
  29858. service.CreateHisPsn(psn)
  29859. return token
  29860. }
  29861. }
  29862. } else {
  29863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29864. return ""
  29865. }
  29866. return token
  29867. }
  29868. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  29869. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29870. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29871. var token string
  29872. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29873. var api string
  29874. if miConfig.MdtrtareaAdmvs == "320921" {
  29875. 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 +
  29876. "&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
  29877. fmt.Println(api)
  29878. } else {
  29879. 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 +
  29880. "&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
  29881. }
  29882. resp, requestErr := http.Get(api)
  29883. if requestErr != nil {
  29884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29885. return ""
  29886. }
  29887. body, ioErr := ioutil.ReadAll(resp.Body)
  29888. if ioErr != nil {
  29889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29891. return ""
  29892. }
  29893. var respJSON map[string]interface{}
  29894. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29897. return ""
  29898. }
  29899. var status string
  29900. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29901. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29902. var res ResultTwo //1101结果
  29903. var res10265 ResultTwo10265 //1101结果
  29904. if status == "0" { //读卡成功
  29905. var card_info string //卡信息
  29906. var busi_card_info string
  29907. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29908. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29909. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29910. fmt.Println(card_info)
  29911. fmt.Println(busi_card_info)
  29912. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29913. result, _ := json.Marshal(respJSON)
  29914. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29915. utils.ErrorLog("解析失败:%v", err)
  29916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29917. return ""
  29918. }
  29919. res.ErrMsg = res10265.ErrMsg
  29920. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29921. res.Infcode = infocode
  29922. res.Output = res10265.Output
  29923. res.InfRefmsgid = res10265.InfRefmsgid
  29924. if res.Infcode == 0 {
  29925. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29926. if err == gorm.ErrRecordNotFound {
  29927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29928. return ""
  29929. } else if err != nil {
  29930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29931. return ""
  29932. } else {
  29933. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29934. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29935. infoStr := string(Iinfos)
  29936. idetinfoStr := string(Idetinfos)
  29937. psn := &models.HisPsn{
  29938. PsnNo: res.Output.Baseinfo.PsnNo,
  29939. PatientId: patient.ID,
  29940. Certno: res.Output.Baseinfo.Certno,
  29941. Gend: res.Output.Baseinfo.Gend,
  29942. Naty: res.Output.Baseinfo.Naty,
  29943. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29944. PsnName: res.Output.Baseinfo.PsnName,
  29945. Idetinfo: idetinfoStr,
  29946. Insuinfo: infoStr,
  29947. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29948. CardInfo: card_info,
  29949. VerifyNumber: token,
  29950. }
  29951. service.CreateHisPsn(psn)
  29952. return token
  29953. }
  29954. }
  29955. } else {
  29956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29957. return ""
  29958. }
  29959. } else { //读卡失败
  29960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29961. return ""
  29962. }
  29963. return token
  29964. }
  29965. func DeleteExtraSpaceTwo(s string) string {
  29966. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29967. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29968. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29969. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29970. s2 := make([]byte, len(s1)) //定义字符数组切片
  29971. copy(s2, s1) //将字符串复制到切片
  29972. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29973. for len(spc_index) > 0 { //找到适配项
  29974. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29975. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29976. }
  29977. return string(s2)
  29978. }
  29979. func Remove0000(s string) string {
  29980. str := make([]rune, 0, len(s))
  29981. for _, v := range []rune(s) {
  29982. if v == 0 {
  29983. continue
  29984. }
  29985. str = append(str, v)
  29986. }
  29987. return string(str)
  29988. }
  29989. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  29990. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  29991. readCard := DllDef.MustFindProc("EcQuery")
  29992. pCardInfo := make([]byte, 8192)
  29993. pBusiCardInfo := make([]byte, 8192)
  29994. data := make(map[string]interface{})
  29995. //pData := make(map[string]interface{})
  29996. inputData := make(map[string]interface{})
  29997. inputData["orgId"] = code
  29998. inputData["businessType"] = "01101"
  29999. inputData["operatorId"] = operator_id
  30000. inputData["operatorName"] = operator_name
  30001. inputData["officeId"] = "001"
  30002. inputData["officeName"] = "血透室"
  30003. //
  30004. data["data"] = inputData
  30005. data["transType"] = "ec.query"
  30006. data["orgId"] = code
  30007. bytesData, _ := json.Marshal(data)
  30008. pCardInfo = bytesData
  30009. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  30010. fmt.Println(ret2)
  30011. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  30012. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  30013. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  30014. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  30015. if ret2 != 0 {
  30016. return "", ""
  30017. }
  30018. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  30019. }
  30020. func DeleteExtraSpace(s string) string {
  30021. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  30022. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  30023. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  30024. reg, _ := regexp.Compile(regstr) //编译正则表达式
  30025. s2 := make([]byte, len(s1)) //定义字符数组切片
  30026. copy(s2, s1) //将字符串复制到切片
  30027. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  30028. for len(spc_index) > 0 { //找到适配项
  30029. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  30030. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  30031. }
  30032. return string(s2)
  30033. }
  30034. // 对账
  30035. func (c *HisApiController) Post3202() {
  30036. start_time := c.GetString("start_time")
  30037. end_time := c.GetString("end_time")
  30038. //insutype := c.GetString("insutype")
  30039. clr_type := c.GetString("clr_type")
  30040. clr_org := c.GetString("clr_optins")
  30041. admin_user_id, _ := c.GetInt64("admin_user_id")
  30042. adminUser := c.GetAdminUserInfo()
  30043. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30044. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30045. if len(clr_org) == 0 {
  30046. clr_org = miConfig.MdtrtareaAdmvs
  30047. }
  30048. timeLayout := "2006-01-02"
  30049. loc, _ := time.LoadLocation("Local")
  30050. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30051. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30052. var orders []*models.HisOrder
  30053. if clr_org == "421300" {
  30054. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30055. } else {
  30056. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30057. }
  30058. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30059. //fixmedins_setl_cnt := int64(len(orders))
  30060. var medfee_sumamt float64
  30061. var acct_pay float64
  30062. var fund_pay_sumamt float64
  30063. for _, item := range orders {
  30064. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30065. acct_pay = acct_pay + item.AcctPay
  30066. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30067. }
  30068. //var medfee_sumamt_two float64
  30069. //var acct_pay_two float64
  30070. //var fund_pay_sumamt_two float64
  30071. //for _, item := range orders_two {
  30072. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30073. // acct_pay_two = acct_pay_two + item.AcctPay
  30074. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30075. //}
  30076. //var user_name string
  30077. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30078. //if role.ID == 0 {
  30079. // user_name = "xxx"
  30080. //} else {
  30081. // user_name = role.UserName
  30082. //}
  30083. var res ResultSix
  30084. if config.IsOpen == 1 {
  30085. var bps []*models.BusinessParamsTwo
  30086. var bp models.BusinessParamsTwo
  30087. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30088. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30089. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  30090. bp.MedfeeSumamt = medfee_sumamt_str
  30091. bp.AcctPay = acct_pay_str
  30092. bp.FundPaySumamt = fund_pay_sumamt_str
  30093. bp.Insutype = ""
  30094. bp.StmtBegndate = start_time
  30095. bp.ClrType = clr_type
  30096. bp.SetlOptins = clr_org
  30097. bp.StmtEnddate = end_time
  30098. bps = append(bps, &bp)
  30099. data := make(map[string]interface{})
  30100. data["bps"] = bps
  30101. data["org_name"] = miConfig.OrgName
  30102. data["doctor"] = role.UserName
  30103. data["fixmedins_code"] = miConfig.Code
  30104. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30105. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30106. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30107. if miConfig.MdtrtareaAdmvs == "421300" {
  30108. client := &http.Client{}
  30109. bytesData, _ := json.Marshal(data)
  30110. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  30111. resp, _ := client.Do(req)
  30112. defer resp.Body.Close()
  30113. body, ioErr := ioutil.ReadAll(resp.Body)
  30114. if ioErr != nil {
  30115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30117. return
  30118. }
  30119. var respJSON map[string]interface{}
  30120. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30123. return
  30124. }
  30125. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30126. userJSONBytes, _ := json.Marshal(respJSON)
  30127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30128. utils.ErrorLog("解析失败:%v", err)
  30129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30130. return
  30131. }
  30132. }
  30133. if miConfig.MdtrtareaAdmvs == "420200" {
  30134. client := &http.Client{}
  30135. bytesData, _ := json.Marshal(data)
  30136. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  30137. resp, _ := client.Do(req)
  30138. defer resp.Body.Close()
  30139. body, ioErr := ioutil.ReadAll(resp.Body)
  30140. if ioErr != nil {
  30141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30143. return
  30144. }
  30145. var respJSON map[string]interface{}
  30146. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30149. return
  30150. }
  30151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30152. userJSONBytes, _ := json.Marshal(respJSON)
  30153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30154. utils.ErrorLog("解析失败:%v", err)
  30155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30156. return
  30157. }
  30158. }
  30159. if miConfig.MdtrtareaAdmvs == "421182" {
  30160. client := &http.Client{}
  30161. bytesData, _ := json.Marshal(data)
  30162. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  30163. resp, _ := client.Do(req)
  30164. defer resp.Body.Close()
  30165. body, ioErr := ioutil.ReadAll(resp.Body)
  30166. if ioErr != nil {
  30167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30169. return
  30170. }
  30171. var respJSON map[string]interface{}
  30172. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30175. return
  30176. }
  30177. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30178. userJSONBytes, _ := json.Marshal(respJSON)
  30179. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30180. utils.ErrorLog("解析失败:%v", err)
  30181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30182. return
  30183. }
  30184. }
  30185. if res.Infcode == 0 {
  30186. c.ServeSuccessJSON(map[string]interface{}{
  30187. "msg": "发起成功",
  30188. })
  30189. } else {
  30190. c.ServeSuccessJSON(map[string]interface{}{
  30191. "failed_code": -10,
  30192. "msg": res.ErrMsg,
  30193. })
  30194. }
  30195. }
  30196. }
  30197. func (c *HisApiController) Post3202b() {
  30198. start_time := c.GetString("start_time")
  30199. end_time := c.GetString("end_time")
  30200. //insutype := c.GetString("insutype")
  30201. clr_type := c.GetString("clr_type")
  30202. clr_org := c.GetString("clr_optins")
  30203. admin_user_id, _ := c.GetInt64("admin_user_id")
  30204. adminUser := c.GetAdminUserInfo()
  30205. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30206. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30207. if len(clr_org) == 0 {
  30208. clr_org = miConfig.MdtrtareaAdmvs
  30209. }
  30210. timeLayout := "2006-01-02"
  30211. loc, _ := time.LoadLocation("Local")
  30212. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30213. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30214. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30215. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30216. //fixmedins_setl_cnt := int64(len(orders))
  30217. var medfee_sumamt float64
  30218. var acct_pay float64
  30219. var fund_pay_sumamt float64
  30220. for _, item := range orders {
  30221. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30222. acct_pay = acct_pay + item.AcctPay
  30223. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30224. }
  30225. //var medfee_sumamt_two float64
  30226. //var acct_pay_two float64
  30227. //var fund_pay_sumamt_two float64
  30228. //for _, item := range orders_two {
  30229. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30230. // acct_pay_two = acct_pay_two + item.AcctPay
  30231. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30232. //}
  30233. //var user_name string
  30234. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30235. //if role.ID == 0 {
  30236. // user_name = "xxx"
  30237. //} else {
  30238. // user_name = role.UserName
  30239. //}
  30240. var res ResultSix
  30241. if config.IsOpen == 1 {
  30242. var bps []*models.BusinessParamsTwo
  30243. var bp models.BusinessParamsTwo
  30244. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30245. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30246. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  30247. bp.MedfeeSumamt = medfee_sumamt_str
  30248. bp.AcctPay = acct_pay_str
  30249. bp.FundPaySumamt = fund_pay_sumamt_str
  30250. bp.Insutype = "390"
  30251. bp.StmtBegndate = start_time
  30252. bp.ClrType = clr_type
  30253. bp.SetlOptins = clr_org
  30254. bp.StmtEnddate = end_time
  30255. bps = append(bps, &bp)
  30256. data := make(map[string]interface{})
  30257. data["bps"] = bps
  30258. data["org_name"] = miConfig.OrgName
  30259. data["doctor"] = role.UserName
  30260. data["fixmedins_code"] = miConfig.Code
  30261. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30262. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30263. if miConfig.MdtrtareaAdmvs == "421300" {
  30264. client := &http.Client{}
  30265. bytesData, _ := json.Marshal(data)
  30266. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30267. resp, _ := client.Do(req)
  30268. defer resp.Body.Close()
  30269. body, ioErr := ioutil.ReadAll(resp.Body)
  30270. if ioErr != nil {
  30271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30273. return
  30274. }
  30275. var respJSON map[string]interface{}
  30276. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30279. return
  30280. }
  30281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30282. userJSONBytes, _ := json.Marshal(respJSON)
  30283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30284. utils.ErrorLog("解析失败:%v", err)
  30285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30286. return
  30287. }
  30288. }
  30289. if miConfig.MdtrtareaAdmvs == "420200" {
  30290. client := &http.Client{}
  30291. bytesData, _ := json.Marshal(data)
  30292. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30293. resp, _ := client.Do(req)
  30294. defer resp.Body.Close()
  30295. body, ioErr := ioutil.ReadAll(resp.Body)
  30296. if ioErr != nil {
  30297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30299. return
  30300. }
  30301. var respJSON map[string]interface{}
  30302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30305. return
  30306. }
  30307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30308. userJSONBytes, _ := json.Marshal(respJSON)
  30309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30310. utils.ErrorLog("解析失败:%v", err)
  30311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30312. return
  30313. }
  30314. }
  30315. if miConfig.MdtrtareaAdmvs == "421182" {
  30316. client := &http.Client{}
  30317. bytesData, _ := json.Marshal(data)
  30318. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  30319. resp, _ := client.Do(req)
  30320. defer resp.Body.Close()
  30321. body, ioErr := ioutil.ReadAll(resp.Body)
  30322. if ioErr != nil {
  30323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30325. return
  30326. }
  30327. var respJSON map[string]interface{}
  30328. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30331. return
  30332. }
  30333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30334. userJSONBytes, _ := json.Marshal(respJSON)
  30335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30336. utils.ErrorLog("解析失败:%v", err)
  30337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30338. return
  30339. }
  30340. }
  30341. if res.Infcode == 0 {
  30342. c.ServeSuccessJSON(map[string]interface{}{
  30343. "msg": "发起成功",
  30344. })
  30345. } else {
  30346. c.ServeSuccessJSON(map[string]interface{}{
  30347. "failed_code": -10,
  30348. "msg": res.ErrMsg,
  30349. })
  30350. }
  30351. }
  30352. }
  30353. func (c *HisApiController) Post1608() {
  30354. start_time := c.GetString("start_time")
  30355. end_time := c.GetString("end_time")
  30356. admin_user_id, _ := c.GetInt64("admin_user_id")
  30357. adminUser := c.GetAdminUserInfo()
  30358. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30359. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30360. timeLayout := "2006-01-02"
  30361. loc, _ := time.LoadLocation("Local")
  30362. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30363. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30364. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30365. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30366. fixmedins_setl_cnt := int64(len(orders))
  30367. var medfee_sumamt float64
  30368. var func_smamt float64
  30369. for _, item := range orders {
  30370. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30371. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  30372. }
  30373. times := strings.Split(start_time, "-")
  30374. time_tows := strings.Split(end_time, "-")
  30375. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30376. var res ResultSix
  30377. if config.IsOpen == 1 {
  30378. //var bps []*models.BusinessParamsTwo
  30379. //var bp models.BusinessParamsTwo
  30380. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30381. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  30382. data := make(map[string]interface{})
  30383. data["org_name"] = miConfig.OrgName
  30384. data["doctor"] = role.UserName
  30385. data["func_smamt"] = func_smamt_str
  30386. data["fixmedins_code"] = miConfig.Code
  30387. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30388. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30389. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  30390. data["medfee_sumamt"] = medfee_sumamt_str
  30391. data["start_time"] = times[0] + times[1] + times[2]
  30392. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  30393. if miConfig.MdtrtareaAdmvs == "421300" {
  30394. client := &http.Client{}
  30395. bytesData, _ := json.Marshal(data)
  30396. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30397. resp, _ := client.Do(req)
  30398. defer resp.Body.Close()
  30399. body, ioErr := ioutil.ReadAll(resp.Body)
  30400. if ioErr != nil {
  30401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30403. return
  30404. }
  30405. var respJSON map[string]interface{}
  30406. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30409. return
  30410. }
  30411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30412. userJSONBytes, _ := json.Marshal(respJSON)
  30413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30414. utils.ErrorLog("解析失败:%v", err)
  30415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30416. return
  30417. }
  30418. }
  30419. if miConfig.MdtrtareaAdmvs == "420200" {
  30420. client := &http.Client{}
  30421. bytesData, _ := json.Marshal(data)
  30422. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30423. resp, _ := client.Do(req)
  30424. defer resp.Body.Close()
  30425. body, ioErr := ioutil.ReadAll(resp.Body)
  30426. if ioErr != nil {
  30427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30429. return
  30430. }
  30431. var respJSON map[string]interface{}
  30432. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30435. return
  30436. }
  30437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30438. userJSONBytes, _ := json.Marshal(respJSON)
  30439. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30440. utils.ErrorLog("解析失败:%v", err)
  30441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30442. return
  30443. }
  30444. }
  30445. if miConfig.MdtrtareaAdmvs == "421182" {
  30446. client := &http.Client{}
  30447. bytesData, _ := json.Marshal(data)
  30448. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  30449. resp, _ := client.Do(req)
  30450. defer resp.Body.Close()
  30451. body, ioErr := ioutil.ReadAll(resp.Body)
  30452. if ioErr != nil {
  30453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30455. return
  30456. }
  30457. var respJSON map[string]interface{}
  30458. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30461. return
  30462. }
  30463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30464. userJSONBytes, _ := json.Marshal(respJSON)
  30465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30466. utils.ErrorLog("解析失败:%v", err)
  30467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30468. return
  30469. }
  30470. }
  30471. if res.Infcode == 0 {
  30472. c.ServeSuccessJSON(map[string]interface{}{
  30473. "msg": "发起成功",
  30474. })
  30475. } else {
  30476. c.ServeSuccessJSON(map[string]interface{}{
  30477. "failed_code": -10,
  30478. "msg": res.ErrMsg,
  30479. })
  30480. }
  30481. }
  30482. }
  30483. // 5.11.1.1【5262】结算信息按时间段查询
  30484. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30485. admin_user_id, _ := c.GetInt64("admin_user_id")
  30486. adminUser := c.GetAdminUserInfo()
  30487. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30488. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30489. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30490. var res Result5262
  30491. if config.IsOpen == 1 {
  30492. if miConfig.MdtrtareaAdmvs == "421300" {
  30493. data := make(map[string]interface{})
  30494. data["bps"] = bp
  30495. data["org_name"] = miConfig.OrgName
  30496. data["doctor"] = role.UserName
  30497. data["fixmedins_code"] = miConfig.Code
  30498. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30499. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30500. data["page"] = strconv.FormatInt(page, 10)
  30501. data["limit"] = strconv.FormatInt(limit, 10)
  30502. fmt.Println(data)
  30503. client := &http.Client{}
  30504. bytesData, _ := json.Marshal(data)
  30505. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30506. resp, _ := client.Do(req)
  30507. defer resp.Body.Close()
  30508. body, ioErr := ioutil.ReadAll(resp.Body)
  30509. if ioErr != nil {
  30510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30512. return
  30513. }
  30514. var respJSON map[string]interface{}
  30515. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30518. return
  30519. }
  30520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30521. userJSONBytes, _ := json.Marshal(respJSON)
  30522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30523. utils.ErrorLog("解析失败:%v", err)
  30524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30525. return
  30526. }
  30527. }
  30528. if miConfig.MdtrtareaAdmvs == "420200" {
  30529. data := make(map[string]interface{})
  30530. data["bps"] = bp
  30531. data["org_name"] = miConfig.OrgName
  30532. data["doctor"] = role.UserName
  30533. data["fixmedins_code"] = miConfig.Code
  30534. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30535. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30536. data["page"] = strconv.FormatInt(page, 10)
  30537. data["limit"] = strconv.FormatInt(limit, 10)
  30538. fmt.Println(data)
  30539. client := &http.Client{}
  30540. bytesData, _ := json.Marshal(data)
  30541. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30542. resp, _ := client.Do(req)
  30543. defer resp.Body.Close()
  30544. body, ioErr := ioutil.ReadAll(resp.Body)
  30545. if ioErr != nil {
  30546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30548. return
  30549. }
  30550. var respJSON map[string]interface{}
  30551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30554. return
  30555. }
  30556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30557. userJSONBytes, _ := json.Marshal(respJSON)
  30558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30559. utils.ErrorLog("解析失败:%v", err)
  30560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30561. return
  30562. }
  30563. }
  30564. if miConfig.MdtrtareaAdmvs == "421182" {
  30565. data := make(map[string]interface{})
  30566. data["bps"] = bp
  30567. data["org_name"] = miConfig.OrgName
  30568. data["doctor"] = role.UserName
  30569. data["fixmedins_code"] = miConfig.Code
  30570. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30571. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30572. data["page"] = strconv.FormatInt(page, 10)
  30573. data["limit"] = strconv.FormatInt(limit, 10)
  30574. fmt.Println(data)
  30575. client := &http.Client{}
  30576. bytesData, _ := json.Marshal(data)
  30577. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  30578. resp, _ := client.Do(req)
  30579. defer resp.Body.Close()
  30580. body, ioErr := ioutil.ReadAll(resp.Body)
  30581. if ioErr != nil {
  30582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30584. return
  30585. }
  30586. var respJSON map[string]interface{}
  30587. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30590. return
  30591. }
  30592. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30593. userJSONBytes, _ := json.Marshal(respJSON)
  30594. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30595. utils.ErrorLog("解析失败:%v", err)
  30596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30597. return
  30598. }
  30599. }
  30600. if res.Infcode == 0 {
  30601. c.ServeSuccessJSON(map[string]interface{}{
  30602. "order": res.Output.Result,
  30603. "total": res.Output.PageInfo.RecordCounts,
  30604. })
  30605. } else {
  30606. c.ServeSuccessJSON(map[string]interface{}{
  30607. "failed_code": -10,
  30608. "msg": res.ErrMsg,
  30609. })
  30610. }
  30611. }
  30612. }
  30613. // 5.11.1.2【5267】异地结算信息时间段查询
  30614. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30615. admin_user_id, _ := c.GetInt64("admin_user_id")
  30616. adminUser := c.GetAdminUserInfo()
  30617. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30618. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30619. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30620. var res Result5267
  30621. if config.IsOpen == 1 {
  30622. if miConfig.MdtrtareaAdmvs == "421300" {
  30623. data := make(map[string]interface{})
  30624. data["bps"] = bp
  30625. data["org_name"] = miConfig.OrgName
  30626. data["doctor"] = role.UserName
  30627. data["fixmedins_code"] = miConfig.Code
  30628. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30629. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30630. data["page"] = page
  30631. data["limit"] = limit
  30632. fmt.Println(data)
  30633. client := &http.Client{}
  30634. bytesData, _ := json.Marshal(data)
  30635. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30636. resp, _ := client.Do(req)
  30637. defer resp.Body.Close()
  30638. body, ioErr := ioutil.ReadAll(resp.Body)
  30639. if ioErr != nil {
  30640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30642. return
  30643. }
  30644. var respJSON map[string]interface{}
  30645. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30648. return
  30649. }
  30650. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30651. userJSONBytes, _ := json.Marshal(respJSON)
  30652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30653. utils.ErrorLog("解析失败:%v", err)
  30654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30655. return
  30656. }
  30657. }
  30658. if miConfig.MdtrtareaAdmvs == "420200" {
  30659. data := make(map[string]interface{})
  30660. data["bps"] = bp
  30661. data["org_name"] = miConfig.OrgName
  30662. data["doctor"] = role.UserName
  30663. data["fixmedins_code"] = miConfig.Code
  30664. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30665. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30666. data["page"] = page
  30667. data["limit"] = limit
  30668. fmt.Println(data)
  30669. client := &http.Client{}
  30670. bytesData, _ := json.Marshal(data)
  30671. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30672. resp, _ := client.Do(req)
  30673. defer resp.Body.Close()
  30674. body, ioErr := ioutil.ReadAll(resp.Body)
  30675. if ioErr != nil {
  30676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30678. return
  30679. }
  30680. var respJSON map[string]interface{}
  30681. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30684. return
  30685. }
  30686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30687. userJSONBytes, _ := json.Marshal(respJSON)
  30688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30689. utils.ErrorLog("解析失败:%v", err)
  30690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30691. return
  30692. }
  30693. }
  30694. if miConfig.MdtrtareaAdmvs == "421182" {
  30695. data := make(map[string]interface{})
  30696. data["bps"] = bp
  30697. data["org_name"] = miConfig.OrgName
  30698. data["doctor"] = role.UserName
  30699. data["fixmedins_code"] = miConfig.Code
  30700. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30701. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30702. data["page"] = page
  30703. data["limit"] = limit
  30704. fmt.Println(data)
  30705. client := &http.Client{}
  30706. bytesData, _ := json.Marshal(data)
  30707. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  30708. resp, _ := client.Do(req)
  30709. defer resp.Body.Close()
  30710. body, ioErr := ioutil.ReadAll(resp.Body)
  30711. if ioErr != nil {
  30712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30714. return
  30715. }
  30716. var respJSON map[string]interface{}
  30717. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30720. return
  30721. }
  30722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30723. userJSONBytes, _ := json.Marshal(respJSON)
  30724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30725. utils.ErrorLog("解析失败:%v", err)
  30726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30727. return
  30728. }
  30729. }
  30730. if res.Infcode == 0 {
  30731. c.ServeSuccessJSON(map[string]interface{}{
  30732. "order": res.Output.Result,
  30733. "total": res.Output.PageInfo.RecordCounts,
  30734. })
  30735. } else {
  30736. c.ServeSuccessJSON(map[string]interface{}{
  30737. "failed_code": -10,
  30738. "msg": res.ErrMsg,
  30739. })
  30740. }
  30741. }
  30742. }
  30743. func (c *HisApiController) Post3501() {
  30744. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30745. data := make(map[string]interface{})
  30746. var struct3501s []models.Struct3501
  30747. var struct3501 models.Struct3501
  30748. struct3501.OrgName = miConfig.OrgName
  30749. struct3501.AccessKey = miConfig.AccessKey
  30750. struct3501.RequestUrl = miConfig.Url
  30751. struct3501.SecretKey = miConfig.SecretKey
  30752. struct3501.ManuDate = "2022-08-17"
  30753. struct3501.FixmedinsBchno = ""
  30754. struct3501.ManuLotnum = ""
  30755. struct3501.RxFlag = "0"
  30756. struct3501.ExpyEnd = "2022-08-17"
  30757. struct3501.Invdate = "2022-08-17"
  30758. struct3501.InvCnt = "20.25"
  30759. struct3501.Memo = ""
  30760. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30761. struct3501.FixmedinsHilistId = miConfig.Code
  30762. struct3501.FixmedinsHilistName = miConfig.OrgName
  30763. struct3501s = append(struct3501s, struct3501)
  30764. data["struct_3501s"] = struct3501s
  30765. client := &http.Client{}
  30766. bytesData, _ := json.Marshal(data)
  30767. var req *http.Request
  30768. if miConfig.MdtrtareaAdmvs == "320921" {
  30769. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30770. } else {
  30771. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30772. }
  30773. resp, _ := client.Do(req)
  30774. defer resp.Body.Close()
  30775. body, ioErr := ioutil.ReadAll(resp.Body)
  30776. if ioErr != nil {
  30777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30779. return
  30780. }
  30781. var respJSON map[string]interface{}
  30782. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30785. return
  30786. }
  30787. var res ResultSix
  30788. var resSix10265 ResultSix10265 //1101结果
  30789. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30790. result, _ := json.Marshal(respJSON)
  30791. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30792. utils.ErrorLog("解析失败:%v", err)
  30793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30794. return
  30795. }
  30796. res.InfRefmsgid = resSix10265.InfRefmsgid
  30797. res.Output = resSix10265.Output
  30798. res.ErrMsg = resSix10265.ErrMsg
  30799. res.Cainfo = resSix10265.Cainfo
  30800. res.WarnMsg = resSix10265.WarnMsg
  30801. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30802. res.Infcode = infocode
  30803. if infocode == 0 {
  30804. c.ServeSuccessJSON(map[string]interface{}{
  30805. "msg": "上传成功",
  30806. })
  30807. return
  30808. } else {
  30809. c.ServeSuccessJSON(map[string]interface{}{
  30810. "failed_code": -10,
  30811. "msg": res.ErrMsg,
  30812. })
  30813. return
  30814. }
  30815. }
  30816. func (c *HisApiController) Post3502() {
  30817. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30818. data := make(map[string]interface{})
  30819. var struct3502s []models.Struct3502
  30820. var struct3502 models.Struct3502
  30821. struct3502.OrgName = miConfig.OrgName
  30822. struct3502.AccessKey = miConfig.AccessKey
  30823. struct3502.RequestUrl = miConfig.Url
  30824. struct3502.SecretKey = miConfig.SecretKey
  30825. struct3502.ManuDate = "2022-08-15"
  30826. struct3502.FixmedinsBchno = ""
  30827. struct3502.ManuLotnum = ""
  30828. struct3502.RxFlag = "0"
  30829. struct3502.ExpyEnd = "2022-08-15"
  30830. struct3502.Invdate = "2022-08-15"
  30831. struct3502.InvCnt = "20.25"
  30832. struct3502.Memo = ""
  30833. struct3502.MedListCodg = "XB01ABD056B002020200517"
  30834. struct3502.FixmedinsHilistId = miConfig.Code
  30835. struct3502.FixmedinsHilistName = miConfig.OrgName
  30836. struct3502s = append(struct3502s, struct3502)
  30837. data["struct_3502s"] = struct3502s
  30838. client := &http.Client{}
  30839. bytesData, _ := json.Marshal(data)
  30840. var req *http.Request
  30841. if miConfig.MdtrtareaAdmvs == "320921" {
  30842. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30843. } else {
  30844. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30845. }
  30846. resp, _ := client.Do(req)
  30847. defer resp.Body.Close()
  30848. body, ioErr := ioutil.ReadAll(resp.Body)
  30849. if ioErr != nil {
  30850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30852. return
  30853. }
  30854. var respJSON map[string]interface{}
  30855. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30858. return
  30859. }
  30860. var res ResultSix
  30861. var resSix10265 ResultSix10265 //1101结果
  30862. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30863. result, _ := json.Marshal(respJSON)
  30864. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30865. utils.ErrorLog("解析失败:%v", err)
  30866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30867. return
  30868. }
  30869. res.InfRefmsgid = resSix10265.InfRefmsgid
  30870. res.Output = resSix10265.Output
  30871. res.ErrMsg = resSix10265.ErrMsg
  30872. res.Cainfo = resSix10265.Cainfo
  30873. res.WarnMsg = resSix10265.WarnMsg
  30874. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30875. res.Infcode = infocode
  30876. if infocode == 0 {
  30877. c.ServeSuccessJSON(map[string]interface{}{
  30878. "msg": "上传成功",
  30879. })
  30880. return
  30881. } else {
  30882. c.ServeSuccessJSON(map[string]interface{}{
  30883. "failed_code": -10,
  30884. "msg": res.ErrMsg,
  30885. })
  30886. return
  30887. }
  30888. }
  30889. func (c *HisApiController) Post3503() {
  30890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30891. data := make(map[string]interface{})
  30892. var struct3501s []models.Struct3501
  30893. var struct3501 models.Struct3501
  30894. struct3501.OrgName = miConfig.OrgName
  30895. struct3501.AccessKey = miConfig.AccessKey
  30896. struct3501.RequestUrl = miConfig.Url
  30897. struct3501.SecretKey = miConfig.SecretKey
  30898. struct3501.ManuDate = "2022-08-15"
  30899. struct3501.FixmedinsBchno = ""
  30900. struct3501.ManuLotnum = ""
  30901. struct3501.RxFlag = "0"
  30902. struct3501.ExpyEnd = "2022-08-15"
  30903. struct3501.Invdate = "2022-08-15"
  30904. struct3501.InvCnt = "20.25"
  30905. struct3501.Memo = ""
  30906. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30907. struct3501.FixmedinsHilistId = miConfig.Code
  30908. struct3501.FixmedinsHilistName = miConfig.OrgName
  30909. struct3501s = append(struct3501s, struct3501)
  30910. data["struct_3501s"] = struct3501s
  30911. client := &http.Client{}
  30912. bytesData, _ := json.Marshal(data)
  30913. var req *http.Request
  30914. if miConfig.MdtrtareaAdmvs == "320921" {
  30915. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30916. } else {
  30917. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30918. }
  30919. resp, _ := client.Do(req)
  30920. defer resp.Body.Close()
  30921. body, ioErr := ioutil.ReadAll(resp.Body)
  30922. if ioErr != nil {
  30923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30925. return
  30926. }
  30927. var respJSON map[string]interface{}
  30928. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30931. return
  30932. }
  30933. var res ResultSix
  30934. var resSix10265 ResultSix10265 //1101结果
  30935. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30936. result, _ := json.Marshal(respJSON)
  30937. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30938. utils.ErrorLog("解析失败:%v", err)
  30939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30940. return
  30941. }
  30942. res.InfRefmsgid = resSix10265.InfRefmsgid
  30943. res.Output = resSix10265.Output
  30944. res.ErrMsg = resSix10265.ErrMsg
  30945. res.Cainfo = resSix10265.Cainfo
  30946. res.WarnMsg = resSix10265.WarnMsg
  30947. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30948. res.Infcode = infocode
  30949. if infocode == 0 {
  30950. c.ServeSuccessJSON(map[string]interface{}{
  30951. "msg": "上传成功",
  30952. })
  30953. return
  30954. } else {
  30955. c.ServeSuccessJSON(map[string]interface{}{
  30956. "failed_code": -10,
  30957. "msg": res.ErrMsg,
  30958. })
  30959. return
  30960. }
  30961. }
  30962. func (c *HisApiController) Post3504() {
  30963. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30964. data := make(map[string]interface{})
  30965. var struct3501s []models.Struct3501
  30966. var struct3501 models.Struct3501
  30967. struct3501.OrgName = miConfig.OrgName
  30968. struct3501.AccessKey = miConfig.AccessKey
  30969. struct3501.RequestUrl = miConfig.Url
  30970. struct3501.SecretKey = miConfig.SecretKey
  30971. struct3501.ManuDate = "2022-08-15"
  30972. struct3501.FixmedinsBchno = ""
  30973. struct3501.ManuLotnum = ""
  30974. struct3501.RxFlag = "0"
  30975. struct3501.ExpyEnd = "2022-08-15"
  30976. struct3501.Invdate = "2022-08-15"
  30977. struct3501.InvCnt = "20.25"
  30978. struct3501.Memo = ""
  30979. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30980. struct3501.FixmedinsHilistId = miConfig.Code
  30981. struct3501.FixmedinsHilistName = miConfig.OrgName
  30982. struct3501s = append(struct3501s, struct3501)
  30983. data["struct_3501s"] = struct3501s
  30984. client := &http.Client{}
  30985. bytesData, _ := json.Marshal(data)
  30986. var req *http.Request
  30987. if miConfig.MdtrtareaAdmvs == "320921" {
  30988. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30989. } else {
  30990. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30991. }
  30992. resp, _ := client.Do(req)
  30993. defer resp.Body.Close()
  30994. body, ioErr := ioutil.ReadAll(resp.Body)
  30995. if ioErr != nil {
  30996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30998. return
  30999. }
  31000. var respJSON map[string]interface{}
  31001. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31004. return
  31005. }
  31006. var res ResultSix
  31007. var resSix10265 ResultSix10265 //1101结果
  31008. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31009. result, _ := json.Marshal(respJSON)
  31010. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31011. utils.ErrorLog("解析失败:%v", err)
  31012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31013. return
  31014. }
  31015. res.InfRefmsgid = resSix10265.InfRefmsgid
  31016. res.Output = resSix10265.Output
  31017. res.ErrMsg = resSix10265.ErrMsg
  31018. res.Cainfo = resSix10265.Cainfo
  31019. res.WarnMsg = resSix10265.WarnMsg
  31020. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31021. res.Infcode = infocode
  31022. if infocode == 0 {
  31023. c.ServeSuccessJSON(map[string]interface{}{
  31024. "msg": "上传成功",
  31025. })
  31026. return
  31027. } else {
  31028. c.ServeSuccessJSON(map[string]interface{}{
  31029. "failed_code": -10,
  31030. "msg": res.ErrMsg,
  31031. })
  31032. return
  31033. }
  31034. }
  31035. func (c *HisApiController) Post3505() {
  31036. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31037. data := make(map[string]interface{})
  31038. var struct3501s []models.Struct3501
  31039. var struct3501 models.Struct3501
  31040. struct3501.OrgName = miConfig.OrgName
  31041. struct3501.AccessKey = miConfig.AccessKey
  31042. struct3501.RequestUrl = miConfig.Url
  31043. struct3501.SecretKey = miConfig.SecretKey
  31044. struct3501.ManuDate = "2022-08-15"
  31045. struct3501.FixmedinsBchno = ""
  31046. struct3501.ManuLotnum = ""
  31047. struct3501.RxFlag = "0"
  31048. struct3501.ExpyEnd = "2022-08-15"
  31049. struct3501.Invdate = "2022-08-15"
  31050. struct3501.InvCnt = "20.25"
  31051. struct3501.Memo = ""
  31052. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31053. struct3501.FixmedinsHilistId = miConfig.Code
  31054. struct3501.FixmedinsHilistName = miConfig.OrgName
  31055. struct3501s = append(struct3501s, struct3501)
  31056. data["struct_3501s"] = struct3501s
  31057. client := &http.Client{}
  31058. bytesData, _ := json.Marshal(data)
  31059. var req *http.Request
  31060. if miConfig.MdtrtareaAdmvs == "320921" {
  31061. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31062. } else {
  31063. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31064. }
  31065. resp, _ := client.Do(req)
  31066. defer resp.Body.Close()
  31067. body, ioErr := ioutil.ReadAll(resp.Body)
  31068. if ioErr != nil {
  31069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31071. return
  31072. }
  31073. var respJSON map[string]interface{}
  31074. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31077. return
  31078. }
  31079. var res ResultSix
  31080. var resSix10265 ResultSix10265 //1101结果
  31081. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31082. result, _ := json.Marshal(respJSON)
  31083. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31084. utils.ErrorLog("解析失败:%v", err)
  31085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31086. return
  31087. }
  31088. res.InfRefmsgid = resSix10265.InfRefmsgid
  31089. res.Output = resSix10265.Output
  31090. res.ErrMsg = resSix10265.ErrMsg
  31091. res.Cainfo = resSix10265.Cainfo
  31092. res.WarnMsg = resSix10265.WarnMsg
  31093. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31094. res.Infcode = infocode
  31095. if infocode == 0 {
  31096. c.ServeSuccessJSON(map[string]interface{}{
  31097. "msg": "上传成功",
  31098. })
  31099. return
  31100. } else {
  31101. c.ServeSuccessJSON(map[string]interface{}{
  31102. "failed_code": -10,
  31103. "msg": res.ErrMsg,
  31104. })
  31105. return
  31106. }
  31107. }
  31108. func (c *HisApiController) Post3506() {
  31109. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31110. data := make(map[string]interface{})
  31111. var struct3501s []models.Struct3501
  31112. var struct3501 models.Struct3501
  31113. struct3501.OrgName = miConfig.OrgName
  31114. struct3501.AccessKey = miConfig.AccessKey
  31115. struct3501.RequestUrl = miConfig.Url
  31116. struct3501.SecretKey = miConfig.SecretKey
  31117. struct3501.ManuDate = "2022-08-15"
  31118. struct3501.FixmedinsBchno = ""
  31119. struct3501.ManuLotnum = ""
  31120. struct3501.RxFlag = "0"
  31121. struct3501.ExpyEnd = "2022-08-15"
  31122. struct3501.Invdate = "2022-08-15"
  31123. struct3501.InvCnt = "20.25"
  31124. struct3501.Memo = ""
  31125. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31126. struct3501.FixmedinsHilistId = miConfig.Code
  31127. struct3501.FixmedinsHilistName = miConfig.OrgName
  31128. struct3501s = append(struct3501s, struct3501)
  31129. data["struct_3501s"] = struct3501s
  31130. client := &http.Client{}
  31131. bytesData, _ := json.Marshal(data)
  31132. var req *http.Request
  31133. if miConfig.MdtrtareaAdmvs == "320921" {
  31134. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31135. } else {
  31136. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31137. }
  31138. resp, _ := client.Do(req)
  31139. defer resp.Body.Close()
  31140. body, ioErr := ioutil.ReadAll(resp.Body)
  31141. if ioErr != nil {
  31142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31144. return
  31145. }
  31146. var respJSON map[string]interface{}
  31147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31150. return
  31151. }
  31152. var res ResultSix
  31153. var resSix10265 ResultSix10265 //1101结果
  31154. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31155. result, _ := json.Marshal(respJSON)
  31156. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31157. utils.ErrorLog("解析失败:%v", err)
  31158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31159. return
  31160. }
  31161. res.InfRefmsgid = resSix10265.InfRefmsgid
  31162. res.Output = resSix10265.Output
  31163. res.ErrMsg = resSix10265.ErrMsg
  31164. res.Cainfo = resSix10265.Cainfo
  31165. res.WarnMsg = resSix10265.WarnMsg
  31166. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31167. res.Infcode = infocode
  31168. if infocode == 0 {
  31169. c.ServeSuccessJSON(map[string]interface{}{
  31170. "msg": "上传成功",
  31171. })
  31172. return
  31173. } else {
  31174. c.ServeSuccessJSON(map[string]interface{}{
  31175. "failed_code": -10,
  31176. "msg": res.ErrMsg,
  31177. })
  31178. return
  31179. }
  31180. }
  31181. func (c *HisApiController) Post3507() {
  31182. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31183. data := make(map[string]interface{})
  31184. var struct3501s []models.Struct3501
  31185. var struct3501 models.Struct3501
  31186. struct3501.OrgName = miConfig.OrgName
  31187. struct3501.AccessKey = miConfig.AccessKey
  31188. struct3501.RequestUrl = miConfig.Url
  31189. struct3501.SecretKey = miConfig.SecretKey
  31190. struct3501.ManuDate = "2022-08-15"
  31191. struct3501.FixmedinsBchno = ""
  31192. struct3501.ManuLotnum = ""
  31193. struct3501.RxFlag = "0"
  31194. struct3501.ExpyEnd = "2022-08-15"
  31195. struct3501.Invdate = "2022-08-15"
  31196. struct3501.InvCnt = "20.25"
  31197. struct3501.Memo = ""
  31198. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31199. struct3501.FixmedinsHilistId = miConfig.Code
  31200. struct3501.FixmedinsHilistName = miConfig.OrgName
  31201. struct3501s = append(struct3501s, struct3501)
  31202. data["struct_3501s"] = struct3501s
  31203. client := &http.Client{}
  31204. bytesData, _ := json.Marshal(data)
  31205. var req *http.Request
  31206. if miConfig.MdtrtareaAdmvs == "320921" {
  31207. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31208. } else {
  31209. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31210. }
  31211. resp, _ := client.Do(req)
  31212. defer resp.Body.Close()
  31213. body, ioErr := ioutil.ReadAll(resp.Body)
  31214. if ioErr != nil {
  31215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31217. return
  31218. }
  31219. var respJSON map[string]interface{}
  31220. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31223. return
  31224. }
  31225. var res ResultSix
  31226. var resSix10265 ResultSix10265 //1101结果
  31227. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31228. result, _ := json.Marshal(respJSON)
  31229. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31230. utils.ErrorLog("解析失败:%v", err)
  31231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31232. return
  31233. }
  31234. res.InfRefmsgid = resSix10265.InfRefmsgid
  31235. res.Output = resSix10265.Output
  31236. res.ErrMsg = resSix10265.ErrMsg
  31237. res.Cainfo = resSix10265.Cainfo
  31238. res.WarnMsg = resSix10265.WarnMsg
  31239. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31240. res.Infcode = infocode
  31241. if infocode == 0 {
  31242. c.ServeSuccessJSON(map[string]interface{}{
  31243. "msg": "上传成功",
  31244. })
  31245. return
  31246. } else {
  31247. c.ServeSuccessJSON(map[string]interface{}{
  31248. "failed_code": -10,
  31249. "msg": res.ErrMsg,
  31250. })
  31251. return
  31252. }
  31253. }
  31254. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31255. // WebSocket服务器地址
  31256. serverURL := "ws://127.0.0.1:8899"
  31257. // 解析WebSocket服务器地址
  31258. u, err := url.Parse(serverURL)
  31259. if err != nil {
  31260. }
  31261. // 建立WebSocket连接
  31262. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31263. if err != nil {
  31264. }
  31265. defer conn.Close()
  31266. input2 := make(map[string]interface{})
  31267. input := make(map[string]interface{})
  31268. inputData := make(map[string]interface{})
  31269. inputData["orgId"] = code
  31270. inputData["businessType"] = "01101"
  31271. inputData["operatorId"] = operator_id
  31272. inputData["operatorName"] = operator_name
  31273. inputData["officeId"] = "001"
  31274. inputData["officeName"] = "血透室"
  31275. inputData["deviceType"] = ""
  31276. input["data"] = inputData
  31277. input["orgId"] = code
  31278. input["transType"] = "ec.query"
  31279. //if md == ""
  31280. if md[:4] == "4403" {
  31281. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31282. } else if md[:4] == "4401" {
  31283. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31284. } else {
  31285. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31286. }
  31287. input2["indata"] = input
  31288. fmt.Println(input2)
  31289. bytesData, _ := json.Marshal(input2)
  31290. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31291. if err != nil {
  31292. fmt.Println(err)
  31293. }
  31294. // 接收消息
  31295. _, receivedMessage, err := conn.ReadMessage()
  31296. if err != nil {
  31297. fmt.Println(err)
  31298. }
  31299. return "", string(receivedMessage)
  31300. }
  31301. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  31302. // WebSocket服务器地址
  31303. serverURL := "ws://127.0.0.1:8899"
  31304. // 解析WebSocket服务器地址
  31305. u, err := url.Parse(serverURL)
  31306. if err != nil {
  31307. }
  31308. // 建立WebSocket连接
  31309. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31310. if err != nil {
  31311. }
  31312. defer conn.Close()
  31313. input2 := make(map[string]interface{})
  31314. input := make(map[string]interface{})
  31315. inputData := make(map[string]interface{})
  31316. inputData["orgId"] = code
  31317. inputData["businessType"] = "01103"
  31318. inputData["operatorId"] = operator_id
  31319. inputData["operatorName"] = operator_name
  31320. inputData["officeId"] = "001"
  31321. inputData["officeName"] = "血透室"
  31322. inputData["deviceType"] = ""
  31323. input["data"] = inputData
  31324. input["orgId"] = code
  31325. input["transType"] = "ec.query"
  31326. //if md ==
  31327. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  31328. input2["indata"] = input
  31329. fmt.Println(input2)
  31330. bytesData, _ := json.Marshal(input2)
  31331. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31332. if err != nil {
  31333. fmt.Println(err)
  31334. }
  31335. // 接收消息
  31336. _, receivedMessage, err := conn.ReadMessage()
  31337. if err != nil {
  31338. fmt.Println(err)
  31339. }
  31340. return "", string(receivedMessage)
  31341. }
  31342. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31343. // WebSocket服务器地址
  31344. serverURL := "ws://127.0.0.1:8899"
  31345. // 解析WebSocket服务器地址
  31346. u, err := url.Parse(serverURL)
  31347. if err != nil {
  31348. }
  31349. // 建立WebSocket连接
  31350. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31351. if err != nil {
  31352. }
  31353. defer conn.Close()
  31354. input2 := make(map[string]interface{})
  31355. input := make(map[string]interface{})
  31356. inputData := make(map[string]interface{})
  31357. inputData["orgId"] = code
  31358. inputData["businessType"] = "01101"
  31359. inputData["operatorId"] = operator_id
  31360. inputData["operatorName"] = operator_name
  31361. inputData["officeId"] = "001"
  31362. inputData["officeName"] = "血透室"
  31363. inputData["deviceType"] = ""
  31364. input["data"] = inputData
  31365. input["orgId"] = code
  31366. input["transType"] = "ec.query"
  31367. //if md == ""
  31368. if md[:4] == "4403" {
  31369. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31370. } else if md[:4] == "4401" {
  31371. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31372. } else {
  31373. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31374. }
  31375. input2["indata"] = input
  31376. fmt.Println(input2)
  31377. bytesData, _ := json.Marshal(input2)
  31378. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31379. if err != nil {
  31380. fmt.Println(err)
  31381. }
  31382. // 接收消息
  31383. _, receivedMessage, err := conn.ReadMessage()
  31384. if err != nil {
  31385. fmt.Println(err)
  31386. }
  31387. return "", string(receivedMessage)
  31388. }
  31389. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  31390. // WebSocket服务器地址
  31391. serverURL := "ws://127.0.0.1:8899"
  31392. // 解析WebSocket服务器地址
  31393. u, err := url.Parse(serverURL)
  31394. if err != nil {
  31395. }
  31396. // 建立WebSocket连接
  31397. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31398. if err != nil {
  31399. }
  31400. defer conn.Close()
  31401. input2 := make(map[string]interface{})
  31402. input := make(map[string]interface{})
  31403. inputData := make(map[string]interface{})
  31404. inputData["orgId"] = code
  31405. inputData["businessType"] = "01301"
  31406. inputData["operatorId"] = operator_id
  31407. inputData["operatorName"] = operator_name
  31408. inputData["officeId"] = "001"
  31409. inputData["officeName"] = "血透室"
  31410. inputData["deviceType"] = ""
  31411. input["data"] = inputData
  31412. input["orgId"] = code
  31413. input["transType"] = "ec.query"
  31414. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31415. input2["indata"] = input
  31416. bytesData, _ := json.Marshal(input2)
  31417. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31418. if err != nil {
  31419. fmt.Println(err)
  31420. }
  31421. // 接收消息
  31422. _, receivedMessage, err := conn.ReadMessage()
  31423. if err != nil {
  31424. fmt.Println(err)
  31425. }
  31426. return "", string(receivedMessage)
  31427. }
  31428. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  31429. newArr = make([]string, 0)
  31430. for i := 0; i < len(arr); i++ {
  31431. repeat := false
  31432. for j := i + 1; j < len(arr); j++ {
  31433. if arr[i] == arr[j] {
  31434. repeat = true
  31435. break
  31436. }
  31437. }
  31438. if !repeat {
  31439. newArr = append(newArr, arr[i])
  31440. }
  31441. }
  31442. return
  31443. }
  31444. func getBirthdateAndAge(idNumber string) (string, int, error) {
  31445. if len(idNumber) != 18 {
  31446. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  31447. }
  31448. // 提取出生日期
  31449. year, err := strconv.Atoi(idNumber[6:10])
  31450. if err != nil {
  31451. return "", 0, err
  31452. }
  31453. month, err := strconv.Atoi(idNumber[10:12])
  31454. if err != nil {
  31455. return "", 0, err
  31456. }
  31457. day, err := strconv.Atoi(idNumber[12:14])
  31458. if err != nil {
  31459. return "", 0, err
  31460. }
  31461. // 格式化生日字符串
  31462. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  31463. birthdateFormatted := birthdate.Format("2006-01-02")
  31464. // 计算年龄
  31465. today := time.Now()
  31466. age := today.Year() - birthdate.Year()
  31467. if today.YearDay() < birthdate.YearDay() {
  31468. age--
  31469. }
  31470. return birthdateFormatted, age, nil
  31471. }